<% Global.storylist %>
function renders a list of stories either contained in a topic or from the story collection. param.sortby determines the sort criteria (title, createtime, modifytime); param.order determines the sort order (asc or desc) param.show determines the text type (story, comment or all)

Sourcecode in Global/macros.js:
1:   function storylist_macro(param) {
2:      // disable caching of any contentPart containing this macro
3:      req.data.cachePart = false;
4:      var site = param.of ? root.get(param.of) : res.handlers.site;
5:      if (!site)
6:         return;
7:   
8:      // untrusted sites are only allowed to use "light" version
9:      if (res.handlers.site && !res.handlers.site.trusted) {
10:        param.limit = param.limit ? Math.min(site.allstories.count(), parseInt(param.limit), 50) : 25;
11:        for (var i=0; i<param.limit; i++) {
12:           var story = site.allcontent.get(i);
13:           if (!story)
14:              continue;
15:           res.write(param.itemprefix);
16:           Html.openLink({href: story.href()});
17:           var str = story.title;
18:           if (!str)
19:              str = story.getRenderedContentPart("text").clip(20).softwrap(30);
20:           res.write(str ? str : "...");
21:           Html.closeLink();
22:           res.write(param.itemsuffix);
23:        }
24:        return;
25:     }
26:  
27:     // this is db-heavy action available for trusted users only (yet?)
28:     if (param.sortby != "title" && param.sortby != "createtime" && param.sortby != "modifytime")
29:        param.sortby = "modifytime";
30:     if (param.order != "asc" && param.order != "desc")
31:        param.order = "asc";
32:     var order = " order by TEXT_" + param.sortby.toUpperCase() + " " + param.order;
33:     var rel = "";
34:     if (param.show == "stories")
35:        rel += " and TEXT_PROTOTYPE = 'story'";
36:     else if (param.show == "comments")
37:        rel += " and TEXT_PROTOTYPE = 'comment'";
38:     if (param.topic)
39:        rel += " and TEXT_TOPIC = '" + param.topic + "'";
40:     var query = "select TEXT_ID from AV_TEXT where TEXT_F_SITE = " + site._id + " and TEXT_ISONLINE > 0" + rel + order;
41:     var connex = getDBConnection("antville");
42:     var rows = connex.executeRetrieval(query);
43:  
44:     if (rows) {
45:        var cnt = 0;
46:        param.limit = param.limit ? Math.min(parseInt(param.limit), 100) : 25;
47:        while (rows.next() && (cnt < param.limit)) {
48:           cnt++;
49:           var id = rows.getColumnItem("TEXT_ID").toString();
50:           var story = site.allcontent.get(id);
51:           if (!story)
52:              continue;
53:           res.write(param.itemprefix);
54:           Html.openLink({href: story.href()});
55:           var str = story.title;
56:           if (!str)
57:              str = story.getRenderedContentPart("text").clip(20).softwrap(30);
58:           res.write(str ? str : "...");
59:           Html.closeLink();
60:           res.write(param.itemsuffix);
61:        }
62:     }
63:     rows.release();
64:     return;
65:  }