From a9ce606cc30d351070036c8a5c0f1a7aaeeb2c10 Mon Sep 17 00:00:00 2001 From: "alexanders@b2ef00c0-3703-41da-baef-cfe82387ac0c" Date: Wed, 3 Feb 2010 11:24:06 +0000 Subject: fixed handling of superdomains --HG-- extra : convert_revision : svn%3Ab2ef00c0-3703-41da-baef-cfe82387ac0c/trunk%4015 --- .hgignore | 1 + etherpad/src/etherpad/control/pro_help_control.js | 60 ----------------------- etherpad/src/etherpad/globals.js | 6 +-- etherpad/src/etherpad/pro/pro_utils.js | 11 +++-- etherpad/src/etherpad/sessions.js | 20 ++++---- etherpad/src/main.js | 2 +- etherpad/src/static/css/pro-help.css | 19 ------- 7 files changed, 21 insertions(+), 98 deletions(-) delete mode 100644 etherpad/src/etherpad/control/pro_help_control.js delete mode 100644 etherpad/src/static/css/pro-help.css diff --git a/.hgignore b/.hgignore index 63140a0..b27483c 100644 --- a/.hgignore +++ b/.hgignore @@ -3,6 +3,7 @@ etherpad/etc/etherpad.spline.properties .class COMMIT_MSG LAST_COMMIT +etherpad/data/ etherpad/appjet-eth-dev.jar infrastructure/build/appjet.jar infrastructure/build/net/appjet/ajstdlib/streaming-client.js diff --git a/etherpad/src/etherpad/control/pro_help_control.js b/etherpad/src/etherpad/control/pro_help_control.js deleted file mode 100644 index 675e976..0000000 --- a/etherpad/src/etherpad/control/pro_help_control.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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. - */ - -import("etherpad.utils.*"); -import("etherpad.globals.*"); -import("etherpad.billing.team_billing"); - -var _helpTopics = [ -/* ['essentials', "EtherPad Essentials"], */ - ['billing', "Account Quotas and Billing"], -/* ['guests', "Collaborating with Teammates and Guests"] */ -]; - -function onRequest() { - var pageId = request.path.split('/')[3]; - if (!pageId) { - _renderPage('main'); - return true; - } - for (var i = 0; i < _helpTopics.length; i++) { - var t = _helpTopics[i]; - if (t[0] == pageId) { - _renderPage(pageId); - return true; - } - } - - response.redirect('/ep/pro-help/'); -} - -function _renderPage(pageId) { - function renderContent() { - return renderTemplateAsString('pro-help/'+pageId+'.ejs', { - helpTopics: _helpTopics, - numFreeAccounts: PRO_FREE_ACCOUNTS, - pricePerAccount: team_billing.COST_PER_USER - }); - } - - renderFramed('pro-help/pro-help-template.ejs', { - renderContent: renderContent - }); -} - - - - diff --git a/etherpad/src/etherpad/globals.js b/etherpad/src/etherpad/globals.js index e279e1a..2bae776 100644 --- a/etherpad/src/etherpad/globals.js +++ b/etherpad/src/etherpad/globals.js @@ -28,9 +28,9 @@ function isProduction() { var SUPERDOMAINS = { 'localhost': true, - 'spline.inf.fu-berlin.de': true, - 'spline.de': true, - 'spline.nomad': true + 'pad.spline.inf.fu-berlin.de': true, + 'pad.spline.de': true, + 'pad.spline.nomad': true }; var PNE_RELEASE_VERSION = "1.1.3"; diff --git a/etherpad/src/etherpad/pro/pro_utils.js b/etherpad/src/etherpad/pro/pro_utils.js index 39a9193..17487b8 100644 --- a/etherpad/src/etherpad/pro/pro_utils.js +++ b/etherpad/src/etherpad/pro/pro_utils.js @@ -46,11 +46,14 @@ function getProRequestSubdomain() { function getRequestSuperdomain() { var parts = request.domain.split('.'); - parts.reverse(); - if (parts[0] == ".") { - parts.shift(); + parts.pop(); // Remove one level + while (parts.length > 0) { + var domain = parts.join('.'); + if (SUPERDOMAINS[domain]) { + return domain; + } + parts.pop(); // Remove next level } - return [parts[1], parts[0]].join('.'); } function isProDomainRequest() { diff --git a/etherpad/src/etherpad/sessions.js b/etherpad/src/etherpad/sessions.js index 633bf0b..c635e41 100644 --- a/etherpad/src/etherpad/sessions.js +++ b/etherpad/src/etherpad/sessions.js @@ -52,18 +52,16 @@ function _updateInitialReferrer(data) { } function _getScopedDomain(subDomain) { - var d = request.domain; - if (d.indexOf(".") == -1) { - // special case for "localhost". For some reason, firefox does not like cookie domains - // to be ".localhost". - return undefined; - } - if (subDomain) { - d = subDomain + "." + d; - } - return "." + d; + var parts = request.domain.split('.'); + parts.pop(); // Remove one level + while (parts.length > 0) { + var domain = parts.join('.'); + if (SUPERDOMAINS[domain]) { + return domain; + } + parts.pop(); // Remove next level + } } - //-------------------------------------------------------------------------------- // pass in subDomain to get the session data for a particular subdomain -- diff --git a/etherpad/src/main.js b/etherpad/src/main.js index ff46fb1..6c9e959 100644 --- a/etherpad/src/main.js +++ b/etherpad/src/main.js @@ -269,7 +269,7 @@ function checkHost() { } // redirect to etherpad.com - var newurl = "http://pad.spline.inf.fu-berlin.de"+request.path; + var newurl = "http://pad.spline.inf.fu-berlin.de/"+request.path; if (request.query) { newurl += "?"+request.query; } response.redirect(newurl); } diff --git a/etherpad/src/static/css/pro-help.css b/etherpad/src/static/css/pro-help.css deleted file mode 100644 index 9237b62..0000000 --- a/etherpad/src/static/css/pro-help.css +++ /dev/null @@ -1,19 +0,0 @@ - -h1 { - font-size: 1.33em; - color: #555; - border-bottom: 1px solid #888; -} - -h2 { - font-size: 1.1em; - color: #333; - border-bottom: 1px solid #888; -} - -div.pro-help { - font-size: 88%; - width: 66%; -} - - -- cgit v1.2.3