MindTouch Developer Center > DekiScript > Samples/FAQ > How do I... Display a list of files attached to a page?
Table of contents
  1. 1. Sample Output

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>"
        );
    }
}
}}

Sample Output

9 files are attached to page Extensions

1) remote-service.png
Description:
Date: Wed, 25 Jul 2007 00:30:56 GMT
Size: 132895 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/437/=remote-service.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/437
Mime: image/png
Author:
Page:

2) yahoo-stock.png
Description: Yahoo! Finance stock widget
Date: Wed, 27 Jun 2007 00:57:26 GMT
Size: 19764 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/443/=yahoo-stock.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/443
Mime: image/png
Author:
Page:

3) imagemagick.png
Description: ImageMagick Polaroid effect
Date: Wed, 27 Jun 2007 01:28:03 GMT
Size: 58540 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/446/=imagemagick.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/446
Mime: image/png
Author:
Page:

4) service-mgmt.png
Description:
Date: Wed, 25 Jul 2007 00:30:54 GMT
Size: 154378 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/436/=service-mgmt.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/436
Mime: image/png
Author:
Page:

5) flickr.png
Description: Flickr Slideshow & Badge
Date: Tue, 26 Jun 2007 05:02:14 GMT
Size: 186960 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/438/=flickr.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/438
Mime: image/png
Author:
Page:

6) control-panel.png
Description:
Date: Wed, 25 Jul 2007 00:30:52 GMT
Size: 138195 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/435/=control-panel.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/435
Mime: image/png
Author:
Page:

7) graphviz.png
Description: Graphviz graph
Date: Wed, 27 Jun 2007 01:28:03 GMT
Size: 11236 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/445/=graphviz.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/445
Mime: image/png
Author:
Page:

8) google-maps.png
Description: Google Maps with marker and pop-up
Date: Tue, 26 Jun 2007 05:02:17 GMT
Size: 57698 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/439/=google-maps.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/439
Mime: image/png
Author:
Page:

9) math.png
Description: Advanced math formulae rendering
Date: Tue, 26 Jun 2007 05:02:18 GMT
Size: 3575 bytes
URI: http://wiki.developer.mindtouch.com/@api/deki/files/440/=math.png
API: http://wiki.developer.mindtouch.com/@api/deki/files/440
Mime: image/png
Author:
Page:

Tag page
You must login to post a comment.
Powered by MindTouch Deki v.8.08.1a