* Fixed reference to parent site in Archive

* Fixed _children.filter in Archive
 * Added missing permission checks
 * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument
 * Added HopObject.macro_macro() method to display userland macro code
 * Removed colorpicker (will be replaced by third-party library)
 * Removed obsolete global constants and functions
 * Overhauled and tested global userland macros like story_macro(), image_macro() etc.
 * Implemented global list_macro() to replace any special listFoobar_macro() methods
 * Moved global autoLogin() method into User prototype
 * Overhauled global randomize_macro()
 * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail()
 * Re-added accidentally removed subskins to Members.skin
 * Fixed some skin names which were changed recently
 * Remove delete_action() from Membership
 * Fixed foreign key of images collection in Membership
 * Removed global username_macro() and replaced it with appropriate membership macros
 * Moved contents of systemscripts.skin into javascript.skin in Root prototype
 * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root
 * Added accessname to sites collection in Root
 * Upgraded jQuery to version 1.2.1
 * Replaced call for global history_macro() with corresponding list_macro() call
 * Renamed "public" collection of Stories prototype to "featured"
 * Moved a lot of styles from Root's style.skin to the one in Site
 * Added comments collection to Site
 * Moved embed.skin as subskin #embed into Site.skin
 * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode)
 * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie
 * Moved a lot of code into compatibility module
This commit is contained in:
Tobi Schäfer 2007-10-11 23:03:17 +00:00
parent ded7f5fcea
commit df9017ab77
38 changed files with 1154 additions and 1736 deletions

View file

