Nextgen Gallery WordPress nggtags template caption option

I have a slightly older version of NGG because I have modded it and have yet to transfer those mods to the latest version. But I just made another minor change that I wanted to document before I forget what I did.

Using the

no images were found

  works well for showing the images from the gallery that are tagged as an automated gallery creation.

But I wanted to get the captions displayed as well like the syntax for the standard gallery by id display

no images were found

.  So I needed to add the ” template=caption” as an option for the nggtags shortcode.

Edit /wp-content/plugins/nextgen-gallery/nggfunctions.php

Around line 867 should start the function into which I inserted the $template value (with relevant comma’s etc.) at 3 places as highlighted with the new text.

[php highlight=”1,13,23″]
function nggShowGalleryTags($taglist, $template = ”) {

// $_GET from wp_query
$pid    = get_query_var(‘pid’);
$pageid = get_query_var(‘pageid’);

// get now the related images
$picturelist = nggTags::find_images_for_tags($taglist , ‘ASC’);

// look for ImageBrowser if we have a $_GET(‘pid’)
if ( $pageid == get_the_ID() || !is_home() )
if (!empty( $pid ))  {
$out = nggCreateImageBrowser( $picturelist, $template);
return $out;
}

// go on if not empty
if ( empty($picturelist) )
return;

// show gallery
if ( is_array($picturelist) )
$out = nggCreateGallery($picturelist, false, $template);

$out = apply_filters(‘ngg_show_gallery_tags_content’, $out, $taglist);
return $out;
}

[/php]

That sorts out the function that is called from the  /wp-content/plugins/nextgen-gallery/lib/shortcodes.php

Around line 114 there is a string evaluation test process that we change to look for a second option referenced as template= etc..  shown in the highlighted line.

[php highlight=”6″]

if ( stristr( $content, ‘[tags’ )) {
$search = "@(?:<p>)*s*[tagss*=s*(.*?)s*]s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

foreach ($matches as $match) {
$replace = "

no images were found

}" template="{$match[2]}"]";
$content = str_replace ($match[0], $replace, $content);
}
}
}

[/php]

Finally around line 273 there is the call to the nggShowGalleryTags in the show_tags function. Insert a new line for $template as a parameter and to the output option.

[php highlight=”5,12″]

function show_tags( $atts ) {

extract(shortcode_atts(array(
‘gallery’       => ”,
‘template’  => ”,
‘album’         => ”
), $atts ));

if ( !empty($album) )
$out = nggShowAlbumTags($album);
else
$out = nggShowGalleryTags($gallery, $template);

return $out;
}

[/php]

Now the nggtags option that will create a custom gallery from Tagged images can optionally include the image caption as well.

 

 

Awstats Configuration Files awstats.conf, awstats.model.conf

The default setup for awstats is really aimed at a minimal number of web site or other logs and the ability to setup specific config files for each site is good but seems a little top heavy.

The awstats.conf and awstats.conf.local files provide for the single site type setup. Configure the main .conf settings or alternatively add the specific overrides of the defaults into the awstats.conf.local file and all is good.

Using the awstats.model.conf for multiple web sites and copying it to a site specific file also is a good plan for a nominal number of sites.

But once we get to having 37 sites it is getting a bit out of hand.

So how to improve the process and automate it?

Roughly:

  • Have a standard config file for all the standard settings
  • Have a standard log file format for the specific type of log being stat’d
  • Have a header type config file that is specific to the site or URL being stat’d
  • Combine them all on-the-fly by using the Includes option in the awstats config files

I think the order should be:

awstats looks in /etc/awstats when the updateall process is executed

in the /etc/awstats directory are the header files which look like:

#include main config file from somewhere else (it cannot be in this directory as it would be read as a conf file directly)
#include the required log file format – parsing both apache and windows logs
#have only the site specific instructions in the file so that the file size and chance of overriding config standards is reduced

I’ll experiment with the above and update this with the result.

Rsync on Debian

