Initial revision

This commit is contained in:
Robert Gaggl 2001-06-18 08:57:33 +00:00
parent 1ba4e8011b
commit bbfcb3d4f4
104 changed files with 3100 additions and 0 deletions

17
code/Comment/delete.hac Normal file
View file

@ -0,0 +1,17 @@
// check if user is logged in and is the owner of this weblog
this.checkPermissions("delete");
if (req.data.submit == "delete")
if (this.parent)
this.parent.deleteComment(this);
else
this.story.deleteComment(this);
else if (req.data.submit == "cancel")
res.redirect(this.story.href("main"));
res.skin = "main";
res.title = "Antville - " + this.weblog.title;
res.head = this.weblog.renderSkinAsString("style");
res.body = this.weblog.renderSkinAsString("header");
res.body += this.renderSkinAsString("delete");

4
code/Comment/delete.skin Normal file
View file

@ -0,0 +1,4 @@
<FORM METHOD="POST">
<P>Warning! You are about to delete the a comment from <B><% this.author %></B>! Be aware of the fact that there is no "undo", so if you klick on delete here the comment will be gone forever!</P>
<P><% this.input type="button" value="delete" %>&nbsp;<% this.input type="button" value="cancel" %></P>
</FORM>

13
code/Comment/edit.hac Normal file
View file

@ -0,0 +1,13 @@
// check if user has right to edit this comment
this.checkPermissions();
res.skin = "main";
res.title = "Antville - " + this.weblog.title;
if (req.data.text)
this.updateComment();
res.head = this.weblog.renderSkinAsString("style");
res.body = this.weblog.renderSkinAsString("header");
res.body += this.renderSkinAsString("edit");

5
code/Comment/edit.skin Normal file
View file

@ -0,0 +1,5 @@
<FORM METHOD="POST">
<P>Title: <% this.title as="editor" %></P>
<P>Text: <% this.text as="editor" %></P>
<% this.input type="button" value="save" %>
</FORM>

View file

@ -0,0 +1,8 @@
/**
* function filters comments
* only toplevel-comments should appear as subnodes of story
*/
function filter() {
this.subnodeRelation = "WHERE PARENT_ID = " + this.__id__ + " ORDER BY CREATETIME asc";
}

132
code/Comment/macros.js Normal file
View file

@ -0,0 +1,132 @@
/**
* macro rendering title of comment
*/
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 comment
*/
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 renders author of comment
*/
function author_macro(param) {
renderPrefix(param);
if (this.author.url) {
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);
renderSuffix(param);
}
/**
* macro renders createtime of comment
*/
function createtime_macro(param) {
renderPrefix(param);
res.write(param.format ? this.createtime.format(param.format) : this.createtime.format());
renderSuffix(param);
}
/**
* 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) {
renderPrefix(param);
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 renders a link to delete the comment
* if user == weblog-owner
*/
function deletelink_macro(param) {
if (this.weblog.hasDiscussions()) {
if (this.weblog.owner == user && path[path.length-1] != this) {
renderPrefix(param);
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 renders a link to reply to a comment
*/
function replylink_macro(param) {
if (this.weblog.hasDiscussions() && user.uid && !user.isBlocked() && path[path.length-1] != this) {
renderPrefix(param);
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();
renderSuffix(param);
}
}
/**
* macro renders replies to this comment
*/
function replies_macro(param) {
if (this.weblog.hasDiscussions()) {
this.filter();
if (this.count()) {
renderPrefix(param);
for (var i=0;i<this.size();i++)
this.get(i).renderSkin("reply");
renderSuffix(param);
}
}
}

View file

@ -0,0 +1,45 @@
/**
* function evaluates changes to posting
*/
function updateComment() {
if (this.author == user) {
this.title = req.data.title;
this.text = req.data.text;
this.modifytime = new Date();
res.message = "Changes were saved successfully!";
} else
res.message = "Sorry, you're not allowed to edit a posting of somebody else!";
res.redirect(this.story.href());
}
/**
* function adds a comment to a comment ...
*/
function addComment() {
var r = new comment();
if (req.data.text) {
r.text = req.data.text;
r.title = req.data.title;
r.author = user;
r.createtime = new Date();
r.weblog = this.weblog;
r.story = this.story;
r.parent = this;
this.add(r);
res.redirect(this.story.href());
}
return (r);
}
/**
* function deletes a comment
*/
function deleteComment(currComment) {
currComment.setParent(this);
this.remove(currComment);
res.message = "The comment was deleted successfully!";
res.redirect(this.story.href());
}

12
code/Comment/reply.hac Normal file
View file

@ -0,0 +1,12 @@
if (this.weblog.hasDiscussions()) {
res.skin = "main";
res.title = "Antville - " + this.weblog.title;
var r = this.addComment();
res.head = this.story.weblog.renderSkinAsString("style");
res.body = this.story.weblog.renderSkinAsString("header");
res.body += this.renderSkinAsString("toplevel");
res.body += r.renderSkinAsString("edit");
} else
res.redirect(this.story.href());

4
code/Comment/reply.skin Normal file
View file

@ -0,0 +1,4 @@
<BLOCKQUOTE><B><% this.title %></B><BR>
<I><% this.author %><% this.createtime format="EEEE, dd.MM.yyyy HH:mm" prefix=",&nbsp;am&nbsp;" %></I><BR>
<% this.text %><BR>
<% this.editlink suffix="&nbsp;&nbsp;" %><% this.deletelink %></BLOCKQUOTE>

View file

@ -0,0 +1,20 @@
/**
* function checks if user has permissions to edit/delete a posting
*/
function checkPermissions(action) {
if (action == "delete") {
if (this.weblog.owner != user) {
res.message = "This is not your weblog, so you can't delete any postings!";
res.redirect(this.story.href());
}
return true;
} else {
if (this.author != user) {
res.message = "Sorry, you're not allowed to edit a posting of somebody else!";
res.redirect(this.story.href());
} else if (!this.weblog.hasDiscussions())
res.redirect(this.story.href());
return true;
}
}

View file

@ -0,0 +1,6 @@
<P><B><% this.title %></B><BR>
<I><% this.author %><% this.createtime format="EEEE, dd.MM.yyyy HH:mm" prefix=",&nbsp;am&nbsp;" %></I><BR>
<% this.text %><BR>
<% this.replylink text="reply to this comment ..." suffix="&nbsp;&nbsp;" %><% this.editlink suffix="&nbsp;&nbsp;" %><% this.deletelink %></P>
<% this.replies %>

View file

@ -0,0 +1,16 @@
_datasource=antville
_tablename=COMMENT
_subnodes=<comment.PARENT_ID
_subnodes.order=CREATETIME
_id=ID
weblog=WEBLOG_ID>weblog.ID
story=STORY_ID>story.ID
parent=PARENT_ID>comment.ID
title=TITLE
text=TEXT
author=AUTHOR>user.ID
createtime=CREATETIME
modifytime=MODIFYTIME
online=ISONLINE
ipaddress=IPADDRESS