@ -29,6 +29,10 @@ Admin.prototype.constructor = function() {
return this; return this;
}; };
Admin.prototype.getPermission = function(action) {
return User.require(User.PRIVILEGED);
};
Admin.prototype.onRequest = function() { Admin.prototype.onRequest = function() {
HopObject.prototype.onRequest.apply(this); HopObject.prototype.onRequest.apply(this);
if (!session.data.admin) { if (!session.data.admin) {
@ -42,10 +46,6 @@ Admin.prototype.onUnhandledMacro = function(name) {
return null; return null;
}; };
Admin.prototype.getPermission = function(action) {
return User.require(User.PRIVILEGED);
};
Admin.prototype.main_action = function() { Admin.prototype.main_action = function() {
return res.redirect(this.href("status")); return res.redirect(this.href("status"));
}; };
@ -216,7 +216,7 @@ Admin.prototype.count_macro = function(param, object, name) {
case "comments": case "comments":
if (object.constructor === Site) { if (object.constructor === Site) {
res.write("FIXME: takes very long... :("); res.write("FIXME: takes very long... :(");
//res.write(object.stories.all.size() - object.stories.size()); //res.write(object.stories.comments.size());
} }
return; return;
} }

View file

@ -31,7 +31,8 @@ Archive.prototype.constructor = function(name, parent) {
}; };
Archive.prototype.getPermission = function(action) { Archive.prototype.getPermission = function(action) {
if (!this._parent.getPermission("main")) { var site = res.handlers.site;
if (!site.getPermission("main")) {
return false; return false;
} }
switch (action) { switch (action) {
@ -40,7 +41,7 @@ Archive.prototype.getPermission = function(action) {
case "next": case "next":
return this.getPage() < this.getSize() / this.getPageSize(); return this.getPage() < this.getSize() / this.getPageSize();
default: default:
return this._parent.archiveMode === Site.PUBLIC; return site.archiveMode === Site.PUBLIC;
} }
return false; return false;
}; };
@ -113,7 +114,7 @@ Archive.prototype.list_macro = function(param, type) {
if (!this.parent) { if (!this.parent) {
var site = res.handlers.site; var site = res.handlers.site;
var offset = (page - 1) * pageSize; var offset = (page - 1) * pageSize;
var stories = site.stories["public"].list(offset, pageSize); var stories = site.stories.featured.list(offset, pageSize);
for each (var story in stories) { for each (var story in stories) {
renderStory(story); renderStory(story);
}; };
@ -190,7 +191,7 @@ Archive.prototype.getFilter = function() {
res.push(); res.push();
res.write("where site_id = "); res.write("where site_id = ");
res.write(site._id); res.write(site._id);
res.write(" and prototype = 'Story' and status <> 'private'"); res.write(" and prototype = 'Story' and status <> 'closed'");
var part; var part;
if (part = this.getDate("year")) { if (part = this.getDate("year")) {
res.write(" and year(created) = " + part); res.write(" and year(created) = " + part);

View file

@ -25,7 +25,7 @@
_children = collection(Story) _children = collection(Story)
_children.local = id _children.local = id
_children.foreign = site_id _children.foreign = site_id
_children.filter = prototype = 'Story' and status <> 'private' _children.filter = prototype = 'Story' and status <> 'closed'
_children.order = created desc _children.order = created desc
_children.group = date_format(created, "%Y%m%d") _children.group = date_format(created, "%Y%m%d")
#_children.group.prototype = Archive #_children.group.prototype = Archive

View file

@ -22,7 +22,8 @@
// $URL$ // $URL$
// //
defineConstants(Comment, "getStatus", "closed", "pending", "readonly", "public"); Comment.getStatus = defineConstants(Comment, "closed",
"pending", "readonly", "public");
Comment.prototype.constructor = function(parent) { Comment.prototype.constructor = function(parent) {
this.site = parent.site; this.site = parent.site;
@ -49,7 +50,10 @@ Comment.prototype.getPermission = function(action) {
case ".": case ".":
case "main": case "main":
case "comment": case "comment":
return this.story.getPermission(action); return this.site.commentsMode === Site.ENABLED &&
this.story.getPermission(action) &&
this.status !== Comment.CLOSED &&
this.status !== Comment.PENDING;
case "delete": case "delete":
case "edit": case "edit":
return this.story.getPermission.call(this, "delete"); return this.story.getPermission.call(this, "delete");

View file

@ -17,7 +17,7 @@
Prototype: <% comment.prototype %><br /> Prototype: <% comment.prototype %><br />
Parent: <% comment.parent_type %> #<% comment.parent_id %><br /> Parent: <% comment.parent_type %> #<% comment.parent_id %><br />
Story: <% comment.story %><br /> --> Story: <% comment.story %><br /> -->
<% comment.creator link %>, <% comment.created short %> <% comment.creator link %>, <% comment.created short %>
</div> </div>
<div class="title"><% comment.title %></div> <div class="title"><% comment.title %></div>
<div><% comment.text | comment.format %></div> <div><% comment.text | comment.format %></div>

View file

@ -1,5 +1,5 @@
<% #main %> <% #main %>
<a href="<% file.href %>" title="<% file.description %>"><% param.text %></a> <a href="<% file.href %>" title="<% file.description %>"><% file.name %></a>
<span class="small"> <span class="small">
(<% file.contentType suffix=", " %><% file.contentLength %>) (<% file.contentType suffix=", " %><% file.contentLength %>)
</span> </span>
@ -9,10 +9,10 @@
<table width="100%" cellspacing="0" cellpadding="0"> <table width="100%" cellspacing="0" cellpadding="0">
<tr> <tr>
<td colspan="2" class="small"> <td colspan="2" class="small">
<strong>Macro:</strong> &lt;% file <% file.name %> %&gt; <strong>Macro:</strong> <% file.macro %>
<div class="ample"><strong>Details: </strong><% file.fileSize %> <div class="ample"><strong>Details: </strong><% file.contentLength %>
<% file.contentType prefix=" " %><% file.requests prefix=", " <% file.contentType prefix=" " %><% ngettext "{0} download" "{0} downloads"
no="0 downloads" one="1 download" more=" downloads"%></div> <% file.requests %> prefix=", " %></div>
</td> </td>
</tr> </tr>
<tr> <tr>

View file

@ -29,6 +29,7 @@ app.addRepository("modules/core/Filters.js");
app.addRepository("modules/helma/Image.js"); app.addRepository("modules/helma/Image.js");
app.addRepository("modules/helma/Html.js"); app.addRepository("modules/helma/Html.js");
app.addRepository("modules/helma/Http.js");
app.addRepository("modules/helma/Mail.js"); app.addRepository("modules/helma/Mail.js");
app.addRepository("modules/helma/Search.js"); app.addRepository("modules/helma/Search.js");
app.addRepository("modules/helma/Zip.js"); app.addRepository("modules/helma/Zip.js");
@ -41,9 +42,6 @@ app.addRepository("modules/jala/code/I18n.js");
//app.addRepository("modules/jala/code/ListRenderer.js"); //app.addRepository("modules/jala/code/ListRenderer.js");
app.addRepository("modules/jala/code/Utilities.js"); app.addRepository("modules/jala/code/Utilities.js");
var _ = gettext;
var search = new helma.Search();
var html = new helma.Html(); var html = new helma.Html();
/** /**
@ -51,7 +49,33 @@ var html = new helma.Html();
* to an application-wide array (mail queue). * to an application-wide array (mail queue).
*/ */
helma.Mail.prototype.queue = function() { helma.Mail.prototype.queue = function() {
return app.data.mailQueue.push(this); app.data.mails || (app.data.mails = []);
return app.data.mails.push(this);
};
SHORTDATEFORMAT = "yyyy-MM-dd HH:mm";
LONGDATEFORMAT = "EEEE, d. MMMM yyyy, HH:mm";
function defineConstants(ctor /*, arguments */) {
var constants = [], name;
for (var i=1; i<arguments.length; i+=1) {
name = arguments[i].toUpperCase().replace(/\s/g, "");
if (ctor[name]) {
app.logger.warn("Constant already defined: " + ctor.name + "." + name);
}
ctor[name] = arguments[i];
constants.push({
value: arguments[i],
display: arguments[i]
});
}
return function() {
return constants;
};
}
function disableMacro(ctor, name) {
return ctor.prototype[name + "_macro"] = function() {return};
}; };
function onStart() { function onStart() {
@ -62,34 +86,7 @@ function onStart() {
var id = rows.getColumnItem("id"); var id = rows.getColumnItem("id");
//Packages.helma.main.Server.getServer().stopApplication(app.name); //Packages.helma.main.Server.getServer().stopApplication(app.name);
rows.release();*/ rows.release();*/
return;
// load application messages and modules
var dir = new Helma.File(app.dir, "../i18n");
var arr = dir.list();
for (var i in arr) {
var fname = arr[i];
if (fname.startsWith("messages.")) {
var name = fname.substring(fname.indexOf(".") + 1, fname.length);
var msgFile = new Helma.File(dir, fname);
app.data[name] = new Packages.helma.util.SystemProperties(msgFile.getAbsolutePath());
app.log("loaded application messages (language: " + name + ")");
}
}
// init index manager
app.data.indexManager = new IndexManager();
// build macro help
app.data.macros = buildMacroHelp();
//eval(macroHelpFile.readAll());
app.log("loaded macro help file");
// creating the vector for referrer-logging
app.data.accessLog = new java.util.Vector();
// creating the hashtable for storyread-counting
app.data.readLog = new java.util.Hashtable();
// define the global mail queue
app.data.mailQueue = new Array();
// init constants
initConstants();
// call onStart methods of modules // call onStart methods of modules
for (var i in app.modules) { for (var i in app.modules) {
if (app.modules[i].onStart) if (app.modules[i].onStart)
@ -110,29 +107,6 @@ function scheduler() {
return 5000; return 5000;
} }
function disableMacro(ctor, name) {
return ctor.prototype[name + "_macro"] = function() {return};
};
function defineConstants(ctor, getterName /* , arguments */) {
var constants = [], name;
for (var i=2; i<arguments.length; i+=1) {
name = arguments[i].toUpperCase().replace(/\s/g, "");
if (ctor[name]) {
app.logger.warn("Constant already defined: " + ctor.name + "." + name);
}
ctor[name] = arguments[i];
constants.push({
value: arguments[i],
display: arguments[i]
});
}
ctor[getterName] = function() {
return constants;
};
return;
}
function logAction(context, action) { function logAction(context, action) {
if (context) { if (context) {
root.admin.log.add(new LogEntry(context, action)); root.admin.log.add(new LogEntry(context, action));
@ -140,7 +114,6 @@ function logAction(context, action) {
root.admin.log.cache.add(new LogEntry(path[path.length - 1])); root.admin.log.cache.add(new LogEntry(path[path.length - 1]));
} }
return; return;
/* FIXME: check whether request really should be logged /* FIXME: check whether request really should be logged
var site = res.handlers.site ? res.handlers.site: root; var site = res.handlers.site ? res.handlers.site: root;
var url = http.evalUrl(req.data.http_referer); var url = http.evalUrl(req.data.http_referer);
@ -178,111 +151,54 @@ function flushLog() {
return; return;
} }
MAY_ADD_STORY = 1; /**
MAY_VIEW_ANYSTORY = 2; * Renders a string depending on the comparison of two values. If the first
MAY_EDIT_ANYSTORY = 4; * value equals the second value, the first result will be returned; the
MAY_DELETE_ANYSTORY = 8; * second result otherwise.
MAY_ADD_COMMENT = 16; * <p>Example: <code>&lt;% if &lt;% macro %&gt; is "value" then "yes!" else "no :(" %&gt;</code>
MAY_EDIT_ANYCOMMENT = 32; * </p>
MAY_DELETE_ANYCOMMENT = 64; * Note that any value or result can be a macro, too. Thus, this can be used as
MAY_ADD_IMAGE = 128; * a simple implementation of an if-then-else statement by using Helma macros
MAY_EDIT_ANYIMAGE = 256; * only.
MAY_DELETE_ANYIMAGE = 512; * @param {Object} param The default Helma macro parameter object
MAY_ADD_FILE = 1024; * @param {String} firstValue The first value
MAY_EDIT_ANYFILE = 2048; * @param {String} _is_ Syntactic sugar; should be "is" for legibility
MAY_DELETE_ANYFILE= 4096; * @param {String} secondValue The second value
MAY_VIEW_STATS = 8192; * @param {String} _then_ Syntactic sugar; should be "then" for legibility
MAY_EDIT_PREFS = 16384; * @param {String} firstResult The first result, ie. the value that will be
MAY_EDIT_LAYOUTS = 32768; * returned if the first value equals the second one
MAY_EDIT_MEMBERS = 65536; * @param {String} _else_ Syntactic sugar; should be "else" for legibility
* @param {String} secondResult The second result, ie. the value that will be
* returned if the first value does not equal the second one
* @returns The resulting value
* @type String
* @member Global
*/
function if_macro(param, firstValue, _is_, secondValue, _then_, firstResult,
_else_, secondResult) {
return (("" + firstValue) == ("" + secondValue)) ? firstResult : secondResult;
}
EDITABLEBY_ADMINS = 0; function gettext_macro(param, text /*, value1, value2, ...*/) {
EDITABLEBY_CONTRIBUTORS = 1; var args = [text];
EDITABLEBY_SUBSCRIBERS = 2; for (var i=2; i<arguments.length; i+=1) {
args.push(arguments[i]);
}
return gettext.apply(this, args);
}
SHORTDATEFORMAT = "yyyy-MM-dd HH:mm"; function ngettext_macro(param, singular, plural, value1 /*, value2, value3, ...*/) {
LONGDATEFORMAT = "EEEE, d. MMMM yyyy, HH:mm"; var args = [singular, plural, value1];
for (var i=4; i<arguments.length; i+=1) {
args.push(arguments[i]);
}
return ngettext.apply(this, args);
}
function now_macro(param, format) { function now_macro(param, format) {
return formatDate(new Date, format || param.format); return formatDate(new Date, format || param.format);
} }
function file_macro(param, name, mode) {
name || (name = param.name);
if (!name) {
return;
}
mode || (mode = param.as);
delete(param.name);
delete(param.as);
var file;
if (name.startsWith("/")) {
if (mode === "url") {
res.write(root.getStaticUrl(name.substring(1)));
}
return;
}
file = HopObject.getFromPath(name, "files");
if (!file) {
return;
}
if (mode === "url") {
res.write(file.getUrl());
} else {
param.text || (param.text = file.name);
file.renderSkin(param.skin || "main", param);
}
return;
}
function image_macro(param, name, mode) {
name || (name = param.name);
if (!name) {
return;
}
mode || (mode = param.as);
var action = param.linkto;
delete(param.name);
delete(param.as);
delete(param.linkto);
var image;
if (name.startsWith("/") && (image = Images.Default[name.substring(1)])) {
param.src = root.getStaticUrl(image.name);
param.border = 0;
if (mode === "url") {
res.write(param.src);
} else if (image.href) {
res.push();
html.tag("img", param);
link_filter(res.pop(), param, image.href);
} else {
html.tag("img", param);
}
return;
}
image = HopObject.getFromPath(name, "images");
if (!image && param.fallback) {
image = HopObject.getFromPath(param.fallback, "images");
}
if (!image) {
return;
}
switch (mode) {
case "url" :
return image.getUrl();
case "thumbnail":
action || (action = image.getUrl());
return image.thumbnail_macro(param);
}
image.render_macro(param);
return;
}
function link_macro() { function link_macro() {
return renderLink.apply(this, arguments); return renderLink.apply(this, arguments);
} }
@ -321,295 +237,278 @@ function breadcrumbs_macro (param, delimiter) {
return; return;
} }
// FIXME: function story_macro(param, id, mode) {
function story_macro(param) { id || (id = param.id);
if (!param.id) var story = HopObject.getFromPath(id, "stories");
if (!story || !story.getPermission("main")) {
return; return;
var storyPath = param.id.split("/"); }
if (storyPath.length == 2) {
var site = root.get(storyPath[0]); mode || (mode = param.as);
if (!site || !site.online) delete(param.name);
return; delete(param.as);
} else if (res.handlers.site)
var site = res.handlers.site; switch (mode) {
else
return;
var story = site.allstories.get(storyPath[1] ? storyPath[1] : param.id);
if (!story)
return getMessage("error", "storyNoExist", param.id);
switch (param.as) {
case "url": case "url":
res.write(story.href()); res.write(story.href());
break; break;
case "link": case "link":
var title = param.text ? param.text : html.link({href: story.href()}, story.getTitle());
story.content.get("title"); break;
html.link({href: story.href()}, title ? title : story._id);
break;
default: default:
story.renderSkin(param.skin ? param.skin : "embed"); story.renderSkin(param.skin ? param.skin : "Story#main");
} }
return; return;
} }
// FIXME: function file_macro(param, id, mode) {
function poll_macro(param) { id || (id = param.name);
if (!param.id) if (!id) {
return; return;
// disable caching of any contentPart containing this macro }
res.meta.cachePart = false;
var parts = param.id.split("/"); mode || (mode = param.as);
if (parts.length == 2) delete(param.name);
var site = root.get(parts[0]); delete(param.as);
else
var site = res.handlers.site; var file;
if (!site) if (id.startsWith("/")) {
name = id.substring(1);
if (mode === "url") {
res.write(root.getStaticUrl(name));
} else {
file = root.getStaticFile(name);
res.push();
File.prototype.contentLength_macro.call({
contentLength: file.getLength()
});
res.handlers.file = {
href: root.getStaticUrl(name),
name: name,
contentLength: res.pop()
};
File.prototype.renderSkin("File#main");
}
return; return;
var poll = site.polls.get(parts[1] ? parts[1] : param.id); }
if (!poll)
return getMessage("error.pollNoExist", param.id); file = HopObject.getFromPath(id, "files");
switch (param.as) { if (!file) {
case "url": return;
res.write(poll.href()); }
break; if (mode === "url") {
case "link": res.write(file.getUrl());
html.link({ } else {
href: poll.href(poll.closed ? "results" : "") file.renderSkin(param.skin || "File#main");
}, poll.question);
break;
default:
if (poll.closed || param.as == "results")
poll.renderSkin("results");
else {
res.data.action = poll.href();
poll.renderSkin("main");
}
} }
return; return;
} }
// FIXME: function image_macro(param, id, mode) {
function sitelist_macro(param) { id || (id = param.name);
// setting some general limitations: if (!id) {
var minDisplay = 10; return;
var maxDisplay = 25; }
var max = Math.min((param.limit ? parseInt(param.limit, 10) : minDisplay), maxDisplay);
root.renderSitelist(max); mode || (mode = param.as);
res.write(res.data.sitelist); delete(param.name);
delete res.data.sitelist; delete(param.as);
delete(param.linkto);
var image;
if (id.startsWith("/") && (image = Images.Default[id.substring(1)])) {
param.src = root.getStaticUrl(image.name);
param.border = 0;
if (mode === "url") {
res.write(param.src);
} else if (image.href) {
res.push();
html.tag("img", param);
link_filter(res.pop(), param, image.href);
} else {
html.tag("img", param);
}
return;
}
image = HopObject.getFromPath(id, "images");
if (!image && param.fallback) {
image = HopObject.getFromPath(param.fallback, "images");
}
if (!image) {
return;
}
switch (mode) {
case "url" :
res.write(image.getUrl());
break;
case "thumbnail":
image.thumbnail_macro(param);
break;
default:
image.render_macro(param);
}
return; return;
} }
// FIXME: function poll_macro(param, id, mode) {
function imagelist_macro(param) { id || (param.id = id);
var site = param.of ? root.get(param.of) : res.handlers.site; if (!id) {
if (!site)
return; return;
if (!site.images.size()) }
var poll = HopObject.getFromPath(id, "polls");
if (!poll) {
return; return;
var max = Math.min(param.limit ? param.limit : 5, site.images.size()); }
var idx = 0;
var imgParam;
var linkParam = {};
delete param.limit;
while (idx < max) { mode || (mode = param.as);
var imgObj = site.images.get(idx++); var action = param.linkto;
delete(param.name);
delete(param.as);
delete(param.linkto);
switch (mode) {
case "url":
res.write(poll.href());
break;
case "link":
html.link({
href: poll.href(poll.closed ? "results" : "")
}, poll.question);
break;
default:
if (poll.status === Poll.CLOSED || mode === "results")
poll.renderSkin("Poll#results");
else {
res.data.action = poll.href();
poll.renderSkin("Poll#main");
}
}
return;
}
imgParam = Object.clone(param); function list_macro(param /*, limit, id */) {
delete imgParam.itemprefix; var id = arguments[2] || arguments[1];
delete imgParam.itemsuffix; var limit = arguments[2] && arguments[1] || 0;
delete imgParam.as; if (!id && !limit) {
delete linkParam.href; return;
delete linkParam.onclick; }
res.write(param.itemprefix); var max = Math.min(Math.max(limit, 5), 20);
// return different display according to param.as var collection, skin;
switch (param.as) { if (id === "sites") {
case "url": collection = root.sites;
res.write(imgObj.getUrl()); skin = "Site#preview";
break; } else {
case "popup": var site;
linkParam.onclick = imgObj.getPopupUrl(); var parts = id.split("/");
case "thumbnail": if (parts.length > 1) {
linkParam.href = param.linkto ? param.linkto : imgObj.getUrl(); type = parts[1];
if (imgObj.thumbnail) site = root.sites.get(parts[0]);
imgObj = imgObj.thumbnail; } else {
type = parts[0];
}
site || (site = res.handlers.site);
var filter = function(item, index) {
return index < max && item.getPermission("main");
};
switch (type) {
case "images":
collection = site.images.list(0, max);
skin = "Image#preview";
break;
case "featured":
collection = site.stories.featured.list(0, max);
skin = "Story#preview";
break;
case "stories":
var stories = site.stories.recent;
collection = stories.list().filter(function(item, index) {
return item.constructor === Story && filter(item, index);
});
skin = "Story#preview";
break;
case "comments":
var comments = site.stories.comments;
collection = comments.list().filter(filter);
skin = "Comment#preview";
break;
case "postings":
content = site.stories.recent;
collection = content.list().filter(filter);
skin = "Story#preview";
break;
default: default:
if (linkParam.href) { break;
html.openLink(linkParam);
renderImage(imgObj, imgParam);
html.closeLink();
} else
renderImage(imgObj, imgParam);
} }
res.write(param.itemsuffix); }
param.skin && (skin = param.skin);
for each (var item in collection) {
item.renderSkin(skin);
} }
return; return;
} };
// FIXME: -> tags! function randomize_macro(param, id) {
function topiclist_macro(param) { var getRandom = function(n) {
var site = param.of ? root.get(param.of) : res.handlers.site; return Math.floor(Math.random() * n);
if (!site) };
var site;
if (id === "sites") {
site = root.sites.get(getRandom(root.sites.size()));
site.renderSkin(param.skin || "Site#preview");
return; return;
site.topics.topiclist_macro(param); }
return;
}
// FIXME: obsolete? var parts = id.split("/");
function username_macro(param) { if (parts.length > 1) {
if (!session.user) type = parts[1];
return; site = root.sites.get(parts[0]);
if (session.user.url && param.as == "link")
html.link({href: session.user.url}, session.user.name);
else if (session.user.url && param.as == "url")
res.write(session.user.url);
else
res.write(session.user.name);
return;
}
// FIXME:
function colorpicker_macro(param) {
if (!param || !param.name)
return;
var param2 = new Object();
param2.as = "editor";
param2["size"] = "10";
param2.onchange = "Antville.ColorPicker.set('" + param.name + "', this.value);";
param2.id = "Antville_ColorValue_" + param.name;
if (!param.text)
param.text = param.name;
if (param.color)
param.color = renderColorAsString(param.color);
if (path.Story || path.StoryMgr) {
var obj = path.Story ? path.Story : new Story();
param2.part = param.name;
// use res.push()/res.pop(), otherwise the macro
// would directly write to response
res.push();
obj.content_macro(param2);
param.editor = res.pop();
param.color = renderColorAsString(obj.content.get(param.name));
} else if (path.Layout) {
var obj = path.Layout;
// use res.push()/res.pop(), otherwise the macro
// would directly write to response
res.push();
obj[param.name + "_macro"](param2);
param.editor = res.pop();
param.color = renderColorAsString(obj.preferences.get(param.name));
} else
return;
renderSkin("colorpickerWidget", param);
return;
}
// FIXME:
function randomize_macro(param) {
var site, obj;
if (param.site) {
var site = root.get(param.site);
if (!site.online)
return;
} else { } else {
var max = root.publicSites.size(); type = parts[0];
while (!site || site.online < 1)
site = root.publicSites.get(Math.floor(Math.random() * max));
} }
var coll; site || (site = res.handlers.site);
switch (param.what) { switch (type) {
case "stories": case "stories":
obj = site.stories.get(Math.floor(Math.random() * site.allstories.size())); var stories = site.stories["public"];
break; var story = stories.get(getRandom(stories.size()));
story && story.renderSkin(param.skin || "Story#preview");
break;
case "images": case "images":
obj = site.images.get(Math.floor(Math.random() * site.images.size())); var image = site.images.get(getRandom(site.images.size()));
break; image && image.renderSkin(param.skin || "Image#preview");
case "sites": break;
default:
obj = site;
break;
} }
obj.renderSkin(param.skin ? param.skin : "embed");
return; return;
} }
// FIXME: function validateEmail(str) {
function randomimage_macro(param) { if (str.isEmail()) {
if (param.images) { return str;
var items = new Array();
var aliases = param.images.split(",");
for (var i=0; i<aliases.length; i++) {
aliases[i] = aliases[i].trim();
var img = getPoolObj(aliases[i], "images");
if (img && img.obj) items[items.length] = img.obj;
}
}
delete(param.images);
var idx = Math.floor(Math.random()*items.length);
var img = items[idx];
param.name = img.alias;
return image_macro(param);
}
// FIXME:
function imageoftheday_macro(param) {
var s = res.handlers.site;
var pool = res.handlers.site.images;
if (pool==null) return;
delete(param.topic);
var img = pool.get(0);
param.name = img.alias;
return image_macro(param);
}
// FIXME:
function evalEmail(str) {
if (!str.isEmail()) {
return null;
}
return str;
}
// FIXME:
function evalURL(str) {
if (url = helma.Http.evalUrl(str)) {
return String(url);
} else if (str.contains("@")) {
return "mailto:" + str;
} else {
return "http://" + str;
} }
return null; return null;
} }
// FIXME: function validateUrl(str) {
function autoLogin() { if (str) {
if (session.user) { if (url = helma.Http.evalUrl(str)) {
return; return String(url);
} else if (str.contains("@")) {
return "mailto:" + str;
} else {
return "http://" + str;
}
} }
var name = req.cookies.avUsr; return null;
var hash = req.cookies.avPw;
if (!name || !hash) {
return;
}
var user = User.getByName(name);
if (!user) {
return;
}
var ip = req.data.http_remotehost.clip(getProperty ("cookieLevel","4"),
"", "\\.");
if ((user.hash + ip).md5() !== hash) {
return;
}
session.login(user);
user.touch();
res.message = gettext('Welcome to "{0}", {1}. Have fun!',
res.handlers.site.title, user.name);
return;
} }
// FIXME: // FIXME:
@ -933,15 +832,6 @@ function buildMacroHelp() {
return macroHelp; return macroHelp;
} }
/**
* wrapper method to expose the indexManager's
* rebuildIndexes method to cron
*/
function rebuildIndexes() {
app.data.indexManager.rebuildIndexes();
return;
}
/** /**
* function tries to check if the color contains just hex-characters * function tries to check if the color contains just hex-characters
* if so, it returns the color-definition prefixed with a '#' * if so, it returns the color-definition prefixed with a '#'
@ -1154,21 +1044,6 @@ function renderPageNavigation(collectionOrSize, url, itemsPerPage, pageIdx) {
return renderSkinAsString("pagenavigation", param); return renderSkinAsString("pagenavigation", param);
} }
/**
* function checks if user is logged in or not
* if false, it redirects to the login-page
* but before it stores the url to jump back (if passed as argument)
*/
function checkIfLoggedIn(referrer) {
if (!session.user) {
// user is not logged in
if (referrer)
session.data.referrer = referrer;
res.redirect(res.handlers.site ? res.handlers.site.members.href("login") : root.members.href("login"));
}
return;
}
function singularize(plural) { function singularize(plural) {
if (plural.endsWith("ies")) { if (plural.endsWith("ies")) {
return plural.substring(0, plural.length-3) + "y"; return plural.substring(0, plural.length-3) + "y";
@ -1256,34 +1131,6 @@ function getDateFormats(type, language) {
return result; return result;
} }
/**
* Renders a string depending on the comparison of two values. If the first
* value equals the second value, the first result will be returned; the
* second result otherwise.
* <p>Example: <code>&lt;% if &lt;% macro %&gt; is "value" then "yes!" else "no :(" %&gt;</code>
* </p>
* Note that any value or result can be a macro, too. Thus, this can be used as
* a simple implementation of an if-then-else statement by using Helma macros
* only.
* @param {Object} param The default Helma macro parameter object
* @param {String} firstValue The first value
* @param {String} _is_ Syntactic sugar; should be "is" for legibility
* @param {String} secondValue The second value
* @param {String} _then_ Syntactic sugar; should be "then" for legibility
* @param {String} firstResult The first result, ie. the value that will be
* returned if the first value equals the second one
* @param {String} _else_ Syntactic sugar; should be "else" for legibility
* @param {String} secondResult The second result, ie. the value that will be
* returned if the first value does not equal the second one
* @returns The resulting value
* @type String
* @member Global
*/
function if_macro(param, firstValue, _is_, secondValue, _then_, firstResult,
_else_, secondResult) {
return (("" + firstValue) == ("" + secondValue)) ? firstResult : secondResult;
}
function age_filter(value, param) { function age_filter(value, param) {
if (!value || value.constructor !== Date) { if (!value || value.constructor !== Date) {
return value; return value;
@ -1322,20 +1169,3 @@ function clip_filter(input, param, limit, clipping, delimiter) {
delimiter || (delimiter = "\\s"); delimiter || (delimiter = "\\s");
return String(input || "").head(limit, clipping, delimiter); return String(input || "").head(limit, clipping, delimiter);
} }
var gettext_macro = function(param, text /*, value1, value2, ...*/) {
var args = [text];
for (var i=2; i<arguments.length; i+=1) {
args.push(arguments[i]);
}
return gettext.apply(this, args);
};
var ngettext_macro = function(param, singular, plural, value1 /*, value2, value3, ...*/) {
var args = [singular, plural, value1];
for (var i=4; i<arguments.length; i+=1) {
args.push(arguments[i]);
}
return ngettext.apply(this, args);
};

View file

@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Antville Colorpicker</title>
<link rel="stylesheet" type="text/css" title="CSS Stylesheet"
href="<% site.href main.css %>" />
<style type="text/css">
<!--
body {
background-color: #ffffff;
font-family: Verdana, Helvetica, Arial, sans-serif;
color: #000000;
}
td {
vertical-align: top;
}
.center {
text-align: right;
vertical-align: middle;
}
.widget {
background-color: #ffffff;
font: 12px verdana;
color: #000000;
}
.link {
color: <% layout.linkcolor %>;
}
.active {
color: <% layout.alinkcolor %>;
}
.visited {
color: <% layout.vlinkcolor %>;
}
.border {
border: 1px solid #eeeeee;
}
// -->
</style>
<script type="text/javascript">
<!--
<% skin name="colorpickerScripts" %>
// -->
</script>
</head>
<body onload="cp.setCurrentColor();">
<p align="center">
<table border="0" cellspacing="4" cellpadding="8">
<tr>
<td width="240" class="widget" colspan="2">
<!-- inner table, containing the color picker widget -->
<table border="0" cellspacing="5" cellpadding="0">
<tr>
<td class="widget" colspan="2" align="center">Select <% request.text %> color:</td>
</tr>
<tr>
<td valign="top" class="border" title="Select color">
<script type="text/javascript">
<!--
var cp = Antville.ColorPicker;
for (var i=0; i<cp.defaultPalette.length; i++) {
var color = cp.defaultPalette[i];
if (i % cp.brightness.length == 0)
document.write("<div>");
document.write('<img id="color' + i + '" style="background-color: #' + color + ';" onclick="cp.updateBrightness(this, ' + i + ');" src="' + Antville.pixel.src + '" width="' + cp.squareSize + '" height="' + cp.squareSize + '" />');
if (i % cp.brightness.length == cp.brightness.length-1)
document.write("</div>");
}
// -->
</script>
</td>
<td valign="top">
<div class="border" title="Select color brightness">
<script type="text/javascript">
<!--
for (var i=0; i<cp.brightness.length; i++)
document.write('<div><img id="bright' + i + '" onclick="cp.updatePalette(this, ' + i + ');" src="' + Antville.pixel.src + '" width="15" height="15" style="background-color: #' + cp.brightness[i][0] + ';"/></div>');
// -->
</script>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="widget"><input class="widget" style="border: none;" id="display" value="" size="10" /></td>
<td align="right" class="widget"><button name="accept" type="button" onclick="cp.submit();" title="accept color selection">Accept</button>&nbsp;&nbsp;<button name="cancel" type="button" onclick="cp.cancel();" title="cancel color selection">Cancel</button>
</td>
</tr>
</table>
</p>
</body>
</html>

View file

@ -1,139 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Antville Colorpicker</title>
<link rel="stylesheet" type="text/css" title="CSS Stylesheet"
href="<% site.href main.css %>" />
<style type="text/css">
<!--
body {
background-color: #ffffff;
font-family: Verdana, Helvetica, Arial, sans-serif;
color: #000000;
}
td {
vertical-align: top;
}
.center {
text-align: right;
vertical-align: middle;
}
.widget {
background-color: #ffffff;
font: 12px verdana;
color: #000000;
}
.link {
color: <% layout.linkcolor %>;
}
.active {
color: <% layout.alinkcolor %>;
}
.visited {
color: <% layout.vlinkcolor %>;
}
.border {
border: 1px solid #eeeeee;
}
// -->
</style>
<script type="text/javascript">
<!--
<% skin name="colorpickerScripts" %>
// -->
</script>
</head>
<body onload="cp.setCurrentColors(); cp.setDropdown(); cp.setCurrentColor();">
<table border="0" cellspacing="4" cellpadding="8">
<tr>
<td width="240" class="widget" rowspan="2">
<!-- inner table, containing the color picker widget -->
<table border="0" cellspacing="5" cellpadding="0" bgcolor="#ffffff">
<tr>
<td class="widget" colspan="2" align="center">Select
<select size="1" id="dropdown" name="color" onchange="cp.setDropDownColor(this);">
<script type="text/javascript">
<!--
var cp = Antville.ColorPicker;
for (var i in cp.colorNames)
document.write('<option value="' + i + '">' + cp.colorNames[i] + '</option>');
// -->
</script>
</select> color:
</td>
</tr>
<tr>
<td valign="top" class="border" title="Select color">
<script type="text/javascript">
<!--
for (var i=0; i<cp.defaultPalette.length; i++) {
var color = cp.defaultPalette[i];
if (i % cp.brightness.length == 0)
document.write("<div>");
document.write('<img id="color' + i + '" style="background-color: #' + color + ';" onclick="cp.updateBrightness(this, ' + i + ');" src="' + Antville.pixel.src + '" width="' + cp.squareSize + '" height="' + cp.squareSize + '" />');
if (i % cp.brightness.length == cp.brightness.length-1)
document.write("</div>");
}
// -->
</script>
</td>
<td valign="top">
<div class="border" title="Select color brightness">
<script type="text/javascript">
<!--
for (var i=0; i<cp.brightness.length; i++)
document.write('<div><img id="bright' + i + '" onclick="cp.updatePalette(this, ' + i + ');" src="' + Antville.pixel.src + '" width="15" height="15" style="background-color: #' + cp.brightness[i][0] + ';"/></div>');
// -->
</script>
</div>
</td>
</tr>
</table>
</td>
<td class="widget">&nbsp;<!-- just a stupid spacer cell --></td>
</tr>
<tr>
<td id="demo">
<div id="titlecolor" class="storyTitle">Sample Text</div>
<div id="textcolor" class="storyText">This is a sample text containing a <a id="linkcolor" class="link">fresh (unvisited) link</a> and a
<a id="vlinkcolor" class="visited">visited link</a>. The <a id="alinkcolor" class="active">active link</a> color is the one
you'll see while pressing the mouse button on the link.</div<br />
<div id="smallcolor" class="small">Finally, some small text.</div>
</td>
</tr>
<tr>
<td class="widget">
<input class="widget" style="border: none;" id="display" value="" size="10" />
</td>
<td align="right" class="widget"><button name="accept" type="button" onclick="cp.submit();" title="accept color selection">Accept</button>&nbsp;&nbsp;<button name="cancel" type="button" onclick="cp.cancel();" title="cancel color selection">Cancel</button>
</td>
</tr>
</table>
</body>
</html>

View file

@ -1,207 +0,0 @@
var Antville = {};
Antville.prefix = "Antville_";
Antville.pixel = new Image();
Antville.pixel.src = "<% image name="/pixel" as="url" %>";
Antville.ColorPickerFactory = function() {
var prefix = Antville.prefix + "ColorPicker_";
var valuePrefix = Antville.prefix + "ColorValue_";
this.colorNames = {
bgcolor: "background",
textcolor: "text",
titlecolor: "title",
linkcolor: "link",
alinkcolor: "active link",
vlinkcolor: "visited link",
smallcolor: "small text"
};
this.colors = {};
for (var i in this.colorNames) {
var el = self.opener.document.getElementById(prefix+i);
if (!el)
continue;
var col = el.style.backgroundColor;
if (col.indexOf("#") == 0)
col = col.substring(1);
this.colors[i] = col;
}
this.brightness = [
["000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000"],
["151515","151313","151212","151010","150e0e","150c0c","150b0b","150909","150707","150505","150404","150202","150000","151515","151413","151312","151310","15120e","15110c","15100b","150f09","150e07","150d05","150c04","150c02","150b00","151515","151513","151512","151510","15150e","15150c","15150b","151509","151507","151505","151504","151502","151500","151515","141513","131512","131510","12150e","11150c","10150b","0f1509","0e1507","0d1505","0c1504","0c1502","0b1500","151515","131513","121512","101510","0e150e","0c150c","0b150b","091509","071507","051505","041504","021502","001500","151515","131514","121513","101513","0e1512","0c1511","0b1510","09150f","07150e","05150d","04150c","02150c","00150b","151515","131515","121515","101515","0e1515","0c1515","0b1515","091515","071515","051515","041515","021515","001515","151515","131415","121315","101315","0e1215","0c1115","0b1015","090f15","070e15","050d15","040c15","020c15","000b15","151515","131315","121215","101015","0e0e15","0c0c15","0b0b15","090915","070715","050515","040415","020215","000015","151515","141315","131215","131015","120e15","110c15","100b15","0f0915","0e0715","0d0515","0c0415","0c0215","0b0015","151515","151315","151215","151015","150e15","150c15","150b15","150915","150715","150515","150415","150215","150015","151515","151314","151213","151013","150e12","150c11","150b10","15090f","15070e","15050d","15040c","15020c","15000b","151515","151313","151212","151010","150e0e","150c0c","150b0b","150909","150707","150505","150404","150202","150000"],
["2b2b2b","2b2727","2b2323","2b2020","2b1c1c","2b1919","2b1515","2b1212","2b0e0e","2b0b0b","2b0707","2b0404","2b0000","2b2b2b","2b2927","2b2723","2b2520","2b231c","2b2219","2b2015","2b1e12","2b1c0e","2b1b0b","2b1907","2b1704","2b1500","2b2b2b","2a2b27","2b2b23","2b2b20","2b2b1c","2a2b19","2b2b15","2b2b12","2a2b0e","2b2b0b","2b2b07","2b2b04","2b2b00","2b2b2b","292b27","272b23","252b20","232b1c","222b19","202b15","1e2b12","1c2b0e","1b2b0b","192b07","172b04","152b00","2b2b2b","272b27","232b23","202b20","1c2b1c","192b19","152b15","122b12","0e2b0e","0b2b0b","072b07","042b04","002b00","2b2b2b","272b29","232b27","202b25","1c2b23","192b22","152b20","122b1e","0e2b1c","0b2b1b","072b19","042b17","002b15","2b2b2b","272b2a","232b2a","202b2b","1c2b2b","192b2a","152b2a","122b2a","0e2b2a","0b2b2a","072b2a","042b2a","002b2a","2b2b2b","27292b","23272b","20252b","1c232b","19222b","15202b","121e2b","0e1c2b","0b1b2b","07192b","04172b","00152b","2b2b2b","27272b","23232b","20202b","1c1c2b","19192b","15152b","12122b","0e0e2b","0b0b2b","07072b","04042b","00002b","2b2b2b","29272b","27232b","25202b","231c2b","22192b","20152b","1e122b","1c0e2b","1b0b2b","19072b","17042b","15002b","2b2b2b","2b272a","2b232b","2b202b","2b1c2b","2b192a","2b152b","2b122b","2b0e2a","2b0b2b","2b072b","2b042b","2b002b","2b2b2b","2b2729","2b2327","2b2025","2b1c23","2b1922","2b1520","2b121e","2b0e1c","2b0b1b","2b0719","2b0417","2b0015","2b2b2b","2b2727","2b2323","2b2020","2b1c1c","2b1919","2b1515","2b1212","2b0e0e","2b0b0b","2b0707","2b0404","2b0000"],
["404040","403a3a","403535","403030","402b2b","402525","402020","401b1b","401515","401010","400b0b","400505","400000","404040","403d3a","403a35","403830","40352b","403225","403020","402d1b","402b15","402810","40250b","402305","402000","404040","40403a","404035","404030","40402b","404025","404020","40401b","404015","404010","40400b","404005","404000","404040","3d403a","3a4035","384030","35402b","324025","304020","2d401b","2b4015","284010","25400b","234005","204000","404040","3a403a","354035","304030","2b402b","254025","204020","1b401b","154015","104010","0b400b","054005","004000","404040","3a403d","35403a","304038","2b4035","254032","204030","1b402d","15402b","104028","0b4025","054023","004020","404040","3a4040","354040","304040","2b4040","254040","204040","1b4040","154040","104040","0b4040","054040","004040","404040","3a3d40","353a40","303840","2b3540","253240","203040","1b2d40","152b40","102840","0b2540","052340","002040","404040","3a3a40","353540","303040","2b2b40","252540","202040","1b1b40","151540","101040","0b0b40","050540","000040","404040","3d3a40","3a3540","383040","352b40","322540","302040","2d1b40","2b1540","281040","250b40","230540","200040","404040","403a40","403540","403040","402b40","402540","402040","401b40","401540","401040","400b40","400540","400040","404040","403a3d","40353a","403038","402b35","402532","402030","401b2d","40152a","401028","400b25","400523","400020","404040","403a3a","403535","403030","402b2b","402525","402020","401b1b","401515","401010","400b0b","400505","400000"],
["555555","554e4e","554747","554040","553939","553232","552b2b","552323","551c1c","551515","550e0e","550707","550000","555555","55514e","554e47","554a40","554739","554332","55402b","553c23","55391c","553515","55320e","552e07","552b00","555555","55554e","555547","555540","555539","555532","55552b","555523","55551c","555515","55550e","555507","555500","555555","51554e","4e5547","4a5540","475539","435532","40552b","3c5523","39551c","355515","32550e","2e5507","2b5500","555555","4e554e","475547","405540","395539","325532","2b552b","235523","1c551c","155515","0e550e","075507","005500","555555","4e5551","47554e","40554a","395547","325543","2b5540","23553c","1c5539","155535","0e5532","07552e","00552b","555555","4e5555","475555","405555","395555","325555","2b5555","235555","1c5555","155555","0e5555","075555","005555","555555","4e5155","474e55","404a55","394755","324355","2b4055","233c55","1c3955","153555","0e3255","072e55","002b55","555555","4e4e55","474755","404055","393955","323255","2b2b55","232355","1c1c55","151555","0e0e55","070755","000055","555555","514e55","4e4755","4a4055","473955","433255","402b55","3c2355","391c55","351555","320e55","2e0755","2b0055","555555","554e55","554755","554055","553955","553255","552b55","552355","551c55","551555","550e55","550755","550055","555555","554e51","55474e","55404a","553947","553243","552b40","55233c","551c39","551535","550e32","55072e","55002a","555555","554e4e","554747","554040","553939","553232","552b2b","552323","551c1c","551515","550e0e","550707","550000"],
["6a6a6a","6a6161","6a5959","6a5050","6a4747","6a3e3e","6a3535","6a2c2c","6a2323","6a1b1b","6a1212","6a0909","6a0000","6a6a6a","6a6661","6a6159","6a5d50","6a5947","6a543e","6a5035","6a4b2c","6a4723","6a421b","6a3e12","6a3a09","6a3500","6a6a6a","6a6a61","6a6a59","6a6a50","6a6a47","6a6a3e","6a6a35","6a6a2c","6a6a23","6a6a1b","6a6a12","6a6a09","6a6a00","6a6a6a","666a61","616a59","5d6a50","596a47","546a3e","506a35","4b6a2c","476a23","426a1b","3e6a12","3a6a09","356a00","6a6a6a","616a61","596a59","506a50","476a47","3e6a3e","356a35","2c6a2c","236a23","1b6a1b","126a12","096a09","006a00","6a6a6a","616a66","596a61","506a5d","476a59","3e6a54","356a50","2c6a4b","236a47","1b6a42","126a3e","096a3a","006a35","6a6a6a","616a6a","596a6a","506a6a","476a6a","3e6a6a","356a6a","2c6a6a","236a6a","1b6a6a","126a6a","096a6a","006a6a","6a6a6a","61666a","59616a","505d6a","47596a","3e546a","35506a","2c4b6a","23476a","1b426a","123e6a","093a6a","00356a","6a6a6a","61616a","59596a","50506a","47476a","3e3e6a","35356a","2c2c6a","23236a","1b1b6a","12126a","09096a","00006a","6a6a6a","66616a","61596a","5d506a","59476a","543e6a","50356a","4b2c6a","47236a","421b6a","3e126a","3a096a","35006a","6a6a6a","6a616a","6a596a","6a506a","6a476a","6a3e6a","6a356a","6a2c6a","6a236a","6a1b6a","6a126a","6a096a","6a006a","6a6a6a","6a6166","6a5961","6a505d","6a4759","6a3e54","6a3550","6a2c4b","6a2347","6a1b42","6a123e","6a093a","6a0035","6a6a6a","6a6161","6a5959","6a5050","6a4747","6a3e3e","6a3535","6a2c2c","6a2323","6a1b1b","6a1212","6a0909","6a0000"],
["7f7f7f","7f7575","7f6a6a","7f6060","7f5555","7f4a4a","7f4040","7f3535","7f2b2b","7f2020","7f1515","7f0b0b","7f0000","7f7f7f","7f7a75","7f756a","7f7060","7f6a55","7f654a","7f6040","7f5a35","7f552b","7f5020","7f4a15","7f450b","7f4000","7f7f7f","7f7f75","7f7f6a","7f7f60","7f7f55","7f7f4a","7f7f40","7f7f35","7f7f2b","7f7f20","7f7f15","7f7f0b","7f7f00","7f7f7f","7a7f75","757f6a","707f60","6a7f55","657f4a","607f40","5a7f35","557f2b","507f20","4a7f15","457f0b","407f00","7f7f7f","757f75","6a7f6a","607f60","557f55","4a7f4a","407f40","357f35","2b7f2b","207f20","157f15","0b7f0b","007f00","7f7f7f","757f7a","6a7f75","607f70","557f6a","4a7f65","407f60","357f5a","2b7f55","207f50","157f4a","0b7f45","007f40","7f7f7f","757f7f","6a7f7f","607f7f","557f7f","4a7f7f","407f7f","357f7f","2b7f7f","207f7f","157f7f","0b7f7f","007f7f","7f7f7f","757a7f","6a757f","60707f","556a7f","4a657f","40607f","355a7f","2b557f","20507f","154a7f","0b457f","00407f","7f7f7f","75757f","6a6a7f","60607f","55557f","4a4a7f","40407f","35357f","2b2b7f","20207f","15157f","0b0b7f","00007f","7f7f7f","7a757f","756a7f","70607f","6a557f","654a7f","60407f","5a357f","552b7f","50207f","4a157f","450b7f","40007f","7f7f7f","7f757f","7f6a7f","7f607f","7f557f","7f4a7f","7f407f","7f357f","7f2b7f","7f207f","7f157f","7f0b7f","7f007f","7f7f7f","7f757a","7f6a75","7f6070","7f556a","7f4a65","7f4060","7f355a","7f2b55","7f2050","7f154a","7f0b45","7f0040","7f7f7f","7f7575","7f6a6a","7f6060","7f5555","7f4a4a","7f4040","7f3535","7f2b2b","7f2020","7f1515","7f0b0b","7f0000"],
["959595","958888","957c7c","957070","956363","955757","954a4a","953e3e","953232","952525","951919","950c0c","950000","959595","958f88","95887c","958270","957c63","957657","95704a","95693e","956332","955d25","955719","95510c","954a00","959595","959588","95957c","959570","959563","959557","95954a","95953e","959532","959525","959519","95950c","959500","959595","8f9588","88957c","829570","7c9563","769557","70954a","69953e","639532","5d9525","579519","51950c","4a9500","959595","889588","7c957c","709570","639563","579557","4a954a","3e953e","329532","259525","199519","0c950c","009500","959595","88958f","7c9588","709582","63957c","579576","4a9570","3e9569","329563","25955d","199557","0c9551","00954a","959595","889595","7c9595","709595","639595","579595","4a9595","3e9595","329595","259595","199595","0c9595","009595","959595","888f95","7c8895","708295","637c95","577695","4a7095","3e6995","326395","255d95","195795","0c5195","004a95","959595","888895","7c7c95","707095","636395","575795","4a4a95","3e3e95","323295","252595","191995","0c0c95","000095","959595","8f8895","887c95","827095","7c6395","765795","704a95","693e95","633295","5d2595","571995","510c95","4a0095","959595","958895","957c95","957095","956395","955795","954a95","953e95","953295","952595","951995","950c95","950095","959595","95888f","957c88","957082","95637c","955776","954a70","953e69","953263","95255d","951957","950c51","95004a","959595","958888","957c7c","957070","956363","955757","954a4a","953e3e","953232","952525","951919","950c0c","950000"],
["aaaaaa","aa9c9c","aa8e8e","aa8080","aa7171","aa6363","aa5555","aa4747","aa3939","aa2b2b","aa1c1c","aa0e0e","aa0000","aaaaaa","aaa39c","aa9c8e","aa9580","aa8e71","aa8763","aa8055","aa7847","aa7139","aa6a2b","aa631c","aa5c0e","aa5500","aaaaaa","aaaa9c","aaaa8e","aaaa80","aaaa71","aaaa63","aaaa55","aaaa47","aaaa39","aaaa2b","aaaa1c","aaaa0e","aaaa00","aaaaaa","a3aa9c","9caa8e","95aa80","8eaa71","87aa63","80aa55","78aa47","71aa39","6aaa2b","63aa1c","5caa0e","55aa00","aaaaaa","9caa9c","8eaa8e","80aa80","71aa71","63aa63","55aa55","47aa47","39aa39","2baa2b","1caa1c","0eaa0e","00aa00","aaaaaa","9caaa3","8eaa9c","80aa95","71aa8e","63aa87","55aa80","47aa78","39aa71","2baa6a","1caa63","0eaa5c","00aa55","aaaaaa","9caaaa","8eaaaa","80aaaa","71aaaa","63aaaa","55aaaa","47aaaa","39aaaa","2baaaa","1caaaa","0eaaaa","00aaaa","aaaaaa","9ca3aa","8e9caa","8095aa","718eaa","6387aa","5580aa","4778aa","3971aa","2b6aaa","1c63aa","0e5caa","0055aa","aaaaaa","9c9caa","8e8eaa","8080aa","7171aa","6363aa","5555aa","4747aa","3939aa","2b2baa","1c1caa","0e0eaa","0000aa","aaaaaa","a39caa","9c8eaa","9580aa","8e71aa","8763aa","8055aa","7847aa","7139aa","6a2baa","631caa","5c0eaa","5500aa","aaaaaa","aa9caa","aa8eaa","aa80aa","aa71aa","aa63aa","aa55aa","aa47aa","aa39aa","aa2baa","aa1caa","aa0eaa","aa00aa","aaaaaa","aa9ca3","aa8e9c","aa8095","aa718e","aa6387","aa557f","aa4778","aa3971","aa2b6a","aa1c63","aa0e5c","aa0055","aaaaaa","aa9c9c","aa8e8e","aa8080","aa7171","aa6363","aa5555","aa4747","aa3939","aa2b2b","aa1c1c","aa0e0e","aa0000"],
["bfbfbf","bfafaf","bf9f9f","bf8f8f","bf8080","bf7070","bf6060","bf5050","bf4040","bf3030","bf2020","bf1010","bf0000","bfbfbf","bfb7af","bfaf9f","bfa78f","bf9f80","bf9770","bf8f60","bf8750","bf8040","bf7830","bf7020","bf6810","bf6000","bfbfbf","bfbfaf","bfbf9f","bfbf8f","bfbf80","bfbf70","bfbf60","bfbf50","bfbf40","bfbf30","bfbf20","bfbf10","bfbf00","bfbfbf","b7bfaf","afbf9f","a7bf8f","9fbf80","97bf70","8fbf60","87bf50","80bf40","78bf30","70bf20","68bf10","60bf00","bfbfbf","afbfaf","9fbf9f","8fbf8f","80bf80","70bf70","60bf60","50bf50","40bf40","30bf30","20bf20","10bf10","00bf00","bfbfbf","afbfb7","9fbfaf","8fbfa7","80bf9f","70bf97","60bf8f","50bf87","40bf80","30bf78","20bf70","10bf68","00bf60","bfbfbf","afbfbf","9fbfbf","8fbfbf","80bfbf","70bfbf","60bfbf","50bfbf","40bfbf","30bfbf","20bfbf","10bfbf","00bfbf","bfbfbf","afb7bf","9fafbf","8fa7bf","809fbf","7097bf","608fbf","5087bf","4080bf","3078bf","2070bf","1068bf","0060bf","bfbfbf","afafbf","9f9fbf","8f8fbf","8080bf","7070bf","6060bf","5050bf","4040bf","3030bf","2020bf","1010bf","0000bf","bfbfbf","b7afbf","af9fbf","a78fbf","9f80bf","9770bf","8f60bf","8750bf","8040bf","7830bf","7020bf","6810bf","6000bf","bfbfbf","bfafbf","bf9fbf","bf8fbf","bf80bf","bf70bf","bf60bf","bf50bf","bf40bf","bf30bf","bf20bf","bf10bf","bf00bf","bfbfbf","bfafb7","bf9faf","bf8fa7","bf809f","bf7097","bf608f","bf5087","bf407f","bf3078","bf2070","bf1068","bf0060","bfbfbf","bfafaf","bf9f9f","bf8f8f","bf8080","bf7070","bf6060","bf5050","bf4040","bf3030","bf2020","bf1010","bf0000"],
["d5d5d5","d5c3c3","d5b1b1","d59f9f","d58e8e","d57c7c","d56a6a","d55959","d54747","d53535","d52323","d51212","d50000","d5d5d5","d5ccc3","d5c3b1","d5ba9f","d5b18e","d5a87c","d59f6a","d59759","d58e47","d58535","d57c23","d57312","d56a00","d5d5d5","d4d5c3","d5d5b1","d5d59f","d5d58e","d4d57c","d5d56a","d5d559","d4d547","d5d535","d5d523","d5d512","d5d500","d5d5d5","ccd5c3","c3d5b1","bad59f","b1d58e","a8d57c","9fd56a","97d559","8ed547","85d535","7cd523","73d512","6ad500","d5d5d5","c3d5c3","b1d5b1","9fd59f","8ed58e","7cd57c","6ad56a","59d559","47d547","35d535","23d523","12d512","00d500","d5d5d5","c3d5cc","b1d5c3","9fd5ba","8ed5b1","7cd5a8","6ad59f","59d597","47d58e","35d585","23d57c","12d573","00d56a","d5d5d5","c3d5d4","b1d5d4","9fd5d5","8ed5d5","7cd5d4","6ad5d4","59d5d4","47d5d4","35d5d4","23d5d4","12d5d4","00d5d4","d5d5d5","c3ccd5","b1c3d5","9fbad5","8eb1d5","7ca8d5","6a9fd5","5997d5","478ed5","3585d5","237cd5","1273d5","006ad5","d5d5d5","c3c3d5","b1b1d5","9f9fd5","8e8ed5","7c7cd5","6a6ad5","5959d5","4747d5","3535d5","2323d5","1212d5","0000d5","d5d5d5","ccc3d5","c3b1d5","ba9fd5","b18ed5","a87cd5","9f6ad5","9759d5","8e47d5","8535d5","7c23d5","7312d5","6a00d5","d5d5d5","d5c3d4","d5b1d5","d59fd5","d58ed5","d57cd4","d56ad5","d559d5","d547d4","d535d5","d523d5","d512d5","d500d5","d5d5d5","d5c3cc","d5b1c3","d59fba","d58eb1","d57ca8","d56a9f","d55997","d5478e","d53585","d5237c","d51273","d5006a","d5d5d5","d5c3c3","d5b1b1","d59f9f","d58e8e","d57c7c","d56a6a","d55959","d54747","d53535","d52323","d51212","d50000"],
["eaeaea","ead6d6","eac3c3","eaafaf","ea9c9c","ea8888","ea7575","ea6161","ea4e4e","ea3a3a","ea2727","ea1313","ea0000","eaeaea","eae0d6","ead6c3","eacdaf","eac39c","eab988","eaaf75","eaa661","ea9c4e","ea923a","ea8827","ea7f13","ea7500","eaeaea","eaead6","eaeac3","eaeaaf","eaea9c","eaea88","eaea75","eaea61","eaea4e","eaea3a","eaea27","eaea13","eaea00","eaeaea","e0ead6","d6eac3","cdeaaf","c3ea9c","b9ea88","afea75","a6ea61","9cea4e","92ea3a","88ea27","7fea13","75ea00","eaeaea","d6ead6","c3eac3","afeaaf","9cea9c","88ea88","75ea75","61ea61","4eea4e","3aea3a","27ea27","13ea13","00ea00","eaeaea","d6eae0","c3ead6","afeacd","9ceac3","88eab9","75eaaf","61eaa6","4eea9c","3aea92","27ea88","13ea7f","00ea75","eaeaea","d6eaea","c3eaea","afeaea","9ceaea","88eaea","75eaea","61eaea","4eeaea","3aeaea","27eaea","13eaea","00eaea","eaeaea","d6e0ea","c3d6ea","afcdea","9cc3ea","88b9ea","75afea","61a6ea","4e9cea","3a92ea","2788ea","137fea","0075ea","eaeaea","d6d6ea","c3c3ea","afafea","9c9cea","8888ea","7575ea","6161ea","4e4eea","3a3aea","2727ea","1313ea","0000ea","eaeaea","e0d6ea","d6c3ea","cdafea","c39cea","b988ea","af75ea","a661ea","9c4eea","923aea","8827ea","7f13ea","7500ea","eaeaea","ead6ea","eac3ea","eaafea","ea9cea","ea88ea","ea75ea","ea61ea","ea4eea","ea3aea","ea27ea","ea13ea","ea00ea","eaeaea","ead6e0","eac3d6","eaafcd","ea9cc3","ea88b9","ea75af","ea61a6","ea4e9c","ea3a92","ea2788","ea137f","ea0075","eaeaea","ead6d6","eac3c3","eaafaf","ea9c9c","ea8888","ea7575","ea6161","ea4e4e","ea3a3a","ea2727","ea1313","ea0000"],
["ffffff","ffeaea","ffd5d5","ffbfbf","ffaaaa","ff9595","ff8080","ff6a6a","ff5555","ff4040","ff2a2a","ff1515","ff0000","ffffff","fff4ea","ffead5","ffdfbf","ffd5aa","ffca95","ffbf80","ffb56a","ffaa55","ff9f40","ff952a","ff8a15","ff8000","ffffff","ffffea","ffffd5","ffffbf","ffffaa","ffff95","ffff80","ffff6a","ffff55","ffff40","ffff2a","ffff15","ffff00","ffffff","f4ffea","eaffd5","dfffbf","d5ffaa","caff95","bfff80","b5ff6a","aaff55","9fff40","95ff2a","8aff15","80ff00","ffffff","eaffea","d5ffd5","bfffbf","aaffaa","95ff95","80ff80","6aff6a","55ff55","40ff40","2aff2a","15ff15","00ff00","ffffff","eafff4","d5ffea","bfffdf","aaffd4","95ffca","80ffbf","6affb5","55ffaa","40ff9f","2aff95","15ff8a","00ff80","ffffff","eaffff","d5ffff","bfffff","aaffff","95ffff","80ffff","6affff","55ffff","40ffff","2affff","15ffff","00ffff","ffffff","eaf4ff","d5eaff","bfdfff","aad5ff","95caff","80bfff","6ab5ff","55aaff","409fff","2a95ff","158aff","0080ff","ffffff","eaeaff","d5d5ff","bfbfff","aaaaff","9595ff","8080ff","6a6aff","5555ff","4040ff","2a2aff","1515ff","0000ff","ffffff","f4eaff","ead5ff","dfbfff","d5aaff","ca95ff","bf80ff","b56aff","aa55ff","9f40ff","952aff","8a15ff","8000ff","ffffff","ffeaff","ffd5ff","ffbfff","ffaaff","ff95ff","ff80ff","ff6aff","ff55ff","ff40ff","ff2aff","ff15ff","ff00ff","ffffff","ffeaf4","ffd5ea","ffbfdf","ffaad4","ff95ca","ff80bf","ff6ab5","ff55aa","ff409f","ff2a95","ff158a","ff007f","ffffff","ffeaea","ffd5d5","ffbfbf","ffaaaa","ff9595","ff8080","ff6a6a","ff5555","ff4040","ff2a2b","ff1515","ff0000"]
];
// the color we're currently editing
this.currentColor = "<% request.name %>";
this.currentColorValue = self.opener.document.getElementById(prefix+this.currentColor).style.backgroundColor;
this.squareSize = 15;
this.defaultPalette = this.brightness[this.brightness.length-1];
this.marquee = new Image();
this.marquee.src = "<% image name="/marquee" as="url" %>";
this.setPaletteMarquee = function(obj) {
if (this.lastPaletteMarquee)
this.lastPaletteMarquee.src = Antville.pixel.src;
obj.src = this.marquee.src;
this.lastPaletteMarquee = obj;
return;
}
this.setBrightnessMarquee = function(obj) {
if (this.lastBrightnessMarquee)
this.lastBrightnessMarquee.src = Antville.pixel.src;
obj.src = this.marquee.src;
this.lastBrightnessMarquee = obj;
return;
}
this.displayColor = function(obj) {
this.displayColorValue(obj);
var col = obj.style.backgroundColor;
// document.getElementById("result").value = col;
this.colors[this.currentColor] = document.getElementById("display").value;
if (this.currentColor == "bgcolor") {
var el = document.getElementById("demo");
if (el)
el.style.backgroundColor = col;
} else {
var el = document.getElementById(this.currentColor);
if (el)
el.style.color = col;
}
return;
}
/**
* Convert various color notations into one canonical six figure hex notation.
*/
this.parseColor = function(color) {
var rgb = new RegExp("rgb ?\\( ?([0-9^,]*), ?([0-9^,]*), ?([0-9^ \\)]*) ?\\)");
var result = color.match(rgb);
if (result) {
var R = parseInt(result[1]).toString(16);
var G = parseInt(result[2]).toString(16);
var B = parseInt(result[3]).toString(16);
if (R.length == 1) R="0"+R;
if (G.length == 1) G="0"+G;
if (B.length == 1) B="0"+B;
return R+G+B;
}
else if (color.indexOf("#") == 0)
return color.substring(1);
else
return color;
}
this.displayColorValue = function(obj) {
var col = obj.style.backgroundColor;
col = this.parseColor(col);
document.getElementById("display").value = col;
return;
}
this.updatePalette = function(obj, p) {
this.setPaletteMarquee(obj);
this.displayColor(obj);
var palette = this.brightness[p];
if (!this.colorPalette) {
this.colorPalette = new Array();
for (var i=0; i<palette.length; i++)
this.colorPalette[i] = document.getElementById("color"+i);
}
for (var i=0; i<palette.length; i++)
this.colorPalette[i].style.backgroundColor = "#"+palette[i];
this.selectedColor = obj;
return;
}
this.updateBrightness = function(obj, p) {
this.setBrightnessMarquee(obj);
this.displayColor(obj);
for (var i=0; i<this.brightness.length; i++)
document.getElementById("bright"+i).style.backgroundColor = "#"+this.brightness[i][p];
return;
}
this.setCurrentColors = function() {
for (var name in this.colors) {
var col = this.colors[name];
if (name == "bgcolor")
document.getElementById("demo").style.backgroundColor = col;
else
document.getElementById(name).style.color = col;
}
}
this.setCurrentColor = function() {
var col = this.colors[this.currentColor];
if (col == null)
col = this.currentColorValue;
col = this.parseColor(col);
for (var i=this.brightness.length-1; i>=0; i--) {
for (var j=0; j<this.brightness[i].length; j++) {
if (this.brightness[i][j] == col) {
var c = document.getElementById("color"+j);
var b = document.getElementById("bright"+i);
this.updateBrightness(c, j);
this.updatePalette(b, i);
return;
}
}
}
return;
}
this.setDropdown = function() {
var select = document.getElementById("dropdown");
for (var i=0; i<select.options.length; i++) {
if (select.options[i].value == this.currentColor) {
select.selectedIndex = i;
break;
}
}
return;
}
this.setDropDownColor = function(select) {
this.currentColor = select.options[select.selectedIndex].value;
this.setCurrentColor();
return;
}
this.submit = function() {
var ref = self.opener.document;
for (var i in this.colors) {
var col = this.colors[i];
col = this.parseColor(col);
ref.getElementById(prefix+i).style.backgroundColor = "#"+col;
ref.getElementById(valuePrefix+i).value = col;
}
this.cancel();
return;
}
this.cancel = function() {
self.close();
return;
}
return this;
}
Antville.ColorPicker = new Antville.ColorPickerFactory();

View file

@ -1 +0,0 @@
<% param.editor %> <img src="<% image name="/pixel" as="url" %>" width="13" height="13" alt="" style="margin-left:5px;background-color:<% param.color %>;" title="Click to pick the <% param.text %> color" onclick="Antville.ColorPicker.open('<% param.name %>', '<% param.text %>', '<% param.skin %>');" id="Antville_ColorPicker_<% param.name %>" class="colorpickerWidget" />

View file

@ -46,9 +46,9 @@ HopObject.prototype.onRequest = function() {
} }
} }
autoLogin(); User.autoLogin();
res.handlers.membership = User.getMembership(); res.handlers.membership = User.getMembership();
if (User.getStatus() === User.BLOCKED) { if (User.getCurrentStatus() === User.BLOCKED) {
session.logout(); session.logout();
res.message = new Error(gettext("Sorry, your account has been disabled. Please contact the maintainer of this site for further information.")); res.message = new Error(gettext("Sorry, your account has been disabled. Please contact the maintainer of this site for further information."));
res.redirect(root.href()); res.redirect(root.href());
@ -114,15 +114,6 @@ res.abort(); */
return; return;
}; };
HopObject.prototype.onUnhandledMacro = function(name) {
return;
switch (name) {
default:
return this[name];
}
};
HopObject.prototype.touch = function() { HopObject.prototype.touch = function() {
return this.map({ return this.map({
modified: new Date, modified: new Date,
@ -205,6 +196,24 @@ HopObject.prototype.upload_macro = function(param, name) {
return; return;
}; };
HopObject.prototype.macro_macro = function(param, handler) {
var ctor = this.constructor;
if ([Story, Image, File, Poll].indexOf(ctor) > -1) {
var quote = function(str) {
if (/\s/.test(str)) {
str = '"' + str + '"';
}
return str;
};
res.encode("<% ");
res.write(handler || ctor.name.toLowerCase());
res.write(String.SPACE);
res.write(quote(this.name) || this._id);
res.encode(" %>");
}
return;
};
HopObject.prototype.getFormValue = function(name) { HopObject.prototype.getFormValue = function(name) {
if (req.isPost()) { if (req.isPost()) {
return req.postParams[name]; return req.postParams[name];
@ -327,7 +336,7 @@ HopObject.getFromPath = function(name, collection) {
} else { } else {
site = res.handlers.site; site = res.handlers.site;
} }
if (site) { if (site && site.getPermission("main")) {
return site[collection].get(name); return site[collection].get(name);
} }
return null; return null;

View file

@ -172,12 +172,9 @@ Image.prototype.url_macro = function() {
return res.write(this.url || this.getUrl()); return res.write(this.url || this.getUrl());
}; };
Image.prototype.code_macro = function() { Image.prototype.macro_macro = function() {
res.write("&lt;% "); return HopObject.prototype.macro_macro.call(this, null,
res.write(this.parent.constructor === Layout ? "layout.image " : "image "); this.parent.constructor === Layout ? "layout.image" : "image");
res.write(this.name);
res.write(" %&gt;");
return;
}; };
Image.prototype.thumbnail_macro = function() { Image.prototype.thumbnail_macro = function() {

View file

@ -1,7 +1,7 @@
<% #main %> <% #main %>
<p><% breadcrumbs %></p> <p><% breadcrumbs %></p>
<p>To insert this image into a story, comment or skin copy/paste the following <p>To insert this image into a story, comment or skin copy/paste the following
code: <pre><% image.code %></pre></p> code: <pre><% image.macro %></pre></p>
<table width="100%" border="0" cellspacing="0" cellpadding="0"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr> <tr>
<td colspan="2" class="small"> <td colspan="2" class="small">
@ -34,7 +34,7 @@ code: <pre><% image.code %></pre></p>
<table width="100%" cellspacing="0" cellpadding="0"> <table width="100%" cellspacing="0" cellpadding="0">
<tr> <tr>
<td colspan="2" class="small"> <td colspan="2" class="small">
<strong>Macro:</strong> <% image.code %> <strong>Macro:</strong> <% image.macro %>
<div class="ample"><strong>Format: </strong><% image.contentType %>, <div class="ample"><strong>Format: </strong><% image.contentType %>,
<% image.width %>&times;<% image.height %> pixels</div> <% image.width %>&times;<% image.height %> pixels</div>
</td> </td>

View file

@ -22,7 +22,7 @@
// $URL$ // $URL$
// //
defineConstants(Layout, "getModes", "default", "shared"); Layout.getModes = defineConstants(Layout, "default", "shared");
this.handleMetadata("title"); this.handleMetadata("title");
this.handleMetadata("description"); this.handleMetadata("description");

View file

@ -62,9 +62,10 @@ Members.prototype.link_macro = function(param, action, text) {
Members.prototype.main_action = function() { Members.prototype.main_action = function() {
res.data.title = gettext("Members of {0}", this._parent.title); res.data.title = gettext("Members of {0}", this._parent.title);
res.data.list = renderList(this, "mgrlistitem", 10, req.data.page); res.data.list = renderList(this, "Membership#members",
res.data.pager = renderPageNavigation(this, this.href(req.action), 10, 10, req.queryParams.page);
req.data.page); res.data.pager = renderPageNavigation(this, this.href(req.action),
10, req.queryParams.page);
res.data.body = this.renderSkinAsString("Members#main"); res.data.body = this.renderSkinAsString("Members#main");
res.handlers.site.renderSkin("page"); res.handlers.site.renderSkin("page");
return; return;
@ -136,8 +137,8 @@ Members.prototype.logout_action = function() {
session.user.name); session.user.name);
session.logout(); session.logout();
delete session.data.referrer; delete session.data.referrer;
res.setCookie("avUsr", ""); res.setCookie(User.COOKIE, String.EMPTY);
res.setCookie("avPw", ""); res.setCookie(User.HASHCOOKIE, String.EMPTY);
} }
res.redirect(this._parent.href()); res.redirect(this._parent.href());
return; return;

View file

@ -11,6 +11,128 @@
<% response.list %> <% response.list %>
<% response.pager %> <% response.pager %>
<% #login %>
<script type="text/javascript">
$(function() {
$("#submit").click(function() {
var token = "<% session.token %>";
var name = $("#name").val();
var password = $("#password").val();
$("input:password").val("");
$.ajax({
async: false,
url: '<% members.href salt.js %>',
data: "user=" + encodeURIComponent(name),
dataType: "json",
success: function(salt) {
$("#digest").val($.md5($.md5(password + salt) + token));
}
});
return true;
});
});
</script>
<form id="login" method="post" action="<% response.action %>">
<input type="hidden" name="digest" id="digest" />
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="small">Username:</td>
<td nowrap="nowrap">
<input type="text" name="name" id="name" size="15" tabindex="1"
value="<% request.name %>" />
</td>
<td rowspan="4" nowrap="nowrap"> </td>
<td class="small">
<% members.link register "Not registered yet" %>
</td>
</tr>
<tr>
<td class="small" nowrap="nowrap">Password:</td>
<td>
<input type="password" name="password" id="password" size="15" tabindex="2" />
</td>
<td class="small">
<% members.link sendpwd "Forgot your password?" %>
</td>
</tr>
<tr>
<td nowrap="nowrap"> </td>
<td colspan="2" class="small">
<input type="checkbox" id="remember" name="remember" tabindex="3"
<% if <% request.remember %> is "on" then 'checked="checked"' %> />
<label for="remember">Remember me</label>
</td>
</tr>
<tr>
<td nowrap="nowrap"> </td>
<td colspan="2"><br />
<button type="submit" id="submit" name="login" value="1"
tabindex="4">login</button>
</td>
</tr>
</table>
</form>
<% #register %>
<script type="text/javascript">
$(function() {
$("#submit").click(function() {
var token = "<% session.token %>";
var password = $("#password").val();
var passwordConfirm = $("#passwordConfirm").val();
$("input:password").val("");
// Check both passwords but let the server do the error handling
if (!password || !passwordConfirm) {
return true;
} else if (password !== passwordConfirm) {
$("#password1").val(0);
$("#password2").val(1);
return true;
}
var hash = $.md5(password + token);
$("#hash").val(hash);
return true;
});
});
</script>
<form method="post" action="<% response.action %>">
<input type="hidden" name="hash" id="hash" />
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="small" nowrap="nowrap">Username:</td>
<td nowrap="nowrap">
<input type="text" name="name" value="<% request.name %>" />
</td>
</tr>
<tr>
<td class="small" valign="top" nowrap="nowrap">e-mail:</td>
<td>
<input type="text" name="email" value="<% request.email %>" />
</td>
</tr>
<tr>
<td class="small" nowrap="nowrap">Password:</td>
<td nowrap="nowrap">
<input type="password" name="password" id="password" />
</td>
</tr>
<tr>
<td class="small" nowrap="nowrap">Confirm password:</td>
<td nowrap="nowrap">
<input type="password" name="passwordConfirm" id="passwordConfirm" />
</td>
</tr>
<tr>
<td nowrap="nowrap">&nbsp;</td>
<td nowrap="nowrap"><br />
<button type="submit" id="submit" name="register"
value="register">Register</button>
<button type="submit" name="cancel" value="cancel">Cancel</button>
</td>
</tr>
</table>
</form>
<% #add %> <% #add %>
<form method="post" action="<% response.action %>"> <form method="post" action="<% response.action %>">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">

View file

@ -22,7 +22,7 @@
// $URL$ // $URL$
// //
defineConstants(Membership, "getRoles", "Subscriber", "Contributor", Membership.getRoles = defineConstants(Membership, "Subscriber", "Contributor",
"Manager", "Owner"); "Manager", "Owner");
Membership.prototype.constructor = function(user, role) { Membership.prototype.constructor = function(user, role) {
@ -50,21 +50,6 @@ Membership.prototype.getPermission = function(action) {
return true; return true;
}; };
Membership.prototype.update = function(data) {
if (!data.role) {
throw Error(gettext("Please choose a role for this member."));
} else if (this.user === session.user) {
throw Error(gettext("Sorry, you are not allowed to edit your own membership."));
} else if (data.role !== this.role) {
this.role = data.role;
this.touch();
/* FIXME: sendMail(root.sys_email, this.user.email,
getMessage("mail.statusChange", this.site.title),
this.renderSkinAsString("mailstatuschange"));*/
}
return;
};
Membership.prototype.edit_action = function() { Membership.prototype.edit_action = function() {
if (req.postParams.save) { if (req.postParams.save) {
try { try {
@ -84,6 +69,29 @@ Membership.prototype.edit_action = function() {
return; return;
}; };
Membership.prototype.getFormOptions = function(name) {
switch (name) {
case "role":
return Membership.getRoles();
}
return;
};
Membership.prototype.update = function(data) {
if (!data.role) {
throw Error(gettext("Please choose a role for this member."));
} else if (this.user === session.user) {
throw Error(gettext("Sorry, you are not allowed to edit your own membership."));
} else if (data.role !== this.role) {
this.role = data.role;
this.touch();
/* FIXME: sendMail(root.sys_email, this.user.email,
getMessage("mail.statusChange", this.site.title),
this.renderSkinAsString("mailstatuschange"));*/
}
return;
};
Membership.prototype.contact_action = function() { Membership.prototype.contact_action = function() {
if (req.postParams.send) { if (req.postParams.send) {
try { try {
@ -109,28 +117,6 @@ Membership.prototype.contact_action = function() {
return; return;
}; };
Membership.prototype.delete_action = function() {
if (req.postParams.proceed) {
try {
var url = this._parent.href();
Membership.remove(this);
res.message = gettext("Successfully deleted the membership.");
res.redirect(url);
} catch(ex) {
res.message = ex;
app.log(ex);
}
}
res.data.action = this.href(req.action);
res.data.title = gettext("Delete membership: {0}", this.name);
res.data.body = this.renderSkinAsString("delete", {
text: gettext('You are about to delete the membership {0}', this.name)
});
this.site.renderSkin("page");
return;
};
Membership.prototype.getMacroHandler = function(name) { Membership.prototype.getMacroHandler = function(name) {
switch (name) { switch (name) {
case "creator": case "creator":
@ -138,18 +124,71 @@ Membership.prototype.getMacroHandler = function(name) {
} }
}; };
Membership.prototype.link_filter = function(value, param) {
return HopObject.prototype.link_filter.call(this, value,
param, this.creator.url);
};
Membership.prototype.email_macro = function(param) { Membership.prototype.email_macro = function(param) {
throw Error("Due to privacy reasons the display of e-mail addresses is disabled.") throw Error("Due to privacy reasons the display of e-mail addresses is disabled.")
}; };
Membership.prototype.getFormOptions = function(name) { Membership.prototype.status_macro = function() {
switch (name) { this.role || (res.handlers.members = {});
case "role": this.renderSkin(session.user ? "Membership#status" : "Membership#login");
return Membership.getRoles();
}
return; return;
}; };
Membership.getByName = function(name) {
var site = res.handlers.site;
if (site) {
return site.members.get(name);
}
return null;
};
Membership.require = function(role) {
var roles = [Membership.SUBSCRIBER, Membership.CONTRIBUTOR,
Membership.MANAGER, Membership.OWNER];
if (role && res.handlers.membership) {
return roles.indexOf(res.handlers.membership.role) >= roles.indexOf(role);
}
return false;
};
Membership.remove = function(membership) {
/*if (!membership) {
throw Error(gettext("Please specify a membership you want to be removed."));
} else if (membership.role === Membership.OWNER) {
throw Error(gettext("Sorry, an owner of a site cannot be removed."));
}*/
membership.remove();
return;
};
/*
MAY_ADD_STORY = 1;
MAY_VIEW_ANYSTORY = 2;
MAY_EDIT_ANYSTORY = 4;
MAY_DELETE_ANYSTORY = 8;
MAY_ADD_COMMENT = 16;
MAY_EDIT_ANYCOMMENT = 32;
MAY_DELETE_ANYCOMMENT = 64;
MAY_ADD_IMAGE = 128;
MAY_EDIT_ANYIMAGE = 256;
MAY_DELETE_ANYIMAGE = 512;
MAY_ADD_FILE = 1024;
MAY_EDIT_ANYFILE = 2048;
MAY_DELETE_ANYFILE= 4096;
MAY_VIEW_STATS = 8192;
MAY_EDIT_PREFS = 16384;
MAY_EDIT_LAYOUTS = 32768;
MAY_EDIT_MEMBERS = 65536;
EDITABLEBY_ADMINS = 0;
EDITABLEBY_CONTRIBUTORS = 1;
EDITABLEBY_SUBSCRIBERS = 2;
Membership.getLevel = function(role) { Membership.getLevel = function(role) {
if (!role) { if (!role) {
var membership = User.getMembership(); var membership = User.getMembership();
@ -168,45 +207,6 @@ Membership.getLevel = function(role) {
} }
}; };
Membership.getByName = function(name) {
var site = res.handlers.site;
if (site) {
return site.members.get(name);
}
return null;
};
Membership.require = function(role) {
var roles = [Membership.SUBSCRIBER, Membership.CONTRIBUTOR,
Membership.MANAGER, Membership.OWNER];
if (role && res.handlers.membership) {
return roles.indexOf(res.handlers.membership.role) >= roles.indexOf(role);
}
return false;
/* if (role && res.handlers.membership) {
return Membership.getLevel(res.handlers.membership.role) -
Membership.getLevel(role) >= 0;
}
return false; */
};
Membership.remove = function(membership) {
/*if (!membership) {
throw Error(gettext("Please specify a membership you want to be removed."));
} else if (membership.role === Membership.OWNER) {
throw Error(gettext("Sorry, an owner of a site cannot be removed."));
}*/
membership.remove();
return;
};
Membership.prototype.status_macro = function() {
this.role || (res.handlers.members = {});
this.renderSkin(session.user ? "Membership#status" : "Membership#login");
return;
};
/*
Membership.getRoles = function() { Membership.getRoles = function() {
return [{ return [{
display: Membership.SUBSCRIBER, display: Membership.SUBSCRIBER,

View file

@ -16,9 +16,9 @@
## See the License for the specific language governing permissions and ## See the License for the specific language governing permissions and
## limitations under the License. ## limitations under the License.
## ##
## $Revision$ ## $Revision:3355 $
## $LastChangedBy$ ## $LastChangedBy:piefke3000 $
## $LastChangedDate$ ## $LastChangedDate:2007-10-11 15:38:29 +0200 (Thu, 11 Oct 2007) $
## $URL$ ## $URL$
## ##
@ -61,7 +61,7 @@ polls.order = created desc
images = collection(Image) images = collection(Image)
images.local = site_id images.local = site_id
images.foreign = site_id images.foreign = parent_id
images.local.1 = creator_id images.local.1 = creator_id
images.foreign.1 = creator_id images.foreign.1 = creator_id
images.filter = prototype = 'Image' and parent_type = 'Site' images.filter = prototype = 'Image' and parent_type = 'Site'

View file

@ -2,7 +2,7 @@
You're not logged in <% site.members.link login prefix="... " %> You're not logged in <% site.members.link login prefix="... " %>
<% #status %> <% #status %>
Logged in as <% username as="link" %><br /> Logged in as <% membership.name | membership.link %><br />
<% membership.role prefix="(" suffix=")<br />" %> <% membership.role prefix="(" suffix=")<br />" %>
<% members.link edit "edit your profile" prefix="...&nbsp;" suffix="<br />" %> <% members.link edit "edit your profile" prefix="...&nbsp;" suffix="<br />" %>
<% site.link subscribe text="subscribe to this site" prefix="...&nbsp;" suffix="<br />" %> <% site.link subscribe text="subscribe to this site" prefix="...&nbsp;" suffix="<br />" %>

View file

@ -22,7 +22,7 @@
// $URL$ // $URL$
// //
defineConstants(Poll, "getStatus", "closed", "readonly", "open"); Poll.getStatus = defineConstants(Poll, "closed", "readonly", "open");
Poll.prototype.constructor = function(question) { Poll.prototype.constructor = function(question) {
this.question = question; this.question = question;

View file

@ -41,7 +41,7 @@
<td rowspan="2" width="5"></td>' <td rowspan="2" width="5"></td>'
%> %>
<td colspan="3" class="small"> <td colspan="3" class="small">
<strong>Macro:</strong> &lt;% poll <% poll.id %> %&gt; <strong>Macro:</strong> <% poll.macro %>
<div class="ample"><strong>Status:</strong> <div class="ample"><strong>Status:</strong>
<% ngettext "{0} vote" "{0} votes" <% poll.votes %> %> <% ngettext "{0} vote" "{0} votes" <% poll.votes %> %>
</td> </td>

View file

@ -22,7 +22,7 @@
// $URL$ // $URL$
// //
defineConstants(Root, "getScopes", markgettext("every site"), Root.getScopes = defineConstants(Root, markgettext("every site"),
markgettext("public sites"), markgettext("trusted sites"), markgettext("public sites"), markgettext("trusted sites"),
markgettext("no site")); markgettext("no site"));
@ -191,39 +191,6 @@ Root.prototype.rss_xml_action = function() {
return; return;
}; };
Root.prototype.main_css_action = function() {
res.dependsOn(res.handlers.layout.modifytime);
res.dependsOn(res.handlers.layout.skins.getSkinSource("Root", "style"));
res.digest();
res.contentType = "text/css";
this.renderSkin("style");
return;
};
Root.prototype.main_js_action = function() {
res.dependsOn(res.handlers.layout.modifytime);
res.dependsOn(res.handlers.layout.skins.getSkinSource("Root", "javascript"));
res.digest();
res.contentType = "text/javascript";
root.renderSkin("javascript");
root.renderSkin("systemscripts");
return;
};
Root.prototype.sitecounter_macro = function(param) {
if (param.count == "all")
var size = root.size();
else
var size = this.publicSites.size();
if (size == 0)
res.write(param.no ? param.no : size);
else if (size == 1)
res.write(param.one ? param.one : size);
else
res.write(size + (param.more ? param.more : ""));
return;
};
Root.prototype.getCreationPermission = function() { Root.prototype.getCreationPermission = function() {
var user; var user;
if (!(user = session.user)) { if (!(user = session.user)) {
@ -235,10 +202,8 @@ Root.prototype.getCreationPermission = function() {
switch (root.creationScope) { switch (root.creationScope) {
case User.PRIVILEGEDUSERS: case User.PRIVILEGEDUSERS:
return false; return false;
case User.TRUSTEDUSERS: case User.TRUSTEDUSERS:
return User.require(User.TRUSTED); return User.require(User.TRUSTED);
default: default:
case User.ALLUSERS: case User.ALLUSERS:
if (root.qualifyingPeriod) { if (root.qualifyingPeriod) {
@ -345,7 +310,7 @@ Root.prototype.renderSitelist = function(limit, show, scroll) {
while (cnt < limit && idx < size) { while (cnt < limit && idx < size) {
var s = collection.get(idx++); var s = collection.get(idx++);
if (!s.blocked && s.online) { if (!s.blocked && s.online) {
s.renderSkin("preview"); s.renderSkin("Site#list");
cnt++; cnt++;
} }
} }

View file

@ -43,6 +43,7 @@ _children.accessname = name
_children.order = modified desc _children.order = modified desc
sites = collection(Site) sites = collection(Site)
sites.accessname = name
sites.filter = name <> '${name}' and mode <> 'closed' and mode <> 'restricted' and status <> 'blocked' sites.filter = name <> '${name}' and mode <> 'closed' and mode <> 'restricted' and status <> 'blocked'
sites.order = name asc sites.order = name asc

View file

@ -0,0 +1,278 @@
Antville = {};
Antville.prefix = "Antville_";
Antville.encode = function(str) {
var chars = ["&", "<", ">", '"'];
for (var i in chars) {
var c = chars[i];
var re = new RegExp(c, "g");
str = str.replace(re, "&#" + c.charCodeAt() + ";");
}
return str;
};
Antville.decode = function(str) {
return str.replace(/&amp;/g, "&");
};
Antville.Referrer = function(url, text, count) {
this.url = url;
this.text = text;
this.count = count;
this.compose = function(key, prefix) {
var query = new Antville.Query(this.url);
if (query[key]) {
if (prefix == null)
prefix = "";
return prefix + Antville.encode(query[key]);
}
return this.text;
}
return this;
};
Antville.Query = function(str) {
if (str == undefined)
var str = location.search.substring(1);
else if (str.indexOf("?") > -1)
var str = str.split("?")[1];
if (str == "")
return this;
var parts = Antville.decode(decodeURIComponent(str)).split("&");
for (var i in parts) {
var pair = parts[i].split("=");
var key = pair[0];
if (key) {
key = key.replace(/\+/g, " ");
var value = pair[1];
if (value)
value = value.replace(/\+/g, " ");
this[key] = value;
}
}
return this;
};
Antville.Filter = function(def, key) {
this.key = key;
if (def == null)
this.items = [];
else if (def instanceof Array)
this.items = def;
else
this.items = def.replace(/\r/g, "\n").split("\n");
this.test = function(str) {
if (!str)
return false;
str = str.replace(/&amp;/g, "&");
for (var n in this.items) {
var re = new RegExp(this.items[n], "i");
if (re.test(str))
return true;
}
return false;
}
return this;
};
/**
* MD5 (Message-Digest Algorithm)
* http://www.webtoolkit.info/
*/
jQuery.md5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
function AddUnsigned(lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
if (lX4 & lY4) {
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
}
if (lX4 | lY4) {
if (lResult & 0x40000000) {
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
}
} else {
return (lResult ^ lX8 ^ lY8);
}
}
function F(x,y,z) { return (x & y) | ((~x) & z); }
function G(x,y,z) { return (x & z) | (y & (~z)); }
function H(x,y,z) { return (x ^ y ^ z); }
function I(x,y,z) { return (y ^ (x | (~z))); }
function FF(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function GG(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function HH(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function II(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function ConvertToWordArray(string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWords_temp1=lMessageLength + 8;
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
var lWordArray=Array(lNumberOfWords-1);
var lBytePosition = 0;
var lByteCount = 0;
while ( lByteCount < lMessageLength ) {
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
return lWordArray;
};
function WordToHex(lValue) {
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
for (lCount = 0;lCount<=3;lCount++) {
lByte = (lValue>>>(lCount*8)) & 255;
WordToHexValue_temp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
}
return WordToHexValue;
};
function Utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
};
var x=Array();
var k,AA,BB,CC,DD,a,b,c,d;
var S11=7, S12=12, S13=17, S14=22;
var S21=5, S22=9 , S23=14, S24=20;
var S31=4, S32=11, S33=16, S34=23;
var S41=6, S42=10, S43=15, S44=21;
string = Utf8Encode(string);
x = ConvertToWordArray(string);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k=0;k<x.length;k+=16) {
AA=a; BB=b; CC=c; DD=d;
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
a=AddUnsigned(a,AA);
b=AddUnsigned(b,BB);
c=AddUnsigned(c,CC);
d=AddUnsigned(d,DD);
}
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
return temp.toLowerCase();
};

View file

@ -1,465 +0,0 @@
Antville = {};
Antville.prefix = "Antville_";
Antville.pixel = new Image();
Antville.pixel.src = '<% image name="/pixel" as="url" %>';
Antville.colors = {"aliceblue": true, "antiquewhite": true, "aqua": true, "aquamarine": true, "azure": true, "beige": true, "bisque": true, "black": true, "blanchedalmond": true, "blue": true, "blueviolet": true, "brown": true, "burlywood": true, "cadetblue": true, "chartreuse": true, "chocolate": true, "coral": true, "cornflowerblue": true, "cornsilk": true, "crimson": true, "cyan": true, "darkblue": true, "darkcyan": true, "darkgoldenrod": true, "darkgray": true, "darkgreen": true, "darkkhaki": true, "darkmagenta": true, "darkolivegreen": true, "darkorange": true, "darkorchid": true, "darkred": true, "darksalmon": true, "darkseagreen": true, "darkslateblue": true, "darkslategray": true, "darkturquoise": true, "darkviolet": true, "deeppink": true, "deepskyblue": true, "dimgray": true, "dodgerblue": true, "firebrick": true, "floralwhite": true, "forestgreen": true, "fuchsia": true, "gainsboro": true, "ghostwhite": true, "gold": true, "goldenrod": true, "gray": true, "green": true, "greenyellow": true, "honeydew": true, "hotpink": true, "indianred ": true, "indigo ": true, "ivory": true, "khaki": true, "lavender": true, "lavenderblush": true, "lawngreen": true, "lemonchiffon": true, "lightblue": true, "lightcoral": true, "lightcyan": true, "lightgoldenrodyellow": true, "lightgrey": true, "lightgreen": true, "lightpink": true, "lightsalmon": true, "lightseagreen": true, "lightskyblue": true, "lightslateblue": true, "lightslategray": true, "lightsteelblue": true, "lightyellow": true, "lime": true, "limegreen": true, "linen": true, "magenta": true, "maroon": true, "mediumaquamarine": true, "mediumblue": true, "mediumorchid": true, "mediumpurple": true, "mediumseagreen": true, "mediumslateblue": true, "mediumspringgreen": true, "mediumturquoise": true, "mediumvioletred": true, "midnightblue": true, "mintcream": true, "mistyrose": true, "moccasin": true, "navajowhite": true, "navy": true, "oldlace": true, "olive": true, "olivedrab": true, "orange": true, "orangered": true, "orchid": true, "palegoldenrod": true, "palegreen": true, "paleturquoise": true, "palevioletred": true, "papayawhip": true, "peachpuff": true, "peru": true, "pink": true, "plum": true, "powderblue": true, "purple": true, "red": true, "rosybrown": true, "royalblue": true, "saddlebrown": true, "salmon": true, "sandybrown": true, "seagreen": true, "seashell": true, "sienna": true, "silver": true, "skyblue": true, "slateblue": true, "slategray": true, "snow": true, "springgreen": true, "steelblue": true, "tan": true, "teal": true, "thistle": true, "tomato": true, "turquoise": true, "violet": true, "violetred": true, "wheat": true, "white": true, "whitesmoke": true, "yellow": true, "yellowgreen": true};
Antville.ColorPickerFactory = function() {
this.prefix = Antville.prefix + "ColorPicker_";
this.valuePrefix = Antville.prefix + "ColorValue_";
this.open = function(name, text, skin) {
if (skin == "colorpickerExt")
var cpWindow = window.open("<% site.href colorpicker %>?name=" + name + "&text=" + text + "&skin=" + skin, Antville.ColorPicker.prefix, "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=480,height=360");
else
var cpWindow = window.open("<% site.href colorpicker %>?name=" + name + "&text=" + text + "&skin=" + skin, Antville.ColorPicker.prefix, "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=350,height=320");
}
this.set = function(name, color) {
var prefix = Antville.ColorPicker.prefix;
var valuePrefix = Antville.ColorPicker.valuePrefix;
var color = Antville.parseColor(color);
if (color)
document.getElementById(prefix + name).style.backgroundColor = color;
else
color = Antville.parseColor(document.getElementById(prefix + name).style.backgroundColor);
if (color.indexOf("#") == 0)
color = color.substr(1,color.length-1);
document.getElementById(valuePrefix + name).value = color;
return;
}
return this;
};
Antville.ColorPicker = new Antville.ColorPickerFactory();
Antville.encode = function(str) {
var chars = ["&", "<", ">", '"'];
for (var i in chars) {
var c = chars[i];
var re = new RegExp(c, "g");
str = str.replace(re, "&#" + c.charCodeAt() + ";");
}
return str;
};
Antville.decode = function(str) {
return str.replace(/&amp;/g, "&");
};
Antville.parseColor = function(color) {
var c = color.toLowerCase();
if (Antville.colors[c])
return c;
var rgb = new RegExp("rgb ?\\( ?([0-9^,]*), ?([0-9^,]*), ?([0-9^ \\)]*) ?\\)");
var result = color.match(rgb);
if (result) {
var R = parseInt(result[1]).toString(16);
var G = parseInt(result[2]).toString(16);
var B = parseInt(result[3]).toString(16);
if (R.length == 1) R="0"+R;
if (G.length == 1) G="0"+G;
if (B.length == 1) B="0"+B;
return "#"+R+G+B;
}
if (c.indexOf("#") == 0)
c = c.substr(1,c.length-1);
if (c.length == 6) {
var nonhex = new RegExp("[^0-9,a-f]");
nonhex.ignoreCase = true;
var found = c.match(nonhex);
if (!found)
return "#" + c;
}
return;
};
Antville.Referrer = function(url, text, count) {
this.url = url;
this.text = text;
this.count = count;
this.compose = function(key, prefix) {
var query = new Antville.Query(this.url);
if (query[key]) {
if (prefix == null)
prefix = "";
return prefix + Antville.encode(query[key]);
}
return this.text;
}
return this;
};
Antville.Query = function(str) {
if (str == undefined)
var str = location.search.substring(1);
else if (str.indexOf("?") > -1)
var str = str.split("?")[1];
if (str == "")
return this;
var parts = Antville.decode(decodeURIComponent(str)).split("&");
for (var i in parts) {
var pair = parts[i].split("=");
var key = pair[0];
if (key) {
key = key.replace(/\+/g, " ");
var value = pair[1];
if (value)
value = value.replace(/\+/g, " ");
this[key] = value;
}
}
return this;
};
Antville.Filter = function(def, key) {
this.key = key;
if (def == null)
this.items = [];
else if (def instanceof Array)
this.items = def;
else
this.items = def.replace(/\r/g, "\n").split("\n");
this.test = function(str) {
if (!str)
return false;
str = str.replace(/&amp;/g, "&");
for (var n in this.items) {
var re = new RegExp(this.items[n], "i");
if (re.test(str))
return true;
}
return false;
}
return this;
};
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
*/
Antville.sha256 = function(s) {
var chrsz = 8;
var hexcase = 0;
function safe_add (x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function S (X, n) { return ( X >>> n ) | (X << (32 - n)); }
function R (X, n) { return ( X >>> n ); }
function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); }
function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); }
function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); }
function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); }
function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); }
function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); }
function core_sha256 (m, l) {
var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2);
var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
var W = new Array(64);
var a, b, c, d, e, f, g, h, i, j;
var T1, T2;
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >> 9) << 4) + 15] = l;
for ( var i = 0; i<m.length; i+=16 ) {
a = HASH[0];
b = HASH[1];
c = HASH[2];
d = HASH[3];
e = HASH[4];
f = HASH[5];
g = HASH[6];
h = HASH[7];
for ( var j = 0; j<44; j++) {
if (j < 16) W[j] = m[j + i];
else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
T2 = safe_add(Sigma0256(a), Maj(a, b, c));
h = g;
g = f;
f = e;
e = safe_add(d, T1);
d = c;
c = b;
b = a;
a = safe_add(T1, T2);
}
HASH[0] = safe_add(a, HASH[0]);
HASH[1] = safe_add(b, HASH[1]);
HASH[2] = safe_add(c, HASH[2]);
HASH[3] = safe_add(d, HASH[3]);
HASH[4] = safe_add(e, HASH[4]);
HASH[5] = safe_add(f, HASH[5]);
HASH[6] = safe_add(g, HASH[6]);
HASH[7] = safe_add(h, HASH[7]);
}
return HASH;
}
function str2binb (str) {
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz) {
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
}
return bin;
}
function Utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
function binb2hex (binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++) {
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
s = Utf8Encode(s);
return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
};
/**
* MD5 (Message-Digest Algorithm)
* http://www.webtoolkit.info/
*/
jQuery.md5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
function AddUnsigned(lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
if (lX4 & lY4) {
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
}
if (lX4 | lY4) {
if (lResult & 0x40000000) {
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
}
} else {
return (lResult ^ lX8 ^ lY8);
}
}
function F(x,y,z) { return (x & y) | ((~x) & z); }
function G(x,y,z) { return (x & z) | (y & (~z)); }
function H(x,y,z) { return (x ^ y ^ z); }
function I(x,y,z) { return (y ^ (x | (~z))); }
function FF(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function GG(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function HH(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function II(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
function ConvertToWordArray(string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWords_temp1=lMessageLength + 8;
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
var lWordArray=Array(lNumberOfWords-1);
var lBytePosition = 0;
var lByteCount = 0;
while ( lByteCount < lMessageLength ) {
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
return lWordArray;
};
function WordToHex(lValue) {
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
for (lCount = 0;lCount<=3;lCount++) {
lByte = (lValue>>>(lCount*8)) & 255;
WordToHexValue_temp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
}
return WordToHexValue;
};
function Utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
};
var x=Array();
var k,AA,BB,CC,DD,a,b,c,d;
var S11=7, S12=12, S13=17, S14=22;
var S21=5, S22=9 , S23=14, S24=20;
var S31=4, S32=11, S33=16, S34=23;
var S41=6, S42=10, S43=15, S44=21;
string = Utf8Encode(string);
x = ConvertToWordArray(string);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k=0;k<x.length;k+=16) {
AA=a; BB=b; CC=c; DD=d;
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
a=AddUnsigned(a,AA);
b=AddUnsigned(b,BB);
c=AddUnsigned(c,CC);
d=AddUnsigned(d,DD);
}
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
return temp.toLowerCase();
};

View file

@ -22,11 +22,11 @@
// $URL$ // $URL$
// //
defineConstants(Site, "getStatus", "blocked", "regular", "trusted"); Site.getStatus = defineConstants(Site, "blocked", "regular", "trusted");
defineConstants(Site, "getModes", "closed", "restricted", "public", "open"); Site.getModes = defineConstants(Site, "closed", "restricted", "public", "open");
defineConstants(Site, "getPageModes", "days", "stories"); Site.getPageModes = defineConstants(Site, "days", "stories");
defineConstants(Site, "getCommentsModes", "disabled", "enabled"); Site.getCommentsModes = defineConstants(Site, "disabled", "enabled");
defineConstants(Site, "getArchiveModes", "closed", "public"); Site.getArchiveModes = defineConstants(Site, "closed", "public");
this.handleMetadata("archiveMode"); this.handleMetadata("archiveMode");
this.handleMetadata("commentsMode"); this.handleMetadata("commentsMode");
@ -88,7 +88,7 @@ Site.prototype.getPermission = function(action) {
case "rss.xml": case "rss.xml":
case "tags": case "tags":
return this.status !== Site.BLOCKED && return this.status !== Site.BLOCKED &&
User.require(User.REGULAR) && !User.require(User.BLOCKED) &&
Site.require(Site.PUBLIC) || Site.require(Site.PUBLIC) ||
Site.require(Site.RESTRICTED) && Site.require(Site.RESTRICTED) &&
Membership.require(Membership.SUBSCRIBER) || Membership.require(Membership.SUBSCRIBER) ||
@ -98,12 +98,12 @@ Site.prototype.getPermission = function(action) {
case "edit": case "edit":
case "referrers": case "referrers":
return this.status !== Site.BLOCKED && return this.status !== Site.BLOCKED &&
User.require(User.REGULAR) && !User.require(User.BLOCKED) &&
Membership.require(Membership.OWNER) || Membership.require(Membership.OWNER) ||
User.require(User.PRIVILEGED); User.require(User.PRIVILEGED);
case "subscribe": case "subscribe":
return this.status !== Site.BLOCKED && return this.status !== Site.BLOCKED &&
User.require(User.REGULAR) && !User.require(User.BLOCKED) &&
Site.require(Site.PUBLIC) && Site.require(Site.PUBLIC) &&
!Membership.require(Membership.SUBSCRIBER); !Membership.require(Membership.SUBSCRIBER);
case "unsubscribe": case "unsubscribe":
@ -201,10 +201,10 @@ Site.prototype.update = function(data) {
mode: data.mode || Site.PRIVATE, mode: data.mode || Site.PRIVATE,
webHookUrl: data.webHookUrl, webHookUrl: data.webHookUrl,
webHookEnabled: data.webHookEnabled ? true : false, webHookEnabled: data.webHookEnabled ? true : false,
pageMode: data.pageMode || 'days', pageMode: data.pageMode || Site.DAYS,
pageSize: parseInt(data.pageSize, 10) || 3, pageSize: parseInt(data.pageSize, 10) || 3,
commentsMode: data.commentsMode, commentsMode: data.commentsMode || Site.DISABLED,
archiveMode: data.archiveMode, archiveMode: data.archiveMode || Site.CLOSED,
timeZone: data.timeZone, timeZone: data.timeZone,
longDateFormat: data.longDateFormat, longDateFormat: data.longDateFormat,
shortDateFormat: data.shortDateFormat, shortDateFormat: data.shortDateFormat,
@ -228,8 +228,8 @@ Site.remove = function(site) {
}; };
Site.prototype.main_css_action = function() { Site.prototype.main_css_action = function() {
res.dependsOn(this.modifytime); res.dependsOn(this.modified);
res.dependsOn(res.handlers.layout.modifytime); res.dependsOn(res.handlers.layout.modified);
res.dependsOn(res.handlers.layout.skins.getSkinSource("Site", "style")); res.dependsOn(res.handlers.layout.skins.getSkinSource("Site", "style"));
res.digest(); res.digest();
res.contentType = "text/css"; res.contentType = "text/css";
@ -238,13 +238,13 @@ Site.prototype.main_css_action = function() {
}; };
Site.prototype.main_js_action = function() { Site.prototype.main_js_action = function() {
res.dependsOn(this.modifytime); res.dependsOn(this.modified);
res.dependsOn(res.handlers.layout.modifytime); res.dependsOn(res.handlers.layout.modified);
res.dependsOn(res.handlers.layout.skins.getSkinSource("Site", "javascript")); res.dependsOn(res.handlers.layout.skins.getSkinSource("Site", "javascript"));
res.digest(); res.digest();
res.contentType = "text/javascript"; res.contentType = "text/javascript";
this.renderSkin("javascript"); this.renderSkin("javascript");
root.renderSkin("systemscripts"); root.renderSkin("javascript");
return; return;
}; };
@ -523,7 +523,7 @@ Site.prototype.getMacroHandler = function(name) {
Site.prototype.list_macro = function(param, type) { Site.prototype.list_macro = function(param, type) {
switch (type) { switch (type) {
case "stories": case "stories":
if (this.stories["public"].size() < 1) { if (this.stories.featured.size() < 1) {
this.renderSkin("Site#welcome"); this.renderSkin("Site#welcome");
if (session.user) { if (session.user) {
if (session.user === this.creator) { if (session.user === this.creator) {
@ -567,39 +567,6 @@ Site.prototype.age_macro = function(param) {
return; return;
}; };
Site.prototype.history_macro = function(param, type) {
param.limit = Math.min(param.limit || 10, 20);
type || (type = param.show);
var stories = this.stories.recent;
var size = stories.size();
var counter = i = 0;
var item;
while (counter < param.limit && i < size) {
if (i % param.limit === 0) {
stories.prefetchChildren(i, param.limit);
}
item = stories.get(i);
i += 1;
switch (item.constructor) {
case Story:
if (type === "comments") {
continue;
}
break;
case Comment:
if (type === "stories" || item.story.mode === Story.PRIVATE ||
item.story.commentsMode === Story.CLOSED ||
this.commentsMode === Site.CLOSED) {
continue;
}
break;
}
item.renderSkin("Story#history");
counter += 1;
}
return;
};
Site.prototype.referrers_macro = function() { Site.prototype.referrers_macro = function() {
var date = new Date; var date = new Date;
date.setDate(date.getDate() - 1); date.setDate(date.getDate() - 1);
@ -810,70 +777,6 @@ Site.prototype.searchCreatetime_macro = function() {
return; return;
}; };
/** FIXME: to be removed!
* function saves new properties of site
* @param Obj Object containing the form values
* @param Obj User-Object modifying this site
* @throws Exception
*/
Site.prototype.evalPreferences = function(data, user) {
res.debug(data);
//res.abort();
return;
this.title = stripTags(param.title);
this.email = param.email;
if (this.online && !param.online)
this.lastoffline = new Date();
this.online = param.online ? 1 : 0;
this.enableping = param.enableping ? 1 : 0;
// store new preferences
var prefs = new HopObject();
for (var i in param) {
if (i.startsWith("properties_"))
prefs[i.substring(12)] = param[i];
}
prefs.days = !isNaN(parseInt(param.properties_days, 10)) ? parseInt(param.properties_days, 10) : 3;
prefs.discussions = param.properties_discussions ? 1 : 0;
prefs.usercontrib = param.properties_usercontrib ? 1 : 0;
prefs.archive = param.properties_archive ? 1 : 0;
// store selected locale
if (param.locale) {
var loc = param.locale.split("_");
prefs.language = loc[0];
prefs.country = loc.length == 2 ? loc[1] : null;
}
prefs.timezone = param.timezone;
prefs.longdateformat = param.longdateformat;
prefs.shortdateformat = param.shortdateformat;
// layout
this.layout = param.layout ? this.layouts.get(param.layout) : null;
// e-mail notification
prefs.notify_create = parseInt(param.notify_create, 10) || null;
prefs.notify_update = parseInt(param.notify_update, 10) || null;
prefs.notify_upload = parseInt(param.notify_upload, 10) || null;
// store preferences
this.properties.setAll(prefs);
// call the evalPreferences method of every module
for (var i in app.modules)
this.applyModuleMethod(app.modules[i], "evalPreferences", param);
// reset cached locale, timezone and dateSymbols
this.cache.locale = null;
this.cache.timezone = null;
this.cache.dateSymbols = null;
this.modifytime = new Date();
this.modifier = modifier;
};
Site.prototype.getLayouts = function() { Site.prototype.getLayouts = function() {
var result = []; var result = [];
this.layouts.forEach(function() { this.layouts.forEach(function() {

View file

@ -1,4 +1,5 @@
<% #main %> <% #main %>
<% list tobi/comments %>
<% site.list stories %> <% site.list stories %>
<% #preview %> <% #preview %>

View file

@ -8,7 +8,7 @@
<meta http-equiv="Content-Type" content="text/html" /> <meta http-equiv="Content-Type" content="text/html" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" /> <meta name="MSSmartTagsPreventParsing" content="TRUE" />
<script type="text/javascript" <script type="text/javascript"
src="<% file /jquery-1.1.3.1.pack.js url %>"></script> src="<% file /jquery-1.2.1.min.js url %>"></script>
<script type="text/javascript" src="<% site.href main.js %>"></script> <script type="text/javascript" src="<% site.href main.js %>"></script>
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
title="CSS Stylesheet" href="<% site.href main.css %>" /> title="CSS Stylesheet" href="<% site.href main.css %>" />
@ -67,8 +67,8 @@
<div class="boxheader">calendar</div> <div class="boxheader">calendar</div>
<div class="box"><% site.calendar %></div> <div class="box"><% site.calendar %></div>
<div class="boxheader">recent comments</div> <div class="boxheader">recent postings</div>
<div class="box"><% site.history comments %></div> <div class="box"><% list postings skin=Story#history %></div>
<div class="boxline"></div><br /> <div class="boxline"></div><br />
<div class="box"><% image /rss.png | site.link rss.xml %><br /> <div class="box"><% image /rss.png | site.link rss.xml %><br />

View file

@ -313,3 +313,61 @@ ul.skinmgrTree li div {
margin-left:20px; margin-left:20px;
margin-bottom:5px; margin-bottom:5px;
} }
/* Admin styles */
.pageTitle {
font-family:<% layout.value titlefont %>;
font-size:<% layout.value titlesize %>;
font-weight:bold;
color:<% layout.value titlecolor %>;
padding-bottom:10pt;
}
.label {
font-family: <% layout.value smallfont %>;
font-size: 7pt;
padding: 2px;
color: #ffffff;
text-transform: uppercase;
}
.regular {
display: none;
}
.blocked {
background-color: #000000;
}
.trusted, .User {
background-color: #0000cc;
}
.closed {
background-color: #cc0000;
}
.public, .Site {
background-color: #006600;
}
.Root, .privileged {
background-color: #ffcc00;
}
.flagLight {
font-family:<% layout.value smallfont %>;
font-size:7pt;
padding:2px;
color:#333333;
}
.sysmgrListitem {
margin-top:15px;
border-top:1px solid #dddddd;
}

View file

@ -16,9 +16,9 @@
## See the License for the specific language governing permissions and ## See the License for the specific language governing permissions and
## limitations under the License. ## limitations under the License.
## ##
## $Revision$ ## $Revision:3355 $
## $LastChangedBy$ ## $LastChangedBy:piefke3000 $
## $LastChangedDate$ ## $LastChangedDate:2007-10-11 15:38:29 +0200 (Thu, 11 Oct 2007) $
## $URL$ ## $URL$
## ##
@ -36,11 +36,11 @@ top.filter = prototype = 'Story' and status <> "closed" and requests > 0
top.order = requests desc top.order = requests desc
top.maxSize = 25 top.maxSize = 25
public = collection(Story) featured = collection(Story)
public.local = id featured.local = id
public.foreign = site_id featured.foreign = site_id
public.filter = prototype = 'Story' and status <> "closed" and mode <> "hidden" featured.filter = prototype = 'Story' and status <> "closed" and mode <> "hidden"
public.order = modified desc featured.order = modified desc
closed = collection(Story) closed = collection(Story)
closed.local = id closed.local = id
@ -48,18 +48,19 @@ closed.foreign site_id
closed.filter = prototype = 'Story' and status = 'closed' closed.filter = prototype = 'Story' and status = 'closed'
closed.order = created desc closed.order = created desc
all = collection(Story)
all.local = id
all.foreign = site_id
all.filter = status <> "closed"
all.order = modified desc
recent = collection(Story) recent = collection(Story)
recent.local = id recent.local = id
recent.foreign = site_id recent.foreign = site_id
recent.filter = status <> "closed" recent.filter = status <> "closed"
recent.order = modified desc recent.order = modified desc
recent.maxsize = 100 recent.maxSize = 100
comments = collection(Comment)
comments.local = id
comments.foreign = site_id
comments.filter = prototype = 'Comment' and status <> 'closed' and status <> 'pending'
comments.order = modified desc
comments.maxSize = 100
tags = collection(Tag) tags = collection(Tag)
tags.accessname = name tags.accessname = name

View file

@ -22,10 +22,11 @@
// $URL$ // $URL$
// //
defineConstants(Story, "getStatus", "closed", "public", "shared", "open"); Story.getStatus = defineConstants(Story, "closed", "public", "shared", "open");
defineConstants(Story, "getModes", "hidden", "featured"); Story.getModes = defineConstants(Story, "hidden", "featured");
defineConstants(Story, "getCommentsModes", "closed", Story.getCommentsModes = defineConstants(Story, "closed",
"readonly", "moderated", "open"); "readonly", "moderated", "open");
this.handleMetadata("title"); this.handleMetadata("title");
this.handleMetadata("text"); this.handleMetadata("text");
@ -182,9 +183,7 @@ Story.prototype.update = function(data) {
this.setContent(data); this.setContent(data);
//this.setTags(data.tags || data.tag_array) //this.setTags(data.tags || data.tag_array)
this.commentsMode = data.commentsMode; this.commentsMode = data.commentsMode;
if (this.creator === session.user) { this.mode = data.mode;
this.mode = data.mode;
}
if (this.status === Story.PRIVATE && data.status !== Story.PRIVATE) { if (this.status === Story.PRIVATE && data.status !== Story.PRIVATE) {
if (delta > 50) { if (delta > 50) {
site.lastUpdate = new Date; site.lastUpdate = new Date;
@ -238,7 +237,7 @@ Story.prototype.rotate_action = function() {
this.mode = Story.FEATURED; this.mode = Story.FEATURED;
this.status = Story.CLOSED; this.status = Story.CLOSED;
} }
return res.redirect(this._parent.href()); return res.redirect(req.data.http_referer || this._parent.href());
}; };
Story.prototype.comment_action = function() { Story.prototype.comment_action = function() {
@ -301,7 +300,7 @@ Story.prototype.summary_macro = function(param) {
Story.prototype.comments_macro = function(param, mode) { Story.prototype.comments_macro = function(param, mode) {
var story = this.story || this; var story = this.story || this;
if (story.site.commentsMode === Site.CLOSED || if (story.site.commentsMode === Site.DISABLED ||
story.commentsMode === Site.CLOSED) { story.commentsMode === Site.CLOSED) {
return; return;
} else if (mode) { } else if (mode) {

View file

@ -33,6 +33,31 @@
</p> </p>
<br /> <br />
<% #embed %>
<% story.title prefix='<div class="storyTitle">'suffix="</div>" %>
<% story.text | clip %>
<span class="small">
<% story.link . "[read more]" %>
<% story.link edit prefix=" ... " %>
</span><br />
<% #history %>
<div class="historyItem">
<% story.summary %>
<div class="small">
by <% story.creator %> (<% story.modified short %>)
</div>
</div>
<% #top %>
<tr>
<td align="right" valign="baseline" class="small"><% param.position %></td>
<td align="right" valign="baseline"><% story.requests %></td>
<td valign="baseline"><% story.created "yyyy-MM-dd" %></td>
<td valign="baseline"><% story.title | story.link %></td>
<td valign="baseline"><% story.creator %></td>
</tr>
<% #comment %> <% #comment %>
<% story.skin Story#day %> <% story.skin Story#day %>
<% story.skin Story#content %> <% story.skin Story#content %>
@ -51,7 +76,7 @@ else <% if <% story.mode %> is hidden then
<td rowspan="2" width="5" nowrap="nowrap"></td>' %> <td rowspan="2" width="5" nowrap="nowrap"></td>' %>
%> %>
<td colspan="3" class="small"> <td colspan="3" class="small">
<strong>Macro:</strong> &lt;% story <% story.id %> %&gt;<br /> <strong>Macro:</strong> <% story.macro %><br />
<div class="ample"><strong>Status: </strong><% story.status %><!-- <div class="ample"><strong>Status: </strong><% story.status %><!--
--><% story.tags link prefix=" in " %>, --><% story.tags link prefix=" in " %>,
<% story.comments link %></div> <% story.comments link %></div>
@ -138,23 +163,6 @@ for (var i in referrers) {
</noscript> </noscript>
</table> </table>
<% #history %>
<div class="historyItem">
<% story.summary %>
<div class="small">
by <% story.creator %> (<% story.modified short %>)
</div>
</div>
<% #top %>
<tr>
<td align="right" valign="baseline" class="small"><% param.position %></td>
<td align="right" valign="baseline"><% story.requests %></td>
<td valign="baseline"><% story.created "yyyy-MM-dd" %></td>
<td valign="baseline"><% story.title | story.link %></td>
<td valign="baseline"><% story.creator %></td>
</tr>
<% #edit %> <% #edit %>
<form method="post" action="<% response.action %>"> <form method="post" action="<% response.action %>">
<p> <p>

View file

@ -1,2 +0,0 @@
<span class="storyTitle"><% story.content part="title" suffix="<br />" %></span>
<% story.content part="text" limit="20" delimiter="\\s" clipping="&nbsp;..." %><span class="small"><% story.link text="[read&nbsp;more]" prefix="&nbsp;" to="main" %><% story.editlink prefix="&nbsp;...&nbsp;" %></span><br />

View file

@ -22,10 +22,13 @@
// $URL$ // $URL$
// //
defineConstants(User, "getStatus", "blocked", "regular", "trusted", User.COOKIE = getProperty("userCookie", "antvilleUser");
"privileged"); User.HASHCOOKIE = getProperty("hashCookie", "antvilleHash");
defineConstants(User, "getScopes", "regular users", "trusted users",
"privileged users"); User.getStatus = defineConstants(User, "blocked",
"regular", "trusted", "privileged");
User.getScopes = defineConstants(User, "regular users",
"trusted users", "privileged users");
this.handleMetadata("hash"); this.handleMetadata("hash");
this.handleMetadata("salt"); this.handleMetadata("salt");
@ -71,10 +74,10 @@ User.prototype.update = function(data) {
salt: session.data.token salt: session.data.token
}); });
} }
this.map({ if (!(this.email = validateEmail(data.email))) {
url: evalURL(data.url), throw Error(gettext("Please enter a valid e-mail address"));
email: evalEmail(data.email), }
}); this.url = validateUrl(data.url);
return this; return this;
}; };
@ -105,7 +108,7 @@ User.prototype.list_macro = function(param, type) {
memberships.forEach(function(membership) { memberships.forEach(function(membership) {
var site; var site;
if (site = membership.get("site")) { if (site = membership.get("site")) {
site.renderSkin("Site#preview"); site.renderSkin("Site#list");
} }
return; return;
}); });
@ -169,6 +172,31 @@ User.register = function(data) {
return user; return user;
}; };
User.autoLogin = function() {
if (session.user) {
return;
}
var name = req.cookies[User.COOKIE];
var hash = req.cookies[User.HASHCOOKIE];
if (!name || !hash) {
return;
}
var user = User.getByName(name);
if (!user) {
return;
}
var ip = req.data.http_remotehost.clip(getProperty("cookieLevel", "4"),
"", "\\.");
if ((user.hash + ip).md5() !== hash) {
return;
}
session.login(user);
user.touch();
res.message = gettext('Welcome to "{0}", {1}. Have fun!',
res.handlers.site.title, user.name);
return;
};
User.login = function(data) { User.login = function(data) {
var user = User.getByName(data.name); var user = User.getByName(data.name);
if (!user) { if (!user) {
@ -185,10 +213,10 @@ User.login = function(data) {
} }
if (data.remember) { if (data.remember) {
// Set long running cookies for automatic login // Set long running cookies for automatic login
res.setCookie("avUsr", user.name, 365); res.setCookie(User.COOKIE, user.name, 365);
var ip = req.data.http_remotehost.clip(getProperty("cookieLevel", "4"), var ip = req.data.http_remotehost.clip(getProperty("cookieLevel", "4"),
"", "\\."); "", "\\.");
res.setCookie("avPw", (user.hash + ip).md5(), 365); res.setCookie(User.HASHCOOKIE, (user.hash + ip).md5(), 365);
} }
user.touch(); user.touch();
session.login(user); session.login(user);
@ -203,7 +231,7 @@ User.require = function(s) {
return false; return false;
}; };
User.getStatus = function() { User.getCurrentStatus = function() {
if (session.user) { if (session.user) {
return session.user.status; return session.user.status;
} }

View file

@ -163,3 +163,95 @@ function fakemail_macro(param) {
} }
return; return;
} }
// FIXME:
function sitelist_macro(param) {
// setting some general limitations:
var minDisplay = 10;
var maxDisplay = 25;
var max = Math.min((param.limit ? parseInt(param.limit, 10) : minDisplay), maxDisplay);
root.renderSitelist(max);
res.write(res.data.sitelist);
delete res.data.sitelist;
return;
}
// FIXME:
function imagelist_macro(param) {
var site = param.of ? root.get(param.of) : res.handlers.site;
if (!site)
return;
if (!site.images.size())
return;
var max = Math.min(param.limit ? param.limit : 5, site.images.size());
var idx = 0;
var imgParam;
var linkParam = {};
delete param.limit;
while (idx < max) {
var imgObj = site.images.get(idx++);
imgParam = Object.clone(param);
delete imgParam.itemprefix;
delete imgParam.itemsuffix;
delete imgParam.as;
delete linkParam.href;
delete linkParam.onclick;
res.write(param.itemprefix);
// return different display according to param.as
switch (param.as) {
case "url":
res.write(imgObj.getUrl());
break;
case "popup":
linkParam.onclick = imgObj.getPopupUrl();
case "thumbnail":
linkParam.href = param.linkto ? param.linkto : imgObj.getUrl();
if (imgObj.thumbnail)
imgObj = imgObj.thumbnail;
default:
if (linkParam.href) {
html.openLink(linkParam);
renderImage(imgObj, imgParam);
html.closeLink();
} else
renderImage(imgObj, imgParam);
}
res.write(param.itemsuffix);
}
return;
}
// FIXME: -> tags!
function topiclist_macro(param) {
var site = param.of ? root.get(param.of) : res.handlers.site;
if (!site)
return;
site.topics.topiclist_macro(param);
return;
}
function imageoftheday_macro(param) {
var s = res.handlers.site;
var pool = res.handlers.site.images;
if (pool==null) return;
delete(param.topic);
var img = pool.get(0);
param.name = img.alias;
return image_macro(param);
}
// FIXME: obsolete?
function username_macro(param) {
if (!session.user)
return;
if (session.user.url && param.as == "link")
html.link({href: session.user.url}, session.user.name);
else if (session.user.url && param.as == "url")
res.write(session.user.url);
else
res.write(session.user.name);
return;
}

View file

@ -62,6 +62,20 @@ Root.prototype.shortdateformat_macro = function(param) {
return; return;
}; };
Root.prototype.sitecounter_macro = function(param) {
if (param.count == "all")
var size = root.size();
else
var size = this.publicSites.size();
if (size == 0)
res.write(param.no ? param.no : size);
else if (size == 1)
res.write(param.one ? param.one : size);
else
res.write(size + (param.more ? param.more : ""));
return;
};
Root.prototype.sysmgrnavigation_macro = function(param) { Root.prototype.sysmgrnavigation_macro = function(param) {
if (session.user && session.user.sysadmin) if (session.user && session.user.sysadmin)
this.renderSkin("sysmgrnavigation"); this.renderSkin("sysmgrnavigation");

View file

@ -145,6 +145,39 @@ Site.prototype.layoutchooser_macro = function(param) {
return this.select_macro(param, "layout"); return this.select_macro(param, "layout");
}; };
Site.prototype.history_macro = function(param, type) {
param.limit = Math.min(param.limit || 10, 20);
type || (type = param.show);
var stories = this.stories.recent;
var size = stories.size();
var counter = i = 0;
var item;
while (counter < param.limit && i < size) {
if (i % param.limit === 0) {
stories.prefetchChildren(i, param.limit);
}
item = stories.get(i);
i += 1;
switch (item.constructor) {
case Story:
if (type === "comments") {
continue;
}
break;
case Comment:
if (type === "stories" || item.story.mode === Story.PRIVATE ||
item.story.commentsMode === Story.CLOSED ||
this.commentsMode === Site.DISABLED) {
continue;
}
break;
}
item.renderSkin("Story#history");
counter += 1;
}
return;
};
Site.prototype.menuext_action = function() { Site.prototype.menuext_action = function() {
this.renderSkin("menuext"); this.renderSkin("menuext");
return; return;