/* 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>| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by