View Full Version : List newest pages?
neilw
11-10-2008, 06:59 PM
I should know the answer to this, but I don't, and can't find it in the forums or on the dev wiki.
Is there a straightforward way to list the newest pages on the wiki? Preferably I'd like to restrict the search to a particular hierarchy.
I could do it with a date-ordered search, and then pick through the list looking for editsummary starting with "page created", but while that is possible it is not particularly efficient or elegant. I may take that approach anyway, if there's no other answer.
Is there a cleaner way to do it?
boldox
11-11-2008, 02:19 PM
I'm trying that right now!
<table width="98%" cellspacing="2" cellpadding="4" border="0" align="center" block="var result = wiki.getsearch('type:wiki', 100, '-date')">
<tbody>
<tr>
<td valign="top" bgcolor="#6e6e6e" colspan="4" style="text-align: center;"><strong><font color="#ffffff">Ultimas Publicaciones</font></strong></td>
</tr>
<tr>
<td valign="top" bgcolor="#d8d8d8" align="center"><strong>Normativa</strong></td>
<td valign="top" bgcolor="#d8d8d8" align="center"><strong>Banca</strong></td>
<td valign="top" bgcolor="#d8d8d8" align="center"><strong>Fecha Publicación</strong></td>
<td valign="top" bgcolor="#d8d8d8" align="center"><strong>Ver Cambios</strong></td>
</tr>
<tr foreach="var p in result" class="{{__count % 2 == 0 ? 'bg1' : 'bg2'}}">
<td valign="top" style="">{{web.link(p.uri, p.title)}}</td>
<td valign="top" align="center">{{web.link(p.author.uri, p.author.name)}}</td>
<td valign="top" align="center">{{date.format(p.date,"dd/MM/yy")}}</td>
<td valign="top" align="center">{{web.link(p.uri.."&action=history", "ver")}}</td>
</tr>
</tbody>
</table>
BUT...
now i need the revisions: http://wiki.developer.mindtouch.com/index.php?title=DekiScript/FAQ/How_do_I..._Show_the_revision_number_for_the_curre nt_page%3F&highlight=revisions (i want to exclude pages with revision > 0)
{{web.text(page.api, 'revisions/@count') }}
(reading the xml,. that should be: )
{{web.text(page.api, '/page/revisions/@count') }}
but i get this error:
(unable to fetch text document from uri [status: 401])
Any1 could help me? please
craigsivils
11-11-2008, 02:55 PM
Take a look at http://deki-examples.wik.is/Templates/Recent_Changes
neilw
11-12-2008, 04:40 PM
Here's some simple code that'll generate a bullet list of newest pages, derived from Craig's recent changes code:
<ul block="var pagelist = list.splice(list.select(wiki.getsearch('type:wiki' , 200, '-date', ''), 'string.substr($.editsummary,0,12)==\'page created\''),10);">
<li foreach="var p in pagelist">{{ p.title }}</li>
</ul>
Restricting this to a particular hierarchy simply requires adding a "path:" constraint to the wiki.getsearch() call. I didn't spend any effort prettifying the output yet, just wanted to test my ability to efficiently generate the list of new pages.
My discomfort with this approach is that I don't know in advance (nor have any way of intelligently guessing) how many search results to ask for to yield (in this case) at least 10 new pages. In my quick testing, asking for 100 items was very quick, and 200 only slightly slower. Asking for 999 items took around 15 seconds. So one approach would be just to ask for 100 or 200, in that ballpark, and if you don't get as many new pages as you'd like then just live with it. I don't have another one at this point.
neilw
11-12-2008, 07:13 PM
I take it back, the above code does not work. It'll only find pages that have not been edited after having been created.
I am left with no solution, not even a bad one. Anyone have any ideas?
lktest
11-15-2008, 11:44 PM
Neil, the only idea that I can come up with is the same that you had suggested originally -- to look through editsummary for the phrase "recent changes".
Two limitations of this that I found while playing around with it:
First, one of my recently created test pages lost the "recent changes" phrase in its editsummary after just 3 edits. I've never noticed how long that phrase stays active in the editsummary.
Second, my users often start a new draft page in their personal section, and then move them into the appropriate public section after several edits. Searching for "recent changes" in the editsummary probably wouldn't work in situations like this.
So, no constructive suggestions, just feedback on possible limitations...
lktest
11-24-2008, 07:39 AM
Neil and others,
I hacked up something that works some of the time on my VM system. I pasted the early code here:
http://wiki.developer.mindtouch.com/Sandbox/Recently_created_pages
I'm having problems with certain search strings (ie, "path:PATH/*"). You'll see in the sandbox that only one of the search strings in the draft code works ( "tag:Minnesota" ).
Please hack away if you have any ideas of how to make it more efficient or stable.
LK
craigsivils
12-01-2008, 07:39 PM
I had to write a c# extension to meet my needs in this area. As a database developer, my c# skills are not my strong point, but I was able to get it working pretty easily.
Craig
neilw
12-01-2008, 08:09 PM
Craig,
Would you care to share your extension? I am neither a C# nor a database developer. :p
Or, instead, can you offer any help on getting started? I am wondering if C# is strictly needed, or if a PHP extension could do equally well. I'd guess that the database wrangling is the key component here.
craigsivils
12-10-2008, 04:37 AM
Here is what I am using. I used to have page permissions logic working so that the code would not return pages that the user did not have visibility too, but that code broke a few upgrades back and I have not had time to go figure out what happened.
Nice enhancements would be:
1. Return page objects rather than page IDs
2. Add the page security check
3. Possibly move the page count limitation logic from the SQL (using the group by) to the C# code similar to how it is done in the wiki recent changes code.
BTW, this also contains my recent user code.
Craig
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.