Initial revision
This commit is contained in:
parent
1ba4e8011b
commit
bbfcb3d4f4
104 changed files with 3100 additions and 0 deletions
1
code/Story/commentlink.skin
Normal file
1
code/Story/commentlink.skin
Normal file
|
@ -0,0 +1 @@
|
|||
<% this.link to="main" text="comment" %> (<% this.commentcounter no=" threads" one=" thread" more=" threads" %>)
|
14
code/Story/delete.hac
Normal file
14
code/Story/delete.hac
Normal file
|
@ -0,0 +1,14 @@
|
|||
// check if user is logged in and is the owner of this weblog
|
||||
this.checkPermissions();
|
||||
|
||||
if (req.data.submit == "delete")
|
||||
this.weblog.deleteStory(this);
|
||||
else if (req.data.submit == "cancel")
|
||||
res.redirect(this.weblog.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/Story/delete.skin
Normal file
4
code/Story/delete.skin
Normal file
|
@ -0,0 +1,4 @@
|
|||
<FORM METHOD="POST">
|
||||
<P>Warning! You are about to delete the Story <B><% this.title %></B>! Be aware of the fact that there is no "undo", so if you klick on delete here the story will be gone forever!</P>
|
||||
<P><% this.input type="button" value="delete" %> <% this.input type="button" value="cancel" %></P>
|
||||
</FORM>
|
14
code/Story/edit.hac
Normal file
14
code/Story/edit.hac
Normal file
|
@ -0,0 +1,14 @@
|
|||
// check if user is logged in and is the owner of this weblog
|
||||
this.checkPermissions();
|
||||
|
||||
if (req.data.submit == "cancel")
|
||||
res.redirect(this.weblog.href());
|
||||
|
||||
this.evalStory();
|
||||
|
||||
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("edit");
|
6
code/Story/edit.skin
Normal file
6
code/Story/edit.skin
Normal file
|
@ -0,0 +1,6 @@
|
|||
<FORM METHOD="POST">
|
||||
<P>Title: <% this.title as="editor" %></P>
|
||||
<P>Text: <% this.text as="editor" width="40" height="10" %></P>
|
||||
<P>is online: <% this.online as="editor" %></P>
|
||||
<P><% this.input type="button" value="save" %> <% this.input type="button" value="cancel" %></P>
|
||||
</FORM>
|
8
code/Story/filterFunctions.js
Normal file
8
code/Story/filterFunctions.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* function filters comments
|
||||
* only toplevel-comments should appear as subnodes of story
|
||||
*/
|
||||
|
||||
function filter() {
|
||||
this.subnodeRelation = "WHERE STORY_ID = " + this.__id__ + " AND PARENT_ID is null ORDER BY CREATETIME asc";
|
||||
}
|
1
code/Story/login.skin
Normal file
1
code/Story/login.skin
Normal file
|
@ -0,0 +1 @@
|
|||
<P><% weblog.loginlink text="login to add your comment!" %></P>
|
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);
|
||||
}
|
||||
}
|
11
code/Story/main.hac
Normal file
11
code/Story/main.hac
Normal file
|
@ -0,0 +1,11 @@
|
|||
this.filter();
|
||||
|
||||
res.skin = "main";
|
||||
|
||||
if (req.data.text && this.weblog.hasDiscussions())
|
||||
this.addComment();
|
||||
|
||||
res.title = "Antville - " + this.weblog.title;
|
||||
res.head = this.weblog.renderSkinAsString("style");
|
||||
res.body = this.weblog.renderSkinAsString("header");
|
||||
res.body += this.renderSkinAsString("main");
|
6
code/Story/main.skin
Normal file
6
code/Story/main.skin
Normal file
|
@ -0,0 +1,6 @@
|
|||
<P><FONT SIZE="-2"><% this.createtime format="EEEE, dd.MM.yyyy" %></FONT><BR>
|
||||
<B><% this.title %></B><BR>
|
||||
<% this.text %></P>
|
||||
<HR>
|
||||
<% this.comments %>
|
||||
<% this.commentform %>
|
57
code/Story/objectFunctions.js
Normal file
57
code/Story/objectFunctions.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* check if story is ok; if true, save changed story
|
||||
*/
|
||||
|
||||
function evalStory() {
|
||||
if (req.data.text) {
|
||||
this.title = req.data.title;
|
||||
this.text = req.data.text;
|
||||
this.online = req.data.online;
|
||||
this.modifytime = new Date();
|
||||
res.message = "The story was updated successfully!";
|
||||
res.redirect(this.weblog.href());
|
||||
} else
|
||||
res.message = "You need at least some text!";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function returns true/false whether story is online or not
|
||||
*/
|
||||
|
||||
function isOnline() {
|
||||
if (parseInt(this.online,10))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function evaluates comment and adds it if ok
|
||||
*/
|
||||
|
||||
function addComment() {
|
||||
if (user.uid && !user.isBlocked()) {
|
||||
var c = new comment();
|
||||
c.title = req.data.title;
|
||||
c.text = req.data.text;
|
||||
c.weblog = this.weblog;
|
||||
c.story = this;
|
||||
c.createtime = new Date();
|
||||
c.author = user;
|
||||
c.online = 1;
|
||||
c.ipadress = req.data.http_remotehost;
|
||||
this.add(c);
|
||||
}
|
||||
res.redirect(this.href());
|
||||
}
|
||||
|
||||
/**
|
||||
* function deletes a comment
|
||||
*/
|
||||
|
||||
function deleteComment(currComment) {
|
||||
currComment.setParent(this);
|
||||
this.remove(currComment);
|
||||
res.message = "The comment was deleted successfully!";
|
||||
res.redirect(this.href());
|
||||
}
|
4
code/Story/preview.skin
Normal file
4
code/Story/preview.skin
Normal file
|
@ -0,0 +1,4 @@
|
|||
<P><FONT SIZE="-2"><% this.createtime format="EEEE, dd.MM.yyyy, HH:mm" suffix=" Uhr"%></FONT><BR>
|
||||
<SPAN CLASS="title"><% this.title %></SPAN><BR>
|
||||
<% this.text %>
|
||||
<% this.commentlink prefix="<BR>" %><% this.editlink prefix=" " %><% this.deletelink prefix=" " %></P>
|
10
code/Story/securityFunction.js
Normal file
10
code/Story/securityFunction.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* check if user is allowed to edit this story
|
||||
*/
|
||||
|
||||
function checkPermissions() {
|
||||
if (this.author != user || user.isBlocked()) {
|
||||
res.message = "Sorry, you're not allowed to edit this story!";
|
||||
res.redirect(this.weblog.href());
|
||||
}
|
||||
}
|
15
code/Story/type.properties
Normal file
15
code/Story/type.properties
Normal file
|
@ -0,0 +1,15 @@
|
|||
_datasource=antville
|
||||
_tablename=STORY
|
||||
_subnodes=<comment.STORY_ID
|
||||
_subnodes.order=CREATETIME ASC
|
||||
|
||||
_id=ID
|
||||
weblog=WEBLOG_ID>weblog.ID
|
||||
day=DAY
|
||||
title=TITLE
|
||||
text=TEXT
|
||||
online=ISONLINE
|
||||
# postdate=POSTDATE
|
||||
author=AUTHOR>user.ID
|
||||
createtime=CREATETIME
|
||||
modifytime=MODIFYTIME
|
Loading…
Add table
Add a link
Reference in a new issue