Difference between revisions of "Extension:CommonsMediaCaching"

From Biowikifarm Metawiki
Jump to: navigation, search
m ((2) Set up logrotate for logging outputs)
m ((2) Set up logrotate for logging outputs: cache/cacheCommons.log not created by default)
Line 40: Line 40:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Similarly you can/should set up a <code>logrotate</code> for all the Wikis in <code>cacheCommons.sh</code>, which log their files into <code>cache/cacheCommons.log</code>, eg.:
+
If you also want to read the <code>cache/cacheCommons.log</code> (which are not created by default), similarly you should set up a <code>logrotate</code> for all the Wikis in <code>cacheCommons.sh</code>, which log their files into <code>cache/cacheCommons.log</code>, eg.:
 
* <code>/var/www/testwiki/cache/cacheCommons.log</code>
 
* <code>/var/www/testwiki/cache/cacheCommons.log</code>
 
* <code>/path/to/wiki/cache/cacheCommons.log</code>
 
* <code>/path/to/wiki/cache/cacheCommons.log</code>

Revision as of 14:42, 15 November 2019

(TODO check correct documentation)

This extension reads all new thumbs (from commons.wikimedia.org/wiki/) in the wiki media or image folder an if they are new it downloads them to a local specified Wiki or repository Wiki (OpenMedia).

Code see in https://biowikifarm.net/svn/LocalSVNextensions/CommonsMediaCaching/

(1) Set up which Wiki(s) shall run the caching

cacheCommons.sh is used to download and cache the images from commons.wikimedia.org/wiki/.

(2) Set up logrotate for logging outputs

Recommendation summary:

logrotate
└ for ─┬─ Wikis in cacheCommons.sh (optional, download)
       ├─ Wikis in runJobs.sh (optional, wiki page jobs)
       ├─ Wikis in runJobs.sh_simple-extensions.sh (optional, wiki page jobs)
       └─ …

If you have set up cron jobs then set up logrotate as well, eg. with a configuration in /etc/logrotate.d/wiki-runJobs

/usr/share/mediawiki26/extensions-rich-features/CommonsMediaCaching/runJobsOutput.log {
  missingok
  compress
  delaycompress
  daily
  size 1M
  create 644 www-data www-data
  rotate 10
}
/usr/share/mediawiki26/extensions-simple-features/CommonsMediaCaching/runJobsOutput.log {
  missingok
  compress
  delaycompress
  daily
  size 1M
  create 644 www-data www-data
  rotate 10
}

If you also want to read the cache/cacheCommons.log (which are not created by default), similarly you should set up a logrotate for all the Wikis in cacheCommons.sh, which log their files into cache/cacheCommons.log, eg.:

  • /var/www/testwiki/cache/cacheCommons.log
  • /path/to/wiki/cache/cacheCommons.log

(3) Set up a cronjob for runJobs.php (optional)

For instance in a file like /etc/cron.d/wiki-run-jobs you can specify how often the job should run the maintenance script runJobs.php

# RUN every 10 minutes 
# NOTE: without  &> /dev/null it will create mails to the specified user (www-data)
*/10 * * * * www-data bash /usr/share/mediawiki26/extensions-rich-features/CommonsMediaCaching/runJobs.sh &> /dev/null 
*/10 * * * * www-data bash /usr/share/mediawiki26/extensions-simple-features/CommonsMediaCaching/runJobs_simple-extensions.sh &> /dev/null

The script …

  • extensions-rich-features/…/runJobs.sh contains all Wikis with extended extension set up
  • and extensions-simple-features/…/runJobs_simple-extensions.sh for those with a simple extension setup.

(4) Set up a template in the local (repository) Wiki

Template:Cached Commons Copy is used on File pages to store the information of the original commons file. It can look like this:

<noinclude>A simplified version of [[Template:Cached Copy]] (see there), specific to Wikimedia commons. It also adds a new parameter: lastuploader  

The parameters are simplified to only:
* '''file=''' (without the File: prefix)
* '''lastuploader''' =for the name of the last user uploading this file on commons (not sufficient for licensing and attribution purposes, this user may only have modified someone elses original work.
* '''time=''' (optional).

Example: <nowiki>{{Cached_Commons_Copy|file=x.jpg|lastuploader=xxuser|time=2011-08-23 : 20:12}}</nowiki> results in:

{{Cached_Commons_Copy|file=x.jpg|lastuploader=xxuser|time=2011-08-23 : 20:12}}

</noinclude><includeonly><table cellspacing="4" cellpadding="4" style="margin:1em 0; width:99%; font-size:100%; background-color:#FFFFEE; border-style:solid; border-color:#BB4020; border-width: 2px; clear: both; position:relative; text-align:left;" width="99%"><tr><td>This media item is originally from ''http://commons.wikimedia.org/wiki/File:{{{file|'''The source file is missing!'''}}}''{{#if:{{{lastuploader|}}}|, last uploaded by [http://commons.wikimedia.org/wiki/User:{{anchorencode:{{{lastuploader}}}}} {{{lastuploader}}}]}}; it was copied to a local repository as a caching mechanism to speed up page rendering and to prevent links to break when media items are renamed on commons. For a full list of earlier authors and contributors please refer to the ''[http://commons.wikimedia.org/wiki/File:{{{file|}}}#filehistory file version history]'' and the ''[http://commons.wikimedia.org/w/index.php?title=File:{{{file|}}}&action=history metadata version history]'' in the repository from which this media item has been copied.

'''Below you find the original information from the metadata page at the time of copying{{#if:{{{time|}}}|&#32;({{{time}}})}}:'''
</td></tr></table><includeonly>{{#ifeq:{{NAMESPACE}}|{{ns:Category}}||[[Category:Cached Commons Images]]}}</includeonly>