Help:SMW Page Refresh
From Tetherless World Wiki
Contents |
Contact and History
Jie Bao, baojie AT gmail.com
First release: Jan 26, 2009
Feb 6, 2009: this extension has been integrated into SMW 1.4.2 [1]. This extension may still be used with previous versions of SMW.
Purpose
To update semantic data of a list of pages in SMW. This is needed since the SMW_refreshPage.php script does not allow by-name refreshing.
This script is particularly useful for importing pages into SMW, since many of those importing scripts will not invoke automatic semantic updating.
Installation
Copy the following code in a file: "extensions/SMWGadget/SMW_refreshPageList.php"
Usage
Goto the folder of this script. Usage example:
php SMW_refreshPageList.php --page="Page 1|Page2"
by default the delimiter is "|", because it can not be in a wiki page name.
php SMW_refreshPageList.php --page="Page 1,Page2" --delimiter=","
How to generate a page list
There are many ways to generate a page list. One of the more convenient way is to use a semantic query. For example, the following query generates a list of pages in the Category:Meeting
{{#ask:[[Category:Meeting]]|format=list}}
If you want other delimiters, especially when some pages have "," in their names, it is useful to use the "String Functions" extension to generate a list, e.g.
{{#replace:{{#ask:[[Category:Meeting]]|format=ul}}|<li>|{{!}}}}
Where "Template:!" is a page with single character "|".
Use it in a wiki bot
This script can be called from another program as a system call. For example, in a perl program, simply call:
$command = "php ". $scriptPath."SMW_refreshPageList.php --page=". $name; system ($command);
where $scriptPath is the full path where this script is saved, and $name is the page to refresh
It is also possible to call from php, Java, C++, Python, etc., in the similar fashion.
It is also a common practice to call this script from a cron job. Check [2] for how to set up a cron job.
