');
+ }
+ return res.pop();
+ }
- var data = eval(metadata);
- res.push();
- for (var key in styles) {
- var name = styles[key];
- var value = String(data[key]).toLowerCase();
- if (key.endsWith("color") && !helma.Color.COLORNAMES[key] &&
- !value.startsWith("#")) {
- value = "#" + value;
- }
- value = value.replace(/([0-9]+) +px/, "$1px");
- res.writeln('<% value "' + name + '" "' + value + '" %>');
+ var quote = function(str) {
+ if (str === null) {
+ return str;
+ }
+ return "'" + str.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'";
+ }
+
+ var clean = function(source) {
+ if (source) {
+ // Renaming prototype and skin names in skin macros
+ var re = /(<%\s*)([^.]+)(\.skin\s+name="?)([^"\s]+)/g;
+ source = source.replace(re, function() {
+ var $ = arguments;
+ var skin = rename($[2].capitalize(), $[4]);
+ if (skin) {
+ // THIS LINE DIFFERS FROM THE UPDATER APP!
+ return $[1] + skin.prototype.toLowerCase() + $[3] +
+ skin.prototype + "#" + skin.name;
+ }
+ return $[0];
+ });
+ // Replacing layout.* macros with corresponding value macros
+ source = source.replace(/(<%\s*)layout\.([^\s]+)/g, function() {
+ var value = styles[arguments[2]];
+ if (value) {
+ return arguments[1] + "value " + quote(value);
+ }
+ return arguments[0];
+ });
+ return source;
+ }
+ }
+ // ***********************************
+ // End of code copied from updater app
+
+ var rename = function(proto, name) {
+ var allowed = ["Comment", "Day", "File", "Global", "Image",
+ "MemberMgr", "Membership", "Site", "Story", "Topic"];
+ if (allowed.indexOf(proto) < 0) {
+ return;
+ }
+
+ switch (proto) {
+ case "Comment":
+ name === "toplevel" && (name = "main");
+ break;
+
+ case "Day":
+ proto = "Archive";
+ break;
+
+ case "MemberMgr":
+ case "Membership":
+ if (name === "statusloggedin") {
+ name = "status";
+ } else if (name === "statusloggedout") {
+ name = "login";
+ } else if (proto === "MemberMgr") {
+ // FIXME: This return causes errors on Ubuntu?!?
+ //return;
}
- return res.pop();
- }
+ break;
- var quote = function(str) {
- if (str === null) {
- return str;
+ case "Site":
+ if (name === "searchbox") {
+ name = "search";
+ } else if (name === "style") {
+ name = "stylesheet";
}
- return "'" + str.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'";
- }
+ break;
- var clean = function(source) {
- if (source) {
- // Renaming prototype and skin names in skin macros
- var re = /(<%\s*)([^.]+)(\.skin\s+name="?)([^"\s]+)/g;
- source = source.replace(re, function() {
- var $ = arguments;
- var skin = rename($[2].capitalize(), $[4]);
- if (skin) {
- // THIS LINE DIFFERS FROM THE UPDATER APP!
- return $[1] + skin.prototype.toLowerCase() + $[3] +
- skin.prototype + "#" + skin.name;
- }
- return $[0];
- });
- // Replacing layout.* macros with corresponding value macros
- source = source.replace(/(<%\s*)layout\.([^\s]+)/g, function() {
- var value = styles[arguments[2]];
- if (value) {
- return arguments[1] + "value " + quote(value);
- }
- return arguments[0];
- });
- return source;
+ case "Story":
+ if (name === "dayheader") {
+ name = "date";
+ } else if (name === "display") {
+ name = "content";
+ } else if (name === "historyview") {
+ name = "history";
}
- }
- // ***********************************
- // End of code copied from updater app
+ break;
- var rename = function(proto, name) {
- var allowed = ["Comment", "Day", "File", "Global", "Image",
- "MemberMgr", "Membership", "Site", "Story", "Topic"];
- if (allowed.indexOf(proto) < 0) {
- return;
- }
+ case "Topic":
+ proto = "Tag";
+ break;
+ }
+ (proto === "MemberMgr") && (proto = "Membership");
+ return {
+ prototype: proto,
+ name: name
+ };
+ }
- switch (proto) {
- case "Comment":
- name === "toplevel" && (name = "main");
- break;
-
- case "Day":
- proto = "Archive";
- break;
-
- case "MemberMgr":
- case "Membership":
- if (name === "statusloggedin") {
- name = "status";
- } else if (name === "statusloggedout") {
- name = "login";
- } else if (proto === "MemberMgr") {
- // FIXME: This return causes errors on Ubuntu?!?
- //return;
- }
- break;
-
- case "Site":
- if (name === "searchbox") {
- name = "search";
- } else if (name === "style") {
- name = "stylesheet";
- }
- break;
-
- case "Story":
- if (name === "dayheader") {
- name = "date";
- } else if (name === "display") {
- name = "content";
- } else if (name === "historyview") {
- name = "history";
- }
- break;
-
- case "Topic":
- proto = "Tag";
- break;
- }
- (proto === "MemberMgr") && (proto = "Membership");
- return {
- prototype: proto,
- name: name
- };
- }
-
- var convert2subskins = function(proto, dir) {
- res.push();
- for each (var fname in dir.list()) {
- var file = new helma.File(dir, fname);
- var name = fname.split(".")[0], skin;
- if (skin = rename(proto, name)) {
- res.writeln("<% #" + skin.name + " %>");
- var source = clean(file.readAll());
- if (skin.prototype === "Site" && skin.name === "stylesheet") {
- source = source.replace(/(\.calHead)/g,
- "table.calendar thead, $1");
- source = source.replace(/(\.calDay)/g,
- "table.calendar th, table.calendar tbody td.day, $1");
- source = source.replace(/(\.calSelDay)/g,
- "table.calendar tbody td.selected, $1");
- source = source.replace(/(\.calFoot)/g,
- "table.calendar tfoot td, $1");
- }
- res.writeln(source);
- }
- }
- var str = res.pop();
- if (!str) {
- return;
- }
- var target = new java.io.File(fpath, skin.prototype);
- target.mkdirs();
- target = new helma.File(target, skin.prototype + ".skin");
- target.open({append: true});
- target.write(str);
- target.close();
- }
-
- var convertImage = function(image) {
- var result = new HopObject;
- result.name = image.alias;
- result.width = image.width;
- result.height = image.height;
- result.created = image.exporttime;
- result.modified = image.exporttime;
- result.description = image.alltext;
- result.fileName = image.alias + "." + image.fileext,
- result.contentType = "image/" + image.fileext;
- result.contentLength = inventory[result.fileName].getLength();
- if (image.thumbnail) {
- result.thumbnailName = image.thumbnail.filename + "." + image.fileext;
- result.thumbnailWidth = image.thumbnail.width;
- result.thumbnailHeight = image.thumbnail.height;
- }
- return result;
- }
-
- var dir = new helma.File(fpath, "images");
- for each (var fname in dir.list()) {
+ var convert2subskins = function(proto, dir) {
+ res.push();
+ for each (var fname in dir.list()) {
var file = new helma.File(dir, fname);
- file.move(new helma.File(fpath, fname));
- }
-
- var inventory = new function() {
- var dir = new helma.File(fpath);
- var result = {};
- for each (var fname in dir.list()) {
- var file = new helma.File(dir, fname);
- if (!file.isDirectory()) {
- // Where does the "image\" prefix come from in files from layouts.antville.org?
- var parts = fname.split("\\");
- var name = parts[parts.length-1];
- if (name !== fname) {
- res.debug(file);
- res.debug(new helma.File(fpath, name))
- file.renameTo(new helma.File(fpath, name));
- }
- result[name] = file;
- }
+ var name = fname.split(".")[0], skin;
+ if (skin = rename(proto, name)) {
+ res.writeln("<% #" + skin.name + " %>");
+ var source = clean(file.readAll());
+ if (skin.prototype === "Site" && skin.name === "stylesheet") {
+ source = source.replace(/(\.calHead)/g,
+ "table.calendar thead, $1");
+ source = source.replace(/(\.calDay)/g,
+ "table.calendar th, table.calendar tbody td.day, $1");
+ source = source.replace(/(\.calSelDay)/g,
+ "table.calendar tbody td.selected, $1");
+ source = source.replace(/(\.calFoot)/g,
+ "table.calendar tfoot td, $1");
+ }
+ res.writeln(source);
}
- return result;
- }
+ }
+ var str = res.pop();
+ if (!str) {
+ return;
+ }
+ var target = new java.io.File(fpath, skin.prototype);
+ target.mkdirs();
+ target = new helma.File(target, skin.prototype + ".skin");
+ target.open({append: true});
+ target.write(str);
+ target.close();
+ }
- var xml = Xml.read(new helma.File(fpath, "preferences.xml"));
- var file = new helma.File(fpath, "Site");
- file.makeDirectory();
- file = new helma.File(file, "Site.skin");
- file.open();
- res.push();
- res.writeln("<% #values %>");
- res.write(values(xml.preferences));
- file.write(res.pop());
- file.close();
+ var convertImage = function(image) {
+ var result = new HopObject;
+ result.name = image.alias;
+ result.width = image.width;
+ result.height = image.height;
+ result.created = image.exporttime;
+ result.modified = image.exporttime;
+ result.description = image.alltext;
+ result.fileName = image.alias + "." + image.fileext,
+ result.contentType = "image/" + image.fileext;
+ result.contentLength = inventory[result.fileName].getLength();
+ if (image.thumbnail) {
+ result.thumbnailName = image.thumbnail.filename + "." + image.fileext;
+ result.thumbnailWidth = image.thumbnail.width;
+ result.thumbnailHeight = image.thumbnail.height;
+ }
+ return result;
+ }
- dir = new helma.File(fpath, "skins");
+ var dir = new helma.File(fpath, "images");
+ for each (var fname in dir.list()) {
+ var file = new helma.File(dir, fname);
+ file.move(new helma.File(fpath, fname));
+ }
- var skin;
- for each (var fname in dir.list()) {
+ var inventory = new function() {
+ var dir = new helma.File(fpath);
+ var result = {};
+ for each (var fname in dir.list()) {
+ var file = new helma.File(dir, fname);
+ if (!file.isDirectory()) {
+ // Where does the "image\" prefix come from in files from layouts.antville.org?
+ var parts = fname.split("\\");
+ var name = parts[parts.length-1];
+ if (name !== fname) {
+ res.debug(file);
+ res.debug(new helma.File(fpath, name))
+ file.renameTo(new helma.File(fpath, name));
+ }
+ result[name] = file;
+ }
+ }
+ return result;
+ }
+
+ var xml = Xml.read(new helma.File(fpath, "preferences.xml"));
+ var file = new helma.File(fpath, "Site");
+ file.makeDirectory();
+ file = new helma.File(file, "Site.skin");
+ file.open();
+ res.push();
+ res.writeln("<% #values %>");
+ res.write(values(xml.preferences));
+ file.write(res.pop());
+ file.close();
+
+ dir = new helma.File(fpath, "skins");
+
+ var skin;
+ for each (var fname in dir.list()) {
+ file = new helma.File(dir, fname);
+ skin = convert2subskins(fname, file);
+ }
+
+ var data = new HopObject;
+ data.images = new HopObject;
+
+ var dir = new helma.File(fpath, "imagedata");
+ for each (fname in dir.list()) {
+ if (fname.endsWith(".xml")) {
file = new helma.File(dir, fname);
- skin = convert2subskins(fname, file);
- }
+ data.images.add(convertImage(Xml.read(file)));
+ }
+ }
- var data = new HopObject;
- data.images = new HopObject;
+ data.version = "1.2-compatible";
+ data.origin = "Antville 1.2 Layout Converter";
+ data.originated = new Date;
+ data.originator = session.user;
+ Xml.write(data, new helma.File(fpath, "data.xml"));
- var dir = new helma.File(fpath, "imagedata");
- for each (fname in dir.list()) {
- if (fname.endsWith(".xml")) {
- file = new helma.File(dir, fname);
- data.images.add(convertImage(Xml.read(file)));
- }
- }
-
- data.version = "1.2-compatible";
- data.origin = "Antville 1.2 Layout Converter";
- data.originated = new Date;
- data.originator = session.user;
- Xml.write(data, new helma.File(fpath, "data.xml"));
-
- (new helma.File(fpath, "preferences.xml")).remove();
- (new helma.File(fpath, "imagedata")).removeDirectory();
- (new helma.File(fpath, "skins")).removeDirectory();
- return;
+ (new helma.File(fpath, "preferences.xml")).remove();
+ (new helma.File(fpath, "imagedata")).removeDirectory();
+ (new helma.File(fpath, "skins")).removeDirectory();
+ return;
}
diff --git a/compat/Layout/Layout.js b/compat/Layout/Layout.js
index f7e018d8..e6886066 100644
--- a/compat/Layout/Layout.js
+++ b/compat/Layout/Layout.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -29,74 +29,74 @@ relocateProperty(Layout, "createtime", "created");
relocateProperty(Layout, "modifytime", "modified");
Layout.prototype.__defineGetter__("shareable", function() {
- return this.mode === Layout.SHARED;
+ return this.mode === Layout.SHARED;
});
Layout.prototype.__defineSetter__("shareable", function(value) {
- this.mode = !!value ? Layout.SHARED : Layout.DEFAULT;
- return;
+ this.mode = !!value ? Layout.SHARED : Layout.DEFAULT;
+ return;
});
Layout.prototype.getTitle = function() {
- return gettext("Layout");
+ return gettext("Layout");
}
Layout.prototype.title_macro = function(param) {
- if (param.as === "editor") {
- this.input_macro(param, "title");
- } else if (param.linkto) {
- (param.linkto === "main") && (param.linkto = "");
- this.link_filter(this.title, param, param.linkto);
- } else {
- res.write(this.title);
- }
- return;
+ if (param.as === "editor") {
+ this.input_macro(param, "title");
+ } else if (param.linkto) {
+ (param.linkto === "main") && (param.linkto = "");
+ this.link_filter(this.title, param, param.linkto);
+ } else {
+ res.write(this.title);
+ }
+ return;
}
Layout.prototype.description_macro = function(param) {
- if (param.as == "editor") {
- this.textarea_macro(param, "description");
- } else if (this.description) {
- if (param.limit) {
- res.write(this.description.clip(param.limit, "...", "\\s"));
- } else {
- res.write(this.description);
- }
- }
- return;
+ if (param.as == "editor") {
+ this.textarea_macro(param, "description");
+ } else if (this.description) {
+ if (param.limit) {
+ res.write(this.description.clip(param.limit, "...", "\\s"));
+ } else {
+ res.write(this.description);
+ }
+ }
+ return;
}
Layout.prototype.parent_macro = function(param) {
- if (param.as === "editor") {
- this.select_macro(param, "parent");
- } else if (this.parent) {
- res.write(this.parent.title);
- }
- return;
+ if (param.as === "editor") {
+ this.select_macro(param, "parent");
+ } else if (this.parent) {
+ res.write(this.parent.title);
+ }
+ return;
}
Layout.prototype.shareable_macro = function(param) {
- if (param.as == "editor" && !this.site) {
- // FIXME: HopObject.createCheckBoxParam() is obsolete
- var inputParam = this.createCheckBoxParam("shareable", param);
- if (req.data.save && !req.data.shareable)
- delete inputParam.checked;
- Html.checkBox(inputParam);
- } else if (this.shareable)
- res.write(param.yes || "yes");
- else
- res.write(param.no || "no");
- return;
+ if (param.as == "editor" && !this.site) {
+ // FIXME: HopObject.createCheckBoxParam() is obsolete
+ var inputParam = this.createCheckBoxParam("shareable", param);
+ if (req.data.save && !req.data.shareable)
+ delete inputParam.checked;
+ Html.checkBox(inputParam);
+ } else if (this.shareable)
+ res.write(param.yes || "yes");
+ else
+ res.write(param.no || "no");
+ return;
}
Layout.prototype.testdrivelink_macro = function(param) {
- return this.link_macro(param, "test", param.text || "test");
+ return this.link_macro(param, "test", param.text || "test");
}
Layout.prototype.deletelink_macro = function(param) {
- return this.link_macro(param, "delete", param.text || "delete");
+ return this.link_macro(param, "delete", param.text || "delete");
}
Layout.prototype.activatelink_macro = function(param) {
- return this.link_macro(param, "activate", param.text || "activate");
+ return this.link_macro(param, "activate", param.text || "activate");
}
diff --git a/compat/Members/Members.js b/compat/Members/Members.js
index 00373620..f7d67277 100644
--- a/compat/Members/Members.js
+++ b/compat/Members/Members.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -24,22 +24,22 @@
// $URL$
Members.prototype.sendpwd_action = function() {
- res.data.title = gettext("Recover your password");
- res.data.body = gettext("Due to security reasons user passwords are not stored in the Antville database any longer. Thus, your password cannot be sent to you, anymore.");
- res.data.body += "" + gettext('If you should really have forgotten your password, you can use the password reset option.',
- this.href("reset")) + "
";
- this._parent.renderSkin("Site#page");
- return;
+ res.data.title = gettext("Recover your password");
+ res.data.body = gettext("Due to security reasons user passwords are not stored in the Antville database any longer. Thus, your password cannot be sent to you, anymore.");
+ res.data.body += "" + gettext('If you should really have forgotten your password, you can use the password reset option.',
+ this.href("reset")) + "
";
+ this._parent.renderSkin("Site#page");
+ return;
}
Members.prototype.subscribelink_macro = function(param) {
- return res.handlers.site.link_macro(param, "subscribe");
+ return res.handlers.site.link_macro(param, "subscribe");
}
Members.prototype.subscriptionslink_macro = function(param) {
- return this.link_macro(param, "subscriptions");
+ return this.link_macro(param, "subscriptions");
}
Members.prototype.membership_macro = function(param) {
- return res.handlers.membership.role;
+ return res.handlers.membership.role;
}
diff --git a/compat/Membership/Membership.js b/compat/Membership/Membership.js
index 767fbb5b..aa0a92a9 100644
--- a/compat/Membership/Membership.js
+++ b/compat/Membership/Membership.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -29,45 +29,45 @@ relocateProperty(Membership, "modifytime", "modified");
relocateProperty(Membership, "user", "creator");
Membership.prototype.username_macro = function(param) {
- if (param.linkto && (param.linkto !== "edit" ||
- this.user !== session.user)) {
- html.link({href: this.href(param.linkto)}, this.name);
- } else {
- res.write(this.name);
- }
- return;
+ if (param.linkto && (param.linkto !== "edit" ||
+ this.user !== session.user)) {
+ html.link({href: this.href(param.linkto)}, this.name);
+ } else {
+ res.write(this.name);
+ }
+ return;
}
Membership.prototype.url_macro = function(param) {
- var url;
- if (url = this.user.url) {
- if (param.as === "link") {
- delete param.as;
- link_filter(url, param, url);
- } else {
- res.write(url);
- }
- }
- return;
+ var url;
+ if (url = this.user.url) {
+ if (param.as === "link") {
+ delete param.as;
+ link_filter(url, param, url);
+ } else {
+ res.write(url);
+ }
+ }
+ return;
}
Membership.prototype.level_macro = function(param) {
- if (param.as === "editor") {
- this.select_macro(param, "role");
- } else {
- res.write(this.role);
- }
- return;
+ if (param.as === "editor") {
+ this.select_macro(param, "role");
+ } else {
+ res.write(this.role);
+ }
+ return;
}
Membership.prototype.editlink_macro = function(param) {
- return this.link_macro(param, "edit");
+ return this.link_macro(param, "edit");
}
Membership.prototype.deletelink_macro = function(param) {
- return this.link_macro(param, "delete");
+ return this.link_macro(param, "delete");
}
Membership.prototype.unsubscribelink_macro = function(param) {
- return res.handlers.site.link_macro(param, "unsubscribe");
+ return res.handlers.site.link_macro(param, "unsubscribe");
}
diff --git a/compat/Poll/Poll.js b/compat/Poll/Poll.js
index 2b1fc8ac..50eea543 100644
--- a/compat/Poll/Poll.js
+++ b/compat/Poll/Poll.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -24,84 +24,84 @@
// $URL$
Poll.prototype.choices_macro = function(param) {
- var vote;
- if (session.user && this.votes.get(session.user.name)) {
- vote = this.votes.get(session.user.name).choice;
- }
- for (var i=0; i 0) {
- param.percent = param.count.toPercent(this.votes.size());
- param.width = Math.round(param.percent * 2.5);
- param.graph = c.renderSkinAsString("graph", param);
- if (param.count == 1)
- param.text = " " + (param2.one || "vote");
- else
- param.text = " " + (param2.more || "votes");
- } else
- param.text = " " + (param2.no || "votes");
- c.renderSkin("$Choice#result", param);
- }
- return;
+ for (var i=0; i 0) {
+ param.percent = param.count.toPercent(this.votes.size());
+ param.width = Math.round(param.percent * 2.5);
+ param.graph = c.renderSkinAsString("graph", param);
+ if (param.count == 1)
+ param.text = " " + (param2.one || "vote");
+ else
+ param.text = " " + (param2.more || "votes");
+ } else
+ param.text = " " + (param2.no || "votes");
+ c.renderSkin("$Choice#result", param);
+ }
+ return;
}
Poll.prototype.editlink_macro = function(param) {
- return this.link_macro(param, "edit");
+ return this.link_macro(param, "edit");
}
Poll.prototype.deletelink_macro = function(param) {
- return this.link_macro(param, "delete");
+ return this.link_macro(param, "delete");
}
Poll.prototype.viewlink_macro = function(param) {
- return this.link_macro(param, ".", "view");
+ return this.link_macro(param, ".", "view");
}
Poll.prototype.closelink_macro = function(param) {
- return this.link_macro(param, "rotate");
+ return this.link_macro(param, "rotate");
}
diff --git a/compat/Root/Root.js b/compat/Root/Root.js
index facd9054..fb1d94a7 100644
--- a/compat/Root/Root.js
+++ b/compat/Root/Root.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -27,27 +27,27 @@
//Root.VERSION += "-compatible";
Root.prototype.rss_action = function() {
- return res.redirect(root.href("rss.xml"));
+ return res.redirect(root.href("rss.xml"));
}
Root.prototype.url_macro = function(param) {
- return this.href_macro(param);
+ return this.href_macro(param);
}
Root.prototype.sitecounter_macro = function(param) {
- if (param.count === "all") {
- var size = root.size();
- } else {
- var size = root.sites.size();
- }
- if (size < 1) {
- res.write(param.no || size);
- } else if (size < 2) {
- res.write(param.one || size);
- } else {
- res.write(size + (param.more || String.EMPTY));
- }
- return;
+ if (param.count === "all") {
+ var size = root.size();
+ } else {
+ var size = root.sites.size();
+ }
+ if (size < 1) {
+ res.write(param.no || size);
+ } else if (size < 2) {
+ res.write(param.one || size);
+ } else {
+ res.write(size + (param.more || String.EMPTY));
+ }
+ return;
}
diff --git a/compat/Site/Site.js b/compat/Site/Site.js
index cedfa0a8..b82b3bc1 100644
--- a/compat/Site/Site.js
+++ b/compat/Site/Site.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -35,291 +35,291 @@ addPropertyMacro(Site, "tagline");
addPropertyMacro(Site, "email");
Site.prototype.__defineGetter__("online", function() {
- return this.mode === Site.PUBLIC;
+ return this.mode === Site.PUBLIC;
});
Site.prototype.__defineSetter__("online", function(value) {
- this.mode = Site.PUBLIC;
- return;
+ this.mode = Site.PUBLIC;
+ return;
});
Site.prototype.__defineGetter__("blocked", function() {
- return this.status === Site.BLOCKED;
+ return this.status === Site.BLOCKED;
});
Site.prototype.__defineGetter__("trusted", function() {
- return this.status === Site.TRUSTED;
+ return this.status === Site.TRUSTED;
});
Site.prototype.__defineGetter__("discussions", function() {
- return this.commentsMode === Comment.ONLINE;
+ return this.commentsMode === Comment.ONLINE;
});
// FIXME: obsolete?
Site.prototype.renderStoryList = function(day) {
- res.push();
- list_macro(param, "stories");
- res.write(res.pop());
- return;
+ res.push();
+ list_macro(param, "stories");
+ res.write(res.pop());
+ return;
}
Site.prototype.rss_action = function() {
- if (req.queryParams.show === "all") {
- return res.redirect(this.href("rss.xml"))
- }
- return res.redirect(this.href("stories.xml"));
+ if (req.queryParams.show === "all") {
+ return res.redirect(this.href("rss.xml"))
+ }
+ return res.redirect(this.href("stories.xml"));
}
//Site.prototype.feeds_action = function() {
-// return disableAction.call(this, "Feeds are currently not available");
+// return disableAction.call(this, "Feeds are currently not available");
//}
Site.prototype.mostread_action = function() {
- return res.redirect(this.stories.href("top"));
+ return res.redirect(this.stories.href("top"));
}
Site.prototype.link_macro = function(param, url, text) {
- param.text || (param.text = text);
- if (!param.to) {
- param.to = url || ".";
- } else if (param.to.contains(":")) {
- link_macro.call(global, param, param.to, param.text);
- return;
- }
- var handler;
- var parts = param.to.split("/");
- var action = parts[0];
- switch (action) {
- case "mostread":
- handler = this.stories;
- param.to = "top"; break;
+ param.text || (param.text = text);
+ if (!param.to) {
+ param.to = url || ".";
+ } else if (param.to.contains(":")) {
+ link_macro.call(global, param, param.to, param.text);
+ return;
+ }
+ var handler;
+ var parts = param.to.split("/");
+ var action = parts[0];
+ switch (action) {
+ case "mostread":
+ handler = this.stories;
+ param.to = "top"; break;
- case "layouts":
- action = ".";
- handler = this.layout;
- param.text = gettext("Layout");
- param.to = "."; break;
+ case "layouts":
+ action = ".";
+ handler = this.layout;
+ param.text = gettext("Layout");
+ param.to = "."; break;
- case "topics":
- case "files":
- case "images":
- case "members":
- case "polls":
- case "stories":
- handler = this[action];
- if (handler) {
- var node = handler.get(parts[1]);
- if (node) {
- handler = node;
- param.to = parts[2] || "main";
- } else {
- param.to = parts[1] || "main";
- }
+ case "topics":
+ case "files":
+ case "images":
+ case "members":
+ case "polls":
+ case "stories":
+ handler = this[action];
+ if (handler) {
+ var node = handler.get(parts[1]);
+ if (node) {
+ handler = node;
+ param.to = parts[2] || "main";
+ } else {
+ param.to = parts[1] || "main";
}
- break;
+ }
+ break;
- default:
- handler = this;
- }
- HopObject.prototype.link_macro.call(handler, param, param.to, param.text);
- return;
+ default:
+ handler = this;
+ }
+ HopObject.prototype.link_macro.call(handler, param, param.to, param.text);
+ return;
}
Site.prototype.title_macro = function(param) {
- if (param.as === "editor") {
- this.input_macro(param, "title");
- } else {
- var title = this.title;
- if (param.linkto) {
- if (param.linkto === "main") {
- param.linkto = ".";
- }
- res.write(this.link_filter(title, param, param.linkto));
- } else {
- res.write(title);
+ if (param.as === "editor") {
+ this.input_macro(param, "title");
+ } else {
+ var title = this.title;
+ if (param.linkto) {
+ if (param.linkto === "main") {
+ param.linkto = ".";
}
- }
- return;
+ res.write(this.link_filter(title, param, param.linkto));
+ } else {
+ res.write(title);
+ }
+ }
+ return;
}
Site.prototype.loginstatus_macro = function(param) {
- return res.handlers.membership.status_macro();
+ return res.handlers.membership.status_macro();
}
Site.prototype.navigation_macro = function(param) {
- var group;
- var navigation = {};
- // HopObject.renderSkinAsString() is overridden and will never return an empty skin
- // due to the added skin edit controls! Thus, we are using the original methods first,
- // and the overriden ones later.
- navigation.contributors = this.__renderSkinAsString__("Site#contribnavigation");
- navigation.admins = this.__renderSkinAsString__("Site#adminnavigation");
- if (!navigation.contributors && !navigation.admins && !res.meta.navigation) {
- res.meta.navigation = true;
- this.renderSkin("Site#navigation");
- } else if ((group = param["for"]) && navigation[group]) {
- if (group === "contributors" && this.stories.getPermission("create")) {
- this.renderSkin("Site#contribnavigation");
- } else if (group === "admins" && this.getPermission("edit")) {
- this.renderSkin("Site#adminnavigation");
- }
- }
- return;
+ var group;
+ var navigation = {};
+ // HopObject.renderSkinAsString() is overridden and will never return an empty skin
+ // due to the added skin edit controls! Thus, we are using the original methods first,
+ // and the overriden ones later.
+ navigation.contributors = this.__renderSkinAsString__("Site#contribnavigation");
+ navigation.admins = this.__renderSkinAsString__("Site#adminnavigation");
+ if (!navigation.contributors && !navigation.admins && !res.meta.navigation) {
+ res.meta.navigation = true;
+ this.renderSkin("Site#navigation");
+ } else if ((group = param["for"]) && navigation[group]) {
+ if (group === "contributors" && this.stories.getPermission("create")) {
+ this.renderSkin("Site#contribnavigation");
+ } else if (group === "admins" && this.getPermission("edit")) {
+ this.renderSkin("Site#adminnavigation");
+ }
+ }
+ return;
}
Site.prototype.image_macro = function() {
- return global.image_macro.apply(global, arguments);
+ return global.image_macro.apply(global, arguments);
}
Site.prototype.xmlbutton_macro = function(param) {
- param.linkto = this.href("rss.xml");
- image_macro(param, "/xmlbutton.gif");
- return;
+ param.linkto = this.href("rss.xml");
+ image_macro(param, "/xmlbutton.gif");
+ return;
}
Site.prototype.lastupdate_macro = function(param) {
- var value;
- if (value = this.modified) {
- res.write(formatDate(value, param.format));
- }
- return;
+ var value;
+ if (value = this.modified) {
+ res.write(formatDate(value, param.format));
+ }
+ return;
}
Site.prototype.online_macro = function(param) {
- var online = true;
- var value = this.mode;
- if (value === Site.PRIVATE || value === Site.CLOSED) {
- online = false;
- }
- if (param.as === "editor") {
- param.name = "online";
- param.value = "true";
- if (req.isPost()) {
- param.selectedValue = req.postParams.online;
- } else {
- param.selectedValue = String(online);
- }
- //res.debug(param.name + ": " + param.value + "/" + param.selectedValue);
- return html.checkBox(param);
- } else if (online) {
- res.write(param.yes || "yes");
- } else {
- res.write(param.no || "no");
- }
- return;
+ var online = true;
+ var value = this.mode;
+ if (value === Site.PRIVATE || value === Site.CLOSED) {
+ online = false;
+ }
+ if (param.as === "editor") {
+ param.name = "online";
+ param.value = "true";
+ if (req.isPost()) {
+ param.selectedValue = req.postParams.online;
+ } else {
+ param.selectedValue = String(online);
+ }
+ //res.debug(param.name + ": " + param.value + "/" + param.selectedValue);
+ return html.checkBox(param);
+ } else if (online) {
+ res.write(param.yes || "yes");
+ } else {
+ res.write(param.no || "no");
+ }
+ return;
}
Site.prototype.usermaycontrib_macro = function(param) {
- if (param.as === "editor") {
- param.name = "usermaycontrib";
- param.value = "true";
- if (req.isPost()) {
- param.selectedValue = req.postParams.usermaycontrib;
- } else {
- param.selectedValue = String(this.mode === Site.OPEN);
- }
- return html.checkBox(param);
- } else {
- res.write(this.mode === Site.OPEN ? "yes" : "no");
- }
- return;
+ if (param.as === "editor") {
+ param.name = "usermaycontrib";
+ param.value = "true";
+ if (req.isPost()) {
+ param.selectedValue = req.postParams.usermaycontrib;
+ } else {
+ param.selectedValue = String(this.mode === Site.OPEN);
+ }
+ return html.checkBox(param);
+ } else {
+ res.write(this.mode === Site.OPEN ? "yes" : "no");
+ }
+ return;
}
Site.prototype.hasdiscussions_macro = function(param) {
- if (param.as === "editor") {
- this.checkbox_macro(param, "commentMode");
- } else {
- res.write(this.commentsMode === Comment.ONLINE ? "yes" : "no");
- }
- return;
+ if (param.as === "editor") {
+ this.checkbox_macro(param, "commentMode");
+ } else {
+ res.write(this.commentsMode === Comment.ONLINE ? "yes" : "no");
+ }
+ return;
}
Site.prototype.showarchive_macro = function(param) {
- if (param.as === "editor") {
- this.checkbox_macro(param, "archiveMode");
- } else {
- res.write(this.archiveMode === Site.PUBLIC ? "yes" : "no");
- }
- return;
+ if (param.as === "editor") {
+ this.checkbox_macro(param, "archiveMode");
+ } else {
+ res.write(this.archiveMode === Site.PUBLIC ? "yes" : "no");
+ }
+ return;
}
Site.prototype.enableping_macro = function(param) {
- if (param.as === "editor") {
- this.checkbox_macro(param, "callbackMode");
- } else {
- res.write(this.callbackMode === Site.ENABLED ? "yes" : "no");
- }
- return;
+ if (param.as === "editor") {
+ this.checkbox_macro(param, "callbackMode");
+ } else {
+ res.write(this.callbackMode === Site.ENABLED ? "yes" : "no");
+ }
+ return;
}
Site.prototype.localechooser_macro = function(param) {
- return this.select_macro(param, "locale");
+ return this.select_macro(param, "locale");
}
Site.prototype.timezonechooser_macro = function(param) {
- return this.select_macro(param, "timeZone");
+ return this.select_macro(param, "timeZone");
}
Site.prototype.history_macro = function(param, type) {
- param.skin || (param.skin = "Story#history");
- var type = isNaN(param.show) ? param.show : "postings";
- var limit = Math.min(param.limit || parseInt(param.show) || 10, 50);
- delete param.show;
- delete param.limit;
- return list_macro(param, type, limit);
+ param.skin || (param.skin = "Story#history");
+ var type = isNaN(param.show) ? param.show : "postings";
+ var limit = Math.min(param.limit || parseInt(param.show) || 10, 50);
+ delete param.show;
+ delete param.limit;
+ return list_macro(param, type, limit);
}
Site.prototype.membercounter_macro = function(param) {
- return this.members.size();
+ return this.members.size();
}
Site.prototype.preferences_macro = function(param) {
- if (param.as === "editor") {
- // FIXME: Site.metadata is now a collection!
- var inputParam = this.metadata.createInputParam(param.name, param);
- delete inputParam.part;
- if (param.cols || param.rows) {
- html.textArea(inputParam);
- } else {
- html.input(inputParam);
- }
- } else {
- res.write(this.getMetadata(param.name));
- } return;
+ if (param.as === "editor") {
+ // FIXME: Site.metadata is now a collection!
+ var inputParam = this.metadata.createInputParam(param.name, param);
+ delete inputParam.part;
+ if (param.cols || param.rows) {
+ html.textArea(inputParam);
+ } else {
+ html.input(inputParam);
+ }
+ } else {
+ res.write(this.getMetadata(param.name));
+ } return;
}
Site.prototype.listReferrers_macro = function(param) {
- return this.referrers_macro(param);
+ return this.referrers_macro(param);
}
Site.prototype.searchbox_macro = function(param) {
- if (this.getPermission("search")) {
- this.renderSkin("Site#search");
- }
- return;
+ if (this.getPermission("search")) {
+ this.renderSkin("Site#search");
+ }
+ return;
}
// FIXME: working?
Site.prototype.monthlist_macro = function(param) {
- if (!this.stories.size() || this.archiveMode !== Site.PUBLIC) {
- return;
- }
- var collection = this.archive;
- var size = Math.min(collection.size(), param.limit || Infinity);
- for (var i=0; i 0) {
- html.link({href: this.tags.get(0).tag.href()}, "topic");
- }
- }
- return;
+ default:
+ if (this.tags.size() > 0) {
+ html.link({href: this.tags.get(0).tag.href()}, "topic");
+ }
+ }
+ return;
}
Story.prototype.topic_macro = function(param) {
- // This method is applied to images as well, thus we check what we got first:
- if (this.constructor !== Image && this.status !== Story.PUBLIC) {
- return;
- }
- if (this.tags.size() < 1) {
- return;
- }
- var tag = this.tags.get(0).tag;
- if (!tag) {
- return;
- }
- if (!param.as || param.as === "text") {
- res.write(tag.name);
- } else if (param.as === "link") {
- html.link({href: tag.href()}, param.text || tag.name);
- } else if (param.as === "image") {
- param.imgprefix || (param.imgprefix = "topic_");
- var img = HopObject.getFromPath(param.imgprefix + tag.name, "images");
- delete param.imgprefix;
- delete param.as;
- if (img) {
- res.push();
- img.render_macro(param);
- delete param.height;
- delete param.width;
- delete param.border;
- delete param.src;
- delete param.alt;
- link_filter(res.pop(), param, tag.href());
- }
- }
- return;
+ // This method is applied to images as well, thus we check what we got first:
+ if (this.constructor !== Image && this.status !== Story.PUBLIC) {
+ return;
+ }
+ if (this.tags.size() < 1) {
+ return;
+ }
+ var tag = this.tags.get(0).tag;
+ if (!tag) {
+ return;
+ }
+ if (!param.as || param.as === "text") {
+ res.write(tag.name);
+ } else if (param.as === "link") {
+ html.link({href: tag.href()}, param.text || tag.name);
+ } else if (param.as === "image") {
+ param.imgprefix || (param.imgprefix = "topic_");
+ var img = HopObject.getFromPath(param.imgprefix + tag.name, "images");
+ delete param.imgprefix;
+ delete param.as;
+ if (img) {
+ res.push();
+ img.render_macro(param);
+ delete param.height;
+ delete param.width;
+ delete param.border;
+ delete param.src;
+ delete param.alt;
+ link_filter(res.pop(), param, tag.href());
+ }
+ }
+ return;
}
Story.prototype.topicchooser_macro = function(param) {
- var site = this.site || res.handlers.site;
- var currentTopic = this.tags.size() > 0 ? this.tags.get(0).tag : null;
- var topics = (this.constructor === Story ? site.stories.tags :
- site.images.galleries);
- var options = [], topic;
- for (var i=0; i 0 ? this.tags.get(0).tag : null;
+ var topics = (this.constructor === Story ? site.stories.tags :
+ site.images.galleries);
+ var options = [], topic;
+ for (var i=0; i 0);
- if (linkflag) {
- html.openTag("a", {href: this.href() + "#comments"});
- }
- if (commentCnt < 1) {
- res.write(param.no || "no comments");
- } else if (commentCnt < 2) {
- res.write(param.one || "one comment");
- } else {
- res.write(commentCnt + (param.more || " " + "comments"));
- }
- if (linkflag) {
- html.closeTag("a");
- }
- return;
+ if (this.site.commentMode === Site.DISABLED ||
+ this.commentMode === Story.CLOSED ||
+ this.commentMode === Story.READONLY) {
+ return;
+ }
+ var commentCnt = this.comments.count();
+ param.linkto || (param.linkto = "main");
+ var linkflag = (param.as === "link" && param.as !== "text" ||
+ !param.as && commentCnt > 0);
+ if (linkflag) {
+ html.openTag("a", {href: this.href() + "#comments"});
+ }
+ if (commentCnt < 1) {
+ res.write(param.no || "no comments");
+ } else if (commentCnt < 2) {
+ res.write(param.one || "one comment");
+ } else {
+ res.write(commentCnt + (param.more || " " + "comments"));
+ }
+ if (linkflag) {
+ html.closeTag("a");
+ }
+ return;
}
Story.prototype.reads_macro = function(param) {
- res.write(this.requests);
- return;
+ res.write(this.requests);
+ return;
}
diff --git a/compat/Topics/Topics.js b/compat/Topics/Topics.js
index 90d2a01e..53e29d87 100644
--- a/compat/Topics/Topics.js
+++ b/compat/Topics/Topics.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -24,15 +24,15 @@
// $URL$
Topics.prototype.main_action = function() {
- return res.redirect(this.href());
+ return res.redirect(this.href());
}
Topics.prototype.getChildElement = function(id) {
- return res.redirect(this.href() + id);
+ return res.redirect(this.href() + id);
}
Topics.prototype.href = function() {
- var mountpoint = (this._parent.constructor === Site ||
- this._parent.constructor === Root ? "tags" : "galleries");
- return this._parent[mountpoint].href();
+ var mountpoint = (this._parent.constructor === Site ||
+ this._parent.constructor === Root ? "tags" : "galleries");
+ return this._parent[mountpoint].href();
}
diff --git a/compat/User/User.js b/compat/User/User.js
index 0c2b1200..03024be9 100644
--- a/compat/User/User.js
+++ b/compat/User/User.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -26,68 +26,68 @@
disableMacro(User, "password");
User.prototype.__defineGetter__("blocked", function() {
- return this.status === User.BLOCKED;
+ return this.status === User.BLOCKED;
});
User.prototype.__defineSetter__("blocked", function(blocked) {
- this.status = blocked ? User.BLOCKED : User.DEFAULT;
+ this.status = blocked ? User.BLOCKED : User.DEFAULT;
});
User.prototype.__defineGetter__("trusted", function() {
- return this.status === User.TRUSTED;
+ return this.status === User.TRUSTED;
});
User.prototype.__defineSetter__("trusted", function(trusted) {
- this.status = trusted ? User.TRUSTED : User.DEFAULT;
+ this.status = trusted ? User.TRUSTED : User.DEFAULT;
});
User.prototype.__defineGetter__("sysadmin", function() {
- return this.status === User.PRIVILEGED;
+ return this.status === User.PRIVILEGED;
});
User.prototype.__defineSetter__("sysadmin", function(privileged) {
- this.status = privileged ? User.PRIVILEGED : User.DEFAULT;
+ this.status = privileged ? User.PRIVILEGED : User.DEFAULT;
});
User.prototype.status_macro = function(param) {
- // This macro is allowed for privileged users only
- if (!User.require(User.PRIVILEGED)) {
- return;
- }
- if (param.as === "editor") {
- this.select_macro(param, "status");
- } else {
- res.write(this.status);
- }
- return;
+ // This macro is allowed for privileged users only
+ if (!User.require(User.PRIVILEGED)) {
+ return;
+ }
+ if (param.as === "editor") {
+ this.select_macro(param, "status");
+ } else {
+ res.write(this.status);
+ }
+ return;
}
User.prototype.name_macro = function(param) {
- if (param.as === "link" && this.url) {
- link_filter(this.name, param, this.url);
- } else {
- res.write(this.name);
- }
- return;
+ if (param.as === "link" && this.url) {
+ link_filter(this.name, param, this.url);
+ } else {
+ res.write(this.name);
+ }
+ return;
}
User.prototype.url_macro = function(param) {
- if (param.as === "editor") {
- this.input_macro(param, "url");
- } else {
- res.write(this.url);
- }
- return;
+ if (param.as === "editor") {
+ this.input_macro(param, "url");
+ } else {
+ res.write(this.url);
+ }
+ return;
}
User.prototype.email_macro = function(param) {
- if (!User.require(User.PRIVILEGED) && this !== session.user) {
- return;
- }
- if (param.as === "editor") {
- this.input_macro(param, "email");
- } else {
- res.write(this.email);
- }
- return;
+ if (!User.require(User.PRIVILEGED) && this !== session.user) {
+ return;
+ }
+ if (param.as === "editor") {
+ this.input_macro(param, "email");
+ } else {
+ res.write(this.email);
+ }
+ return;
}
diff --git a/extra/connect/Global/connect.js b/extra/connect/Global/connect.js
index 4bc79ee7..98bde8ef 100644
--- a/extra/connect/Global/connect.js
+++ b/extra/connect/Global/connect.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -34,301 +34,301 @@ app.addRepository(app.dir + "/../extra/connect/scribe-1.3.0.jar");
// FIXME: Might be good to somehow define the action together with its permissions...
Members.prototype.connect_action = function() {
- try {
- var connect = Feature.get("connect");
- switch (req.data.type) {
- case "facebook":
- connect.facebook(req);
- break;
- case "google":
- connect.google(req);
- break;
- case "twitter":
- connect.scribe(req.data.type);
- break;
- }
- } catch (ex) {
- session.logout();
- res.message = String(ex);
- res.redirect(res.handlers.members.href("login"));
- }
- JSON.sendPaddedResponse(this._parent.stories.getPermission("create"));
- res.redirect(User.getLocation() || res.handlers.site.href());
- return;
+ try {
+ var connect = Feature.get("connect");
+ switch (req.data.type) {
+ case "facebook":
+ connect.facebook(req);
+ break;
+ case "google":
+ connect.google(req);
+ break;
+ case "twitter":
+ connect.scribe(req.data.type);
+ break;
+ }
+ } catch (ex) {
+ session.logout();
+ res.message = String(ex);
+ res.redirect(res.handlers.members.href("login"));
+ }
+ JSON.sendPaddedResponse(this._parent.stories.getPermission("create"));
+ res.redirect(User.getLocation() || res.handlers.site.href());
+ return;
}
Members.prototype.disconnect_action = function() {
- switch (req.data.type) {
- case "facebook":
- case "google":
- case "twitter":
- res.handlers.membership.creator.deleteMetadata(req.data.type + "_id");
- break;
- }
- res.redirect(req.data.http_referer);
- return;
+ switch (req.data.type) {
+ case "facebook":
+ case "google":
+ case "twitter":
+ res.handlers.membership.creator.deleteMetadata(req.data.type + "_id");
+ break;
+ }
+ res.redirect(req.data.http_referer);
+ return;
}
Feature.add("connect", "http://code.google.com/p/antville/wiki/ConnectFeature", {
- _getPermission: function(action) {
- if (this.constructor === Members) {
- switch (action) {
- case "connect":
- return true;
- case "disconnect":
- return User.require(User.REGULAR);
- }
+ _getPermission: function(action) {
+ if (this.constructor === Members) {
+ switch (action) {
+ case "connect":
+ return true;
+ case "disconnect":
+ return User.require(User.REGULAR);
}
- },
-
- main: function(options) {
- var defaultDomain = getProperty("domain.*");
- var domain = getProperty("domain." + res.handlers.site.name);
- if (defaultDomain && domain && !domain.endsWith(defaultDomain)) {
- return;
- }
- var suffix = options.context ? "_" + options.context : "";
- getProperty("connect.facebook.id") && renderSkin("connect#facebook" + suffix);
- getProperty("connect.google.id") && renderSkin("connect#google" + suffix);
- getProperty("connect.twitter.id") && renderSkin("connect#twitter" + suffix);
- },
-
- getUserByConnection: function(type, id) {
- var user;
- var connections = root.connections.get(id);
- if (connections) {
- connections.forEach(function(index) {
- if (this.name === type + "_id") {
- user = this.parent;
- }
- });
- }
- return user;
- },
-
- scribe: function(type) {
- var name = type.titleize();
- var appId = getProperty("connect." + type + ".id");
- var secret = getProperty("connect." + type + ".key");
-
- if (!secret || req.data.denied) {
- throw Error(gettext("Connecting with {0} failed. {1} Please try again.", name,
- gettext("You denied the request.")));
- }
-
- if (req.isPost()) {
- try {
- User.login(req.postParams);
- } catch (ex) { }
- }
-
- var scribe = Packages.org.scribe;
- var provider, requestUrl, scope, getValues;
- var headers = {};
-
- switch (type) {
- case "google":
- provider = scribe.builder.api.GoogleApi;
- requestUrl = "http://www-opensocial.googleusercontent.com/api/people/@me/@self";
- scope = "http://www-opensocial.googleusercontent.com/api/people/";
- headers["GData-Version"] = "3.0";
- getValues = function(data) {
- data = data.entry;
- return {
- id: data.id,
- name: data.displayName,
- email: data.email,
- url: data.url
- }
- }
- break;
-
- case "twitter":
- provider = scribe.builder.api.TwitterApi;
- requestUrl = "https://api.twitter.com/1.1/account/verify_credentials.json";
- getValues = function(data) {
- return {
- id: data.id_str,
- name: data.screen_name,
- email: data.email,
- url: data.profileUrl
- }
- }
- break;
- }
-
- var url = res.handlers.members.href(req.action) + "?type=" + type;
-
- var service = new scribe.builder.ServiceBuilder()
- .provider(provider)
- .apiKey(appId)
- .apiSecret(secret)
- .callback(url);
-
- if (scope) {
- service.scope(scope);
- }
-
- var oauth = service.build();
-
- var verifier = req.data.oauth_verifier;
- if (!verifier) {
- // Because the service provider will redirect back to this URL the
- // request token needs to be stored in the session object
- session.data.requestToken = oauth.getRequestToken();
- res.redirect(oauth.getAuthorizationUrl(session.data.requestToken));
- }
-
- try {
- var accessToken = oauth.getAccessToken(session.data.requestToken,
- new scribe.model.Verifier(verifier));
- } catch (ex) {
- throw Error(gettext("Connecting with {0} failed. {1} Please try again.", name,
- gettext("Something went wrong.")));
- }
-
- var request = new scribe.model.OAuthRequest(scribe.model.Verb.GET, requestUrl);
- oauth.signRequest(accessToken, request);
- for (let name in headers) {
- request.addHeader(name, headers[name]);
- }
- var response = request.send();
-
- var data = getValues(JSON.parse(response.getBody()));
- var user = this.getUserByConnection(type, data.id);
- if (!user) {
- if (!session.user) {
- var name = root.users.getAccessName(data.name);
- user = User.register({
- name: name,
- hash: session.data.requestToken.getToken(),
- email: data.email || root.replyTo,
- url: data.url
- });
- session.login(user);
- } else {
- user = session.user;
- }
- user.setMetadata(type + "_id", data.id);
- } else if (user !== session.user) {
- user.touch();
- session.login(user);
- }
-
- return;
+ }
},
- facebook: function(req) {
- var appId = getProperty("connect.facebook.id");
- var secret = getProperty("connect.facebook.key");
- if (!secret || req.data.error) {
- throw Error(gettext("Could not connect with Facebook. ({0})", -1));
- }
-
- if (req.isPost()) {
- try {
- User.login(req.postParams);
- } catch (ex) { }
- }
-
- var url = res.handlers.members.href(req.action) + "?type=facebook";
-
- var code = req.data.code;
- if (!code) {
- res.redirect("https://www.facebook.com/dialog/oauth?client_id=" + appId +
- "&scope=email&redirect_uri=" + url);
- return;
- }
-
- var mime = getURL("https://graph.facebook.com/oauth/access_token?client_id=" + appId +
- "&redirect_uri=" + url + "&client_secret=" + secret + "&code=" + code);
- if (!mime || !mime.text) {
- throw Error(gettext("Could not connect with Facebook. ({0})", -3));
- }
-
- var token = mime.text;
- mime = getURL("https://graph.facebook.com/me?" + token);
- if (!mime) {
- throw Error(gettext("Could not connect with Facebook. ({0})", -4));
- }
-
- var content = Packages.org.apache.commons.io.IOUtils.toString(mime.inputStream);
- if (!content) {
- throw Error(gettext("Could not connect with Facebook. ({0})", -5));
- }
-
- var data = JSON.parse(content);
- var user = this.getUserByConnection("facebook", data.id);
- if (!user) {
- if (!session.user) {
- var name = root.users.getAccessName(data.name);
- user = User.register({
- name: name,
- hash: token,
- email: data.email,
- url: data.link,
- });
- session.login(user);
- } else {
- user = session.user;
- }
- user.setMetadata("facebook_id", data.id);
- } else if (user !== session.user) {
- user.touch();
- session.login(user);
- }
-
+ main: function(options) {
+ var defaultDomain = getProperty("domain.*");
+ var domain = getProperty("domain." + res.handlers.site.name);
+ if (defaultDomain && domain && !domain.endsWith(defaultDomain)) {
return;
- },
+ }
+ var suffix = options.context ? "_" + options.context : "";
+ getProperty("connect.facebook.id") && renderSkin("connect#facebook" + suffix);
+ getProperty("connect.google.id") && renderSkin("connect#google" + suffix);
+ getProperty("connect.twitter.id") && renderSkin("connect#twitter" + suffix);
+ },
- google: function(req) {
- if (req.isPost()) {
- try {
- User.login(req.postParams);
- } catch (ex) { }
+ getUserByConnection: function(type, id) {
+ var user;
+ var connections = root.connections.get(id);
+ if (connections) {
+ connections.forEach(function(index) {
+ if (this.name === type + "_id") {
+ user = this.parent;
+ }
+ });
+ }
+ return user;
+ },
+
+ scribe: function(type) {
+ var name = type.titleize();
+ var appId = getProperty("connect." + type + ".id");
+ var secret = getProperty("connect." + type + ".key");
+
+ if (!secret || req.data.denied) {
+ throw Error(gettext("Connecting with {0} failed. {1} Please try again.", name,
+ gettext("You denied the request.")));
+ }
+
+ if (req.isPost()) {
+ try {
+ User.login(req.postParams);
+ } catch (ex) { }
+ }
+
+ var scribe = Packages.org.scribe;
+ var provider, requestUrl, scope, getValues;
+ var headers = {};
+
+ switch (type) {
+ case "google":
+ provider = scribe.builder.api.GoogleApi;
+ requestUrl = "http://www-opensocial.googleusercontent.com/api/people/@me/@self";
+ scope = "http://www-opensocial.googleusercontent.com/api/people/";
+ headers["GData-Version"] = "3.0";
+ getValues = function(data) {
+ data = data.entry;
+ return {
+ id: data.id,
+ name: data.displayName,
+ email: data.email,
+ url: data.url
+ }
}
+ break;
- var url = root.members.href('connect') + "?type=google";
+ case "twitter":
+ provider = scribe.builder.api.TwitterApi;
+ requestUrl = "https://api.twitter.com/1.1/account/verify_credentials.json";
+ getValues = function(data) {
+ return {
+ id: data.id_str,
+ name: data.screen_name,
+ email: data.email,
+ url: data.profileUrl
+ }
+ }
+ break;
+ }
- if (req.data.code) {
- var http = new helma.Http();
- http.setMethod("POST");
- http.setContent("code=" + encodeURIComponent(req.data.code) +
- "&client_id=" + encodeURIComponent(getProperty("connect.google.id")) +
- "&client_secret=" + encodeURIComponent(getProperty("connect.google.key")) +
- "&redirect_uri=" + encodeURIComponent(url) + "&grant_type=authorization_code");
- var response = http.getUrl("https://accounts.google.com/o/oauth2/token");
- var data = JSON.parse(response.content);
- var token = data.access_token;
- var mime = getURL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" +
- encodeURIComponent(data.access_token));
- var data = JSON.parse(Packages.org.apache.commons.io.IOUtils.toString(mime.inputStream));
- var user = this.getUserByConnection("google", data.id);
- if (!user) {
- if (!session.user) {
- var name = root.users.getAccessName(data.name);
- user = User.register({
- name: name,
- hash: token,
- email: data.email,
- url: data.link
- });
- session.login(user);
- } else {
- user = session.user;
- }
- user.setMetadata("google_id", data.id);
- } else if (user !== session.user) {
- user.touch();
- session.login(user);
- }
+ var url = res.handlers.members.href(req.action) + "?type=" + type;
+
+ var service = new scribe.builder.ServiceBuilder()
+ .provider(provider)
+ .apiKey(appId)
+ .apiSecret(secret)
+ .callback(url);
+
+ if (scope) {
+ service.scope(scope);
+ }
+
+ var oauth = service.build();
+
+ var verifier = req.data.oauth_verifier;
+ if (!verifier) {
+ // Because the service provider will redirect back to this URL the
+ // request token needs to be stored in the session object
+ session.data.requestToken = oauth.getRequestToken();
+ res.redirect(oauth.getAuthorizationUrl(session.data.requestToken));
+ }
+
+ try {
+ var accessToken = oauth.getAccessToken(session.data.requestToken,
+ new scribe.model.Verifier(verifier));
+ } catch (ex) {
+ throw Error(gettext("Connecting with {0} failed. {1} Please try again.", name,
+ gettext("Something went wrong.")));
+ }
+
+ var request = new scribe.model.OAuthRequest(scribe.model.Verb.GET, requestUrl);
+ oauth.signRequest(accessToken, request);
+ for (let name in headers) {
+ request.addHeader(name, headers[name]);
+ }
+ var response = request.send();
+
+ var data = getValues(JSON.parse(response.getBody()));
+ var user = this.getUserByConnection(type, data.id);
+ if (!user) {
+ if (!session.user) {
+ var name = root.users.getAccessName(data.name);
+ user = User.register({
+ name: name,
+ hash: session.data.requestToken.getToken(),
+ email: data.email || root.replyTo,
+ url: data.url
+ });
+ session.login(user);
} else {
- res.redirect("https://accounts.google.com/o/oauth2/auth?" +
- "client_id=" + encodeURIComponent(getProperty("connect.google.id")) +
- "&redirect_uri=" + encodeURIComponent(url) +
- "&scope=" + encodeURIComponent("https://www.googleapis.com/auth/userinfo.profile") +
- "+" + encodeURIComponent("https://www.googleapis.com/auth/userinfo.email") +
- "&response_type=code");
+ user = session.user;
}
- }
+ user.setMetadata(type + "_id", data.id);
+ } else if (user !== session.user) {
+ user.touch();
+ session.login(user);
+ }
+
+ return;
+ },
+
+ facebook: function(req) {
+ var appId = getProperty("connect.facebook.id");
+ var secret = getProperty("connect.facebook.key");
+ if (!secret || req.data.error) {
+ throw Error(gettext("Could not connect with Facebook. ({0})", -1));
+ }
+
+ if (req.isPost()) {
+ try {
+ User.login(req.postParams);
+ } catch (ex) { }
+ }
+
+ var url = res.handlers.members.href(req.action) + "?type=facebook";
+
+ var code = req.data.code;
+ if (!code) {
+ res.redirect("https://www.facebook.com/dialog/oauth?client_id=" + appId +
+ "&scope=email&redirect_uri=" + url);
+ return;
+ }
+
+ var mime = getURL("https://graph.facebook.com/oauth/access_token?client_id=" + appId +
+ "&redirect_uri=" + url + "&client_secret=" + secret + "&code=" + code);
+ if (!mime || !mime.text) {
+ throw Error(gettext("Could not connect with Facebook. ({0})", -3));
+ }
+
+ var token = mime.text;
+ mime = getURL("https://graph.facebook.com/me?" + token);
+ if (!mime) {
+ throw Error(gettext("Could not connect with Facebook. ({0})", -4));
+ }
+
+ var content = Packages.org.apache.commons.io.IOUtils.toString(mime.inputStream);
+ if (!content) {
+ throw Error(gettext("Could not connect with Facebook. ({0})", -5));
+ }
+
+ var data = JSON.parse(content);
+ var user = this.getUserByConnection("facebook", data.id);
+ if (!user) {
+ if (!session.user) {
+ var name = root.users.getAccessName(data.name);
+ user = User.register({
+ name: name,
+ hash: token,
+ email: data.email,
+ url: data.link,
+ });
+ session.login(user);
+ } else {
+ user = session.user;
+ }
+ user.setMetadata("facebook_id", data.id);
+ } else if (user !== session.user) {
+ user.touch();
+ session.login(user);
+ }
+
+ return;
+ },
+
+ google: function(req) {
+ if (req.isPost()) {
+ try {
+ User.login(req.postParams);
+ } catch (ex) { }
+ }
+
+ var url = root.members.href('connect') + "?type=google";
+
+ if (req.data.code) {
+ var http = new helma.Http();
+ http.setMethod("POST");
+ http.setContent("code=" + encodeURIComponent(req.data.code) +
+ "&client_id=" + encodeURIComponent(getProperty("connect.google.id")) +
+ "&client_secret=" + encodeURIComponent(getProperty("connect.google.key")) +
+ "&redirect_uri=" + encodeURIComponent(url) + "&grant_type=authorization_code");
+ var response = http.getUrl("https://accounts.google.com/o/oauth2/token");
+ var data = JSON.parse(response.content);
+ var token = data.access_token;
+ var mime = getURL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" +
+ encodeURIComponent(data.access_token));
+ var data = JSON.parse(Packages.org.apache.commons.io.IOUtils.toString(mime.inputStream));
+ var user = this.getUserByConnection("google", data.id);
+ if (!user) {
+ if (!session.user) {
+ var name = root.users.getAccessName(data.name);
+ user = User.register({
+ name: name,
+ hash: token,
+ email: data.email,
+ url: data.link
+ });
+ session.login(user);
+ } else {
+ user = session.user;
+ }
+ user.setMetadata("google_id", data.id);
+ } else if (user !== session.user) {
+ user.touch();
+ session.login(user);
+ }
+ } else {
+ res.redirect("https://accounts.google.com/o/oauth2/auth?" +
+ "client_id=" + encodeURIComponent(getProperty("connect.google.id")) +
+ "&redirect_uri=" + encodeURIComponent(url) +
+ "&scope=" + encodeURIComponent("https://www.googleapis.com/auth/userinfo.profile") +
+ "+" + encodeURIComponent("https://www.googleapis.com/auth/userinfo.email") +
+ "&response_type=code");
+ }
+ }
});
diff --git a/extra/proxy/Global/proxy.js b/extra/proxy/Global/proxy.js
index a515a823..696ee124 100644
--- a/extra/proxy/Global/proxy.js
+++ b/extra/proxy/Global/proxy.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -28,33 +28,33 @@
*/
Root.prototype.proxy_action = function() {
- var url = req.data.url;
- if (!url) {
- return;
- }
+ var url = req.data.url;
+ if (!url) {
+ return;
+ }
- var http = new helma.Http;
- var data = http.getUrl(url);
+ var http = new helma.Http;
+ var data = http.getUrl(url);
- if (!data.content) {
- throw Error("Failed to retrieve URL.");
- }
+ if (!data.content) {
+ throw Error("Failed to retrieve URL.");
+ }
- var callback = req.data.callback;
- if (callback) {
- res.contentType = "text/javascript";
- res.write(JSON.pad(data.content, callback));
- } else {
- res.write(data.content);
- }
- return;
+ var callback = req.data.callback;
+ if (callback) {
+ res.contentType = "text/javascript";
+ res.write(JSON.pad(data.content, callback));
+ } else {
+ res.write(data.content);
+ }
+ return;
}
Feature.add("proxy", "http://code.google.com/p/antville/wiki/ProxyFeature", {
- _getPermission: function(action) {
- if (this._prototype in {Root: 1} &&
- action === "proxy" && User.require(User.TRUSTED)) {
- return true;
- }
- }
+ _getPermission: function(action) {
+ if (this._prototype in {Root: 1} &&
+ action === "proxy" && User.require(User.TRUSTED)) {
+ return true;
+ }
+ }
});
diff --git a/extra/recaptcha/Global/recaptcha.js b/extra/recaptcha/Global/recaptcha.js
index 39c34014..ef47a324 100644
--- a/extra/recaptcha/Global/recaptcha.js
+++ b/extra/recaptcha/Global/recaptcha.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -29,35 +29,35 @@
*/
Feature.add("recaptcha", "http://code.google.com/p/antville/wiki/RecaptchaFeature", new function() {
- var key = getProperty("recaptcha.key");
+ var key = getProperty("recaptcha.key");
- return {
- main: function() {
- if (key && !session.user) {
- renderSkin("recaptcha", {id: getProperty("recaptcha.id")});
- }
- return;
- },
-
- verify: function(data) {
- if (session.user) {
- return;
- }
- var http = new helma.Http;
- http.setTimeout(200);
- http.setReadTimeout(300);
- http.setMethod("POST");
- http.setContent({
- privatekey: key,
- remoteip: req.data.http_remotehost,
- challenge: data.recaptcha_challenge_field,
- response: data.recaptcha_response_field
- });
- var request = http.getUrl("http://www.google.com/recaptcha/api/verify");
- if (request.code === 200 && !request.content.startsWith("true")) {
- throw Error(gettext("Please enter the correct words in the CAPTCHA box."));
- }
- return;
+ return {
+ main: function() {
+ if (key && !session.user) {
+ renderSkin("recaptcha", {id: getProperty("recaptcha.id")});
}
- }
+ return;
+ },
+
+ verify: function(data) {
+ if (session.user) {
+ return;
+ }
+ var http = new helma.Http;
+ http.setTimeout(200);
+ http.setReadTimeout(300);
+ http.setMethod("POST");
+ http.setContent({
+ privatekey: key,
+ remoteip: req.data.http_remotehost,
+ challenge: data.recaptcha_challenge_field,
+ response: data.recaptcha_response_field
+ });
+ var request = http.getUrl("http://www.google.com/recaptcha/api/verify");
+ if (request.code === 200 && !request.content.startsWith("true")) {
+ throw Error(gettext("Please enter the correct words in the CAPTCHA box."));
+ }
+ return;
+ }
+ }
});
diff --git a/extra/updater/Global/Global.js b/extra/updater/Global/Global.js
index 3d1ab44f..c2cfb2b8 100644
--- a/extra/updater/Global/Global.js
+++ b/extra/updater/Global/Global.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -29,307 +29,307 @@ app.data.status = "idle";
var server = Packages.helma.main.Server.getServer();
var status = function(type) {
- if (type) {
- app.data.status = type;
- return;
- } else {
- return app.data.status;
- }
+ if (type) {
+ app.data.status = type;
+ return;
+ } else {
+ return app.data.status;
+ }
}
var antville = function() {
- return new Packages.helma.framework.core.ApplicationBean(server.
- getApplication("antville"));
+ return new Packages.helma.framework.core.ApplicationBean(server.
+ getApplication("antville"));
}
var db = function() {
- app.data.db || (app.data.db = new Packages.helma.scripting.rhino.extensions.
- DatabaseObject(antville().getDbSource("antville")));
- return app.data.db;
+ app.data.db || (app.data.db = new Packages.helma.scripting.rhino.extensions.
+ DatabaseObject(antville().getDbSource("antville")));
+ return app.data.db;
}
var ResultWrapper = function(result) {
- var columns = [];
- this.values = {};
+ var columns = [];
+ this.values = {};
- for (var i=1; i<=result.getColumnCount(); i+=1) {
- columns.push(result.getColumnName(i));
- }
+ for (var i=1; i<=result.getColumnCount(); i+=1) {
+ columns.push(result.getColumnName(i));
+ }
- this.update = function() {
- for each (var key in columns) {
- this.values[key] = result.getColumnItem(key);
- }
- return;
- }
+ this.update = function() {
+ for each (var key in columns) {
+ this.values[key] = result.getColumnItem(key);
+ }
+ return;
+ }
- return this;
+ return this;
}
var version = function() {
- try {
- var rootSite = antville().__app__.getDataRoot();
- var metadata = eval(rootSite.metadata_source);
- return metadata.version || "";
- } catch (ex) {
- return "";
- }
+ try {
+ var rootSite = antville().__app__.getDataRoot();
+ var metadata = eval(rootSite.metadata_source);
+ return metadata.version || "";
+ } catch (ex) {
+ return "";
+ }
}
var init = function() {
- var currentVersion = version();
- if (status() === "running") {
- msg("Updater is already running");
- return false;
- } else if (getProperty("version.to") == currentVersion) {
- msg("Antville installation is already up-to-date");
- status("finished");
- return false;
- } else if (getProperty("version.from") != currentVersion) {
- msg("Updater cannot upgrade version " + currentVersion);
- status("failed")
- return false;
- } else {
- status("running");
- }
+ var currentVersion = version();
+ if (status() === "running") {
+ msg("Updater is already running");
+ return false;
+ } else if (getProperty("version.to") == currentVersion) {
+ msg("Antville installation is already up-to-date");
+ status("finished");
+ return false;
+ } else if (getProperty("version.from") != currentVersion) {
+ msg("Updater cannot upgrade version " + currentVersion);
+ status("failed")
+ return false;
+ } else {
+ status("running");
+ }
return true;
}
var finalize = function() {
- var rootSite = antville().__app__.getDataRoot();
- var metadata = eval(rootSite.metadata_source);
- metadata.version = getProperty("version.to");
- rootSite.metadata_source = metadata.toSource();
- status("finished");
- return;
+ var rootSite = antville().__app__.getDataRoot();
+ var metadata = eval(rootSite.metadata_source);
+ metadata.version = getProperty("version.to");
+ rootSite.metadata_source = metadata.toSource();
+ status("finished");
+ return;
}
var out = function() {
- var str;
- if (app.data.out.length() > 0) {
- str = app.data.out.toString();
- app.data.out.setLength(0);
- }
- res.write({
- status: status(),
- log: str
- }.toSource());
- return;
+ var str;
+ if (app.data.out.length() > 0) {
+ str = app.data.out.toString();
+ app.data.out.setLength(0);
+ }
+ res.write({
+ status: status(),
+ log: str
+ }.toSource());
+ return;
}
var log = function(str) {
- app.log(str);
- return;
+ app.log(str);
+ return;
}
var msg = function(str1 /* , str2, str2, ... */) {
- var str = "";
- for (var i=0; i 0) {
- var callback;
- if (typeof values[values.length - 1] === "function") {
- callback = values.pop();
- }
- if (typeof values[0] === "object") {
- values = values[0];
- }
- str = str.replace(/\$(\w*)/g, function(str, key) {
- return callback ? callback(values[key]) : values[key];
- });
- }
- return str;
+ var values = Array.prototype.slice.call(arguments, 1);
+ if (values.length > 0) {
+ var callback;
+ if (typeof values[values.length - 1] === "function") {
+ callback = values.pop();
+ }
+ if (typeof values[0] === "object") {
+ values = values[0];
+ }
+ str = str.replace(/\$(\w*)/g, function(str, key) {
+ return callback ? callback(values[key]) : values[key];
+ });
+ }
+ return str;
}
var retrieve = function(sql /*, value1, ..., valueN */) {
- // Add callback for global value() method to stringf() arguments
- Array.prototype.push.call(arguments, value);
- app.data.query = stringf.apply(null, arguments);
- return;
+ // Add callback for global value() method to stringf() arguments
+ Array.prototype.push.call(arguments, value);
+ app.data.query = stringf.apply(null, arguments);
+ return;
}
var traverse = function(callback, noOffset, idName) {
- if (!app.data.query || !callback) {
- return;
- }
- var STEP = 5000, start = Date.now();
- var sql, rows, offset = 0;
- while (true) {
- start = Date.now();
- if (noOffset) {
- sql = app.data.query.replace(/\$min/, offset);
- sql = sql.replace(/\$max/, offset += noOffset);
- msg(sql);
- } else {
- sql = app.data.query + " limit " + STEP;
- sql += " offset " + offset;
- offset += STEP;
- msg(sql);
- }
- result = db().executeRetrieval(sql);
- error();
- msg("Select statement took " + (Date.now() - start) + " millis");
- // FIXME: The hasMoreRows() method does not work as expected
- rows = result.next();
- if (!rows) {
- result.release();
- break;
- }
- do {
- var wrapper = new ResultWrapper(result);
- wrapper.update(result);
- callback.call(wrapper.values, result);
- } while (rows = result.next());
+ if (!app.data.query || !callback) {
+ return;
+ }
+ var STEP = 5000, start = Date.now();
+ var sql, rows, offset = 0;
+ while (true) {
+ start = Date.now();
+ if (noOffset) {
+ sql = app.data.query.replace(/\$min/, offset);
+ sql = sql.replace(/\$max/, offset += noOffset);
+ msg(sql);
+ } else {
+ sql = app.data.query + " limit " + STEP;
+ sql += " offset " + offset;
+ offset += STEP;
+ msg(sql);
+ }
+ result = db().executeRetrieval(sql);
+ error();
+ msg("Select statement took " + (Date.now() - start) + " millis");
+ // FIXME: The hasMoreRows() method does not work as expected
+ rows = result.next();
+ if (!rows) {
result.release();
- msg("Update took " + (Date.now() - start) + " millis");
- }
- return;
+ break;
+ }
+ do {
+ var wrapper = new ResultWrapper(result);
+ wrapper.update(result);
+ callback.call(wrapper.values, result);
+ } while (rows = result.next());
+ result.release();
+ msg("Update took " + (Date.now() - start) + " millis");
+ }
+ return;
}
var execute = function(sql /*, value1, ..., valueN */) {
- // Add callback for global value() method to stringf() arguments
- Array.prototype.push.call(arguments, value);
- sql = stringf.apply(null, arguments);
- log(sql.contains("\n") ? sql.substr(0, sql.indexOf("\n")) + " ..." : sql);
- try {
- db().executeCommand(sql);
- error();
- } catch (ex) {
- error(ex);
- }
- return;
+ // Add callback for global value() method to stringf() arguments
+ Array.prototype.push.call(arguments, value);
+ sql = stringf.apply(null, arguments);
+ log(sql.contains("\n") ? sql.substr(0, sql.indexOf("\n")) + " ..." : sql);
+ try {
+ db().executeCommand(sql);
+ error();
+ } catch (ex) {
+ error(ex);
+ }
+ return;
}
var archive = function() {
- var staticDir = new helma.File(app.dir + "/../static");
- for each (var siteName in staticDir.list()) {
- var site = siteName !== "www" ? root.get(siteName) : root;
- if (!site) {
- continue;
+ var staticDir = new helma.File(app.dir + "/../static");
+ for each (var siteName in staticDir.list()) {
+ var site = siteName !== "www" ? root.get(siteName) : root;
+ if (!site) {
+ continue;
+ }
+ var dir = new helma.File(staticDir, siteName + "/layouts");
+ for each (var layoutName in dir.list()) {
+ if (layoutName.startsWith(".")) {
+ continue;
}
- var dir = new helma.File(staticDir, siteName + "/layouts");
- for each (var layoutName in dir.list()) {
- if (layoutName.startsWith(".")) {
- continue;
- }
- var layout = new Layout(site);
- for each (var image in dir.listRecursive(/\.(jpg|gif|png)$/)) {
- var name = image.split("/").pop().split(".")[0];
- retrieve(query("archive", name, layoutName, siteName));
- traverse(function() {
- var img = new Image(this);
- log(img);
- });
- }
+ var layout = new Layout(site);
+ for each (var image in dir.listRecursive(/\.(jpg|gif|png)$/)) {
+ var name = image.split("/").pop().split(".")[0];
+ retrieve(query("archive", name, layoutName, siteName));
+ traverse(function() {
+ var img = new Image(this);
+ log(img);
+ });
}
- }
+ }
+ }
}
diff --git a/extra/updater/Global/convert.js b/extra/updater/Global/convert.js
index 7e4a2fd5..979c2752 100644
--- a/extra/updater/Global/convert.js
+++ b/extra/updater/Global/convert.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -24,606 +24,606 @@
// $URL$
var convert = function(type) {
- if (!type) {
- return;
- }
+ if (!type) {
+ return;
+ }
- var func;
- if (func = arguments.callee[type]) {
- try {
- func();
- } catch (ex) {
- error(ex.toString());
- }
- } else {
- execute(query(type));
- }
+ var func;
+ if (func = arguments.callee[type]) {
+ try {
+ func();
+ } catch (ex) {
+ error(ex.toString());
+ }
+ } else {
+ execute(query(type));
+ }
}
convert.files = function() {
- retrieve(query("files"));
- traverse(function() {
- var metadata = {
- fileName: this.fileName,
- contentType: this.type,
- contentLength: this.size || 0,
- }
- this.description && (metadata.description = clean(this.description));
- execute("update file set prototype = 'File', parent_type = 'Site', " +
- "parent_id = site_id, metadata = $0 where id = $1",
- metadata.toSource(), this.id);
- });
+ retrieve(query("files"));
+ traverse(function() {
+ var metadata = {
+ fileName: this.fileName,
+ contentType: this.type,
+ contentLength: this.size || 0,
+ }
+ this.description && (metadata.description = clean(this.description));
+ execute("update file set prototype = 'File', parent_type = 'Site', " +
+ "parent_id = site_id, metadata = $0 where id = $1",
+ metadata.toSource(), this.id);
+ });
}
convert.images = function() {
- execute("alter table tag change id id int(11) not null auto_increment")
- execute("alter table tag_hub change id id int(11) not null auto_increment");
+ execute("alter table tag change id id int(11) not null auto_increment")
+ execute("alter table tag_hub change id id int(11) not null auto_increment");
- retrieve("select distinct(IMAGE_TOPIC), IMAGE_F_SITE " +
- "from AV_IMAGE where IMAGE_TOPIC is not null");
- traverse(function() {
- execute("insert into tag set site_id = $0, name = $1, type = $2",
- this.IMAGE_F_SITE, this.IMAGE_TOPIC.replace(/^[\/\.]*$/, "?"), 'Image');
- });
+ retrieve("select distinct(IMAGE_TOPIC), IMAGE_F_SITE " +
+ "from AV_IMAGE where IMAGE_TOPIC is not null");
+ traverse(function() {
+ execute("insert into tag set site_id = $0, name = $1, type = $2",
+ this.IMAGE_F_SITE, this.IMAGE_TOPIC.replace(/^[\/\.]*$/, "?"), 'Image');
+ });
- retrieve("select *, t.IMAGE_WIDTH as thumbnailWidth, t.IMAGE_HEIGHT " +
- "as thumbnailHeight from AV_IMAGE i left join AV_IMAGE t on " +
- "i.IMAGE_F_IMAGE_THUMB = t.IMAGE_ID left join tag on " +
- "i.IMAGE_F_SITE = site_id and i.IMAGE_TOPIC = name and " +
- "type = 'Image' left join AV_LAYOUT l on LAYOUT_ID = i.IMAGE_F_LAYOUT " +
- "where i.IMAGE_WIDTH is not null and i.IMAGE_HEIGHT is not null and " +
- "i.IMAGE_F_IMAGE_PARENT is null and i.IMAGE_ID > $min and " +
- "i.IMAGE_ID <= $max order by i.IMAGE_ID");
+ retrieve("select *, t.IMAGE_WIDTH as thumbnailWidth, t.IMAGE_HEIGHT " +
+ "as thumbnailHeight from AV_IMAGE i left join AV_IMAGE t on " +
+ "i.IMAGE_F_IMAGE_THUMB = t.IMAGE_ID left join tag on " +
+ "i.IMAGE_F_SITE = site_id and i.IMAGE_TOPIC = name and " +
+ "type = 'Image' left join AV_LAYOUT l on LAYOUT_ID = i.IMAGE_F_LAYOUT " +
+ "where i.IMAGE_WIDTH is not null and i.IMAGE_HEIGHT is not null and " +
+ "i.IMAGE_F_IMAGE_PARENT is null and i.IMAGE_ID > $min and " +
+ "i.IMAGE_ID <= $max order by i.IMAGE_ID");
- traverse(function() {
- var metadata = {
- fileName: this.IMAGE_FILENAME + "." + this.IMAGE_FILEEXT,
- contentLength: this.IMAGE_FILESIZE || 0,
- contentType: "image/" + this.IMAGE_FILEEXT,
- width: this.IMAGE_WIDTH,
- height: this.IMAGE_HEIGHT
- };
- this.IMAGE_ALTTEXT && (metadata.description = clean(this.IMAGE_ALTTEXT));
- if (this.thumbnailWidth && this.thumbnailHeight) {
- metadata.thumbnailName = this.IMAGE_FILENAME + "_small" + "." +
- this.IMAGE_FILEEXT;
- metadata.thumbnailWidth = this.thumbnailWidth;
- metadata.thumbnailHeight = this.thumbnailHeight;
- }
- this.metadata = metadata;
+ traverse(function() {
+ var metadata = {
+ fileName: this.IMAGE_FILENAME + "." + this.IMAGE_FILEEXT,
+ contentLength: this.IMAGE_FILESIZE || 0,
+ contentType: "image/" + this.IMAGE_FILEEXT,
+ width: this.IMAGE_WIDTH,
+ height: this.IMAGE_HEIGHT
+ };
+ this.IMAGE_ALTTEXT && (metadata.description = clean(this.IMAGE_ALTTEXT));
+ if (this.thumbnailWidth && this.thumbnailHeight) {
+ metadata.thumbnailName = this.IMAGE_FILENAME + "_small" + "." +
+ this.IMAGE_FILEEXT;
+ metadata.thumbnailWidth = this.thumbnailWidth;
+ metadata.thumbnailHeight = this.thumbnailHeight;
+ }
+ this.metadata = metadata;
- this.IMAGE_F_SITE = this.IMAGE_F_SITE || this.LAYOUT_F_SITE || null;
- this.IMAGE_F_IMAGE_PARENT = this.IMAGE_F_LAYOUT || this.IMAGE_F_SITE;
- this.IMAGE_CREATETIME || (this.IMAGE_CREATETIME = null);
- this.IMAGE_F_USER_CREATOR || (this.IMAGE_F_USER_CREATOR = null);
- this.IMAGE_MODIFYTIME || (this.IMAGE_MODIFYTIME = null);
- this.IMAGE_F_USER_MODIFIER || (this.IMAGE_F_USER_MODIFIER = null);
+ this.IMAGE_F_SITE = this.IMAGE_F_SITE || this.LAYOUT_F_SITE || null;
+ this.IMAGE_F_IMAGE_PARENT = this.IMAGE_F_LAYOUT || this.IMAGE_F_SITE;
+ this.IMAGE_CREATETIME || (this.IMAGE_CREATETIME = null);
+ this.IMAGE_F_USER_CREATOR || (this.IMAGE_F_USER_CREATOR = null);
+ this.IMAGE_MODIFYTIME || (this.IMAGE_MODIFYTIME = null);
+ this.IMAGE_F_USER_MODIFIER || (this.IMAGE_F_USER_MODIFIER = null);
- execute("insert into image values ($IMAGE_ID, $IMAGE_ALIAS, " +
- "$IMAGE_PROTOTYPE, $IMAGE_F_SITE, $IMAGE_F_IMAGE_PARENT, null, " +
- "$metadata, $IMAGE_CREATETIME, $IMAGE_F_USER_CREATOR, " +
- "$IMAGE_MODIFYTIME, $IMAGE_F_USER_MODIFIER)", this);
+ execute("insert into image values ($IMAGE_ID, $IMAGE_ALIAS, " +
+ "$IMAGE_PROTOTYPE, $IMAGE_F_SITE, $IMAGE_F_IMAGE_PARENT, null, " +
+ "$metadata, $IMAGE_CREATETIME, $IMAGE_F_USER_CREATOR, " +
+ "$IMAGE_MODIFYTIME, $IMAGE_F_USER_MODIFIER)", this);
- if (this.IMAGE_TOPIC) {
- execute("insert into tag_hub set tag_id = $0, tagged_id = $1, " +
- "tagged_type = 'Image', user_id = $2", this.id, this.IMAGE_ID,
- this.IMAGE_F_USER_MODIFIER || this.IMAGE_F_USER_CREATOR);
- }
+ if (this.IMAGE_TOPIC) {
+ execute("insert into tag_hub set tag_id = $0, tagged_id = $1, " +
+ "tagged_type = 'Image', user_id = $2", this.id, this.IMAGE_ID,
+ this.IMAGE_F_USER_MODIFIER || this.IMAGE_F_USER_CREATOR);
+ }
- //execute("delete from AV_IMAGE where IMAGE_ID = $0", this.IMAGE_ID);
- }, 5000);
+ //execute("delete from AV_IMAGE where IMAGE_ID = $0", this.IMAGE_ID);
+ }, 5000);
- execute("alter table tag change id id int(11)")
- execute("alter table tag_hub change id id int(11)");
+ execute("alter table tag change id id int(11)")
+ execute("alter table tag_hub change id id int(11)");
}
convert.layoutImages = function() {
- retrieve("select *, i.IMAGE_ALIAS, l.LAYOUT_ALIAS as layoutName, " +
- "l.LAYOUT_ID as layoutId, t.IMAGE_WIDTH as thumbnailWidth, " +
- "t.IMAGE_HEIGHT as thumbnailHeight, pl.LAYOUT_ALIAS as " +
- "parentLayout from AV_LAYOUT pl, AV_IMAGE i left join " +
- "AV_IMAGE t on i.IMAGE_F_IMAGE_THUMB = t.IMAGE_ID, AV_LAYOUT l " +
- "left join AV_SITE site on SITE_ID = l.LAYOUT_F_SITE where " +
- "i.IMAGE_F_LAYOUT = pl.LAYOUT_ID and l.LAYOUT_F_LAYOUT_PARENT = " +
- "pl.LAYOUT_ID and pl.LAYOUT_F_SITE is null and i.IMAGE_PROTOTYPE " +
- "= 'LayoutImage' and i.IMAGE_F_IMAGE_PARENT is null and " +
- "i.IMAGE_ALIAS not in (select IMAGE_ALIAS from AV_IMAGE, " +
- "AV_LAYOUT, AV_SITE where LAYOUT_ID = IMAGE_F_LAYOUT and " +
- "SITE_ID = LAYOUT_F_SITE and IMAGE_PROTOTYPE = 'LayoutImage' " +
- "and IMAGE_F_IMAGE_PARENT is null and LAYOUT_ID = l.LAYOUT_ID " +
- "and SITE_ID = site.SITE_ID) and l.LAYOUT_ID > $min and " +
- "l.LAYOUT_ID <= $max order by l.LAYOUT_ID");
+ retrieve("select *, i.IMAGE_ALIAS, l.LAYOUT_ALIAS as layoutName, " +
+ "l.LAYOUT_ID as layoutId, t.IMAGE_WIDTH as thumbnailWidth, " +
+ "t.IMAGE_HEIGHT as thumbnailHeight, pl.LAYOUT_ALIAS as " +
+ "parentLayout from AV_LAYOUT pl, AV_IMAGE i left join " +
+ "AV_IMAGE t on i.IMAGE_F_IMAGE_THUMB = t.IMAGE_ID, AV_LAYOUT l " +
+ "left join AV_SITE site on SITE_ID = l.LAYOUT_F_SITE where " +
+ "i.IMAGE_F_LAYOUT = pl.LAYOUT_ID and l.LAYOUT_F_LAYOUT_PARENT = " +
+ "pl.LAYOUT_ID and pl.LAYOUT_F_SITE is null and i.IMAGE_PROTOTYPE " +
+ "= 'LayoutImage' and i.IMAGE_F_IMAGE_PARENT is null and " +
+ "i.IMAGE_ALIAS not in (select IMAGE_ALIAS from AV_IMAGE, " +
+ "AV_LAYOUT, AV_SITE where LAYOUT_ID = IMAGE_F_LAYOUT and " +
+ "SITE_ID = LAYOUT_F_SITE and IMAGE_PROTOTYPE = 'LayoutImage' " +
+ "and IMAGE_F_IMAGE_PARENT is null and LAYOUT_ID = l.LAYOUT_ID " +
+ "and SITE_ID = site.SITE_ID) and l.LAYOUT_ID > $min and " +
+ "l.LAYOUT_ID <= $max order by l.LAYOUT_ID");
- traverse(function() {
- var metadata = {
- fileName: this.IMAGE_FILENAME + "." + this.IMAGE_FILEEXT,
- contentLength: this.IMAGE_FILESIZE || 0,
- contentType: "image/" + this.IMAGE_FILEEXT,
- width: this.IMAGE_WIDTH,
- height: this.IMAGE_HEIGHT
- };
- this.IMAGE_ALTTEXT && (metadata.description = clean(this.IMAGE_ALTTEXT));
- if (this.thumbnailWidth && this.thumbnailHeight) {
- metadata.thumbnailName = this.IMAGE_FILENAME + "_small" + "." +
- this.IMAGE_FILEEXT;
- metadata.thumbnailWidth = this.thumbnailWidth;
- metadata.thumbnailHeight = this.thumbnailHeight;
+ traverse(function() {
+ var metadata = {
+ fileName: this.IMAGE_FILENAME + "." + this.IMAGE_FILEEXT,
+ contentLength: this.IMAGE_FILESIZE || 0,
+ contentType: "image/" + this.IMAGE_FILEEXT,
+ width: this.IMAGE_WIDTH,
+ height: this.IMAGE_HEIGHT
+ };
+ this.IMAGE_ALTTEXT && (metadata.description = clean(this.IMAGE_ALTTEXT));
+ if (this.thumbnailWidth && this.thumbnailHeight) {
+ metadata.thumbnailName = this.IMAGE_FILENAME + "_small" + "." +
+ this.IMAGE_FILEEXT;
+ metadata.thumbnailWidth = this.thumbnailWidth;
+ metadata.thumbnailHeight = this.thumbnailHeight;
+ }
+ this.metadata = metadata;
+
+ this.SITE_ID || (this.SITE_ID = null);
+ this.IMAGE_CREATETIME || (this.IMAGE_CREATETIME = this.SITE_CREATETIME);
+ this.IMAGE_F_USER_CREATOR || (this.IMAGE_F_USER_CREATOR =
+ this.SITE_F_USER_CREATOR || null);
+ this.IMAGE_MODIFYTIME || (this.IMAGE_MODIFYTIME = null);
+ this.IMAGE_F_USER_MODIFIER || (this.IMAGE_F_USER_MODIFIER = null);
+
+ execute("insert into image values ($IMAGE_ID, $IMAGE_ALIAS, " +
+ "'LayoutImage', $SITE_ID, $layoutId, 'Layout', $metadata, " +
+ "$IMAGE_CREATETIME, $IMAGE_F_USER_CREATOR, $IMAGE_MODIFYTIME, " +
+ "$IMAGE_F_USER_MODIFIER)", this);
+
+ var fpath = antville().properties.staticPath;
+ var files = [metadata.fileName, metadata.thumbnailName];
+ for each (var fname in files) {
+ var source = new helma.File(fpath + "/layouts/" +
+ this.parentLayout, fname);
+ var layoutDir = new helma.File(fpath + this.SITE_ALIAS +
+ "/layouts/", this.layoutName);
+ layoutDir.exists() || layoutDir.makeDirectory();
+ var dest = new helma.File(layoutDir, fname);
+ if (source.exists()) {
+ log("Copy " + source + " to " + dest);
+ if (dest.exists()) {
+ dest.remove();
+ }
+ source.hardCopy(dest);
}
- this.metadata = metadata;
-
- this.SITE_ID || (this.SITE_ID = null);
- this.IMAGE_CREATETIME || (this.IMAGE_CREATETIME = this.SITE_CREATETIME);
- this.IMAGE_F_USER_CREATOR || (this.IMAGE_F_USER_CREATOR =
- this.SITE_F_USER_CREATOR || null);
- this.IMAGE_MODIFYTIME || (this.IMAGE_MODIFYTIME = null);
- this.IMAGE_F_USER_MODIFIER || (this.IMAGE_F_USER_MODIFIER = null);
-
- execute("insert into image values ($IMAGE_ID, $IMAGE_ALIAS, " +
- "'LayoutImage', $SITE_ID, $layoutId, 'Layout', $metadata, " +
- "$IMAGE_CREATETIME, $IMAGE_F_USER_CREATOR, $IMAGE_MODIFYTIME, " +
- "$IMAGE_F_USER_MODIFIER)", this);
-
- var fpath = antville().properties.staticPath;
- var files = [metadata.fileName, metadata.thumbnailName];
- for each (var fname in files) {
- var source = new helma.File(fpath + "/layouts/" +
- this.parentLayout, fname);
- var layoutDir = new helma.File(fpath + this.SITE_ALIAS +
- "/layouts/", this.layoutName);
- layoutDir.exists() || layoutDir.makeDirectory();
- var dest = new helma.File(layoutDir, fname);
- if (source.exists()) {
- log("Copy " + source + " to " + dest);
- if (dest.exists()) {
- dest.remove();
- }
- source.hardCopy(dest);
- }
- }
- }, 100);
+ }
+ }, 100);
}
convert.layouts = function() {
- convert.xml("layout");
- retrieve(query("layouts"));
- traverse(function() {
- var metadata = eval(this.metadata) || {};
- metadata.title = this.LAYOUT_TITLE || "Layout #" + this.id;
- metadata.description = this.LAYOUT_DESCRIPTION;
- if (this.LAYOUT_ISIMPORT) {
- // FIXME: metadata.origin = Layout.getById(id).href();
- }
- execute("update layout set metadata = " +
- quote(metadata.toSource()) + " where id = " + this.id);
- });
+ convert.xml("layout");
+ retrieve(query("layouts"));
+ traverse(function() {
+ var metadata = eval(this.metadata) || {};
+ metadata.title = this.LAYOUT_TITLE || "Layout #" + this.id;
+ metadata.description = this.LAYOUT_DESCRIPTION;
+ if (this.LAYOUT_ISIMPORT) {
+ // FIXME: metadata.origin = Layout.getById(id).href();
+ }
+ execute("update layout set metadata = " +
+ quote(metadata.toSource()) + " where id = " + this.id);
+ });
}
convert.sites = function() {
- convert.xml("site");
- retrieve(query("sites"));
- traverse(function() {
- var metadata = eval(this.metadata) || {};
- metadata.email = this.SITE_EMAIL;
- metadata.title = this.SITE_TITLE;
- metadata.configured = this.SITE_LASTUPDATE;
- metadata.pageSize = metadata.days || 3;
- metadata.pageMode = "days";
- metadata.timeZone = metadata.timezone || "CET";
- metadata.archiveMode = metadata.archive ? "public" : "closed";
- metadata.commentMode = metadata.discussions ? "enabled" : "disabled";
- metadata.shortDateFormat = metadata.shortdateformat;
- metadata.longDateFormat = metadata.longdateformat;
- metadata.closed = this.SITE_LASTOFFLINE;
- metadata.notifiedOfBlocking = this.SITE_LASTBLOCKWARN;
- metadata.notifiedOfDeletion = this.SITE_LASTDELWARN;
- metadata.callbackMode = this.SITE_ENABLEPING ?
- "enabled" : "disabled";
- // FIXME: metadata.webHookUrl = "";
- metadata.locale = metadata.language;
- if (metadata.country) {
- metadata.locale += "_" + metadata.country;
- }
- var mode = metadata.usercontrib ? 'open' : this.mode;
- for each (var key in ["enableping", "usercontrib", "archive",
- "discussions", "days", "shortdateformat", "longdateformat",
- "linkcolor", "alinkcolor", "vlinkcolor", "smallcolor",
- "titlecolor", "titlefont", "textfont", "textcolor", "smallsize",
- "smallfont", "textsize", "titlesize", "timezone", "bgcolor",
- "language", "country"]) {
- delete metadata[key];
- }
- execute("update site set metadata = " + quote(metadata.toSource()) +
- ", mode = " + quote(mode) + " where id = " + this.id);
- });
+ convert.xml("site");
+ retrieve(query("sites"));
+ traverse(function() {
+ var metadata = eval(this.metadata) || {};
+ metadata.email = this.SITE_EMAIL;
+ metadata.title = this.SITE_TITLE;
+ metadata.configured = this.SITE_LASTUPDATE;
+ metadata.pageSize = metadata.days || 3;
+ metadata.pageMode = "days";
+ metadata.timeZone = metadata.timezone || "CET";
+ metadata.archiveMode = metadata.archive ? "public" : "closed";
+ metadata.commentMode = metadata.discussions ? "enabled" : "disabled";
+ metadata.shortDateFormat = metadata.shortdateformat;
+ metadata.longDateFormat = metadata.longdateformat;
+ metadata.closed = this.SITE_LASTOFFLINE;
+ metadata.notifiedOfBlocking = this.SITE_LASTBLOCKWARN;
+ metadata.notifiedOfDeletion = this.SITE_LASTDELWARN;
+ metadata.callbackMode = this.SITE_ENABLEPING ?
+ "enabled" : "disabled";
+ // FIXME: metadata.webHookUrl = "";
+ metadata.locale = metadata.language;
+ if (metadata.country) {
+ metadata.locale += "_" + metadata.country;
+ }
+ var mode = metadata.usercontrib ? 'open' : this.mode;
+ for each (var key in ["enableping", "usercontrib", "archive",
+ "discussions", "days", "shortdateformat", "longdateformat",
+ "linkcolor", "alinkcolor", "vlinkcolor", "smallcolor",
+ "titlecolor", "titlefont", "textfont", "textcolor", "smallsize",
+ "smallfont", "textsize", "titlesize", "timezone", "bgcolor",
+ "language", "country"]) {
+ delete metadata[key];
+ }
+ execute("update site set metadata = " + quote(metadata.toSource()) +
+ ", mode = " + quote(mode) + " where id = " + this.id);
+ });
}
convert.content = function() {
- execute("alter table tag change id id int(11) not null auto_increment")
- execute("alter table tag_hub change id id int(11) not null auto_increment");
+ execute("alter table tag change id id int(11) not null auto_increment")
+ execute("alter table tag_hub change id id int(11) not null auto_increment");
- retrieve("select distinct(TEXT_TOPIC), TEXT_F_SITE " +
- "from AV_TEXT where TEXT_TOPIC is not null");
- traverse(function() {
- execute("insert into tag set site_id = $0, name = $1, type = 'Story'",
- this.TEXT_F_SITE, this.TEXT_TOPIC.replace(/^[\/\.]*$/, "?"));
- });
+ retrieve("select distinct(TEXT_TOPIC), TEXT_F_SITE " +
+ "from AV_TEXT where TEXT_TOPIC is not null");
+ traverse(function() {
+ execute("insert into tag set site_id = $0, name = $1, type = 'Story'",
+ this.TEXT_F_SITE, this.TEXT_TOPIC.replace(/^[\/\.]*$/, "?"));
+ });
- var metadata = function(xml) {
- try {
- return Xml.readFromString(clean(xml));
- } catch (ex) {
- app.debug(ex);
- }
- return {};
- }
+ var metadata = function(xml) {
+ try {
+ return Xml.readFromString(clean(xml));
+ } catch (ex) {
+ app.debug(ex);
+ }
+ return {};
+ }
- retrieve("select * from AV_TEXT left join tag on TEXT_F_SITE = site_id " +
- "and TEXT_TOPIC = name and type = 'Story' where TEXT_ID > $min " +
- "and TEXT_ID <= $max order by TEXT_ID");
+ retrieve("select * from AV_TEXT left join tag on TEXT_F_SITE = site_id " +
+ "and TEXT_TOPIC = name and type = 'Story' where TEXT_ID > $min " +
+ "and TEXT_ID <= $max order by TEXT_ID");
- traverse(function() {
- if (this.TEXT_PROTOTYPE === "Comment") {
- if (!this.TEXT_F_TEXT_PARENT) {
- this.parent_type = "Story";
- this.TEXT_F_TEXT_PARENT = this.TEXT_F_TEXT_STORY;
- } else {
- this.parent_type = "Comment";
- }
- this.status = "public";
- this.mode = "hidden";
- this.comment_mode = "open";
+ traverse(function() {
+ if (this.TEXT_PROTOTYPE === "Comment") {
+ if (!this.TEXT_F_TEXT_PARENT) {
+ this.parent_type = "Story";
+ this.TEXT_F_TEXT_PARENT = this.TEXT_F_TEXT_STORY;
} else {
- this.TEXT_F_TEXT_STORY = this.TEXT_F_TEXT_PARENT = null;
- this.parent_type = null;
+ this.parent_type = "Comment";
+ }
+ this.status = "public";
+ this.mode = "hidden";
+ this.comment_mode = "open";
+ } else {
+ this.TEXT_F_TEXT_STORY = this.TEXT_F_TEXT_PARENT = null;
+ this.parent_type = null;
- this.status = "public";
- this.mode = "featured";
- if (this.TEXT_ISONLINE == 1) {
- this.mode = "hidden";
- } else if (this.TEXT_ISONLINE != 2) {
- this.status = "closed";
- }
-
- if (this.TEXT_EDITABLEBY == 1) {
- this.status = "shared";
- } else if (this.TEXT_EDITABLEBY == 2) {
- this.status = "open";
- }
- this.comment_mode = this.TEXT_HASDISCUSSIONS == 1 ? "open" : "closed";
+ this.status = "public";
+ this.mode = "featured";
+ if (this.TEXT_ISONLINE == 1) {
+ this.mode = "hidden";
+ } else if (this.TEXT_ISONLINE != 2) {
+ this.status = "closed";
}
- this.TEXT_F_USER_MODIFIER || (this.TEXT_F_USER_MODIFIER = null);
-
- this.name = this.ALIAS || "";
- this.metadata = metadata(this.TEXT_CONTENT);
- execute("insert into content values ($TEXT_ID, $name, " +
- "$TEXT_PROTOTYPE, $TEXT_F_SITE, $TEXT_F_TEXT_STORY, " +
- "$TEXT_F_TEXT_PARENT, $parent_type, $TEXT_READS, $status, " +
- "$mode, $comment_mode, $metadata, $TEXT_CREATETIME, " +
- "$TEXT_F_USER_CREATOR, $TEXT_MODIFYTIME, $TEXT_F_USER_MODIFIER)",
- this);
- if (this.TEXT_TOPIC) {
- execute("insert into tag_hub set tag_id = $0, tagged_id = $1, " +
- "tagged_type = 'Story', user_id = $2", this.id, this.TEXT_ID,
- this.TEXT_F_USER_MODIFIER || this.TEXT_F_USER_CREATOR);
+ if (this.TEXT_EDITABLEBY == 1) {
+ this.status = "shared";
+ } else if (this.TEXT_EDITABLEBY == 2) {
+ this.status = "open";
}
- //execute("delete from AV_TEXT where TEXT_ID = " + this.TEXT_ID);
- }, 5000);
+ this.comment_mode = this.TEXT_HASDISCUSSIONS == 1 ? "open" : "closed";
+ }
- execute("alter table tag change id id int(11)")
- execute("alter table tag_hub change id id int(11)");
+ this.TEXT_F_USER_MODIFIER || (this.TEXT_F_USER_MODIFIER = null);
+
+ this.name = this.ALIAS || "";
+ this.metadata = metadata(this.TEXT_CONTENT);
+ execute("insert into content values ($TEXT_ID, $name, " +
+ "$TEXT_PROTOTYPE, $TEXT_F_SITE, $TEXT_F_TEXT_STORY, " +
+ "$TEXT_F_TEXT_PARENT, $parent_type, $TEXT_READS, $status, " +
+ "$mode, $comment_mode, $metadata, $TEXT_CREATETIME, " +
+ "$TEXT_F_USER_CREATOR, $TEXT_MODIFYTIME, $TEXT_F_USER_MODIFIER)",
+ this);
+ if (this.TEXT_TOPIC) {
+ execute("insert into tag_hub set tag_id = $0, tagged_id = $1, " +
+ "tagged_type = 'Story', user_id = $2", this.id, this.TEXT_ID,
+ this.TEXT_F_USER_MODIFIER || this.TEXT_F_USER_CREATOR);
+ }
+ //execute("delete from AV_TEXT where TEXT_ID = " + this.TEXT_ID);
+ }, 5000);
+
+ execute("alter table tag change id id int(11)")
+ execute("alter table tag_hub change id id int(11)");
}
convert.users = function() {
- retrieve("select id, hash, salt, USER_URL from user");
- traverse(function() {
- var metadata = {
- hash: this.hash,
- salt: this.salt,
- url: this.USER_URL
- }
- execute("update user set metadata = " +
- quote(metadata.toSource()) + " where id = " + this.id);
- });
+ retrieve("select id, hash, salt, USER_URL from user");
+ traverse(function() {
+ var metadata = {
+ hash: this.hash,
+ salt: this.salt,
+ url: this.USER_URL
+ }
+ execute("update user set metadata = " +
+ quote(metadata.toSource()) + " where id = " + this.id);
+ });
}
convert.xml = function(table) {
- var metadata = function(xml) {
- try {
- return Xml.readFromString(clean(xml));
- } catch (ex) {
- app.debug(ex);
- }
- return {};
- };
- retrieve(query("jsonize", table));
- traverse(function() {
- var data = metadata(this.xml);
- execute("update " + table + " set metadata = " +
- quote(data.toSource()) + ", xml = '' where id = " + this.id);
- });
+ var metadata = function(xml) {
+ try {
+ return Xml.readFromString(clean(xml));
+ } catch (ex) {
+ app.debug(ex);
+ }
+ return {};
+ };
+ retrieve(query("jsonize", table));
+ traverse(function() {
+ var data = metadata(this.xml);
+ execute("update " + table + " set metadata = " +
+ quote(data.toSource()) + ", xml = '' where id = " + this.id);
+ });
}
convert.skins = function() {
- var styles = {
- "bgcolor": "background color",
- "linkcolor": "link color",
- "alinkcolor": "active link color",
- "vlinkcolor": "visited link color",
- "titlefont": "big font",
- "titlesize": "big font size",
- "titlecolor": "big font color",
- "textfont": "base font",
- "textsize": "base font size",
- "textcolor": "base font color",
- "smallfont": "small font",
- "smallsize": "small font size",
- "smallcolor": "small font color"
- }
+ var styles = {
+ "bgcolor": "background color",
+ "linkcolor": "link color",
+ "alinkcolor": "active link color",
+ "vlinkcolor": "visited link color",
+ "titlefont": "big font",
+ "titlesize": "big font size",
+ "titlecolor": "big font color",
+ "textfont": "base font",
+ "textsize": "base font size",
+ "textcolor": "base font color",
+ "smallfont": "small font",
+ "smallsize": "small font size",
+ "smallcolor": "small font color"
+ }
- var rename = function(prototype, skin) {
- var map = {
- Day: "Archive",
- LayoutImage: "Image",
- LayoutImageMgr: "Images",
- RootLayoutMgr: "Layouts", // FIXME: obsolete
- StoryMgr: "Stories",
- SysMgr: "Admin",
- SysLog: "LogEntry",
- Topic: "Tag",
- TopicMgr: "Tags",
+ var rename = function(prototype, skin) {
+ var map = {
+ Day: "Archive",
+ LayoutImage: "Image",
+ LayoutImageMgr: "Images",
+ RootLayoutMgr: "Layouts", // FIXME: obsolete
+ StoryMgr: "Stories",
+ SysMgr: "Admin",
+ SysLog: "LogEntry",
+ Topic: "Tag",
+ TopicMgr: "Tags",
- Comment: {
- toplevel: "main"
- },
+ Comment: {
+ toplevel: "main"
+ },
- Members: {
- statusloggedin: ["Membership", "status"],
- statusloggedout: ["Membership", "login"]
- },
+ Members: {
+ statusloggedin: ["Membership", "status"],
+ statusloggedout: ["Membership", "login"]
+ },
- Site: {
- searchbox: "search",
- style: "stylesheet"
- },
+ Site: {
+ searchbox: "search",
+ style: "stylesheet"
+ },
- Story: {
- dayheader: "date",
- display: "content",
- historyview: "history"
- }
+ Story: {
+ dayheader: "date",
+ display: "content",
+ historyview: "history"
}
+ }
- var renamed;
- if (renamed = map[prototype]) {
- if (renamed.constructor === String) {
- return rename(renamed, skin);
- } else if (skin) {
- renamed = renamed[skin];
- if (renamed) {
- if (renamed.constructor === Array) {
- prototype = renamed[0];
- skin = renamed[1];
- } else {
- skin = renamed;
- }
- }
- }
- } else if (prototype.lastIndexOf("Mgr") > 0) {
- prototype = prototype.substr(0, prototype.length - 3) + "s";
- return rename(prototype, skin);
+ var renamed;
+ if (renamed = map[prototype]) {
+ if (renamed.constructor === String) {
+ return rename(renamed, skin);
+ } else if (skin) {
+ renamed = renamed[skin];
+ if (renamed) {
+ if (renamed.constructor === Array) {
+ prototype = renamed[0];
+ skin = renamed[1];
+ } else {
+ skin = renamed;
+ }
+ }
}
- return [prototype, skin];
- }
+ } else if (prototype.lastIndexOf("Mgr") > 0) {
+ prototype = prototype.substr(0, prototype.length - 3) + "s";
+ return rename(prototype, skin);
+ }
+ return [prototype, skin];
+ }
- var values = function(metadata) {
- if (!metadata) {
- return;
- }
-
- var data = eval(metadata);
- res.push();
- for (var key in styles) {
- var name = styles[key];
- var value = String(data[key]).toLowerCase();
- if (key.endsWith("color") && !helma.Color.COLORNAMES[key] &&
- !value.startsWith("#")) {
- value = "#" + value;
- }
- value = value.replace(/([0-9]+) +px/, "$1px");
- res.writeln('<% value "' + name + '" "' + value + '" %>');
- }
- return res.pop();
- }
-
- var clean = function(source) {
- if (source) {
- // Renaming prototype and skin names in skin macros
- var re = /(<%\s*)([^.]+)(\.skin\s+name="?)([^"\s]+)/g;
- source = source.replace(re, function() {
- var $ = arguments;
- var renamed = rename($[2].capitalize(), $[4]);
- return $[1] + renamed[0].toLowerCase() + $[3] +
- renamed[0] + "#" + renamed[1];
- });
- // Replacing layout.* macros with corresponding value macros
- source = source.replace(/(<%\s*)layout\.([^\s]+)/g, function() {
- var value = styles[arguments[2]];
- if (value) {
- return arguments[1] + "value " + quote(value);
- }
- return arguments[0];
- });
- return source;
- }
- }
-
- var move = function(sourcePath, destPath) {
- var source = new helma.File(sourcePath);
- if (source.exists()) {
- var destination = new helma.File(destPath);
- if (destination.exists()) {
- destination.removeDirectory();
- }
- destination.makeDirectory();
- var files = source.list();
- for each (var fname in files) {
- (new helma.File(source, fname)).hardCopy(new helma.File(destination, fname));
- }
- }
- return destPath;
- }
-
- var save = function(skins, fpath) {
- if (!skins) {
- return;
- }
-
- for (var prototype in skins) {
- res.push();
- var skinset = skins[prototype];
- for (var skinName in skinset) {
- res.writeln("<% #" + skinName + " %>");
- skinset[skinName] && res.writeln(skinset[skinName].trim());
- }
- var data = res.pop();
-
- if (data) {
- var dir = new java.io.File(fpath, prototype);
- dir.exists() || dir.mkdirs();
- var file = new java.io.File(dir, prototype + ".skin");
- file.exists() && file["delete"]();
- log("Write " + prototype + ".skin" + " to " + file.getCanonicalPath());
- var fos = new java.io.FileOutputStream(file);
- var bos = new java.io.BufferedOutputStream(fos);
- var writer = new java.io.OutputStreamWriter(bos, "UTF-8");
- writer.write(data);
- writer.close();
- bos.close();
- fos.close();
- }
- }
+ var values = function(metadata) {
+ if (!metadata) {
return;
- }
+ }
- var appSkins = {};
- var skinfiles = antville().getSkinfiles();
-
- for (var prototype in skinfiles) {
- // Ignore lowercase prototypes
- if (prototype.charCodeAt(0) > 90) {
- continue;
+ var data = eval(metadata);
+ res.push();
+ for (var key in styles) {
+ var name = styles[key];
+ var value = String(data[key]).toLowerCase();
+ if (key.endsWith("color") && !helma.Color.COLORNAMES[key] &&
+ !value.startsWith("#")) {
+ value = "#" + value;
}
- appSkins[prototype] || (appSkins[prototype] = {});
- var skin = createSkin(skinfiles[prototype][prototype]);
- var subskins = skin.getSubskinNames();
- for each (var name in subskins) {
- appSkins[prototype][name] = skin.getSubskin(name).getSource();
- }
- }
+ value = value.replace(/([0-9]+) +px/, "$1px");
+ res.writeln('<% value "' + name + '" "' + value + '" %>');
+ }
+ return res.pop();
+ }
- var current, fpath, skins;
- retrieve(query("skins"));
- traverse(function() {
- var site = this.site_name || "";
- if (current !== site + this.layout_name) {
- save(skins, fpath);
- current = site + this.layout_name;
- fpath = antville().properties.staticPath + site;
- if (!site) {
- return; // FIXME: root layouts not ready, yet
- var file = new helma.File("db/antville/0.xml");
- var xml = file.readAll();
- var rootLayoutId = /sys_layout idref="(\d)*"/.exec(xml)[1] || 1;
- fpath += rootLayoutId == this.layout_id ?
- "/layout/" : "/layouts/" + this.layout_name;
- } else {
- fpath += "/layouts/" + this.layout_name;
- }
- skins = appSkins.clone({}, true);
- skins.Site.values = values(this.layout_metadata);
- }
+ var clean = function(source) {
+ if (source) {
+ // Renaming prototype and skin names in skin macros
+ var re = /(<%\s*)([^.]+)(\.skin\s+name="?)([^"\s]+)/g;
+ source = source.replace(re, function() {
+ var $ = arguments;
+ var renamed = rename($[2].capitalize(), $[4]);
+ return $[1] + renamed[0].toLowerCase() + $[3] +
+ renamed[0] + "#" + renamed[1];
+ });
+ // Replacing layout.* macros with corresponding value macros
+ source = source.replace(/(<%\s*)layout\.([^\s]+)/g, function() {
+ var value = styles[arguments[2]];
+ if (value) {
+ return arguments[1] + "value " + quote(value);
+ }
+ return arguments[0];
+ });
+ return source;
+ }
+ }
- if (!this.prototype || !this.name) {
- return;
+ var move = function(sourcePath, destPath) {
+ var source = new helma.File(sourcePath);
+ if (source.exists()) {
+ var destination = new helma.File(destPath);
+ if (destination.exists()) {
+ destination.removeDirectory();
}
+ destination.makeDirectory();
+ var files = source.list();
+ for each (var fname in files) {
+ (new helma.File(source, fname)).hardCopy(new helma.File(destination, fname));
+ }
+ }
+ return destPath;
+ }
- var renamed = rename(this.prototype, this.name);
- var prototype = renamed[0];
- var skinName = renamed[1];
- var source, parent;
- var appSkin = (skins[prototype] && skins[prototype][skinName]);
- if (this.source !== null) {
- source = this.source;
- parent = this.parent !== null ? this.parent : appSkin;
+ var save = function(skins, fpath) {
+ if (!skins) {
+ return;
+ }
+
+ for (var prototype in skins) {
+ res.push();
+ var skinset = skins[prototype];
+ for (var skinName in skinset) {
+ res.writeln("<% #" + skinName + " %>");
+ skinset[skinName] && res.writeln(skinset[skinName].trim());
+ }
+ var data = res.pop();
+
+ if (data) {
+ var dir = new java.io.File(fpath, prototype);
+ dir.exists() || dir.mkdirs();
+ var file = new java.io.File(dir, prototype + ".skin");
+ file.exists() && file["delete"]();
+ log("Write " + prototype + ".skin" + " to " + file.getCanonicalPath());
+ var fos = new java.io.FileOutputStream(file);
+ var bos = new java.io.BufferedOutputStream(fos);
+ var writer = new java.io.OutputStreamWriter(bos, "UTF-8");
+ writer.write(data);
+ writer.close();
+ bos.close();
+ fos.close();
+ }
+ }
+ return;
+ }
+
+ var appSkins = {};
+ var skinfiles = antville().getSkinfiles();
+
+ for (var prototype in skinfiles) {
+ // Ignore lowercase prototypes
+ if (prototype.charCodeAt(0) > 90) {
+ continue;
+ }
+ appSkins[prototype] || (appSkins[prototype] = {});
+ var skin = createSkin(skinfiles[prototype][prototype]);
+ var subskins = skin.getSubskinNames();
+ for each (var name in subskins) {
+ appSkins[prototype][name] = skin.getSubskin(name).getSource();
+ }
+ }
+
+ var current, fpath, skins;
+ retrieve(query("skins"));
+ traverse(function() {
+ var site = this.site_name || "";
+ if (current !== site + this.layout_name) {
+ save(skins, fpath);
+ current = site + this.layout_name;
+ fpath = antville().properties.staticPath + site;
+ if (!site) {
+ return; // FIXME: root layouts not ready, yet
+ var file = new helma.File("db/antville/0.xml");
+ var xml = file.readAll();
+ var rootLayoutId = /sys_layout idref="(\d)*"/.exec(xml)[1] || 1;
+ fpath += rootLayoutId == this.layout_id ?
+ "/layout/" : "/layouts/" + this.layout_name;
} else {
- source = this.parent;
- parent = appSkin;
+ fpath += "/layouts/" + this.layout_name;
}
- if (source !== null && source !== undefined) {
- // FIXME: Ugly hack to change Membership to Members in a few skins
- if (prototype === "Membership" &&
- (skinName === "login" || skinName === "status")) {
- source = source.replace(/(<%\s*)this./g, "$1members.");
- }
- // Adding the new calendar CSS classes to the old ones
- if (prototype === "Site" && skinName === "stylesheet") {
- source = source.replace(/(\.calHead)/g,
- "table.calendar thead, $1");
- source = source.replace(/(\.calDay)/g,
- "table.calendar th, table.calendar tbody td.day, $1");
- source = source.replace(/(\.calSelDay)/g,
- "table.calendar tbody td.selected, $1");
- source = source.replace(/(\.calFoot)/g,
- "table.calendar tfoot td, $1");
- }
- ref = (skins[prototype] || (skins[prototype] = {}));
- ref[skinName] = clean(source);
+ skins = appSkins.clone({}, true);
+ skins.Site.values = values(this.layout_metadata);
+ }
+
+ if (!this.prototype || !this.name) {
+ return;
+ }
+
+ var renamed = rename(this.prototype, this.name);
+ var prototype = renamed[0];
+ var skinName = renamed[1];
+ var source, parent;
+ var appSkin = (skins[prototype] && skins[prototype][skinName]);
+ if (this.source !== null) {
+ source = this.source;
+ parent = this.parent !== null ? this.parent : appSkin;
+ } else {
+ source = this.parent;
+ parent = appSkin;
+ }
+ if (source !== null && source !== undefined) {
+ // FIXME: Ugly hack to change Membership to Members in a few skins
+ if (prototype === "Membership" &&
+ (skinName === "login" || skinName === "status")) {
+ source = source.replace(/(<%\s*)this./g, "$1members.");
}
- if (parent !== null && parent !== undefined) {
- execute("update skin set source = '" +
- clean(parent).replace(/'/g, "\\'") + "' where " +
- 'id = ' + this.id);
+ // Adding the new calendar CSS classes to the old ones
+ if (prototype === "Site" && skinName === "stylesheet") {
+ source = source.replace(/(\.calHead)/g,
+ "table.calendar thead, $1");
+ source = source.replace(/(\.calDay)/g,
+ "table.calendar th, table.calendar tbody td.day, $1");
+ source = source.replace(/(\.calSelDay)/g,
+ "table.calendar tbody td.selected, $1");
+ source = source.replace(/(\.calFoot)/g,
+ "table.calendar tfoot td, $1");
}
- });
- // One last time to be sure every layout's skins are saved
- save(skins, fpath);
- return;
+ ref = (skins[prototype] || (skins[prototype] = {}));
+ ref[skinName] = clean(source);
+ }
+ if (parent !== null && parent !== undefined) {
+ execute("update skin set source = '" +
+ clean(parent).replace(/'/g, "\\'") + "' where " +
+ 'id = ' + this.id);
+ }
+ });
+ // One last time to be sure every layout's skins are saved
+ save(skins, fpath);
+ return;
}
convert.folders = function() {
- retrieve("select site.name as site_name, layout.name as layout_name from " +
- "site left join layout on site.layout_id = layout.id");
- traverse(function() {
- var dir = antville().properties.staticPath + this.site_name;
- var source = new helma.File(dir, "layouts/" + this.layout_name);
- var dest = new helma.File(dir, "layout");
- log("Copy " + source + " to " + dest);
- if (dest.exists()) {
- dest.removeDirectory();
- }
- source.renameTo(dest);
- });
+ retrieve("select site.name as site_name, layout.name as layout_name from " +
+ "site left join layout on site.layout_id = layout.id");
+ traverse(function() {
+ var dir = antville().properties.staticPath + this.site_name;
+ var source = new helma.File(dir, "layouts/" + this.layout_name);
+ var dest = new helma.File(dir, "layout");
+ log("Copy " + source + " to " + dest);
+ if (dest.exists()) {
+ dest.removeDirectory();
+ }
+ source.renameTo(dest);
+ });
}
convert.root = function() {
- var rootId = antville().__app__.getProperty("rootId");
- var staticDir = antville().properties.staticPath;
- retrieve("select name from site where id = " + rootId);
- traverse(function() {
- if (this.name === "www") {
- return;
- }
- var dir = new helma.File(staticDir, this.name);
- var files = dir.list();
- for each (fname in files) {
- var source = new helma.File(dir, fname);
- var dest = new helma.File(staticDir, "www/" + fname);
- log("Rename " + source + " to " + dest);
- source.renameTo(dest);
- }
+ var rootId = antville().__app__.getProperty("rootId");
+ var staticDir = antville().properties.staticPath;
+ retrieve("select name from site where id = " + rootId);
+ traverse(function() {
+ if (this.name === "www") {
return;
- });
- execute("update site set name = 'www' where id = " + rootId);
- return;
+ }
+ var dir = new helma.File(staticDir, this.name);
+ var files = dir.list();
+ for each (fname in files) {
+ var source = new helma.File(dir, fname);
+ var dest = new helma.File(staticDir, "www/" + fname);
+ log("Rename " + source + " to " + dest);
+ source.renameTo(dest);
+ }
+ return;
+ });
+ execute("update site set name = 'www' where id = " + rootId);
+ return;
}
diff --git a/extra/updater/Root/Root.js b/extra/updater/Root/Root.js
index a5696f40..dd0b19be 100644
--- a/extra/updater/Root/Root.js
+++ b/extra/updater/Root/Root.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -30,86 +30,86 @@ app.addRepository("modules/helma/Color.js");
app.addRepository("modules/helma/File.js");
Root.prototype.updater_action = function() {
- // Disabled for safety reasons
- return;
+ // Disabled for safety reasons
+ return;
- app.invokeAsync(global, function() {
- if (init()) {
- //update("size"); // DEBUG
- //update("legacy");
- update("tag");
- update("tag_hub");
- update("AV_ACCESSLOG");
- update("AV_CHOICE");
- update("AV_FILE");
- update("AV_IMAGE");
- update("AV_LAYOUT");
- update("AV_MEMBERSHIP");
- update("AV_POLL");
- update("AV_SITE");
- update("AV_SKIN");
- update("AV_TEXT");
- update("AV_USER");
- update("AV_VOTE");
- update("AV_SYSLOG"); // This table has to go last!
- convert("folders");
- convert("root");
- finalize();
- }
- return;
- }, [], -1);
- this.renderSkin("~Root");
- return;
+ app.invokeAsync(global, function() {
+ if (init()) {
+ //update("size"); // DEBUG
+ //update("legacy");
+ update("tag");
+ update("tag_hub");
+ update("AV_ACCESSLOG");
+ update("AV_CHOICE");
+ update("AV_FILE");
+ update("AV_IMAGE");
+ update("AV_LAYOUT");
+ update("AV_MEMBERSHIP");
+ update("AV_POLL");
+ update("AV_SITE");
+ update("AV_SKIN");
+ update("AV_TEXT");
+ update("AV_USER");
+ update("AV_VOTE");
+ update("AV_SYSLOG"); // This table has to go last!
+ convert("folders");
+ convert("root");
+ finalize();
+ }
+ return;
+ }, [], -1);
+ this.renderSkin("~Root");
+ return;
}
Root.prototype.out_action = function() {
- res.contentType = "text/plain";
- return out();
+ res.contentType = "text/plain";
+ return out();
}
Root.prototype.nonames_action = function() {
- app.invokeAsync(global, function() {
- ["image", "file"].forEach(function(table) {
- retrieve("select * from " + table + " where name = ''");
- traverse(function() {
- this.name = Date.now() + "-" + this.id;
- var metadata = eval(this.metadata);
- var extension = metadata.contentType.split("/").pop();
- metadata.fileName = this.name + "." + extension;
- metadata.thumbnailName = this.name + "_small." + extension;
- this.metadata = metadata;
- execute("update " + table + " set name = $name, metadata = " +
- "$metadata where id = $id", this);
- });
+ app.invokeAsync(global, function() {
+ ["image", "file"].forEach(function(table) {
+ retrieve("select * from " + table + " where name = ''");
+ traverse(function() {
+ this.name = Date.now() + "-" + this.id;
+ var metadata = eval(this.metadata);
+ var extension = metadata.contentType.split("/").pop();
+ metadata.fileName = this.name + "." + extension;
+ metadata.thumbnailName = this.name + "_small." + extension;
+ this.metadata = metadata;
+ execute("update " + table + " set name = $name, metadata = " +
+ "$metadata where id = $id", this);
});
- status("finished");
- }, [], -1);
- this.renderSkin("~Root");
- return;
+ });
+ status("finished");
+ }, [], -1);
+ this.renderSkin("~Root");
+ return;
}
Root.prototype.galleries_action = function() {
- var oldDatabase = "antville_1_1";
- app.invokeAsync(global, function() {
- execute("alter table tag_hub add column `tagged_id_old` int(11) default NULL");
- execute("alter table tag_hub add column `tagged_type_old` enum('Story','Image') default NULL");
- execute("update tag_hub set tagged_type_old = tagged_type, tagged_id_old = tagged_id;");
- retrieve(stringf("select tag_hub.*, IMAGE_ALIAS as name, " +
- "IMAGE_F_SITE as site from tag_hub left join $0.AV_IMAGE on " +
- "IMAGE_ID = tagged_id where tagged_id in " +
- "(select IMAGE_ID from $0.AV_IMAGE where IMAGE_TOPIC is not " +
- "null and IMAGE_F_IMAGE_PARENT is null)", oldDatabase));
- traverse(function() {
- execute("update tag_hub set tagged_type = 'Image', tagged_id = " +
- "(select id from image where name = $name and site_id = " +
- "$site and parent_type = 'Site') where id = $id", this);
- });
- status("finished");
- }, [], -1);
- this.renderSkin("~Root");
- return;
+ var oldDatabase = "antville_1_1";
+ app.invokeAsync(global, function() {
+ execute("alter table tag_hub add column `tagged_id_old` int(11) default NULL");
+ execute("alter table tag_hub add column `tagged_type_old` enum('Story','Image') default NULL");
+ execute("update tag_hub set tagged_type_old = tagged_type, tagged_id_old = tagged_id;");
+ retrieve(stringf("select tag_hub.*, IMAGE_ALIAS as name, " +
+ "IMAGE_F_SITE as site from tag_hub left join $0.AV_IMAGE on " +
+ "IMAGE_ID = tagged_id where tagged_id in " +
+ "(select IMAGE_ID from $0.AV_IMAGE where IMAGE_TOPIC is not " +
+ "null and IMAGE_F_IMAGE_PARENT is null)", oldDatabase));
+ traverse(function() {
+ execute("update tag_hub set tagged_type = 'Image', tagged_id = " +
+ "(select id from image where name = $name and site_id = " +
+ "$site and parent_type = 'Site') where id = $id", this);
+ });
+ status("finished");
+ }, [], -1);
+ this.renderSkin("~Root");
+ return;
}
Root.prototype.patch = function(code) {
- eval(code);
+ eval(code);
}
diff --git a/extra/updater/patch-20080913.js b/extra/updater/patch-20080913.js
index bdfa75a1..1abc7b62 100644
--- a/extra/updater/patch-20080913.js
+++ b/extra/updater/patch-20080913.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -26,48 +26,48 @@
// Apply with enabled updater repository via ant patch -Dpatch.id=20080913
root.forEach(function() {
- var site = this;
- if (site.layout) {
- res.handlers.layout = site.layout;
- res.skinpath = site.layout.getSkinPath();
+ var site = this;
+ if (site.layout) {
+ res.handlers.layout = site.layout;
+ res.skinpath = site.layout.getSkinPath();
- // Fixing the corrupted <% site#history" %> macros
- var skin = site.layout.skins.getSkin("Site", "page");
+ // Fixing the corrupted <% site#history" %> macros
+ var skin = site.layout.skins.getSkin("Site", "page");
+ var source = skin.getSource();
+
+ var newSource = source.replace(/<%(\s+site#(history|searchbox)"[^%]*%>)/g, function() {
+ var replacement = "<% // " + arguments[1];
+ app.log(arguments[0] + " ==> " + replacement);
+ return replacement;
+ });
+ if (newSource !== source) {
+ var delta = source.length - newSource.length;
+ //if (Math.abs(delta) > 5) res.debug("!!! Delta in " + site + ": " + delta);
+ skin.setSource(newSource);
+ }
+
+ // Fixing the macro handlers in skins shared between Story and Comment
+ ["history", "rss", "result"].forEach(function(name) {
+ var skin = site.layout.skins.getSkin("Story", name);
var source = skin.getSource();
-
- var newSource = source.replace(/<%(\s+site#(history|searchbox)"[^%]*%>)/g, function() {
- var replacement = "<% // " + arguments[1];
- app.log(arguments[0] + " ==> " + replacement);
- return replacement;
- });
- if (newSource !== source) {
- var delta = source.length - newSource.length;
- //if (Math.abs(delta) > 5) res.debug("!!! Delta in " + site + ": " + delta);
- skin.setSource(newSource);
+ if (!source) {
+ // FIXME: What the heck is going on here?
+ app.log("????? " + site.name + ": " + skin);
+ return;
}
-
- // Fixing the macro handlers in skins shared between Story and Comment
- ["history", "rss", "result"].forEach(function(name) {
- var skin = site.layout.skins.getSkin("Story", name);
- var source = skin.getSource();
- if (!source) {
- // FIXME: What the heck is going on here?
- app.log("????? " + site.name + ": " + skin);
- return;
- }
- var newSource = source.replace(/(<%\s+)story\./g, function() {
- var replacement = arguments[1] + "this.";
- app.log(arguments[0] + " ==> " + replacement);
- return replacement;
- });
- var delta = source.length - newSource.length;
- if (delta !== 0) {
- //if (Math.abs(delta) > 5) app.log("!!! Delta in " + site + " skin Story:" + name + ": " + delta);
- skin.setSource(newSource);
- }
+ var newSource = source.replace(/(<%\s+)story\./g, function() {
+ var replacement = arguments[1] + "this.";
+ app.log(arguments[0] + " ==> " + replacement);
+ return replacement;
});
+ var delta = source.length - newSource.length;
+ if (delta !== 0) {
+ //if (Math.abs(delta) > 5) app.log("!!! Delta in " + site + " skin Story:" + name + ": " + delta);
+ skin.setSource(newSource);
+ }
+ });
} else {
- app.log("Creating missing layout for site " + site.name);
- site.layout = new Layout(site);
- }
+ app.log("Creating missing layout for site " + site.name);
+ site.layout = new Layout(site);
+ }
});
diff --git a/extra/updater/patch-20081211.js b/extra/updater/patch-20081211.js
index 3cf5d2e4..2fb6f859 100644
--- a/extra/updater/patch-20081211.js
+++ b/extra/updater/patch-20081211.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -26,22 +26,22 @@
// Apply with enabled updater repository via ant patch -Dpatch.id=20081211
root.forEach(function() {
- var site = this;
- if (site.layout) {
- res.handlers.layout = site.layout;
- res.skinpath = site.layout.getSkinPath();
+ var site = this;
+ if (site.layout) {
+ res.handlers.layout = site.layout;
+ res.skinpath = site.layout.getSkinPath();
- // Fixing the <% if <% comment.created %> %> macro
- var skin = site.layout.skins.getSkin("Comment", "edit");
- var source = skin.getSource();
- var re = /(<%\s+if\s+<%\s+comment\.creat)ed(\s+%>\s+is\s+null)/g;
- var newSource = source.replace(re, function() {
- var replacement = arguments[1] + "or" + arguments[2];
- app.log(arguments[0] + " ==> " + replacement);
- return replacement;
- });
- if (newSource !== source) {
- skin.setSource(newSource);
- }
- }
+ // Fixing the <% if <% comment.created %> %> macro
+ var skin = site.layout.skins.getSkin("Comment", "edit");
+ var source = skin.getSource();
+ var re = /(<%\s+if\s+<%\s+comment\.creat)ed(\s+%>\s+is\s+null)/g;
+ var newSource = source.replace(re, function() {
+ var replacement = arguments[1] + "or" + arguments[2];
+ app.log(arguments[0] + " ==> " + replacement);
+ return replacement;
+ });
+ if (newSource !== source) {
+ skin.setSource(newSource);
+ }
+ }
});
diff --git a/extra/updater/patch-20091207.js b/extra/updater/patch-20091207.js
index 9090b9c8..16419a25 100644
--- a/extra/updater/patch-20091207.js
+++ b/extra/updater/patch-20091207.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -30,8 +30,8 @@ var template;
// Add deleted mode to site table
sql.execute("alter table antville.site change column mode mode \
- enum('deleted','closed','restricted','public','open') \
- character set latin1 collate latin1_general_ci default 'closed'");
+ enum('deleted','closed','restricted','public','open') \
+ character set latin1 collate latin1_general_ci default 'closed'");
// Rename user table to conform to standard SQL / Postgre specification
sql.execute("alter table antville.user rename to account");
diff --git a/extra/updater/patch-20100401.js b/extra/updater/patch-20100401.js
index 9a807b20..b78e6a91 100644
--- a/extra/updater/patch-20100401.js
+++ b/extra/updater/patch-20100401.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -30,15 +30,15 @@ var sql = new Sql;
// Correct Image.contentLength property for some images
sql.retrieve("select id from image");
sql.traverse(function() {
- var image = Image.getById(this.id);
- try {
- var contentLength = image.getFile().getLength();
- app.log("Processing " + image + ": " + image.contentLength);
- if (contentLength && image.contentLength !== contentLength) {
- app.log("Updating content length to " + contentLength);
- image.contentLength = contentLength;
- res.commit();
- }
- } catch (x) { }
+ var image = Image.getById(this.id);
+ try {
+ var contentLength = image.getFile().getLength();
+ app.log("Processing " + image + ": " + image.contentLength);
+ if (contentLength && image.contentLength !== contentLength) {
+ app.log("Updating content length to " + contentLength);
+ image.contentLength = contentLength;
+ res.commit();
+ }
+ } catch (x) { }
});
app.log("Done.");
diff --git a/extra/updater/patch-20100405.js b/extra/updater/patch-20100405.js
index 491f393a..f71c242a 100644
--- a/extra/updater/patch-20100405.js
+++ b/extra/updater/patch-20100405.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -34,25 +34,25 @@ var template;
// Afterwards user permissions should be restored:
// mysql -e "grant select, insert, update, delete on antville.* to 'antville'@'localhost'"
if (app.getDbSource("antville").isMySQL()) {
- template = "alter table $0 modify column $1 varchar(20) default null";
- sql.execute(template, "account", "status");
- sql.execute(template, "content", "comment_mode");
- sql.execute(template, "content", "mode");
- sql.execute(template, "content", "parent_type");
- sql.execute(template, "content", "prototype");
- sql.execute(template, "content", "status");
- sql.execute(template, "file", "prototype");
- sql.execute(template, "file", "parent_type");
- sql.execute(template, "image", "prototype");
- sql.execute(template, "image", "parent_type");
- sql.execute(template, "layout", "mode");
- sql.execute(template, "log", "context_type");
- sql.execute(template, "membership", "role");
- sql.execute(template, "poll", "status");
- sql.execute(template, "site", "status");
- sql.execute(template, "site", "mode");
- sql.execute(template, "tag", "type");
- sql.execute(template, "tag_hub", "tagged_type");
+ template = "alter table $0 modify column $1 varchar(20) default null";
+ sql.execute(template, "account", "status");
+ sql.execute(template, "content", "comment_mode");
+ sql.execute(template, "content", "mode");
+ sql.execute(template, "content", "parent_type");
+ sql.execute(template, "content", "prototype");
+ sql.execute(template, "content", "status");
+ sql.execute(template, "file", "prototype");
+ sql.execute(template, "file", "parent_type");
+ sql.execute(template, "image", "prototype");
+ sql.execute(template, "image", "parent_type");
+ sql.execute(template, "layout", "mode");
+ sql.execute(template, "log", "context_type");
+ sql.execute(template, "membership", "role");
+ sql.execute(template, "poll", "status");
+ sql.execute(template, "site", "status");
+ sql.execute(template, "site", "mode");
+ sql.execute(template, "tag", "type");
+ sql.execute(template, "tag_hub", "tagged_type");
}
// Convert membership roles to lowercase
@@ -64,7 +64,7 @@ sql.execute(template, 'owner', 'Owner');
// Convert notification modes to lowercase
root.forEach(function() {
- if (this.notificationMode !== null) {
- this.notificationMode = this.notificationMode.toLowerCase()
- }
+ if (this.notificationMode !== null) {
+ this.notificationMode = this.notificationMode.toLowerCase()
+ }
});
diff --git a/extra/updater/patch-20101209.js b/extra/updater/patch-20101209.js
index 2cacc474..8cce5606 100644
--- a/extra/updater/patch-20101209.js
+++ b/extra/updater/patch-20101209.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -26,20 +26,20 @@
// Apply with enabled updater repository via ant patch -Dpatch.id=20101209
root.forEach(function() {
- var site = this;
- var locale = site.locale;
- // Update locales to new format
- if (locale.contains("_")) {
- site.locale = locale.substr(0, locale.lastIndexOf("_"));
- }
- // Update time zones to new format
- var timeZone = site.timeZone;
- switch (timeZone) {
- case "CET":
- site.timeZone = "Europe/Vienna";
- break;
- case "GMT":
- site.timeZone = "Europe/London";
- break;
- }
+ var site = this;
+ var locale = site.locale;
+ // Update locales to new format
+ if (locale.contains("_")) {
+ site.locale = locale.substr(0, locale.lastIndexOf("_"));
+ }
+ // Update time zones to new format
+ var timeZone = site.timeZone;
+ switch (timeZone) {
+ case "CET":
+ site.timeZone = "Europe/Vienna";
+ break;
+ case "GMT":
+ site.timeZone = "Europe/London";
+ break;
+ }
});
diff --git a/extra/updater/patch-20110209.js b/extra/updater/patch-20110209.js
index 7b289fd5..77e337ed 100644
--- a/extra/updater/patch-20110209.js
+++ b/extra/updater/patch-20110209.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -26,7 +26,7 @@
// Apply with enabled updater repository via ant patch -Dpatch.id=20110209
if (!String(Root.VERSION).startsWith("1.2")) {
- throw Error("This patch needs to be applied to version 1.2 of the Antville codebase.");
+ throw Error("This patch needs to be applied to version 1.2 of the Antville codebase.");
}
app.addRepository("modules/helma/Database.js");
diff --git a/extra/updater/patch-20110210.js b/extra/updater/patch-20110210.js
index 28aee0be..45d2d028 100644
--- a/extra/updater/patch-20110210.js
+++ b/extra/updater/patch-20110210.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -26,7 +26,7 @@
// Apply with enabled updater repository via ant patch -Dpatch.id=20110210
if (Root.VERSION.minor < 1.3) {
- throw Error("Please update the Antville codebase to version 1.3 first.");
+ throw Error("Please update the Antville codebase to version 1.3 first.");
}
app.addRepository("modules/helma/Database.js");
@@ -34,40 +34,40 @@ app.addRepository("modules/helma/Database.js");
var sql = new Sql;
function convertMetadata(prototype, table) {
- table || (table = prototype.name.toLowerCase());
+ table || (table = prototype.name.toLowerCase());
- var start = 0;
- var max, end;
+ var start = 0;
+ var max, end;
- sql.retrieve("select max(id) as count from $0", table);
- sql.traverse(function() {
- max = this.count;
- });
+ sql.retrieve("select max(id) as count from $0", table);
+ sql.traverse(function() {
+ max = this.count;
+ });
- while (start < max) {
- end = start + 1000;
- sql.retrieve("select id, metadata from $0 where id >= $1 and id < $2", table, start, end);
- sql.traverse(function() {
- try {
- var newMetadata;
- var parent = prototype.getById(this.id);
- var metadata = eval(this.metadata);
- for (let name in metadata) {
- let value = metadata[name];
- parent.setMetadata(name, value);
- }
- } catch (ex) {
- app.log("***** Original or converted metadata might not be kosher for " +
- prototype.name + " #" + this.id);
- app.log(ex.rhinoException);
- }
- });
- res.commit();
- start = end;
- app.log(java.lang.String.format("Processed %.0f of %.0f %s objects", start, max, prototype.name));
- }
+ while (start < max) {
+ end = start + 1000;
+ sql.retrieve("select id, metadata from $0 where id >= $1 and id < $2", table, start, end);
+ sql.traverse(function() {
+ try {
+ var newMetadata;
+ var parent = prototype.getById(this.id);
+ var metadata = eval(this.metadata);
+ for (let name in metadata) {
+ let value = metadata[name];
+ parent.setMetadata(name, value);
+ }
+ } catch (ex) {
+ app.log("***** Original or converted metadata might not be kosher for " +
+ prototype.name + " #" + this.id);
+ app.log(ex.rhinoException);
+ }
+ });
+ res.commit();
+ start = end;
+ app.log(java.lang.String.format("Processed %.0f of %.0f %s objects", start, max, prototype.name));
+ }
- return;
+ return;
}
convertMetadata(File);
diff --git a/extra/updater/patch-20110301.js b/extra/updater/patch-20110301.js
index ff08b7a6..3c749c46 100644
--- a/extra/updater/patch-20110301.js
+++ b/extra/updater/patch-20110301.js
@@ -10,7 +10,7 @@
// 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
+// 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,
@@ -28,9 +28,9 @@
var sql = new Sql();
var sql2 = new Sql();
for each (let table in ["file", "image", "tag"]) {
- sql.retrieve("select * from $0 where name like '%?%';", table);
- sql.traverse(function() {
- var name = "-".repeat(this.name.count("?"));
- sql2.execute("update $0 set name = '$1' where id = $2", table, name, this.id);
- });
+ sql.retrieve("select * from $0 where name like '%?%';", table);
+ sql.traverse(function() {
+ var name = "-".repeat(this.name.count("?"));
+ sql2.execute("update $0 set name = '$1' where id = $2", table, name, this.id);
+ });
}
diff --git a/extra/updater/patch-20110606.js b/extra/updater/patch-20110606.js
index 645d04fa..3d6f695e 100644
--- a/extra/updater/patch-20110606.js
+++ b/extra/updater/patch-20110606.js
@@ -10,7 +10,7 @@
// 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
+// 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,
diff --git a/static/www/antville.js b/static/www/antville.js
index b72c16bc..c97c097b 100644
--- a/static/www/antville.js
+++ b/static/www/antville.js
@@ -1,82 +1,82 @@
$(function() {
-
- setLayoutMode();
- // Extend jQuery with selectText() method.
- $.fn.selectText = function() {
- var element = this.get(0);
- if (document.body.createTextRange) { // ms
- var range = document.body.createTextRange();
- range.moveToElementText(element);
- range.select();
- } else if (window.getSelection) { // moz, opera, webkit
- var selection = window.getSelection();
- var range = document.createRange();
- range.selectNodeContents(element);
- selection.removeAllRanges();
- selection.addRange(range);
- }
- }
-
- // Go back one step in history when clicking on links with the cancel class.
- $("a.cancel").click(function(event) {
- event.preventDefault();
- history.back();
- });
+ setLayoutMode();
- // Select the macro code when clicking on elements with the macro-code class.
- $('.macro-code').click(function(event) {
- $(this).selectText();
- });
+ // Extend jQuery with selectText() method.
+ $.fn.selectText = function() {
+ var element = this.get(0);
+ if (document.body.createTextRange) { // ms
+ var range = document.body.createTextRange();
+ range.moveToElementText(element);
+ range.select();
+ } else if (window.getSelection) { // moz, opera, webkit
+ var selection = window.getSelection();
+ var range = document.createRange();
+ range.selectNodeContents(element);
+ selection.removeAllRanges();
+ selection.addRange(range);
+ }
+ }
- // Group related