* check for param.as == "url" and/or param.as == "link" wherevery it (hopefully) makes sense

* cleaned up a little bit (code, comments)
This commit is contained in:
Tobi Schäfer 2004-07-30 13:34:13 +00:00
parent c42c959be7
commit 94cb4c0a22
7 changed files with 53 additions and 19 deletions

View file

@ -102,9 +102,13 @@ function file_macro(param) {
var p = getPoolObj(param.name, "files");
if (!p)
return;
if (!param.text)
param.text = p.obj.alias;
p.obj.renderSkin(param.skin ? param.skin : "main", param);
if (param.as == "url")
res.write(p.obj.getUrl());
else {
if (!param.text)
param.text = p.obj.alias;
p.obj.renderSkin(param.skin ? param.skin : "main", param);
}
return;
}
@ -152,7 +156,18 @@ function story_macro(param) {
var story = site.allstories.get(storyPath[1] ? storyPath[1] : param.id);
if (!story)
return getMessage("error", "storyNoExist", param.id);
story.renderSkin(param.skin ? param.skin : "embed");
switch (param.as) {
case "url":
res.write(story.href());
break;
case "link":
var title = param.text ? param.text :
story.content.getProperty("title");
Html.link({href: story.href()}, title ? title : story._id);
break;
default:
story.renderSkin(param.skin ? param.skin : "embed");
}
return;
}
@ -173,13 +188,22 @@ function poll_macro(param) {
var poll = site.polls.get(parts[1] ? parts[1] : param.id);
if (!poll)
return getMessage("error.pollNoExist", param.id);
if (param.as == "link")
Html.link({href: poll.href(poll.closed ? "results" : "")}, poll.question);
else if (poll.closed || param.as == "results")
poll.renderSkin("results");
else {
res.data.action = poll.href();
poll.renderSkin("main");
switch (param.as) {
case "url":
res.write(poll.href());
break;
case "link":
Html.link({
href: poll.href(poll.closed ? "results" : "")
}, poll.question);
break;
default:
if (poll.closed || param.as == "results")
poll.renderSkin("results");
else {
res.data.action = poll.href();
poll.renderSkin("main");
}
}
return;
}
@ -234,6 +258,8 @@ function username_macro(param) {
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

@ -43,6 +43,8 @@ function creator_macro(param) {
return;
if (param.as == "link" && this.creator.url)
Html.link({href: this.creator.url}, this.creator.name);
else if (param.as == "url")
res.write(this.creator.url);
else
res.write(this.creator.name);
return;
@ -56,6 +58,8 @@ function modifier_macro(param) {
return;
if (param.as == "link" && this.modifier.url)
Html.link({href: this.modifier.url}, this.modifier.name);
else if (param.as == "url")
res.write(this.modifier.url);
else
res.write(this.modifier.name);
return;

View file

@ -16,7 +16,7 @@ function username_macro(param) {
function email_macro(param) {
if (this.user.publishemail)
return this.user.email;
return "**********";
return "***";
}
/**

View file

@ -534,9 +534,12 @@ function layoutchooser_macro(param) {
* please add some error message for undefined param.event
*/
function notify_macro(param) {
var notifyContributors = param.notifyContributors ? param.notifyContributors : getMessage("Site.notifyContributors");
var notifyAdmins = param.notifyAdmins ? param.notifyAdmins : getMessage("Site.notifyAdmins");
var notifyNobody = param.notifyNobody ? param.notifyNobody : getMessage("Site.notifyNobody");
var notifyContributors = param.notifyContributors ?
param.notifyContributors : getMessage("Site.notifyContributors");
var notifyAdmins = param.notifyAdmins ?
param.notifyAdmins : getMessage("Site.notifyAdmins");
var notifyNobody = param.notifyNobody ?
param.notifyNobody : getMessage("Site.notifyNobody");
var pref = this.preferences.getProperty("notify_" + param.event);
if (param.as == "editor") {

View file

@ -113,7 +113,8 @@ function setContent(newContent) {
// set rawcontent property used for searching
res.push();
for (var i in newContent) {
res.write(newContent[i]+'\r\n');
res.write(newContent[i]);
res.write("\r\n");
}
this.rawcontent = res.pop();
}

View file

@ -1,5 +1,5 @@
/**
* Display a link to let the use add a new writeup
* Display a link to let the user add a new writeup
* to this topic.
*/
function addstory_macro (param) {
@ -21,7 +21,7 @@ function addstory_macro (param) {
/**
* Display a link to let the use add a new Image to this topic
* Display a link to let the user add a new Image to this topic
*/
function addimage_macro (param) {
try {

View file

@ -3,7 +3,7 @@
*/
function name_macro(param) {
if (param.as == "url" && this.url)
if (param.as == "link" && this.url)
Html.link({href: this.url}, this.name);
else
res.write(this.name);