aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-03-28 03:26:16 +0200
committerEgil Moeller <egil.moller@freecode.no>2010-03-28 03:26:16 +0200
commitc177de288a16dbe6e88acdb91a6488a191df41cc (patch)
tree494476e911fcd7412cd0a5aeb3754ac435a46e1e
parent1d1583996664d21ff56c805d55179b745c8d466f (diff)
downloadetherpad-c177de288a16dbe6e88acdb91a6488a191df41cc.tar.gz
etherpad-c177de288a16dbe6e88acdb91a6488a191df41cc.tar.xz
etherpad-c177de288a16dbe6e88acdb91a6488a191df41cc.zip
Added RSS support for the tag browser
-rw-r--r--etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js22
-rw-r--r--etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs1
-rw-r--r--etherpad/src/plugins/twitterStyleTags/templates/tagRss.ejs69
3 files changed, 88 insertions, 4 deletions
diff --git a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js
index 46175c8..461f30a 100644
--- a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js
+++ b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js
@@ -199,6 +199,7 @@ function onRequest() {
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 ' +
@@ -207,7 +208,7 @@ function onRequest() {
' join PAD_TAG_CACHE as c on ' +
' c.PAD_ID = q.ID ' +
'order by ' +
- ' lastWriteTime desc ' +
+ ' m.lastWriteTime desc ' +
'limit 10';
matchingPads = sqlobj.executeRaw(sql, querySql.params);
@@ -232,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,
@@ -245,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;
}
diff --git a/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs b/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs
index 61c8e93..1f1c0e3 100644
--- a/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs
+++ b/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs
@@ -40,6 +40,7 @@ limitations under the License. */ %>
helpers.includeJs("pad2.js");
helpers.suppressGA();
helpers.setRobotsPolicy({index: false, follow: false});
+ helpers.addToHead('\n<link rel="alternate" href="/ep/tag/?query=' + tagsToQuery(tags, antiTags) + '&format=rss" type="application/rss+xml" title="Query results as RSS" />\n');
function inArray(item, arr) {
for (var i = 0; i < arr.length; i++)
diff --git a/etherpad/src/plugins/twitterStyleTags/templates/tagRss.ejs b/etherpad/src/plugins/twitterStyleTags/templates/tagRss.ejs
new file mode 100644
index 0000000..2d06781
--- /dev/null
+++ b/etherpad/src/plugins/twitterStyleTags/templates/tagRss.ejs
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<%
+ function inArray(item, arr) {
+ for (var i = 0; i < arr.length; i++)
+ if (arr[i] == item)
+ return true;
+ return false;
+ }
+%>
+<rss version="2.0">
+ <channel>
+ <title>
+ <% if (tags.length == 0 && antiTags.length == 0) { %>
+ Latest changed pads
+ <% } else { %>
+ <% for (i = 0; i < tags.length; i++) { %>
+ #<%= tags[i] %>
+ <% } %>
+ <% for (i = 0; i < antiTags.length; i++) { %>
+ !#<%= antiTags[i] %>
+ <% } %>
+ <% } %>
+ </title>
+ <link>http://liftoff.msfc.nasa.gov/</link>
+ <description>
+ Etherpad pads / changes for the query:
+ <% if (tags.length == 0 && antiTags.length == 0) { %>
+ Latest changed pads
+ <% } else { %>
+ <% for (i = 0; i < tags.length; i++) { %>
+ #<%= tags[i] %>
+ <% } %>
+ <% for (i = 0; i < antiTags.length; i++) { %>
+ !#<%= antiTags[i] %>
+ <% } %>
+ <% } %>
+ </description>
+ <language>en-us</language>
+ <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
+ <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
+ <docs>http://blogs.law.harvard.edu/tech/rss</docs>
+ <generator>Etherpad</generator>
+ <managingEditor>editor@example.com</managingEditor>
+ <webMaster>webmaster@example.com</webMaster>
+
+ <% for (i = 0; i < matchingPads.length; i++) { %>
+ <%
+ var matchingPadId = matchingPads[i].ID;
+ var matchingPadUrl = matchingPadId;
+ if (!inArray('writable', matchingPads[i].TAGS)) {
+ matchingPadId = padIdToReadonly(matchingPads[i].ID);
+ matchingPadUrl = 'ep/pad/view/' + matchingPadId + '/latest';
+ }
+ %>
+ <item>
+ <title><%= matchingPadId %></title>
+ <link>http://<%= request.host %>/<%= matchingPadUrl %></link>
+ <description>
+ <% for (j = 0; j < matchingPads[i].TAGS.length; j++) { %>
+ #<%= matchingPads[i].TAGS[j] %>
+ <% } %>
+ </description>
+ <pubDate><%= matchingPads[i].lastWriteTime %></pubDate>
+ <guid>http://<%= request.host %>/<%= matchingPadUrl %></guid>
+ </item>
+ <% } %>
+
+ </channel>
+</rss> \ No newline at end of file