Initial revision
This commit is contained in:
parent
1ba4e8011b
commit
bbfcb3d4f4
104 changed files with 3100 additions and 0 deletions
195
code/Story/macros.js
Normal file
195
code/Story/macros.js
Normal file
|
@ -0,0 +1,195 @@
|
|||
/**
|
||||
* macro rendering title of story
|
||||
*/
|
||||
|
||||
function title_macro(param) {
|
||||
renderPrefix(param);
|
||||
if (param.as == "editor")
|
||||
this.renderInputText(this.createInputParam("title",param));
|
||||
else
|
||||
res.write(this.title);
|
||||
renderSuffix(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* macro rendering text of story
|
||||
*/
|
||||
|
||||
function text_macro(param) {
|
||||
renderPrefix(param);
|
||||
if (param.as == "editor")
|
||||
this.renderInputTextarea(this.createInputParam("text",param));
|
||||
else {
|
||||
var text = createSkin(format(this.text));
|
||||
this.renderSkin(text);
|
||||
}
|
||||
renderSuffix(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* macro rendering online-status of story
|
||||
*/
|
||||
|
||||
function online_macro(param) {
|
||||
renderPrefix(param);
|
||||
if (param.as == "editor")
|
||||
this.renderInputCheckbox(this.createInputParam("online",param));
|
||||
else
|
||||
res.write(parseInt(this.online,10) ? "yes" : "no");
|
||||
renderSuffix(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* macro rendering createtime of story
|
||||
*/
|
||||
|
||||
function createtime_macro(param) {
|
||||
renderPrefix(param);
|
||||
if (param.as == "editor")
|
||||
this.renderDateDropdown(this.createInputParam("createtime",param));
|
||||
else {
|
||||
res.write(param.format ? this.createtime.format(param.format) : this.createtime.format());
|
||||
}
|
||||
renderSuffix(param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro rendering a link to edit
|
||||
* if user is allowed to edit
|
||||
*/
|
||||
|
||||
function editlink_macro(param) {
|
||||
renderPrefix(param);
|
||||
if (this.author == user) {
|
||||
var linkParam = new HopObject();
|
||||
linkParam.linkto = "edit";
|
||||
this.openLink(linkParam);
|
||||
if (!param.image)
|
||||
res.write(param.text ? param.text : "edit");
|
||||
else
|
||||
this.renderImage(param);
|
||||
this.closeLink();
|
||||
}
|
||||
renderSuffix(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* macro rendering a link to delete
|
||||
* if user is owner of this story
|
||||
*/
|
||||
|
||||
function deletelink_macro(param) {
|
||||
renderPrefix(param);
|
||||
if (this.author == user) {
|
||||
var linkParam = new HopObject();
|
||||
linkParam.linkto = "delete";
|
||||
this.openLink(linkParam);
|
||||
if (!param.image)
|
||||
res.write(param.text ? param.text : "delete");
|
||||
else
|
||||
this.renderImage(param);
|
||||
this.closeLink();
|
||||
}
|
||||
renderSuffix(param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro rendering link to comments
|
||||
*/
|
||||
|
||||
function commentlink_macro(param) {
|
||||
if (path[path.length-1] != this && this.weblog.hasDiscussions()) {
|
||||
renderPrefix(param);
|
||||
this.renderSkin(param.useskin ? param.useskin : "commentlink");
|
||||
renderSuffix(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* macro renders number of comments
|
||||
* options: text to use when no comment
|
||||
* text to use when one comment
|
||||
* text to use when more than one comment
|
||||
*/
|
||||
|
||||
function commentcounter_macro(param) {
|
||||
if (this.weblog.hasDiscussions()) {
|
||||
renderPrefix(param);
|
||||
this.filter();
|
||||
if (this.count() == 0) {
|
||||
res.write(this.count() + (param.no ? param.no : " threads"));
|
||||
} else if (this.count() == 1) {
|
||||
res.write(this.count() + (param.one ? param.one : " thread"));
|
||||
} else if (this.count() > 1) {
|
||||
res.write(this.count() + (param.more ? param.more : " threads"));
|
||||
}
|
||||
renderSuffix(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* macro loops over comments and renders them
|
||||
*/
|
||||
|
||||
function comments_macro(param) {
|
||||
if (this.weblog.hasDiscussions() && this.count()) {
|
||||
renderPrefix(param);
|
||||
for (var i=0;i<this.size();i++) {
|
||||
this.get(i).renderSkin("toplevel");
|
||||
}
|
||||
renderSuffix(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* macro checks if user is logged in and not blocked
|
||||
* if true, render form to add a comment
|
||||
*/
|
||||
|
||||
function commentform_macro(param) {
|
||||
if (this.weblog.hasDiscussions()) {
|
||||
renderPrefix(param);
|
||||
if (user.uid && !user.isBlocked()) {
|
||||
var c = new comment();
|
||||
c.renderSkin("edit");
|
||||
// this.renderSkin(param.useskin ? param.useskin : "commentform");
|
||||
} else if (!user.isBlocked())
|
||||
res.write("<A HREF=\"" + this.weblog.members.href("login") + "\">Login to add your comment</A>");
|
||||
renderSuffix(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* macro renders an image out of image-pool
|
||||
* either as plain image or as image-link
|
||||
* overrideable parameters: width,height,alttext,border
|
||||
* additional parameters: align, valign
|
||||
*/
|
||||
|
||||
function image_macro(param) {
|
||||
if (param && param.name) {
|
||||
renderPrefix(param);
|
||||
this.weblog.renderImage(param);
|
||||
/*
|
||||
if (param.linkto)
|
||||
this.openLink(param);
|
||||
var img = this.weblog.images.get(param.name);
|
||||
if (img) {
|
||||
res.write("<IMG SRC=\"" + getProperty("imgUrl") + this.weblog.alias + "/" + img.filename + "." + img.fileext + "\"");
|
||||
res.write(" WIDTH=\"" + (param.width ? param.width : img.width) + "\"");
|
||||
res.write(" HEIGHT=\"" + (param.height ? param.height : img.height) + "\"");
|
||||
res.write(" ALT=\"" + (param.alttext ? param.alttext : img.alttext) + "\"");
|
||||
if (param.align)
|
||||
res.write(" ALIGN=\"" + param.align + "\"");
|
||||
if (param.valign)
|
||||
res.write(" VALIGN=\"" + param.valign + "\"");
|
||||
res.write(" BORDER=\"" + (param.border ? param.border : 0) + "\">");
|
||||
}
|
||||
if (param.linkto)
|
||||
this.closeLink(param);
|
||||
*/
|
||||
renderSuffix(param);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue