some small changes to blog

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4457 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
lulabad 17 years ago
parent 159aaf8889
commit 8358652fa9

@ -82,11 +82,13 @@ public class Blog {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
blogBoard.entry page = null; blogBoard.entry page = null;
final boolean authenticated = switchboard.adminAuthenticated(header) >= 2;
final int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0);
prop.put("display", display);
boolean hasRights = switchboard.verifyAuthentication(header, true); boolean hasRights = switchboard.verifyAuthentication(header, true);
//final int display = (hasRights || post == null) ? 1 : post.getInt("display", 0);
//prop.put("display", display);
prop.put("display", 1); // Fixed to 1
final boolean xml = ((String)header.get(httpHeader.CONNECTION_PROP_PATH)).endsWith(".xml"); final boolean xml = ((String)header.get(httpHeader.CONNECTION_PROP_PATH)).endsWith(".xml");
final String address = yacyCore.seedDB.mySeed().getPublicAddress(); final String address = yacyCore.seedDB.mySeed().getPublicAddress();

@ -67,6 +67,7 @@ import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroMapObjects; import de.anomic.kelondro.kelondroMapObjects;
import de.anomic.kelondro.kelondroNaturalOrder; import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.server.serverDate; import de.anomic.server.serverDate;
import de.anomic.server.logging.serverLog;
public class blogBoard { public class blogBoard {
@ -163,7 +164,8 @@ public class blogBoard {
try { try {
String c = record.get("date"); String c = record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard"); serverLog.logFinest("Blog", "ERROR: date field missing in blogBoard");
//System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return new Date(); return new Date();
} }
return serverDate.parseShortSecond(c); return serverDate.parseShortSecond(c);
@ -175,7 +177,8 @@ public class blogBoard {
public String timestamp() { public String timestamp() {
String c = record.get("date"); String c = record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard"); serverLog.logFinest("Blog", "ERROR: date field missing in blogBoard");
//System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return serverDate.formatShortSecond(); return serverDate.formatShortSecond();
} }
return c; return c;

@ -68,6 +68,7 @@ import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroDyn; import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroMapObjects; import de.anomic.kelondro.kelondroMapObjects;
import de.anomic.kelondro.kelondroNaturalOrder; import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.server.logging.serverLog;
public class blogBoardComments { public class blogBoardComments {
@ -123,109 +124,111 @@ public class blogBoardComments {
} }
public CommentEntry newEntry(String key, byte[] subject, byte[] author, String ip, Date date, byte[] page) { public CommentEntry newEntry(String key, byte[] subject, byte[] author, String ip, Date date, byte[] page) {
return new CommentEntry(normalize(key), subject, author, ip, date, page); return new CommentEntry(normalize(key), subject, author, ip, date, page);
} }
public class CommentEntry { public class CommentEntry {
String key; String key;
HashMap<String, String> record; HashMap<String, String> record;
public CommentEntry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page) { public CommentEntry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page) {
record = new HashMap<String, String>(); record = new HashMap<String, String>();
key = nkey; key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
if(date == null) date = new Date(); if(date == null) date = new Date();
record.put("date", dateString(date)); record.put("date", dateString(date));
if (subject == null) record.put("subject",""); if (subject == null) record.put("subject","");
else record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject)); else record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));
if (author == null) record.put("author",""); if (author == null) record.put("author","");
else record.put("author", kelondroBase64Order.enhancedCoder.encode(author)); else record.put("author", kelondroBase64Order.enhancedCoder.encode(author));
if ((ip == null) || (ip.length() == 0)) ip = ""; if ((ip == null) || (ip.length() == 0)) ip = "";
record.put("ip", ip); record.put("ip", ip);
if (page == null) record.put("page", ""); if (page == null) record.put("page", "");
else record.put("page", kelondroBase64Order.enhancedCoder.encode(page)); else record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
wikiBoard.setAuthor(ip, new String(author)); wikiBoard.setAuthor(ip, new String(author));
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString()); //System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
} }
private CommentEntry(String key, HashMap<String, String> record) { private CommentEntry(String key, HashMap<String, String> record) {
this.key = key; this.key = key;
this.record = record; this.record = record;
if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList<String>())); if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList<String>()));
} }
public String key() { public String key() {
return key; return key;
} }
public byte[] subject() { public byte[] subject() {
String m = (String) record.get("subject"); String m = (String) record.get("subject");
if (m == null) return new byte[0]; if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoardComments.subject()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoardComments.subject()");
if (b == null) return "".getBytes(); if (b == null) return "".getBytes();
return b; return b;
} }
public Date date() { public Date date() {
try { try {
String c = (String) record.get("date"); String c = (String) record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard"); serverLog.logFinest("Blog", "ERROR: date field missing in blogBoard");
//System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return new Date(); return new Date();
} }
synchronized (SimpleFormatter) { synchronized (SimpleFormatter) {
return SimpleFormatter.parse(c); return SimpleFormatter.parse(c);
} }
} catch (ParseException e) { } catch (ParseException e) {
return new Date(); return new Date();
} }
} }
public String timestamp() { public String timestamp() {
String c = (String) record.get("date"); String c = (String) record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard"); serverLog.logFinest("Blog", "ERROR: date field missing in blogBoard");
return dateString(new Date()); //System.out.println("DEBUG - ERROR: date field missing in blogBoard");
} return dateString(new Date());
return c; }
} return c;
}
public byte[] author() {
String m = (String) record.get("author"); public byte[] author() {
if (m == null) return new byte[0]; String m = (String) record.get("author");
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoardComments.author()"); if (m == null) return new byte[0];
if (b == null) return "".getBytes(); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoardComments.author()");
return b; if (b == null) return "".getBytes();
} return b;
}
public String ip() {
String a = (String) record.get("ip"); public String ip() {
if (a == null) return "127.0.0.1"; String a = (String) record.get("ip");
return a; if (a == null) return "127.0.0.1";
} return a;
}
public byte[] page() {
String m = (String) record.get("page"); public byte[] page() {
if (m == null) return new byte[0]; String m = (String) record.get("page");
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoardComments.page()"); if (m == null) return new byte[0];
if (b == null) return "".getBytes(); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoardComments.page()");
return b; if (b == null) return "".getBytes();
} return b;
}
public boolean isAllowed() {
return (record.get("moderated") != null) && record.get("moderated").equals("true");
}
public void allow() { public boolean isAllowed() {
record.put("moderated", "true"); return (record.get("moderated") != null) && record.get("moderated").equals("true");
} }
public void allow() {
record.put("moderated", "true");
}
} }
public String write(CommentEntry page) { public String write(CommentEntry page) {
// writes a new page and returns key // writes a new page and returns key
try { try {
datbase.set(page.key, page.record); datbase.set(page.key, page.record);
return page.key; return page.key;
@ -345,7 +348,7 @@ public class blogBoardComments {
} }
public Iterator<String> keys(boolean up) throws IOException { public Iterator<String> keys(boolean up) throws IOException {
return datbase.keys(up, false); return datbase.keys(up, false);
} }
} }

Loading…
Cancel
Save