Skip to content
Snippets Groups Projects
Commit 2f119641 authored by deuce's avatar deuce
Browse files

Some minor overhauls...

Use the from header rather than from_ext
Do a case insensitive comparison

This now blogifies DOVE-General "properly" :-)
parent d6b23b13
Branches
Tags
No related merge requests found
......@@ -16,20 +16,20 @@ var min_chars=400;
// 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 year=parseInt(parameters[1],10);
var month=parseInt(parameters[2],10);
var day=parseInt(parameters[3],10);
var msgid=parseInt(parameters[4],10);
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 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()) {
......@@ -37,7 +37,7 @@ if(!msgbase.open()) {
exit(1);
}
if(msgid != undefined && msgid != "") {
if(!isNaN(msgid)) {
if(subject==undefined || subject=="") {
var hdr=msgbase.get_msg_header(parseInt(msgid));
http_reply.status="301 Moved Permanently";
......
<?xjs
load("/synchronet/src/web/root/blog/blog_config.js");
load("/synchronet/src/web/root/blogs/blog_config.js");
?>
<html>
......@@ -13,50 +13,45 @@ load("/synchronet/src/web/root/blog/blog_config.js");
</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) {
function not_found_error(reason)
{
http_reply.status="404 Not Found";
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found.</body></hmtl>");
write("<html><head><title>Not found</title></head><body>The requested URL cannot be found. Reason: "+reason+"</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);
}
}
}
}
var hdr=msgbase.get_msg_header(msgid);
if(hdr.from.toUpperCase() != poster.toUpperCase())
not_found_error("poster");
//if(hdr.from_ext != pnum)
// not_found_error("pnum");
if(hdr.thread_back)
not_found_error("top");
var date=new Date(hdr.date);
this_year=date.getFullYear();
this_month=date.getMonth()+1;
this_day=date.getDate();
var body=msgbase.get_msg_body(i, true);
if(year != this_year)
not_found_error("year");
if(month != this_month)
not_found_error("month "+month+"!="+this_month);
if(day != this_day)
not_found_error("day");
if(subject != clean_subject(hdr.subject))
not_found_error("subject");
var body=msgbase.get_msg_body(msgid, 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(" ");
//body=body.split("&#13;&#10;&#13;&#10;").join("</p><p>");
//body=body.split("&#13;&#10;").join(" ");
body=body.split("&#13;&#10;").join("<br>");
?>
<b><?xjs write(hdr.subject); ?></b> (<?xjs write(date); ?>)<br>
......@@ -65,10 +60,52 @@ body=body.split("&#13;&#10;").join(" ");
<hr>
<?xjs
// "Comments"
var thread_depth=0;
var skip=0;
/* Depth-first traversal of the thread */
while(1) {
if(!skip && hdr.thread_first) {
msgid=hdr.thread_first;
thread_depth++;
skip=0;
}
else {
if(hdr.thread_next) {
msgid=hdr.thread_next;
skip=0;
}
else {
if(hdr.thread_back) {
msgid=hdr.thread_back;
hdr=msgbase.get_msg_header(msgid);
thread_depth--;
skip=1;
continue;
}
else
break;
}
}
hdr=msgbase.get_msg_header(msgid);
var body=msgbase.get_msg_body(msgid, 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(" ");
body=body.split("&#13;&#10;").join("<br>");
?>
<div style="padding-left: <?xjs write(thread_depth*10) ?>px">
<b><?xjs write(hdr.subject); ?></b> (<?xjs write(date); ?>)<br>
By: <?xjs write(hdr.from); ?><br>
<p><?xjs write(body); ?></p>
<hr>
</div>
<?xjs
}
?>
</body>
</html>
<?xjs
load("/synchronet/src/web/root/blog/blog_config.js");
if(msgid != undefined && msgid != "") {
load("/synchronet/src/web/root/blogs/blog_config.js");
if(!isNaN(msgid)) {
xjs_load("blog_item.xjs");
exit(0);
}
......@@ -19,26 +19,28 @@ if(msgid != undefined && msgid != "") {
<?xjs
for(i=msgbase.last_msg; i>=msgbase.first_msg; i--) {
var hdr=msgbase.get_msg_header(i);
if(hdr.from_ext != pnum)
if(hdr.from.toUpperCase() != poster.toUpperCase())
continue;
// 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)
this_year=date.getFullYear();
this_month=date.getMonth()+1;
this_day=date.getDate();
if(!isNaN(year)) {
if(year != this_year)
continue;
if(month != undefined && month != "") {
if(date.getMonth()+1 != month)
if(!isNaN(month)) {
if(month != this_month)
continue;
if(day != undefined && day != "") {
if(date.getDate() != day)
if(!isNaN(day)) {
if(day != this_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;
......@@ -48,8 +50,9 @@ for(i=msgbase.last_msg; i>=msgbase.first_msg; i--) {
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(" ");
// exerpt=exerpt.split("&#13;&#10;&#13;&#10;").join("</p><p>");
// exerpt=exerpt.split("&#13;&#10;").join(" ");
exerpt=exerpt.split("&#13;&#10;").join("<br>");
?>
<b><?xjs write(hdr.subject); ?></b> (<?xjs write(date); ?>)<br>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment