0

Hello,

I did customization (BugMonkey) that adding to my wiki page some useful info (Last modified day, W#, Company logo) when the page is printed.

My question is how can I get revision number? There is any API to retrieve it?

Thanks!

flag

2 Answers

1

I'm not sure if you can get at the revision number via JavaScript or not, but there is a $revision_number$ template placeholder you could use. It's not perfect, but as an alternative solution, you could try the following:

  1. Create a custom template (it will start out as a copy of the built-in template)
  2. Add a div to the top/bottom of the wiki page that includes everything you want to display when printing ($url$, $revision_number$, $lastmodified$, logo, etc.).
  3. Only display that div when printing by tweaking your template's CSS

HTML:

<div class="printonly">
    Last Modified: $lastmodified$ <br />
    Revision: $revision_number$ <br />
    URL: $url$
</div>

CSS:

.printonly /* hide from regular view (if you want to) */
{
    display: none;
}

@media print
{
    .printonly { display: block; }
}

Note: There is a summary of all the other template placeholders available to you on this question.

link|flag
1

If you already know the wiki number, then you can use ajax to read the first link node (which is the latest revision) from the RSS feed for the article, which would look something like this:

var ixWiki = 123; // ... whatever the wiki number is
$.ajax({
   url: "?pg=pgRss&ixWikiPage=" + ixWiki, 
   dataType: "xml", 
   success: function(xml) { 
      var sLink = $(x).find("item:first link").text();
      var ixRevision = /nRevision\d+=(\d+)/.exec(sLink)[1];
      // Whatever you want to do with the revision
   }
});

You can also get a lot of other information about the other revisions, if you look at the rest of the link nodes.

For reference, the XML response will look something like this:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
   <channel>
      <title>Example Article Title</title>
      <link>https://example.fogbugz.com</link>
      <description>FogBugz RSS Feed</description>
      <language>en-us</language>
      <copyright>Copyright 2000-2011 Fog Creek Software</copyright>
      <item>
         <title><![CDATA[Example Article Title]]></title>
         <link>https://example.fogbugz.com/default.asp?pg=pgWikiDiff&amp;ixWikiPage=123&amp;nRevision1=5</link>
         <description><![CDATA[Edited by Your Name]]></description>
         <author><![CDATA[Your Name]]></author>
         <category>FogBugzWikiPage123</category>
         <guid>https://example.fogbugz.com/default.asp?pg=pgWikiDiff&amp;ixWikiPage=123&amp;nRevision1=5</guid>
         <pubDate>Fri, 10 Dec 2010 16:25:51 GMT</pubDate>   
      </item>
      <item>
       ... info for revision 4 ...
      </item>
      <item>
       ... info for revision 3 ...
      </item>
      <item>
       ... info for revision 2 ...
      </item>
      <item>
       ... info for revision 1 ...
      </item>
   </channel>
</rss>

... and in the code above, I just found the first item, and pulled the nRevision part from the link tag inside it.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.