diff options
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js | 19 | ||||
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/models/tagQuery.js | 25 |
2 files changed, 25 insertions, 19 deletions
diff --git a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js index ac0d949..f0b7470 100644 --- a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js +++ b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js @@ -35,20 +35,10 @@ import("etherpad.pad.padutils"); function onRequest() { - var tags = new Array(); - var antiTags = new Array(); - - if (request.params.query != undefined && request.params.query != '') { - var query = request.params.query.split(','); - for (i = 0; i < query.length; i++) - if (query[i][0] == '!') - antiTags.push(query[i].substring(1)); - else - tags.push(query[i]); - } + var tags = tagQuery.queryToTags(request.params.query); /* Create the pad filter sql */ - var querySql = tagQuery.getQueryToSql(tags.concat(['public']), antiTags); + var querySql = tagQuery.getQueryToSql(tags.tags.concat(['public']), tags.antiTags); /* Use the pad filter sql to figure out which tags to show in the tag browser this time. */ var queryNewTagsSql = tagQuery.newTagsSql(querySql); @@ -77,7 +67,6 @@ function onRequest() { var isProUser = (isPro && ! padusers.isGuest(userId)); - padutils.setOptsAndCookiePrefs(request); var prefs = helpers.getClientVar('cookiePrefsToSet'); var bodyClass = (prefs.isFullWidth ? "fullwidth" : "limwidth") @@ -87,8 +76,8 @@ function onRequest() { config: appjet.config, tagQuery: tagQuery, padIdToReadonly: server_utils.padIdToReadonly, - tags: tags, - antiTags: antiTags, + tags: tags.tags, + antiTags: tags.antiTags, newTags: newTags, matchingPads: matchingPads, bodyClass: 'nonpropad', diff --git a/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js b/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js index 8665b96..8a32ef7 100644 --- a/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js +++ b/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js @@ -21,10 +21,27 @@ import("sqlbase.sqlobj"); import("etherpad.log"); function tagsToQuery(tags, antiTags) { - var prefixed = []; - for (i = 0; i < antiTags.length; i++) - prefixed[i] = '!' + antiTags[i]; - return tags.concat(prefixed).join(','); + var prefixed = []; + for (i = 0; i < antiTags.length; i++) + prefixed[i] = '!' + antiTags[i]; + return tags.concat(prefixed).join(','); +} + +function queryToTags(query) { + var tags = { + tags: new Array(), + antiTags: new Array() + }; + + if (query != undefined && query != '') { + var query = query.split(','); + for (i = 0; i < query.length; i++) + if (query[i][0] == '!') + tags.antiTags.push(query[i].substring(1)); + else + tags.tags.push(query[i]); + } + return tags; } function stringFormat(text, obj) { |