Difference between revisions of "Extension:CommonsMediaCaching"
m |
m |
||
Line 3: | Line 3: | ||
This extension reads all new thumbs (from [https://commons.wikimedia.org/wiki/ commons.wikimedia.org/wiki/]) in the wiki <code>media</code> or <code>image</code> folder an if they are new it downloads them to a local specified Wiki or repository Wiki ([https://species-id.net/openmedia/ OpenMedia]). | This extension reads all new thumbs (from [https://commons.wikimedia.org/wiki/ commons.wikimedia.org/wiki/]) in the wiki <code>media</code> or <code>image</code> folder an if they are new it downloads them to a local specified Wiki or repository Wiki ([https://species-id.net/openmedia/ OpenMedia]). | ||
− | + | Code see in https://biowikifarm.net/svn/LocalSVNextensions/CommonsMediaCaching/ | |
− | + | == (1) Set up which Wiki(s) shall run the caching == | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <code>cacheCommons.sh</code> is used to download and cache the images from [https://commons.wikimedia.org/wiki/ commons.wikimedia.org/wiki/]. | |
− | + | ||
− | + | ||
− | == (2) | + | == (2) Set up <code>logrotate</code> for logging outputs == |
− | + | If you have [[#set up cronjobs for runJobs|set up cron jobs]] then set up <code>logrotate</code> as well, eg. with a configuration in <code>/etc/logrotate.d/wiki-runJobs</code> | |
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
/usr/share/mediawiki26/extensions-rich-features/CommonsMediaCaching/runJobsOutput.log { | /usr/share/mediawiki26/extensions-rich-features/CommonsMediaCaching/runJobsOutput.log { | ||
Line 42: | Line 33: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == Set up a template in the local (repository) Wiki == | + | 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.: |
+ | * <code>/var/www/testwiki/cache/cacheCommons.log</code> | ||
+ | * <code>/path/to/wiki/cache/cacheCommons.log</code> | ||
+ | |||
+ | == (3) Set up a <code>cronjob</code> for runJobs.php (optional){{anchor|set up cronjobs for runJobs}} == | ||
+ | |||
+ | For instance in a file like <code>/etc/cron.d/wiki-run-jobs</code> you can specify how often the job should run the maintenance script <code>runJobs.php</code> | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | # 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 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | The script … | ||
+ | * <code>extensions-rich-features/…/runJobs.sh</code> contains all Wikis with extended extension set up | ||
+ | * and <code>extensions-simple-features/…/runJobs_simple-extensions.sh</code> for those with a simple extension setup. | ||
+ | |||
+ | == (4) Set up a template in the local (repository) Wiki == | ||
<code>Template:Cached Commons Copy</code> is used on File pages to store the information of the original commons file. It can look like this: | <code>Template:Cached Commons Copy</code> is used on File pages to store the information of the original commons file. It can look like this: |
Revision as of 10:26, 14 November 2019
TODO 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/
Contents
(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
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
}
Similarly you can/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|}}}| ({{{time}}})}}:'''
</td></tr></table><includeonly>{{#ifeq:{{NAMESPACE}}|{{ns:Category}}||[[Category:Cached Commons Images]]}}</includeonly>