Skip to content
Snippets Groups Projects
Commit 063c8b9f authored by deuce's avatar deuce
Browse files

Start of a blog thinger... here's how it works:

1) Any message which is NOT a reply to another message is a blog post.
2) All replies to that message (and replies to them etc.) are "comments"
3) Blog posts can be filtered by poster, year, month, and day by the URL
	http://mybbs.synchro.net/blogs/Deuce
		Would be my blog entries.
	http://mybbs.synchro.net/blogs/Deuce/2007
		Would be my blog entries for 2007
	http://mybbs.synchro.net/blogs/Deuce/2007/02/18
		My blog entries for Feb. 18th, 2007

I still haven't figured out the best way to display comment threads...
Any succestions are welcome.
parent a5938301
No related branches found
No related tags found
No related merge requests found
// User editable settings...
// Internal code of the message base
var msg_code="GENERAL";
// Number of posts to show per page.
var max_posts=16;
// Minimum number of characters in an exerpt
var min_chars=400;
//
// Don't change stuff down here.
//
// User name of the blogger
var parameters=http_request.path_info.substr(1).split("/");
var poster=parameters[0];
var year=parameters[1];
var month=parameters[2];
var day=parameters[3];
var msgid=parameters[4];
var subject=parameters[5];
if(poster.indexOf("/")>=0) {
poster=poster.substr(0,poster.indexOf("/"));
}
var pnum=system.matchuser(poster);
if(pnum==0) {
write("<html><head><title>Error</title></head><body>Error getting UserID for "+poster+"!</body></html>");
exit(1);
}
var msgbase = new MsgBase(msg_code);
if(!msgbase.open()) {
write("<html><head><title>Error</title></head><body>Error opening "+msg_code+"!</body></html>");
exit(1);
}
if(msgid != undefined && msgid != "") {
if(subject==undefined || subject=="") {
var hdr=msgbase.get_msg_header(parseInt(msgid));
http_reply.status="301 Moved Permanently";
http_reply.header["Location"]="http://"+http_request.host+http_request.virtual_path+poster+"/"+format("%04d",year)+"/"+format("%02d",month)+"/"+format("%02d",day)+"/"+msgid+"/"+clean_subject(hdr.subject);
exit(0);
}
}
function clean_subject(sub)
{
sub=sub.replace(/[^a-zA-Z0-9]/g,"_");
return(sub);
}
<?xjs
load("/synchronet/src/web/root/blog/blog_config.js");
?>
<html>
<head>
<title>The Blogifier!</title>
</head>
<body>
<p>
Welcome to the <?xjs write(msgbase.cfg.name); ?> Blogifier for <?xjs write(poster); ?>
</p>
<?xjs
var hdr=msgbase.get_msg_header(i);
if(hdr.from_ext != pnum) {
http_reply.status="404 Not Found";
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found.</body></hmtl>");
exit(0);
}
if(hdr.thread_back) {
http_reply.status="404 Not Found";
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found.</body></hmtl>");
exit(0);
}
var date=new Date(hdr.date);
if(year != undefined && year != "") {
if(date.getFullYear() != year) {
http_reply.status="404 Not Found";
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found.</body></hmtl>");
exit(0);
}
if(month != undefined && month != "") {
if(date.getMonth()+1 != month) {
http_reply.status="404 Not Found";
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found.</body></hmtl>");
exit(0);
}
if(day != undefined && day != "") {
if(date.getDate() != day) {
http_reply.status="404 Not Found";
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found.</body></hmtl>");
exit(0);
}
}
}
}
this_year=date.getFullYear();
this_month=date.getMonth()+1;
this_day=date.getDate();
var body=msgbase.get_msg_body(i, true);
body=html_encode(body,true,true,false,false);
body=body.split("&#13;&#10;&#13;&#10;").join("</p><p>");
body=body.split("&#13;&#10;").join(" ");
?>
<b><?xjs write(hdr.subject); ?></b> (<?xjs write(date); ?>)<br>
<p><?xjs write(body); ?></p>
<hr>
<?xjs
?>
<hr>
</body>
</html>
<?xjs
load("/synchronet/src/web/root/blog/blog_config.js");
if(msgid != undefined && msgid != "") {
xjs_load("blog_item.xjs");
exit(0);
}
?>
<html>
<head>
<title>The Blogifier!</title>
</head>
<body>
<p>
Welcome to the <?xjs write(msgbase.cfg.name); ?> Blogifier for <?xjs write(poster); ?>
</p>
<?xjs
for(i=msgbase.last_msg; i>=msgbase.first_msg; i--) {
var hdr=msgbase.get_msg_header(i);
if(hdr.from_ext != pnum)
continue;
if(hdr.thread_back)
continue;
var date=new Date(hdr.date);
if(year != undefined && year != "") {
if(date.getFullYear() != year)
continue;
if(month != undefined && month != "") {
if(date.getMonth()+1 != month)
continue;
if(day != undefined && day != "") {
if(date.getDate() != day)
continue;
}
}
}
this_year=date.getFullYear();
this_month=date.getMonth()+1;
this_day=date.getDate();
var body=msgbase.get_msg_body(i, true);
j=min_chars;
while(j<body.length && body.substr(j, 1)!=" ")
j++;
if(j<body.length)
var read_more=true;
exerpt=body.substr(0,j);
exerpt=html_encode(exerpt,true,true,false,false);
exerpt=exerpt.split("&#13;&#10;&#13;&#10;").join("</p><p>");
exerpt=exerpt.split("&#13;&#10;").join(" ");
?>
<b><?xjs write(hdr.subject); ?></b> (<?xjs write(date); ?>)<br>
<p><?xjs write(exerpt); if(read_more) write("<b>...</b>"); ?></p>
<p><a href="<?xjs
write("http://"+http_request.host+http_request.virtual_path+poster+"/"+format("%04d",this_year)+"/"+format("%02d",this_month)+"/"+format("%02d",this_day)+"/"+i+"/"+clean_subject(hdr.subject));
?>">Comments...</a></p>
<?xjs
?>
<hr>
<?xjs
}
?>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment