From f7dd3aa34cad8a59ad00172339c565731ad80fbb Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Thu, 25 Mar 2010 18:21:35 +0100 Subject: Generalized linestylefilter.getURLFilter to a linestylefilter.getRegexpFilter --- .../twitterStyleTags/controllers/tagBrowser.js | 57 ++++++++++++++++++++++ etherpad/src/plugins/twitterStyleTags/hooks.js | 12 +++++ etherpad/src/plugins/twitterStyleTags/main.js | 23 +++++++++ .../src/plugins/twitterStyleTags/static/js/main.js | 11 +++++ .../twitterStyleTags/templates/tagBrowser.ejs | 28 +++++++++++ 5 files changed, 131 insertions(+) create mode 100644 etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js create mode 100644 etherpad/src/plugins/twitterStyleTags/hooks.js create mode 100644 etherpad/src/plugins/twitterStyleTags/main.js create mode 100644 etherpad/src/plugins/twitterStyleTags/static/js/main.js create mode 100644 etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs (limited to 'etherpad/src/plugins') diff --git a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js new file mode 100644 index 0000000..bf7c5b7 --- /dev/null +++ b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js @@ -0,0 +1,57 @@ +/** + * Copyright 2009 RedHog, Egil Möller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import("faststatic"); +import("dispatch.{Dispatcher,PrefixMatcher,forward}"); + +import("etherpad.utils.*"); +import("etherpad.collab.server_utils"); +import("etherpad.globals.*"); +import("etherpad.log"); +import("etherpad.pad.padusers"); +import("etherpad.pro.pro_utils"); +import("etherpad.helpers"); +import("etherpad.pro.pro_accounts.getSessionProAccount"); +import("sqlbase.sqlbase"); +import("sqlbase.sqlcommon"); +import("sqlbase.sqlobj"); + + +function onRequest() { + var isPro = pro_utils.isProDomainRequest(); + var userId = padusers.getUserId(); + + helpers.addClientVars({ + userAgent: request.headers["User-Agent"], + debugEnabled: request.params.djs, + clientIp: request.clientAddr, + colorPalette: COLOR_PALETTE, + serverTimestamp: +(new Date), + isProPad: isPro, + userIsGuest: padusers.isGuest(userId), + userId: userId, + }); + + var isProUser = (isPro && ! padusers.isGuest(userId)); + + renderHtml("tagBrowser.ejs", + { + isPro: isPro, + isProAccountHolder: isProUser, + account: getSessionProAccount(), // may be falsy + }, 'twitterStyleTags'); + return true; +} diff --git a/etherpad/src/plugins/twitterStyleTags/hooks.js b/etherpad/src/plugins/twitterStyleTags/hooks.js new file mode 100644 index 0000000..65aef83 --- /dev/null +++ b/etherpad/src/plugins/twitterStyleTags/hooks.js @@ -0,0 +1,12 @@ +import("etherpad.log"); +import("dispatch.{Dispatcher,PrefixMatcher,forward}"); +import("plugins.twitterStyleTags.controllers.tagBrowser"); + +function aceGetFilterStack() { + log.info("aceGetFilterStack"); + return []; +} + +function handlePath() { + return [[PrefixMatcher('/ep/tags/'), forward(tagBrowser)]]; +} diff --git a/etherpad/src/plugins/twitterStyleTags/main.js b/etherpad/src/plugins/twitterStyleTags/main.js new file mode 100644 index 0000000..686c863 --- /dev/null +++ b/etherpad/src/plugins/twitterStyleTags/main.js @@ -0,0 +1,23 @@ +import("etherpad.log"); +import("plugins.twitterStyleTags.hooks"); +import("plugins.twitterStyleTags.static.js.main"); + +function init() { + this.hooks = ['handlePath']; + this.client = new main.init(); + this.description = 'Twitter-style tags'; + this.handlePath = hooks.handlePath; + this.aceGetFilterStack = hooks.aceGetFilterStack; + + this.install = install; + this.uninstall = uninstall; +} + +function install() { + log.info("Installing Twitter-style tags"); +} + +function uninstall() { + log.info("Uninstalling Twitter-style tags"); +} + diff --git a/etherpad/src/plugins/twitterStyleTags/static/js/main.js b/etherpad/src/plugins/twitterStyleTags/static/js/main.js new file mode 100644 index 0000000..96be013 --- /dev/null +++ b/etherpad/src/plugins/twitterStyleTags/static/js/main.js @@ -0,0 +1,11 @@ +function init() { + this.hooks = ['aceGetFilterStack']; + this.aceGetFilterStack = aceGetFilterStack; +} + +function aceGetFilterStack() { + console.log('aceGetFilterStack'); +} + +/* used on the client side only */ +twitterStyleTags = new init(); diff --git a/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs b/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs new file mode 100644 index 0000000..aed5d9b --- /dev/null +++ b/etherpad/src/plugins/twitterStyleTags/templates/tagBrowser.ejs @@ -0,0 +1,28 @@ +<% /* Copyright 2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS-IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ %> +<% + helpers.setHtmlTitle("Test plugin"); + helpers.setBodyId("padbody"); + helpers.addBodyClass("limwidth nonpropad nonprouser"); + helpers.includeCss("pad2_ejs.css"); + helpers.setRobotsPolicy({index: false, follow: false}) + helpers.includeJQuery(); + helpers.includeCometJs(); + helpers.includeJs("json2.js"); + helpers.addToHead('\n\n'); +%> + +
+ Welcome to the tag browser plugin +
-- cgit v1.2.3-1-g7c22