GrepRC
Questions answered by this recipe
- How can I view just some part of the RecentPages without having to resort to the overhead of a pagelist?
- How can I see changes just by one author?
- How can I see changes made during a certain date range?
- How can I see changes made to just certain pages?
Description
Search RecentChanges entries by page name, author, date, etc. and list matching lines.
Installation
Download attach:greprc.php and put it in your cookbook directory.
Include this line in your config.php or farmconfig.php:
include_once("$FarmD/cookbook/greprc.php");
Optionally set any default values in $GrepRCDefaults array.
If you have changed your RecentChanges format then you will need to set a new value for $GrepRCPat. This will require some knowledge of regular expressions.
Place the (:recentchanges:)
markup on a page in the location you want to view the subset of lines. (Include arguments to that markup or include arguments in your URL to specify the search.)
Notes
The following arguments are honored:
name=x,y,-z
just like pagelist syntax, but applied to the page names row by row in RecentChangesgroup=a,b,-c
yeah, like pagelist againlist=default
(or all or whatever) once again, the pagelist syntax thingscanlines=100
Only scan the first 100 lines of the RecentChanges page (default 1000)after=datestring
only list lines where the date occurs after this date string (date can be anything strtodate() recognizes -- "yesterday", "last week", "November 21, 2007", "last Monday", etc.)before=datestring
just likeafter
but before. (isn't that profound?)authname=Sam,Jane*
Specify just likename=
orgroup=
but it applies to author names instead (wildcards accepted)source=Site.AllRecentChanges
Get the lines from a different page besides $Group.RecentChanges.
Arguments can be specified in one of 3 ways, each successive one superseding the prior one:
- Defaults set in config.php by setting in the $GrepRCDefaults array
$GrepRCDefaults['scanlines'] = 500;
$GrepRCDefaults['after'] = "last week";
- Arguments specified in the
(:recentchanges:)
markup (put quotes around arguments with spaces)(:recentchanges scanlines=500 after="last week":)
- Parameters in the URL (replace spaces with
+
sign)http://www.example.com/pmwiki/Test/RC?after=last+week&scanlines=500
Defaults are overridden by markup arguments. Markup arguments are overridden by parameters in the URL. This allows an administrator to set global defaults but a page author can set it up to see what he wants to see and then a page viewer can change those defaults without editing the page. (The URL parameters also allow forms to be created to do the search very easily.)
Note that most (all?) of this capability and more could be easily created via pagelists. However, a pagelist can easily take tens of seconds to generate if it is at all complicated (see WatchLists) whereas this recipe can quickly scan through a single page without taking hardly any time or system resources.
Changes to your RecentChanges format or to your standard time format or etc. will have significant impact on this recipe and will require potential re-coding or at least re-configuring.
I cannot verify whether it will work for sites in other languages.
A form could very easily be set up like this, allowing dynamic searches to be done:
(:input form method="GET":) (:input default request=1:) || border=1 width=50% || Page Names:|| (:input text name:) || || Group Name(s):|| (:input text group:) || || Author Name(s):|| (:input text authname:) || || Show changes '''before''' this date:|| (:input text before:) || || Show changes '''after''' this date:|| (:input text after:) || || ||(:input submit Search Search:) || (:input end:) |
Release notes
- Release 2010-02-05 Initial release
See also
Contributors
Comments
See discussion at GrepRC-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.