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

View file

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

View file

@ -16,7 +16,7 @@ function username_macro(param) {
function email_macro(param) { function email_macro(param) {
if (this.user.publishemail) if (this.user.publishemail)
return this.user.email; 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 * please add some error message for undefined param.event
*/ */
function notify_macro(param) { function notify_macro(param) {
var notifyContributors = param.notifyContributors ? param.notifyContributors : getMessage("Site.notifyContributors"); var notifyContributors = param.notifyContributors ?
var notifyAdmins = param.notifyAdmins ? param.notifyAdmins : getMessage("Site.notifyAdmins"); param.notifyContributors : getMessage("Site.notifyContributors");
var notifyNobody = param.notifyNobody ? param.notifyNobody : getMessage("Site.notifyNobody"); 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); var pref = this.preferences.getProperty("notify_" + param.event);
if (param.as == "editor") { if (param.as == "editor") {

View file

@ -113,7 +113,8 @@ function setContent(newContent) {
// set rawcontent property used for searching // set rawcontent property used for searching
res.push(); res.push();
for (var i in newContent) { for (var i in newContent) {
res.write(newContent[i]+'\r\n'); res.write(newContent[i]);
res.write("\r\n");
} }
this.rawcontent = res.pop(); 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. * to this topic.
*/ */
function addstory_macro (param) { 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) { function addimage_macro (param) {
try { try {

View file

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