Fixed numberbug in Blog, see http://forum.yacy-websuche.de/viewtopic.php?f=6&t=639. This wont fix existing Blogentrys (comes later).

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4443 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
lulabad 17 years ago
parent 141db7ba48
commit 40a0591942

@ -362,11 +362,7 @@ public class Blog {
prop.put("mode_entries_" + number + "_commentsactive", "1");
prop.put("mode_entries_" + number + "_commentsactive_pageid", entry.key());
prop.put("mode_entries_" + number + "_commentsactive_address", address);
try {
prop.put("mode_entries_" + number + "_commentsactive_comments", new String(entry.commentsSize(),"UTF-8"));
} catch (UnsupportedEncodingException e) {
prop.put("mode_entries_" + number + "_commentsactive_comments", new String(entry.commentsSize()));
}
prop.put("mode_entries_" + number + "_commentsactive_comments", entry.commentsSize());
}
prop.put("mode_entries_" + number + "_date", dateString(entry.date()));

@ -246,11 +246,7 @@ public class BlogComments {
prop.putHTML("mode_author", new String(page.author()));
prop.putHTML("mode_allow_author", new String(author));
}
try {
prop.put("mode_comments", new String(page.commentsSize(),"UTF-8"));
} catch (UnsupportedEncodingException e) {
prop.put("mode_comments", new String(page.commentsSize()));
}
prop.put("mode_comments", page.commentsSize());
prop.put("mode_date", dateString(page.date()));
prop.putWiki("mode_page", page.page());
if(hasRights) {
@ -272,7 +268,7 @@ public class BlogComments {
int num = post.getInt("num",10); //indicates how many entries should be shown
boolean prev = false; //indicates if there were previous comments to the ones that are dispalyed
if(xml) num = 0;
if (start < 1) start = 1; // dirrrty fix for incorrect comment count, need to find reason
if (start < 0) start = 0;
if (start > 1) prev = true;
int nextstart = start+num; //indicates the starting offset for next results
int prevstart = start-num; //indicates the starting offset for previous results

@ -114,125 +114,121 @@ public class blogBoard {
public class entry {
String key;
HashMap<String, String> record;
public entry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
record = new HashMap<String, String>();
key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength);
if(date == null) date = new Date();
record.put("date", serverDate.formatShortSecond(date));
if (subject == null) record.put("subject","");
else record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));
if (author == null) record.put("author","");
else record.put("author", kelondroBase64Order.enhancedCoder.encode(author));
if ((ip == null) || (ip.length() == 0)) ip = "";
record.put("ip", ip);
if (page == null) record.put("page", "");
else record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
if (comments == null) record.put("comments", listManager.collection2string(new ArrayList<String>()));
else record.put("comments", listManager.collection2string(comments));
if (commentMode == null) record.put("commentMode", "1");
else record.put("commentMode", commentMode);
wikiBoard.setAuthor(ip, new String(author));
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
}
String key;
HashMap<String, String> record;
public entry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
record = new HashMap<String, String>();
key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength);
if(date == null) date = new Date();
record.put("date", serverDate.formatShortSecond(date));
if (subject == null) record.put("subject","");
else record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));
if (author == null) record.put("author","");
else record.put("author", kelondroBase64Order.enhancedCoder.encode(author));
if ((ip == null) || (ip.length() == 0)) ip = "";
record.put("ip", ip);
if (page == null) record.put("page", "");
else record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
if (comments == null) record.put("comments", listManager.collection2string(new ArrayList<String>()));
else record.put("comments", listManager.collection2string(comments));
if (commentMode == null) record.put("commentMode", "1");
else record.put("commentMode", commentMode);
wikiBoard.setAuthor(ip, new String(author));
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
}
private entry(String key, HashMap<String, String> record) {
this.key = key;
this.record = record;
if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList<String>()));
if (this.record.get("commentMode")==null || this.record.get("commentMode").equals("")) this.record.put("commentMode", "1");
}
private entry(String key, HashMap<String, String> record) {
this.key = key;
this.record = record;
if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList<String>()));
if (this.record.get("commentMode")==null || this.record.get("commentMode").equals("")) this.record.put("commentMode", "1");
}
public String key() {
return key;
}
public String key() {
return key;
}
public byte[] subject() {
String m = record.get("subject");
if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.subject()");
if (b == null) return "".getBytes();
return b;
}
public byte[] subject() {
String m = record.get("subject");
if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.subject()");
if (b == null) return "".getBytes();
return b;
}
public Date date() {
try {
String c = record.get("date");
if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return new Date();
}
return serverDate.parseShortSecond(c);
} catch (ParseException e) {
return new Date();
}
}
public Date date() {
try {
String c = record.get("date");
if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return new Date();
}
return serverDate.parseShortSecond(c);
} catch (ParseException e) {
return new Date();
}
}
public String timestamp() {
String c = record.get("date");
if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return serverDate.formatShortSecond();
public String timestamp() {
String c = record.get("date");
if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return serverDate.formatShortSecond();
}
return c;
}
return c;
}
public byte[] author() {
String m = record.get("author");
if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.author()");
if (b == null) return "".getBytes();
return b;
}
public byte[] author() {
String m = record.get("author");
if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.author()");
if (b == null) return "".getBytes();
return b;
}
public byte[] commentsSize() {
ArrayList<String> m = listManager.string2arraylist(record.get("comments"));
if (m == null) return new byte[0];
byte[] b = Integer.toString(m.size()).getBytes();
if (b == null) return "".getBytes();
return b;
}
public int commentsSize() {
ArrayList<String> m = listManager.string2arraylist(record.get("comments"));
return m.size();
}
public ArrayList<String> comments() {
ArrayList<String> m = listManager.string2arraylist(record.get("comments"));
if (m == null) return new ArrayList<String>();
return m;
}
public ArrayList<String> comments() {
ArrayList<String> m = listManager.string2arraylist(record.get("comments"));
return m;
}
public String ip() {
String a = record.get("ip");
if (a == null) return "127.0.0.1";
return a;
}
public String ip() {
String a = record.get("ip");
if (a == null) return "127.0.0.1";
return a;
}
public byte[] page() {
String m = record.get("page");
if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.page()");
if (b == null) return "".getBytes();
return b;
}
public byte[] page() {
String m = record.get("page");
if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.page()");
if (b == null) return "".getBytes();
return b;
}
public void addComment(String commentID) {
ArrayList<String> comments = listManager.string2arraylist(record.get("comments"));
comments.add(commentID);
record.put("comments", listManager.collection2string(comments));
}
public void addComment(String commentID) {
ArrayList<String> comments = listManager.string2arraylist(record.get("comments"));
comments.add(commentID);
record.put("comments", listManager.collection2string(comments));
}
public boolean removeComment(String commentID) {
ArrayList<String> comments = listManager.string2arraylist(record.get("comments"));
boolean success = comments.remove(commentID);
record.put("comments", listManager.collection2string(comments));
return success;
}
public boolean removeComment(String commentID) {
ArrayList<String> comments = listManager.string2arraylist(record.get("comments"));
boolean success = comments.remove(commentID);
record.put("comments", listManager.collection2string(comments));
return success;
}
public int getCommentMode(){
return Integer.parseInt(record.get("commentMode"));
}
public int getCommentMode(){
return Integer.parseInt(record.get("commentMode"));
}
}
public String write(entry page) {

@ -327,7 +327,7 @@ public class listManager {
public static ArrayList<String> string2arraylist(String string){
ArrayList<String> l;
if (string != null) {
if (string != null && string.length() > 0) {
l = new ArrayList<String>(Arrays.asList(string.split(",")));
} else {
l = new ArrayList<String>();

Loading…
Cancel
Save