I’ve acquired a few more Linux servers recently with Debian Squeeze installed (version 6.0.6 according to #cat /etc/debian_version).

Installing Rsync is easy:

[bash]
apt-get install rsync
[/bash]

The tricks are in getting the config files done, actually running the service, connecting, etc.

The default config file is in /etc/default/rsync  which sets up how rsync will run.

The default settings file is expected as /etc/rsync.conf  which I change to set to /etc/rsyncd/rsyncd.conf   just so I am clear which config is ‘mine’ to work on.  The actual change in the /etc/default/rsync file is shown here with the RSYNC_CONFIG_FILE line enabled (removed the # at the start) and with the path setting as described.

[text]
# which file should be used as the configuration file for rsync.
# This file is used instead of the default /etc/rsyncd.conf
# Warning: This option has no effect if the daemon is accessed
#          using a remote shell. When using a different file for
#          rsync you might want to symlink /etc/rsyncd.conf to
#          that file.
RSYNC_CONFIG_FILE=/etc/rsyncd/rsyncd.conf

[/text]

The other important bit is the Rsync is not enabled by default and is therefore not going to run or be running!  In the same /etc/default/rsync file edit the RSYNC_ENABLE option to change false to true

[text]
# start rsync in daemon mode from init.d script?
#  only allowed values are "true", "false", and "inetd"
#  Use "inetd" if you want to start the rsyncd from inetd,
#  all this does is prevent the init.d script from printing a message
#  about not starting rsyncd (you still need to modify inetd’s config yourself).
RSYNC_ENABLE=true
#
#
[/text]
[bash]
#service rsync restart
[/bash]

I used the restart command even though I knew that it was not running (yet) as I can reuse the command via Ctrl-R when I do more edits to the config settings

[bash]
/etc/default# service rsync restart
Restarting rsync daemon: rsyncrsync daemon not running, attempting to start. … (warning).
missing or empty config file /etc/rsyncd/rsyncd.conf … failed!
failed!
/etc/default#
[/bash]

And as expected there is a warning that it was not running to be able to stop it, and then the start action fails as there is no config file, as yet.

So that is all good.

Next create the appropriate config file. Easiest to start with the example conf file from the default install

[bash]
/etc/rsyncd/# cp /usr/share/doc/rsync/examples/rsyncd.conf .
[/bash]

Then edit it…

[text]
# sample rsyncd.conf configuration file
# GLOBAL OPTIONS
#motd file=/etc/motd
log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
# pid file=/var/run/rsyncd.pid
#syslog facility=daemon
#socket options=
[/text]

The sections in the config file are based on the sample config file and in the top Global Options I only check that the log file path is correct and enabled

For each backup set that is going to be inbound to this server I add a new section to the config file:

[text]
# MODULE OPTIONS

[ftp]
comment = public archive <– a clever comment
path = /var/www/pub <– set the path
      use chroot = yes
#      max connections=10 <– do not set it to 1
lock file = /var/lock/rsyncd
# the default for read only is yes…
read only = yes <– change this to no so source files can be written
list = yes
       uid = nobody <– the username for the newly uploaded files
       gid = nogroup <– the group for the files
#       exclude =
#       exclude from =
#       include =
#       include from =
#       auth users = <– comma space delimited list of names that appear in the secrets file
#       secrets file =/etc/rsyncd.secrets <– a text file with a username:password
        strict modes = yes
#       hosts allow = <– ip address for the source system
#       hosts deny =
       ignore errors = no
       ignore nonreadable = yes
       transfer logging = no
#       log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
       timeout = 600
refuse options = checksum dry-run
       dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
[/text]

and after each update to the config file restart the service to load the new config and confirm that Rsync will run with it.

[bash]
/etc/default# service rsync restart
[/bash]

I’ve not looked at SSH / SSL type connections for Rsync in this. The main thing was to get Rsync setup as a server and control the inbound traffic based on accounts, servers, and ip restrictions.

Another post will update SSH configuration.

Rsync Backups Windows Servers

Backups are problematic. It is a love / hate thing for me. I love having them when I need them but I hate the prep work that goes into getting them done. Of course, that is offset by the hate for the work I have to do when there isn’t one…..  … in any case backups are necessary.

Ok. So setting up yet another server for Rsync backups. This time Windows to a Linux based server. Of course I’ve never documented the process in the past so this time I will spend the extra minutes and make a complete note of what I am doing so I have a consistent process for the next time. I also decided to look at what options are available to provide minimum fuss.

I looked at the various options of cwRsync (which I have used before), Grsync, Cygwin with Rsync as a self-build, a few tools that appear to only support their specific hosted solution like rsync.net.  After doing some reading and some basic testing I scrapped all of them and was about to give up when I tried QtdSync and finally found something that worked as intended, but…  I cannot get it to schedule the backups.

For the record:

cwRsync: skip this. The Windows GUI version is paid only without a trial to see what it is like. The free GPL version is command line and the instructions are vague. I know I have used this in the past but the developer seems to have changed focus.

Grsync: Appears to be a useful GUI but it is unclear as to how to set it to connect to a remote Rsync server and as a result I uninstalled within a few minutes.

QtdSync. SourceForge, GPL Free Software. Simple installation. On the test server it worked fine. I then noted all the steps as I installed to a production server. But I cannot get it to run as a service or schedule to work without being logged into the system. I think it looks like a great utility for desktop to server / NAS type devices for home or small business but it just does not cut it for this. I think it will be up for it at some stage, given a bit of new breath in the development.

DeltaCopy: Is held apparently in high regard and I spent several hours on this and gave up.  It connected and everything appeared to be ok, except I kept getting an error that it was wanting a directory to exist on the remote backup server before it would transfer files. If I manually added the directory it worked fine. I tried many things but could not figure it out.

That was a few days ago and I have come back to it today and it worked first time. The chair to keyboard interface playing up again!

I’ll document how I’ve used it as another post. Suffice to say I like DeltaCopy for Windows server Rsync backups.