From 630d57aa4d017cca3d12f234497e9832005c3ded Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Sat, 17 Apr 2010 00:16:58 +0200 Subject: Fixed so that parts of a URL query can be modified w/o affecting the rest of the query --- etherpad/src/etherpad/helpers.js | 26 ++++++++++++++++++++++ .../twitterStyleTags/controllers/tagBrowser.js | 2 +- .../twitterStyleTags/templates/tagBrowser.ejs | 12 +++++----- .../plugins/urlIndexer/controllers/urlBrowser.js | 4 ++-- .../plugins/urlIndexer/templates/urlBrowser.ejs | 4 ++-- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/etherpad/src/etherpad/helpers.js b/etherpad/src/etherpad/helpers.js index aec3bc3..54bee2d 100644 --- a/etherpad/src/etherpad/helpers.js +++ b/etherpad/src/etherpad/helpers.js @@ -278,3 +278,29 @@ function rafterTerminationDate() { return "March 31, 2010"; } +function updateToUrl(setParams, deleteParams, setPath) { + var params = {}; + + for (param in request.params) + if (deleteParams === undefined || deleteParams.indexOf(param) == -1) + params[param] = request.params[param]; + + if (setParams !== undefined) + for (param in setParams) + params[param] = setParams[param]; + + var path = request.path; + if (setPath !== undefined) + path = setPath; + + var paramStr = ''; + for (param in params) { + if (paramStr == '') + paramStr += '?'; + else + paramStr += '&'; + paramStr += param + '=' + params[param]; + } + + return path + paramStr; +} \ No newline at end of file diff --git a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js index f0b7470..5335ab7 100644 --- a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js +++ b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js @@ -34,7 +34,7 @@ import("sqlbase.sqlobj"); import("etherpad.pad.padutils"); -function onRequest() { +function onRequest() { var tags = tagQuery.queryToTags(request.params.query); /* Create the pad filter sql */ diff --git a/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs b/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs index c5b6215..ea1076e 100644 --- a/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs +++ b/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs @@ -18,7 +18,7 @@ limitations under the License. */ %> helpers.setHtmlTitle("EtherPad: Browse tags"); helpers.includeCss("plugins/twitterStyleTags/tagBrowser.css"); helpers.includeCss("plugins/twitterStyleTags/pad.css"); - helpers.addToHead('\n\n'); + helpers.addToHead('\n\n'); function inArray(item, arr) { for (var i = 0; i < arr.length; i++) @@ -59,10 +59,10 @@ limitations under the License. */ %> Latest changed pads <% } else { %> <% for (i = 0; i < tags.length; i++) { %> - #<%= tags[i] %> + #<%= tags[i] %> <% } %> <% for (i = 0; i < antiTags.length; i++) { %> - !#<%= antiTags[i] %> + !#<%= antiTags[i] %> <% } %> <% } %> @@ -74,12 +74,12 @@ limitations under the License. */ %> <%: template.use('queryRefiner', function() { var ejs_data=''; %>

Search for pads that have the tag

<% for (i = 0; i < newTags.length; i++) { %> - #<%= newTags[i].tagname %> + #<%= newTags[i].tagname %> <% } %>

Search for pads that don't have the tag

<% for (i = 0; i < newTags.length; i++) { %> - !#<%= newTags[i].tagname %> + !#<%= newTags[i].tagname %> <% } %> <% return ejs_data; }); %> @@ -98,7 +98,7 @@ limitations under the License. */ %>
<%= matchingPadId %>
<% for (j = 0; j < matchingPads[i].TAGS.length; j++) { %> - #<%= matchingPads[i].TAGS[j] %> + #<%= matchingPads[i].TAGS[j] %> <% } %>
<% } %> diff --git a/etherpad/src/plugins/urlIndexer/controllers/urlBrowser.js b/etherpad/src/plugins/urlIndexer/controllers/urlBrowser.js index ebd39bd..cdb9602 100644 --- a/etherpad/src/plugins/urlIndexer/controllers/urlBrowser.js +++ b/etherpad/src/plugins/urlIndexer/controllers/urlBrowser.js @@ -72,8 +72,8 @@ function onRequest() { var queryNewTagsSql = tagQuery.newTagsSql(querySql); var newTags = sqlobj.executeRaw(queryNewTagsSql.sql, queryNewTagsSql.params); - urlSql = urlSql(querySql, 10); - var matchingUrls = sqlobj.executeRaw(urlSql.sql, urlSql.params); + url = urlSql(querySql, 10); + var matchingUrls = sqlobj.executeRaw(url.sql, url.params); for (i = 0; i < matchingUrls.length; i++) { matchingUrls[i].TAGS = matchingUrls[i].TAGS.split('#'); diff --git a/etherpad/src/plugins/urlIndexer/templates/urlBrowser.ejs b/etherpad/src/plugins/urlIndexer/templates/urlBrowser.ejs index a254dc1..1996dc5 100644 --- a/etherpad/src/plugins/urlIndexer/templates/urlBrowser.ejs +++ b/etherpad/src/plugins/urlIndexer/templates/urlBrowser.ejs @@ -18,7 +18,7 @@ limitations under the License. */ %> helpers.setHtmlTitle("EtherPad: Browse URLs by tags"); helpers.includeCss("plugins/twitterStyleTags/tagBrowser.css"); helpers.includeCss("plugins/twitterStyleTags/pad.css"); - helpers.addToHead('\n\n'); + helpers.addToHead('\n\n'); function inArray(item, arr) { for (var i = 0; i < arr.length; i++) @@ -46,7 +46,7 @@ limitations under the License. */ %>
<%= matchingPadId %>: <% for (j = 0; j < matchingUrls[i].TAGS.length; j++) { %> - #<%= matchingUrls[i].TAGS[j] %> + #<%= matchingUrls[i].TAGS[j] %> <% } %>
<% } %> -- cgit v1.2.3