This template will provide you will the newest items within a given path. It allows you to control the number of items returned, as well as how deep to drill down the tree. This template will also count comments as changes if desired.
NOTE: This was one of my first templates that I built and can be improved. I will update page this with ver. 2 soon. I will likely incorporate a page viewed ranking within the same template as well.
PERFORMANCE: For best performance it is a good idea to keep your max results and depth as small as needed.
| Version | Date | Author | Description |
| 1.3.1 | 27/07/2010 | neilw | Put in a small check to avoid throwing an error if a page is unreadable (don't know why this should be necessary, but apparently it is) |
| 1.3 | 19/03/2010 | neilw | Use @pageid to extract page list from wiki.tree(), for more reliable handling of pages with special characters in their names |
| 1.2 | 28/08/2009 | rberinger | Change from using div id's to div classes for css. Added ability to order pages by original creation date. |
| 1.1 | 27/08/2009 | rberinger | Optimized Code, Added: Styles, Date Formating, Div Containers |
| 1.0 | 22/05/2009 | rberinger | Initial template |
For all the examples on this page, the code is shown before the working example. The code is shown with the syntax extension, and looks like this:
WhatsNew{arguments}
This means that the actual code on the page should be enclosed in a Dekiscript block. If you want to copy the code from this page, then use the same procedure as described in steps 2-4 above.
Simply create a dekiscript block where you would like to have the Whats New list appear and make a call to the template. See the example below.
| Name | Type | Default | Description |
| title | str | Whats New! | This string will become the title of the results |
| path | str | page.path | The path to serve as the starting point |
| max | num | 10 | The maximum number of results to display |
| depth | num | 10 | The tree depth to look for pages (just like wiki.tree) |
| comments | bool | true | Test comment dates against page dates. |
| dateformat | str | 'MM/dd/yyyy' | Any valid date format mask. |
| blockstyle | str | See Template | Any valid in-line css. Controls container that wraps entire template |
| titlestyle | str | See Template | Any valid in-line css. Control Title Section |
| bodystyle | str | See Template | Any valid in-line css. Controls the body or content section. |
| onlynew | bool | false | If true will only evaluate pages by their original creation date. This provides a true newest pages list not just a newest updated list. NOTE: If set to true the comments argument is ignored as well as the page edited date. |
The following example limits the results to the top 5 newly updated or created pages (including comments). The styling also shrinks the template and centers within the container.
WhatsNew {
title: 'New or updated App Catalog entries with comments',
path: 'app catalog',
max: 5,
depth: 1,
dateformat: 'MM/dd/yyyy',
blockstyle: 'width:50%; margin: 0 auto;',
titlestyle: 'background-color: rgb(234, 234, 234);text-align: center;padding: 2px;font-weight: bold;font-size: 16px;border-style: outset;'
}
The following example limits the results to the top 10 newly updated or created pages (NOT including comments) and will evaluate pages down 2 levels from the start page.
WhatsNew {
title: 'New or updated App Catalog entries no comments',
path: 'app catalog',
max: 10,
depth: 2,
comments: false,
titlesyle: 'background-color: rgb(234, 234, 234);text-align: center;padding: 2px;font-weight: bold;font-size: 16px;border-style: outset;'
}
The following example limits the results to the top 10 newly created pages and will evaluate pages down 2 levels from the start page.
WhatsNew {
title: 'Newest App Catalog entries',
path: 'app catalog',
max: 10,
depth: 2,
onlynew: true,
titlesyle: background-color: rgb(234, 234, 234);text-align: center;padding: 2px;font-weight: bold;font-size: 16px;border-style: outset;'
}
None.
Everyone in the MindTouch Community Forum
/* WARNING
* WARNING: this community-contributed template is not fit for production use as it performs a complete db-scan with every invocation
* WARNING
*/
// Parameters:
// title: The title text
// Path: path to the starting page
// max: Maximum number of items to list
// comments: Include comment date when checking for newest changes
// dateformat: Date Format mask
// blockstyle: Any valid styling. The entire template is wrapped in this template
// titlestyle: Any valid styling. This controls the title area of this template
// bodystyle: Any valid styling. This control the content or body of this template
// onlynew: Only list the newest pages by original creation date.
/*
In a dekiscript block:
whatsnew2{ title: 'testing',
path: '/resources',
max: 5,
depth: 1,
comments: true,
dateformat:'MM/dd/yyyy'
};
Vesion History: 1.0 - Initial release
1.1 - Optimized code, added: Styles, DateFormat Options, Div Containers
1.2 - Changed from using div id's to div classes
Added the ability to order pages by original creation date
1.3 - (neilw) switched to using @pageid to look up pages
*/
var title = ($0 ?? args.title ?? 'Whats New!');
var path = ($1 ?? args.path ?? page.path);
var maxnum = ($2 ?? args.max ?? 10);
var depth = ($3 ?? args.depth ?? 10);
var tstcmts = ($4 ?? args.comments ?? true);
var dteformat = ($5 ?? args.dateformat ?? 'MM/dd/yyyy hh:mm:ss');
var blockstyle = ($6 ?? args.blockstyle ?? 'width:100%');
var titlestyle = ($7 ?? args.titlestyle ?? 'background-color: rgb(234, 234, 234);text-align: center;padding: 2px;font-weight: bold;font-size: 16px;border-style: outset;');
var bodystyle = ($87 ?? args.bodystyle ?? 'background-color: #FFF;padding: 2px;border-style: solid;border-width: 1px;text-align: left;');
var onlynew = ($9 ?? args.onlynew ?? false);
var cmtdte = '';
var pagedte='';
var latestdte='';
var lst = [];
var cmtoredit = '';
var pxml = wiki.tree(path,depth);
foreach(var pid in xml.list(pxml, "//a/@pageid")) {
let p = wiki.getpage(num.cast(pid));
let pagedte = p.date;
if (pagedte is nil) continue;
if(onlynew == false) {
if(tstcmts == true) {
let cmtdte = (p.comments[#p.comments-1].date ?? p.date);
// let latestdte = ((date.format(p.date,'s') > date.format(cmtdte,'s')) ? p.date : cmtdte);
// let cmtoredit = ((date.format(p.date,'s') >= date.format(cmtdte,'s')) ? 'p' : 'c');
let latestdte = ((date.compare(p.date, cmtdte) >=0 ) ? p.date : cmtdte);
let cmtoredit = ((date.compare(p.date, cmtdte) >=0 ) ? 'p' : 'c');
} else {
let latestdte = date.format(p.date,'s');
let cmtoredit = 'p';
}
let latestdte = ((date.isvalid(latestdte) == 'true') ? date.format(latestdte, 's') : '01/01/2099');
let lst ..=[ {uri: p.uri, path: p.path, title: p.title, pagedate: pagedte, cmtdate: cmtdte, latestdate: latestdte, pgorcmt: cmtoredit } ];
} else {
let lst ..=[ {uri: p.uri, path: p.path, title: p.title, pagedate: p.date, latestdate: date.format(p.revisions[0].date,'s'), pgorcmt: 'n' } ];
}
}
let lst = list.sort(lst, 'latestdate', true);
<div class="whtsnew" style=(blockstyle)>
<div class="whtsnewttl" style=(titlestyle)>
title;
</div>
<div class="whtsnewbdy" style=(bodystyle)>
foreach(var p in lst) {
if(__count >= maxnum) {break;}
if(p.uri) {
if(onlynew == false) {
web.link(p.uri, p.title); <span style="font-size: xx-small;">;' - ' ..((p.pgorcmt == 'p') ? ' Page Edited on: ' : ' Comment Added on: ') ..date.format(p.latestdate, dteformat); </span> <br/>;
} else {
web.link(p.uri, p.title); <span style="font-size: xx-small;">;' - ' ..' Page Created on: ' ..date.format(p.latestdate, dteformat); </span> <br/>;
}
}
}
</div>
</div>
// styles
<html>
<head>
<style type="text/css">"
div.whtsnew {
width: 100%;
}
div.whtsnewttl {
background-color: rgb(234, 234, 234);
text-align: center;
padding: 2px;
font-weight: bold;
font-size: 16px;
border-style: outset;
}
div.whtsnewbdy {
background-color: #FFF;
padding: 2px;
border-style: solid;
border-width: 1px;
text-align: left;
}
"
</style>
</head>
</html>
None.
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by
Oh yeah... Thank you for your kind comments. edited 10:40, 31 Aug 2009
On every other page the template is working! edited 04:31, 17 Dec 2009
{{NewPages()}}
{{NewPages{title: 'Newest Pages', max: 6, depth: 4, path:page.parent.path}}}
I tried it also from a different page with the following:
NewPages{title: 'Newest Pages', path:''}
All of them with the message: /content/body/pre, function 'date.compare' failed (click for details)
The "date.compare" failure should be fixed now with the new version. Give it a try.
{{ PagesMonitor{favorites:false, paths:[ "path to monitor"]} }} edited 07:10, 19 Mar 2010
Source code is back, sorry about that folks.