antville/code/Comment/macros.js

162 lines
4 KiB
JavaScript
Raw Normal View History

2001-06-18 08:57:33 +00:00
/**
* macro rendering title of comment
*/
function title_macro(param) {
res.write(param.prefix)
2001-06-18 08:57:33 +00:00
if (param.as == "editor")
this.renderInputText(this.createInputParam("title",param));
else if (param.as == "link") {
var linkParam = new HopObject();
linkParam.linkto = "main";
linkParam.urlparam = "#"+this.__id__;
this.story.openLink(linkParam);
if (this.title)
res.write(this.title);
else {
// no title, so we show the first words of the comment-text as link
this.renderTextPreview(20);
}
this.story.closeLink();
} else
2001-06-18 08:57:33 +00:00
res.write(this.title);
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
/**
* macro rendering text of comment
*/
function text_macro(param) {
res.write(param.prefix)
2001-06-18 08:57:33 +00:00
if (param.as == "editor")
this.renderInputTextarea(this.createInputParam("text",param));
else {
if (!param.limit)
this.renderSkin(createSkin(format(this.text)));
else {
this.renderTextPreview(param.limit);
res.write(" ...");
}
2001-06-18 08:57:33 +00:00
}
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
/**
* macro renders author of comment
*/
function author_macro(param) {
res.write(param.prefix)
if (param.as == "link" && this.author.url) {
2001-06-18 08:57:33 +00:00
var linkParam = new HopObject();
linkParam.to = this.author.url;
this.openLink(linkParam);
res.write(this.author.name);
this.closeLink();
} else
res.write(this.author.name);
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
/**
* macro renders createtime of comment
*/
function createtime_macro(param) {
res.write(param.prefix)
res.write(this.weblog.formatTimestamp(this.createtime,param));
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
2001-06-28 17:53:07 +00:00
/**
* macro renders modifytime of comment
*/
function modifytime_macro(param) {
if (this.modifytime) {
res.write(param.prefix)
res.write(this.weblog.formatTimestamp(this.modifytime,param));
res.write(param.suffix);
2001-06-28 17:53:07 +00:00
}
}
2001-06-18 08:57:33 +00:00
/**
* macro renders a link for editing a posting
* if user == author of posting
*/
function editlink_macro(param) {
if (this.weblog.hasDiscussions() && this.author == user && path[path.length-1] != this) {
res.write(param.prefix)
2001-06-18 08:57:33 +00:00
var linkParam = new HopObject();
linkParam.linkto = "edit";
this.openLink(linkParam);
if (param.image && this.weblog.images.get(param.image))
this.weblog.renderImage(this.weblog.images.get(param.image),param);
2001-06-18 08:57:33 +00:00
else
res.write(param.text ? param.text : "edit");
2001-06-18 08:57:33 +00:00
this.closeLink();
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
}
/**
* macro renders a link to delete the comment
* if user == weblog-admin
2001-06-18 08:57:33 +00:00
*/
function deletelink_macro(param) {
if (this.weblog.hasDiscussions()) {
if (this.weblog.isUserAdmin() && path[path.length-1] != this) {
res.write(param.prefix)
2001-06-18 08:57:33 +00:00
var linkParam = new HopObject();
linkParam.linkto = "delete";
this.openLink(linkParam);
if (param.image && this.weblog.images.get(param.image))
this.weblog.renderImage(this.weblog.images.get(param.image),param);
2001-06-18 08:57:33 +00:00
else
res.write(param.text ? param.text : "delete");
2001-06-18 08:57:33 +00:00
this.closeLink();
}
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
}
/**
* macro renders a link to reply to a comment
*/
function replylink_macro(param) {
2001-06-28 17:53:07 +00:00
if (this.weblog.hasDiscussions() && !user.isBlocked() && path[path.length-1] != this) {
res.write(param.prefix)
2001-06-18 08:57:33 +00:00
var linkParam = new HopObject();
linkParam.linkto = "reply";
this.openLink(linkParam);
if (!param.image)
res.write(param.text ? param.text : "reply");
else
this.renderImage(param);
this.closeLink();
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
}
/**
* macro renders replies to this comment
*/
function replies_macro(param) {
if (this.weblog.hasDiscussions()) {
if (this.count()) {
res.write(param.prefix)
for (var i=0;i<this.size();i++) {
res.write("<a name=\""+this.get(i).__id__+"\"></a>");
2001-06-18 08:57:33 +00:00
this.get(i).renderSkin("reply");
}
res.write(param.suffix);
2001-06-18 08:57:33 +00:00
}
}
}