From 75ff272950e537ba7938b3fb6a9a42615d4309fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20Sch=C3=A4fer?= Date: Sun, 27 Apr 2008 14:35:35 +0000 Subject: [PATCH] * Fixed and finalized Layout.reset_action() as well as Layout.remove() and Skin.remove() methods * Completely render skin outline and drop down menu from application directory * Moved remaining skins into protected (ie. non-customizable) skin files * Removed obsolete skin files * Removed obsolete code --- code/Admin/{Admin.skin => $Admin.skin} | 24 +++ code/Admin/Admin.js | 4 +- code/Admin/Admin.properties | 1 - code/Admin/Messages.skin | 19 -- code/Layout/Layout.js | 154 +++++++------- code/Root/{Root.skin => $Root.skin} | 0 code/Skin/$Skin.skin | 14 +- code/Skin/Skin.js | 200 ++++++++---------- code/Skins/Skins.js | 277 +++---------------------- 9 files changed, 232 insertions(+), 461 deletions(-) rename code/Admin/{Admin.skin => $Admin.skin} (92%) delete mode 100644 code/Admin/Messages.skin rename code/Root/{Root.skin => $Root.skin} (100%) diff --git a/code/Admin/Admin.skin b/code/Admin/$Admin.skin similarity index 92% rename from code/Admin/Admin.skin rename to code/Admin/$Admin.skin index 7c1acdfb..7bda372e 100644 --- a/code/Admin/Admin.skin +++ b/code/Admin/$Admin.skin @@ -534,3 +534,27 @@ default front page. + +<% +////////////////////// Notification skins +%> + +<% #block %> +(You're receiving this mail because you are Administrator of <% param.site %>). + +<% param.site %> (<% param.url %>) has been private for more than <% param.privatetime %> days. Due to policy reasons your site will be blocked in <% param.daysleft %> days if you keep it private. This does *not* mean that your site will be removed, but neither you nor other members of it will have access to <% param.site %> unless one of the system administrators decides to unblock your site. + +So please either change the preferences of your site (select the checkbox "public") or send a mail to <% param.contact %> containing reasons why your site should stay private. + +--------------------------------------- +<% root.title %> - <% root.url %> +--------------------------------------- + +<& #delete %> +(You're receiving this mail because you are Administrator of <% param.site %>). + +<% param.site %> (<% param.url %>) was inactive for more than <% param.inactivity %> days. You have <% param.daysleft %> days time to reactivate your site, otherwise it will be deleted. Please note that the removal of <% param.site %> is an irreversible process! + +--------------------------------------- +<% root.title %> - <% root.url %> +--------------------------------------- diff --git a/code/Admin/Admin.js b/code/Admin/Admin.js index b55646ac..8e606998 100644 --- a/code/Admin/Admin.js +++ b/code/Admin/Admin.js @@ -540,12 +540,12 @@ Admin.prototype.deleteInactiveSites = function() { if (site.trusted) continue; - var idleFor = new Date() - site.lastupdate; + var idleFor = new Date() - site.modified; var timeSinceWarning = new Date() - site.lastdelwarn; if (idleFor >= warnThreshold) { // check if site-admins have been warned already var alreadyWarned = false; - if (site.lastdelwarn > site.lastupdate) + if (site.lastdelwarn > site.modified) alreadyWarned = true; // check whether warn admins or block site if (!alreadyWarned) { diff --git a/code/Admin/Admin.properties b/code/Admin/Admin.properties index ef7f1fd6..9c307b2e 100644 --- a/code/Admin/Admin.properties +++ b/code/Admin/Admin.properties @@ -32,7 +32,6 @@ sites.accessname = name sites.order = created desc privateSites = collection(Site) -#privateSites.order = SITE_LASTOFFLINE asc privateSites.filter = mode = 'private' and status <> 'blocked' users = collection(User) diff --git a/code/Admin/Messages.skin b/code/Admin/Messages.skin deleted file mode 100644 index 8869a8b9..00000000 --- a/code/Admin/Messages.skin +++ /dev/null @@ -1,19 +0,0 @@ -<% #block %> -(You're receiving this mail because you are Administrator of <% param.site %>). - -<% param.site %> (<% param.url %>) has been private for more than <% param.privatetime %> days. Due to policy reasons your site will be blocked in <% param.daysleft %> days if you keep it private. This does *not* mean that your site will be removed, but neither you nor other members of it will have access to <% param.site %> unless one of the system administrators decides to unblock your site. - -So please either change the preferences of your site (select the checkbox "public") or send a mail to <% param.contact %> containing reasons why your site should stay private. - ---------------------------------------- -<% root.title %> - <% root.url %> ---------------------------------------- - -<& #delete %> -(You're receiving this mail because you are Administrator of <% param.site %>). - -<% param.site %> (<% param.url %>) was inactive for more than <% param.inactivity %> days. You have <% param.daysleft %> days time to reactivate your site, otherwise it will be deleted. Please note that the removal of <% param.site %> is an irreversible process! - ---------------------------------------- -<% root.title %> - <% root.url %> ---------------------------------------- diff --git a/code/Layout/Layout.js b/code/Layout/Layout.js index 926ef908..48d69606 100644 --- a/code/Layout/Layout.js +++ b/code/Layout/Layout.js @@ -22,6 +22,32 @@ // $URL$ // +Layout.VALUES = [ + "background color", + "link color", + "active link color", + "visited link color", + "big font", + "big font size", + "big font color", + "base font", + "base font size", + "base font color", + "small font", + "small font size", + "small font color" +]; + +Layout.remove = function(layout) { + layout || (layout = this); + if (layout.constructor === Layout) { + Skins.remove.call(layout.skins); + Images.remove.call(layout.images); + layout.getFile().removeDirectory(); + } + return; +} + Layout.getModes = defineConstants(Layout, "default", "shared"); this.handleMetadata("title"); @@ -118,18 +144,22 @@ Layout.prototype.update = function(data) { return; } -Layout.remove = function() { - Skins.remove.call(this.skins); - this.getFile().removeDirectory(); - Images.remove.call(this.images); - return; -} - Layout.prototype.reset_action = function() { - if (req.postParams.proceed) { + if (req.data.proceed) { try { - Skins.remove.call(this.skins); - this.getFile().removeDirectory(); + Layout.remove.call(this); + var skinFiles = app.getSkinfilesInPath(res.skinpath); + var content, file; + for (var name in skinFiles) { + if (content = skinFiles[name][name]) { + var dir = this.getFile(name); + var file = new helma.File(dir, name + ".skin"); + dir.makeDirectory(); + file.open(); + file.write(content); + file.close(); + } + } res.message = gettext("The layout was successfully reset."); res.redirect(this.href()); } catch(ex) { @@ -207,42 +237,8 @@ Layout.prototype.import_action = function() { return; } -Layout.prototype.getMacroHandler = function(name) { - switch (name) { - case "skins": - return this[name]; - - default: - return null; - } -} - -Layout.prototype.image_macro = function(param, name, mode) { - name || (name = param.name); - if (!name) { - return; - } - - var image = this.getImage(name, param.fallback); - if (!image) { - return; - } - - mode || (mode = param.as); - var action = param.linkto; - delete(param.name); - delete(param.as); - delete(param.linkto); - - switch (mode) { - case "url" : - return res.write(image.getUrl()); - case "thumbnail" : - action || (action = image.getUrl()); - return image.thumbnail_macro(param); - } - image.render_macro(param); - return; +Layout.prototype.getTitle = function() { + return "Layout"; } Layout.prototype.getImage = function(name, fallback) { @@ -269,14 +265,9 @@ Layout.prototype.getSkinPath = function() { return null; } var skinPath = [this.getFile().toString()]; - //this.parent && (skinPath.push(this.parent.getFile().toString())); return skinPath; } -Layout.prototype.getTitle = function() { - return "Layout"; -} - Layout.prototype.getArchive = function(skinpath) { var zip = new helma.Zip(); for each (var fpath in skinpath) { @@ -316,15 +307,46 @@ Layout.prototype.getArchive = function(skinpath) { return zip; } +Layout.prototype.getMacroHandler = function(name) { + switch (name) { + case "skins": + return this[name]; + + default: + return null; + } +} + +Layout.prototype.image_macro = function(param, name, mode) { + name || (name = param.name); + if (!name) { + return; + } + + var image = this.getImage(name, param.fallback); + if (!image) { + return; + } + + mode || (mode = param.as); + var action = param.linkto; + delete(param.name); + delete(param.as); + delete(param.linkto); + + switch (mode) { + case "url" : + return res.write(image.getUrl()); + case "thumbnail" : + action || (action = image.getUrl()); + return image.thumbnail_macro(param); + } + image.render_macro(param); + return; +} + Layout.prototype.values_macro = function() { - /* FIXME: should be enough to render res.meta.values in HopObject.onRequest - res.push(); - var skin = new Skin("Site", "values"); - skin.render(); - res.pop(); - */ var values = []; - //for each (var key in Layout.VALUES) { for (var key in res.meta.values) { values.push({key: key, value: res.meta.values[key]}); } @@ -337,19 +359,3 @@ Layout.prototype.values_macro = function() { } return; } - -Layout.VALUES = [ - "background color", - "link color", - "active link color", - "visited link color", - "big font", - "big font size", - "big font color", - "base font", - "base font size", - "base font color", - "small font", - "small font size", - "small font color" -] diff --git a/code/Root/Root.skin b/code/Root/$Root.skin similarity index 100% rename from code/Root/Root.skin rename to code/Root/$Root.skin diff --git a/code/Skin/$Skin.skin b/code/Skin/$Skin.skin index a73b8754..7e92dd70 100644 --- a/code/Skin/$Skin.skin +++ b/code/Skin/$Skin.skin @@ -2,7 +2,7 @@

<% response.title %>

<% response.message prefix='
' suffix="
" %>
-<% if <% skin.name %> is null then +<% if <% skin.name %> is "" then <% skin.select prototype prefix=<% gettext Prototype suffix=": " %> suffix=<% skin.input name prefix=<% gettext Name suffix=": " %> %> %> else @@ -12,7 +12,7 @@ else + class="formWide"><% skin.content encoding="form" %>