*) fixed Blog updating timestamp on edit (now always keeps creation-date)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1997 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
auron_x 19 years ago
parent 22de954a57
commit 0bf2eb4813

@ -72,6 +72,7 @@ public class Blog {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
blogBoard.entry page = null;
boolean hasRights = switchboard.verifyAuthentication(header, true);
@ -120,16 +121,22 @@ public class Blog {
content = post.get("content", "").getBytes();
}
//set name for new entry
Date date = null;
//set name for new entry or date for old entry
if(pagename.equals("blog_default"))
pagename = String.valueOf(System.currentTimeMillis());
else {
page = switchboard.blogDB.read(pagename); //must I read it again after submitting?
date = page.date();
}
try {
switchboard.blogDB.write(switchboard.blogDB.newEntry(pagename, post.get("subject",""), author, ip, content));
switchboard.blogDB.write(switchboard.blogDB.newEntry(pagename, post.get("subject",""), author, ip, date, content));
} catch (IOException e) {}
}
blogBoard.entry page = switchboard.blogDB.read(pagename);
page = switchboard.blogDB.read(pagename); //maybe "if(page == null)"
if (post.containsKey("edit")) {
//edit an entry

@ -96,10 +96,6 @@ public class blogBoard {
public void close() {
try {datbase.close();} catch (IOException e) {}
}
private static String dateString() {
return dateString(new GregorianCalendar(GMTTimeZone).getTime());
}
private static String dateString(Date date) {
return SimpleFormatter.format(date);
@ -123,8 +119,8 @@ public class blogBoard {
return wikiBoard.guessAuthor(ip);
}
public entry newEntry(String key, String subject, String author, String ip, byte[] page) throws IOException {
return new entry(normalize(key), subject, author, ip, page);
public entry newEntry(String key, String subject, String author, String ip, Date date, byte[] page) throws IOException {
return new entry(normalize(key), subject, author, ip, date, page);
}
public class entry {
@ -132,11 +128,12 @@ public class blogBoard {
String key;
Map record;
public entry(String nkey, String subject, String author, String ip, byte[] page) throws IOException {
public entry(String nkey, String subject, String author, String ip, Date date, byte[] page) throws IOException {
record = new HashMap();
key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength);
record.put("date", dateString());
if(date == null) date = new GregorianCalendar(GMTTimeZone).getTime();
record.put("date", dateString(date));
if ((subject == null) || (subject.length() == 0)) subject = "";
record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject.getBytes("UTF-8")));
if ((author == null) || (author.length() == 0)) author = "anonymous";
@ -215,7 +212,7 @@ public class blogBoard {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
Map record = base.get(key);
if (record == null) return newEntry(key, "", "anonymous", "127.0.0.1", "".getBytes());
if (record == null) return newEntry(key, "", "anonymous", "127.0.0.1", new GregorianCalendar(GMTTimeZone).getTime(), "".getBytes());
return new entry(key, record);
} catch (IOException e) {
return null;

Loading…
Cancel
Save