This is a working DekiScript block to list the files attached to the Extensions page.
{{
var page = wiki.getpage( '/MindTouch_Deki/Extensions' );
if( #map.values( page.files ) == 0 ) {
web.html( "<p>No files are attached to page " .. page.name .. "</p>" );
}
else {
web.html( "<p>" .. #map.values( page.files ) .. " files are attached to page " .. page.name .. "</p>" );
foreach( var file in map.values( page.files ) ) {
web.html(
"<p>" ..
__count + 1 .. ") <b>" .. file.name .. "</b><br />" ..
"<i>Description:</i> " .. file.description .. "<br />" ..
"<i>Date:</i> " .. file.date .. "<br />" ..
"<i>Size:</i> " .. file.size .. " bytes<br />" ..
"<i>URI:</i> <a href='" .. file.uri .. "'>" .. file.uri .. "</a><br />" ..
"<i>API:</i> <a href='" .. file.api .. "'>" .. file.api .. "</a><br />" ..
"<i>Mime:</i> " .. file.mime .. "<br />" ..
"<i>Author:</i> " .. file.author .. "<br />" ..
"<i>Page:</i> " .. file.page .. "<br />" ..
"</p>"
);
}
}
}}
2 files are attached to page Display_a_list_of_files_attached_to_a_page
1) dir300.release.note.txt
Description: Simple description
Date: Tue, 26 Oct 2010 07:48:35 GMT
Size: 30865 bytes
URI: http://developer.mindtouch.com/@api/deki/files/4306/=dir300.release.note.txt
API: http://developer.mindtouch.com/@api/deki/files/4306
Mime: text/plain
Author: SteveB
Page: Display a list of files attached to a page
2) dir300_v1.05_93gb.bin
Description: Simple description
Date: Tue, 26 Oct 2010 07:48:36 GMT
Size: 2416768 bytes
URI: http://developer.mindtouch.com/@api/deki/files/4307/=dir300_v1.05_93gb.bin
API: http://developer.mindtouch.com/@api/deki/files/4307
Mime: text/plain
Author: SteveB
Page: Display a list of files attached to a page
| File | Version | Size | Modified | |
|---|---|---|---|---|
| ||||
| ||||
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by
It works Perfect!
I wanna sort it by file Description, I did this way: list.sort(map.values( page.files ), 'desc') but it doesn't sort it,
change the order but not on alphabetic way. what can I do?
Thanks! edited 07:43, 13 Jul 2009
this error show me:
/content/body/div/p/span/span/span, function 'list.sort' failed
can you help me? thanks! edited 06:52, 23 Jul 2009
Please, tell us also what version of mindtouch you're running. edited 05:54, 27 Jul 2009
Now it's working fine.
thanks for your reply! edited 08:28, 29 Jul 2009
I have checked the script multiple times, but can't see where the problem is. I'm sure it must be something simple - any advice? Thanks.
thanks!!
file1
file2
file3
.
.
file10
file11
etc etc
How can I sort on the "mathematical" value of the numbers at the end of the filename, so that they display in order file1,file2,file3,file10,file11 - instead of file1,file10,file11,file2,file3 ?
I guess it's quite simple, but I've not enough Dekiscript knowledge to figure it out yet!
I get this error:
content/body/p/span, line 1, column 507: invalid XmlNode
Any ideas to fix it? thanks!