Recent Changes - Search:




Summary: View Historical Revisions of Pages
Version: 2009-04-18B
Prerequisites: PHP5
Status: experimental
Maintainer: Peter Bowers
Users: (View? / Edit)
Download: pagehist.phpΔ
Categories: Uncategorized
Discussion: PageHist-Talk?

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

  • How can I view pages "as of" a certain time, in other words to see a snapshot from a given time


View information about page revisions and view page(s) "as of" a particular point in time.


  • Download pagehist.phpΔ and place it in the cookbook directory
  • Add include_once("$FarmD/cookbook/pagehist.php"); to your config.php


By appending "?asof=TIMESTAMP" to the URL in your address bar you can view a page as of that particular point in time. An effort is made to append the same "?asof=TIMESTAMP" to all intra-wiki links automatically (once you have explicitly requested the first one) so that you can actually browse your site as of that point in time.

A markup expression is also provided with lots of options to list the revisions of a given page.

Here is perhaps the most useful version of this MX:

{(pagehist fmt="{name} as of %m/%d/%Y %T" links=1 count=10 Group.Pagename)}

This will list the last 10 revisions of Group.Pagename in the format "Group.Pagename as of 04/07/2009 10:01:31" and that text will be a link pointing to "Group.Pagename?asof=12342345", thus allowing you to go directly to the view of that page as of that point in time.

The {(pagehist ...)} MX also supports a bunch of other options.

sep=xchange the separator between elements
n=1include name as an element
a=1include author as an element
u=1include unixtime as an element
fmt=Xspecify the format to be used ({name}, {author}, {host}, {desc}, {diff}, or any strftime elements will be substituted)
h=1include host as an element
l=1include # of lines in diff output as an element
s=1include # of chars in diff output as an element
d=1include description of change as an element
t=1set fmt to '%Y-%m-%d %T'
count=xonly list the x most recent revisions
start=xonly list revisions occurring after x (x can be either unixtime or input to strtotime())
end=xonly list revisions occurring before x (x can be either unixtime or input to strtotime())
table=1put || before and after each line with || as separator to form a table
links=1make each line into a link to that page with the appropriate ?asof=12341234 in the URL
only_pagehist=1don't do ANYTHING unless ?pagehist=1 is found in the URL
line_prefix=Xput X in front of every line of output
line_suffix=Xput X after every line of output

Obviously pagehist can be used within WikiSh in which case you can use usage such as pagehist -ud to specify the unixtime and the description -- this is where the single-letter options become much more useful.

The following script gives an idea of how @@pagehist could be integrated into WikiSh and manipulation of page revisions could be done very powerfully (don't forget the existence of the diff command as well):

pagehist -ud Pagename | while read timestamp desc
   echo "----\n${desc}\n----"
   cat Pagename@${timestamp}

You can also specify ?asof=<timestamp in words> in your URL where <timestamp in words> is any words which correspond to valid input for strtotime(). However, this feature hasn't been as well tested and may break on links and etc.

Note that everything in your site will be viewed as of this particular date. This means (:include:) will include the version as of that time, and etc. It also means that if your account in authuser was added after that time then you're potentially going to have problems. To get around this difficulty there is a global variable $PageHistIgnorePages which can be set to an array of pagenames (group period pagename) and these pages will be ignored (i.e., they will always be read as of the current snapshot rather than as of the date being used for other pages). It defaults to no pages being ignored -- in other words all pages will be viewed as of the time specified in the URL.

This recipe is only active if the action is "browse" or "source". This can be changed by changing the global variable $PageHistActions.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • 2009-04-18B - added $PageHistIgnorePages
  • 2009-04-18 - Initial release. Consider it "played with" rather than "tested."

See Also

  • ViewDiff Compare arbitrary revisions and view a particular version.



See discussion at PageHist-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.

Edit - History - Print - Recent Changes - Search
Page last modified on November 01, 2013, at 10:59 PM