diff options
Diffstat (limited to 'etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js')
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js index f5e63f7..461f30a 100644 --- a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js +++ b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js @@ -196,12 +196,22 @@ function onRequest() { var newTags = sqlobj.executeRaw(queryNewTagsSql.sql, queryNewTagsSql.params); var matchingPads; - if (tags.length > 0 || antiTags.length > 0) { - var sql = "select p.PAD_ID as ID, p.TAGS from PAD_TAG_CACHE as p, " + querySql.sql + " as q where p.PAD_ID = q.ID limit 10" + var sql = '' + + 'select ' + + ' m.id as ID, ' + + ' DATE_FORMAT(m.lastWriteTime, \'%a, %d %b %Y %H:%i:%s GMT\') as lastWriteTime, ' + + ' c.TAGS ' + + 'from ' + + querySql.sql + ' as q ' + + ' join PAD_SQLMETA as m on ' + + ' m.id = q.ID ' + + ' join PAD_TAG_CACHE as c on ' + + ' c.PAD_ID = q.ID ' + + 'order by ' + + ' m.lastWriteTime desc ' + + 'limit 10'; + matchingPads = sqlobj.executeRaw(sql, querySql.params); - } else { - matchingPads = []; - } for (i = 0; i < matchingPads.length; i++) { matchingPads[i].TAGS = matchingPads[i].TAGS.split('#'); @@ -223,8 +233,7 @@ function onRequest() { var isProUser = (isPro && ! padusers.isGuest(userId)); - renderHtml("tagBrowser.ejs", - { + var info = { config: appjet.config, tagsToQuery: tagsToQuery, padIdToReadonly: server_utils.padIdToReadonly, @@ -236,6 +245,20 @@ function onRequest() { isPro: isPro, isProAccountHolder: isProUser, account: getSessionProAccount(), // may be falsy - }, 'twitterStyleTags'); + }; + + var format = "html"; + if (request.params.format != undefined) + format = request.params.format; + + if (format == "html") + renderHtml("tagBrowser.ejs", info, 'twitterStyleTags'); + else if (format == "rss") { + response.setContentType("application/xml; charset=utf-8"); + response.write(renderTemplateAsString("tagRss.ejs", info, 'twitterStyleTags')); + if (request.acceptsGzip) { + response.setGzip(true); + } + } return true; } |