From 6938cf57d04bf1af1065c054e7002d44d48265ab Mon Sep 17 00:00:00 2001 From: Peter Martischka Date: Fri, 9 Apr 2010 16:42:33 +0200 Subject: Revert "Can't really use SSL when checking for it always returns false, right?" This reverts commit b2661df17ef0765d07fbb9233f1f37fec96e1dfe. --- etherpad/src/main.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'etherpad') diff --git a/etherpad/src/main.js b/etherpad/src/main.js index 6d99e16..b77d5ee 100644 --- a/etherpad/src/main.js +++ b/etherpad/src/main.js @@ -287,6 +287,14 @@ function checkHost() { // Check for HTTPS function checkHTTPS() { + /* Open-source note: this function used to check the protocol and make + * sure that pages that needed to be secure went over HTTPS, and pages + * that didn't go over HTTP. However, when we open-sourced the code, + * we disabled HTTPS because we didn't want to ship the etherpad.com + * private crypto keys. --aiba */ + return; + + if (stringutils.startsWith(request.path, "/static/")) { return; } if (sessions.getSession().disableHttps || request.params.disableHttps) { -- cgit v1.2.3-1-g7c22 From 7f57da299f144054de41ca8f61ac4f2f45098c77 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Fri, 9 Apr 2010 21:45:27 +0200 Subject: Added template.use, template.define and template.inherit to templates --- etherpad/src/etherpad/utils.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'etherpad') diff --git a/etherpad/src/etherpad/utils.js b/etherpad/src/etherpad/utils.js index 3e35f00..67592b1 100644 --- a/etherpad/src/etherpad/utils.js +++ b/etherpad/src/etherpad/utils.js @@ -64,10 +64,34 @@ function findTemplate(filename, plugin) { return '/templates/' + filename; } +function Template(params, plugin) { + this._defines = {} + this._params = params; + this._params.template = this; + this._plugin = plugin; +} + +Template.prototype.define = function(name, fn) { + this._defines[name] = fn; + return ''; +} + +Template.prototype.use = function (name, fn, arg) { + if (this._defines[name] != undefined) + return this._defines[name](arg); + else + return fn(arg); +} + +Template.prototype.inherit = function (template) { + return renderTemplateAsString(template, this._params, this._plugin); +} + function renderTemplateAsString(filename, data, plugin) { data = data || {}; data.helpers = helpers; // global helpers data.plugins = plugins; // Access callHook and the like... + new Template(data, plugin); var f = findTemplate(filename, plugin); //"/templates/"+filename; if (! appjet.scopeCache.ejs) { -- cgit v1.2.3-1-g7c22 From 07f65c61458cf4909ffce9c129e9200bbc3f3abb Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Fri, 9 Apr 2010 22:04:53 +0200 Subject: Added a default templatye.use('body') at the end of each template --- etherpad/src/etherpad/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'etherpad') diff --git a/etherpad/src/etherpad/utils.js b/etherpad/src/etherpad/utils.js index 67592b1..83a1ec4 100644 --- a/etherpad/src/etherpad/utils.js +++ b/etherpad/src/etherpad/utils.js @@ -91,7 +91,7 @@ function renderTemplateAsString(filename, data, plugin) { data = data || {}; data.helpers = helpers; // global helpers data.plugins = plugins; // Access callHook and the like... - new Template(data, plugin); + var template = new Template(data, plugin); var f = findTemplate(filename, plugin); //"/templates/"+filename; if (! appjet.scopeCache.ejs) { @@ -100,6 +100,7 @@ function renderTemplateAsString(filename, data, plugin) { var cacheObj = appjet.scopeCache.ejs[filename]; if (cacheObj === undefined || fileLastModified(f) > cacheObj.mtime) { var templateText = readFile(f); + templateText += "<%: template.use('body', function () { return ''; }); %> "; cacheObj = {}; cacheObj.tmpl = new EJS({text: templateText, name: filename}); cacheObj.mtime = fileLastModified(f); -- cgit v1.2.3-1-g7c22 From 866f7fe7ebf27a90902d83dc80fc5f768381ff81 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Fri, 9 Apr 2010 22:06:50 +0200 Subject: Added example usage of template.use/define/inherit --- .../plugins/testplugin/controllers/testplugin.js | 15 +++++++------- etherpad/src/plugins/testplugin/templates/page.ejs | 23 ++++++++++++++++++++++ .../plugins/testplugin/templates/testplugin.ejs | 10 +++++++--- 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 etherpad/src/plugins/testplugin/templates/page.ejs (limited to 'etherpad') diff --git a/etherpad/src/plugins/testplugin/controllers/testplugin.js b/etherpad/src/plugins/testplugin/controllers/testplugin.js index 0c79e06..da74ade 100644 --- a/etherpad/src/plugins/testplugin/controllers/testplugin.js +++ b/etherpad/src/plugins/testplugin/controllers/testplugin.js @@ -29,7 +29,6 @@ import("sqlbase.sqlbase"); import("sqlbase.sqlcommon"); import("sqlbase.sqlobj"); - function onRequest() { var isPro = pro_utils.isProDomainRequest(); var userId = padusers.getUserId(); @@ -47,11 +46,13 @@ function onRequest() { var isProUser = (isPro && ! padusers.isGuest(userId)); - renderHtml("testplugin.ejs", - { - isPro: isPro, - isProAccountHolder: isProUser, - account: getSessionProAccount(), // may be falsy - }, 'testplugin'); + renderHtml( + "testplugin.ejs", + { + isPro: isPro, + isProAccountHolder: isProUser, + account: getSessionProAccount(), // may be falsy + }, + 'testplugin'); return true; } diff --git a/etherpad/src/plugins/testplugin/templates/page.ejs b/etherpad/src/plugins/testplugin/templates/page.ejs new file mode 100644 index 0000000..71633c0 --- /dev/null +++ b/etherpad/src/plugins/testplugin/templates/page.ejs @@ -0,0 +1,23 @@ +<% /* 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. */ %> + +<% template.define('body', function() { var ejs_data=''; %> +
+

Page header

+ <%: template.use('content', function() { var ejs_data=''; %> + Original content + <% return ejs_data; }); %> +
footer
+
+<% return ejs_data; }); %> diff --git a/etherpad/src/plugins/testplugin/templates/testplugin.ejs b/etherpad/src/plugins/testplugin/templates/testplugin.ejs index f70ca8d..69c4453 100644 --- a/etherpad/src/plugins/testplugin/templates/testplugin.ejs +++ b/etherpad/src/plugins/testplugin/templates/testplugin.ejs @@ -24,6 +24,10 @@ limitations under the License. */ %> helpers.addToHead('\n\n'); %> -
- Welcome to the test plugin -
+<% template.inherit('page.ejs') %> + +<% template.define('content', function() { var ejs_data=''; %> +
+ Welcome to the test plugin +
+<% return ejs_data; }); %> -- cgit v1.2.3-1-g7c22 From 8fb886cc2df636fd42cb075254f986c500e3e50f Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Sat, 10 Apr 2010 02:17:24 +0200 Subject: Separated the padpage into a common part (page.ejs) and an inheriting part adding actual pad stuff. --- etherpad/src/etherpad/utils.js | 4 +- etherpad/src/templates/pad/pad_body2.ejs | 981 ++++++++++++++----------------- etherpad/src/templates/page.ejs | 139 +++++ 3 files changed, 594 insertions(+), 530 deletions(-) create mode 100644 etherpad/src/templates/page.ejs (limited to 'etherpad') diff --git a/etherpad/src/etherpad/utils.js b/etherpad/src/etherpad/utils.js index 83a1ec4..57ca5de 100644 --- a/etherpad/src/etherpad/utils.js +++ b/etherpad/src/etherpad/utils.js @@ -79,8 +79,10 @@ Template.prototype.define = function(name, fn) { Template.prototype.use = function (name, fn, arg) { if (this._defines[name] != undefined) return this._defines[name](arg); - else + else if (fn != undefined) return fn(arg); + else + return ''; } Template.prototype.inherit = function (template) { diff --git a/etherpad/src/templates/pad/pad_body2.ejs b/etherpad/src/templates/pad/pad_body2.ejs index 0eb9029..a19e685 100644 --- a/etherpad/src/templates/pad/pad_body2.ejs +++ b/etherpad/src/templates/pad/pad_body2.ejs @@ -13,564 +13,487 @@ 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("EtherPad: "+pageTitle); %> -<% helpers.setBodyId("padbody") %> -<% helpers.addBodyClass(bodyClass) %> -<% helpers.includeCss("pad2_ejs.css") %> -<% helpers.includeJs("undo-xpopup.js") %> -<% helpers.includeCometJs() %> -<% helpers.includeJQuery(); %> -<% helpers.includeJs("json2.js") %> -<% helpers.includeJs("colorutils.js") %> -<% helpers.includeJs("ace.js") %> -<% helpers.includeJs("collab_client.js") %> -<% helpers.includeJs("draggable.js") %> -<% helpers.includeJs("pad_utils.js") %> -<% helpers.includeJs("pad_cookie.js") %> -<% helpers.includeJs("pad_editor.js") %> -<% helpers.includeJs("pad_userlist.js") %> -<% helpers.includeJs("pad_editbar.js") %> -<% helpers.includeJs("pad_chat.js") %> -<% helpers.includeJs("pad_docbar.js") %> -<% helpers.includeJs("pad_impexp.js") %> -<% helpers.includeJs("pad_savedrevs.js") %> -<% helpers.includeJs("pad_connectionstatus.js") %> -<% helpers.includeJs("pad_modals.js") %> -<% helpers.includeJs("pad2.js") %> -<% helpers.suppressGA() %> -<% helpers.setRobotsPolicy({index: false, follow: false}) %> -<% - var padUrlAttrValue = request.url.split("?", 1)[0].replace(/\"/g, '"'); //" -%> + +<% template.inherit('page.ejs') %> <% - function exportLink(type, n, label, requiresOffice, url, title) { - url = url || '/ep/pad/export/'+localPadId+'/latest?format='+type; - var classes = ["exportlink", "exporthref"+type, "n"+n]; - if (requiresOffice && !hasOffice) { - classes.push("disabledexport"); - } - else { - classes.push("requiresoffice"); - } - var pieces = ['', label); - /* if (title) { - pieces.push('?'); - }*/ - pieces.push(''); - return pieces.join(''); - } + helpers.setHtmlTitle("EtherPad: "+pageTitle); + helpers.includeJs("ace.js"); + helpers.includeJs("collab_client.js"); + helpers.includeJs("pad_userlist.js"); + helpers.includeJs("pad_chat.js"); + helpers.includeJs("pad_impexp.js"); + helpers.includeJs("pad_savedrevs.js"); + helpers.includeJs("pad_connectionstatus.js"); + + var padUrlAttrValue = request.url.split("?", 1)[0].replace(/\"/g, '"'); + + function exportLink(type, n, label, requiresOffice, url, title) { + url = url || '/ep/pad/export/'+localPadId+'/latest?format='+type; + var classes = ["exportlink", "exporthref"+type, "n"+n]; + if (requiresOffice && !hasOffice) { + classes.push("disabledexport"); + } + else { + classes.push("requiresoffice"); + } + var pieces = ['', label); + /* if (title) { + pieces.push('?'); + }*/ + pieces.push(''); + return pieces.join(''); + } %> -
- -
-
- <% /* floated left */ %> -
- <% /* New Pad */ %> - <% /* floated right */ %> -
- <% /* Toggle Width */ %> - <% /* non-floated */ %> -
- EtherPad -
-<% if (isProAccountHolder) { %> - Return to pad list -
<%= toHTML(account.email) %> - (sign out) -
-<% } else if (isPro) { %> -
- sign in -
-<% } %> -
-
-
-
-

Server Notice:

- hide -

+ +<% template.define('docBarTitleEditor', function() { var ejs_data=''; %> + <% if (isProAccountHolder) { %> + + <% } /* isProAccountHolder */ %> + +
+ Save + Cancel
+<% return ejs_data; }); %> + -
- - - - - - <% - plugins.callHookStr('docbarItemsAll', {}, '', ''); - plugins.callHookStr('docbarItemsPad', {}, '', ''); - %> - <% if (isProAccountHolder) { %> - - <% } /* isProAccountHolder */ %> - - - - - - -
<%= initialTitle %> ', '', ' - - Security - - - - Pad Options - - - Import/Export - - - Saved revisions - - - Time Slider -
- <% if (isProAccountHolder) { %> -