aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-04-17 00:16:58 +0200
committerEgil Moeller <egil.moller@freecode.no>2010-04-17 00:16:58 +0200
commit630d57aa4d017cca3d12f234497e9832005c3ded (patch)
tree8322f566d9b6066613a8474a0a7c580e0e1d82df
parent6bd555cb7ff5f45b041eab0179fa758e50a5158c (diff)
downloadetherpad-630d57aa4d017cca3d12f234497e9832005c3ded.tar.gz
etherpad-630d57aa4d017cca3d12f234497e9832005c3ded.tar.xz
etherpad-630d57aa4d017cca3d12f234497e9832005c3ded.zip
Fixed so that parts of a URL query can be modified w/o affecting the rest of the query
-rw-r--r--etherpad/src/etherpad/helpers.js26
-rw-r--r--etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js2
-rw-r--r--etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs12
-rw-r--r--etherpad/src/plugins/urlIndexer/controllers/urlBrowser.js4
-rw-r--r--etherpad/src/plugins/urlIndexer/templates/urlBrowser.ejs4
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<link rel="alternate" href="/ep/tag/?query=' + tagQuery.tagsToQuery(tags, antiTags) + '&format=rss" type="application/rss+xml" title="Query results as RSS" />\n');
+ helpers.addToHead('\n<link rel="alternate" href="' + helpers.updateToUrl({format:'rss'}) + '" type="application/rss+xml" title="Query results as RSS" />\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++) { %>
- <a href="/ep/tag/?query=<%= tagQuery.tagsToQuery(tags.filter(function (tag) { return tag != tags[i]}), antiTags) %>" class="padtag" title="<%= tags[i] %> matches">#<%= tags[i] %></a>
+ <a href="<%= helpers.updateToUrl({query:tagQuery.tagsToQuery(tags.filter(function (tag) { return tag != tags[i]}), antiTags)}) %>" class="padtag" title="<%= tags[i] %> matches">#<%= tags[i] %></a>
<% } %>
<% for (i = 0; i < antiTags.length; i++) { %>
- <a href="/ep/tag/?query=<%= tagQuery.tagsToQuery(tags, antiTags.filter(function (tag) { return tag != antiTags[i]})) %>" class="anti_padtag" title="<%= antiTags[i] %> matches">!#<%= antiTags[i] %></a>
+ <a href="<%= helpers.updateToUrl({query:tagQuery.tagsToQuery(tags, antiTags.filter(function (tag) { return tag != antiTags[i]}))}) %>" class="anti_padtag" title="<%= antiTags[i] %> matches">!#<%= antiTags[i] %></a>
<% } %>
<% } %>
</td>
@@ -74,12 +74,12 @@ limitations under the License. */ %>
<%: template.use('queryRefiner', function() { var ejs_data=''; %>
<h1>Search for pads that have the tag</h1>
<% for (i = 0; i < newTags.length; i++) { %>
- <a href="/ep/tag/?query=<%= tagQuery.tagsToQuery(tags.concat([newTags[i].tagname]),antiTags) %>" class="padtag" title="<%= newTags[i].matches %> matches">#<%= newTags[i].tagname %></a>
+ <a href="<%= helpers.updateToUrl({query:tagQuery.tagsToQuery(tags.concat([newTags[i].tagname]),antiTags)}) %>" class="padtag" title="<%= newTags[i].matches %> matches">#<%= newTags[i].tagname %></a>
<% } %>
<h1>Search for pads that <em>don't</em> have the tag</h1>
<% for (i = 0; i < newTags.length; i++) { %>
- <a href="/ep/tag/?query=<%= tagQuery.tagsToQuery(tags,antiTags.concat([newTags[i].tagname])) %>" class="anti_padtag" title="<%= newTags[i].antimatches %> matches">!#<%= newTags[i].tagname %></a>
+ <a href="<%= helpers.updateToUrl({query:tagQuery.tagsToQuery(tags,antiTags.concat([newTags[i].tagname]))}) %>" class="anti_padtag" title="<%= newTags[i].antimatches %> matches">!#<%= newTags[i].tagname %></a>
<% } %>
<% return ejs_data; }); %>
</div>
@@ -98,7 +98,7 @@ limitations under the License. */ %>
<dt><a href="/<%= matchingPadUrl %>"><%= matchingPadId %></a><dt>
<dd>
<% for (j = 0; j < matchingPads[i].TAGS.length; j++) { %>
- <a href="/ep/tag/?query=<%= tagQuery.tagsToQuery(tags.concat([matchingPads[i].TAGS[j]]), antiTags) %>" class="padtag" title="<%= matchingPads[i].TAGS[j] %> matches">#<%= matchingPads[i].TAGS[j] %></a>
+ <a href="<%= helpers.updateToUrl({query:tagQuery.tagsToQuery(tags.concat([matchingPads[i].TAGS[j]]), antiTags)}) %>" class="padtag" title="<%= matchingPads[i].TAGS[j] %> matches">#<%= matchingPads[i].TAGS[j] %></a>
<% } %>
</dd>
<% } %>
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<link rel="alternate" href="/ep/url/?query=' + tagQuery.tagsToQuery(tags, antiTags) + '&format=rss" type="application/rss+xml" title="Query results as RSS" />\n');
+ helpers.addToHead('\n<link rel="alternate" href="' + helpers.updateToUrl({format:'rss'}) + '" type="application/rss+xml" title="Query results as RSS" />\n');
function inArray(item, arr) {
for (var i = 0; i < arr.length; i++)
@@ -46,7 +46,7 @@ limitations under the License. */ %>
<dd>
<a href="<%= matchingPadUrl %>"><%= matchingPadId %></a>:
<% for (j = 0; j < matchingUrls[i].TAGS.length; j++) { %>
- <a href="/ep/url/?query=<%= tagQuery.tagsToQuery(tags.concat([matchingUrls[i].TAGS[j]]), antiTags) %>" class="padtag" title="<%= matchingUrls[i].TAGS[j] %> matches">#<%= matchingUrls[i].TAGS[j] %></a>
+ <a href="<%= helpers.updateToUrl({query:tagQuery.tagsToQuery(tags.concat([matchingUrls[i].TAGS[j]]), antiTags)}) %>" class="padtag" title="<%= matchingUrls[i].TAGS[j] %> matches">#<%= matchingUrls[i].TAGS[j] %></a>
<% } %>
</dd>
<% } %>