*) cleaning up whitespaces, no changes in functionality

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1733 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 19 years ago
parent 8ce01307f8
commit 521e4121db

@ -69,39 +69,37 @@ public class Wiki {
private static SimpleDateFormat SimpleFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); private static SimpleDateFormat SimpleFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
public static String dateString(Date date) { public static String dateString(Date date) {
return SimpleFormatter.format(date); return SimpleFormatter.format(date);
} }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws IOException { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws IOException {
plasmaSwitchboard switchboard = (plasmaSwitchboard) env; plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
if (post == null) { if (post == null) {
post = new serverObjects(); post = new serverObjects();
post.put("page", "start"); post.put("page", "start");
} }
String pagename = post.get("page", "start"); String pagename = post.get("page", "start");
String ip = post.get("CLIENTIP", "127.0.0.1"); String ip = post.get("CLIENTIP", "127.0.0.1");
String author = post.get("author", "anonymous"); String author = post.get("author", "anonymous");
if (author.equals("anonymous")) { if (author.equals("anonymous")) {
author = switchboard.wikiDB.guessAuthor(ip); author = switchboard.wikiDB.guessAuthor(ip);
if (author == null) { if (author == null) {
if (de.anomic.yacy.yacyCore.seedDB.mySeed == null) if (de.anomic.yacy.yacyCore.seedDB.mySeed == null) author = "anonymous";
author = "anonymous"; else author = de.anomic.yacy.yacyCore.seedDB.mySeed.get("Name", "anonymous");
else
author = de.anomic.yacy.yacyCore.seedDB.mySeed.get("Name", "anonymous");
} }
} }
if (post.containsKey("submit")) { if (post.containsKey("submit")) {
// store a new page // store a new page
byte[] content; byte[] content;
try { try {
content = post.get("content", "").getBytes("UTF-8"); content = post.get("content", "").getBytes("UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
content = post.get("content", "").getBytes(); content = post.get("content", "").getBytes();
} }
switchboard.wikiDB.write(switchboard.wikiDB.newEntry(pagename, author, ip, post.get("reason", "edit"), content)); switchboard.wikiDB.write(switchboard.wikiDB.newEntry(pagename, author, ip, post.get("reason", "edit"), content));
// create a news message // create a news message
HashMap map = new HashMap(); HashMap map = new HashMap();
@ -111,74 +109,73 @@ public class Wiki {
try { try {
yacyCore.newsPool.publishMyNews(new yacyNewsRecord("wiki_upd", map)); yacyCore.newsPool.publishMyNews(new yacyNewsRecord("wiki_upd", map));
} catch (IOException e) {} } catch (IOException e) {}
} }
wikiBoard.entry page = switchboard.wikiDB.read(pagename); wikiBoard.entry page = switchboard.wikiDB.read(pagename);
if (post.containsKey("edit")) { if (post.containsKey("edit")) {
// edit the page // edit the page
try { try {
prop.put("mode", 1); //edit prop.put("mode", 1); //edit
prop.put("mode_author", author); prop.put("mode_author", author);
prop.put("mode_page-code", new String(page.page(), "UTF-8")); prop.put("mode_page-code", new String(page.page(), "UTF-8"));
prop.put("mode_pagename", pagename); prop.put("mode_pagename", pagename);
} catch (UnsupportedEncodingException e) {} } catch (UnsupportedEncodingException e) {}
} }
//contributed by [MN] //contributed by [MN]
else if (post.containsKey("preview")) { else if (post.containsKey("preview")) {
// preview the page // preview the page
wikiCode wikiTransformer=new wikiCode(switchboard); wikiCode wikiTransformer=new wikiCode(switchboard);
prop.put("mode", 2);//preview
prop.put("mode", 2);//preview prop.put("mode_pagename", pagename);
prop.put("mode_pagename", pagename); prop.put("mode_author", author);
prop.put("mode_author", author); prop.put("mode_date", dateString(new Date()));
prop.put("mode_date", dateString(new Date())); prop.put("mode_page", wikiTransformer.transform(post.get("content", "")));
prop.put("mode_page", wikiTransformer.transform(post.get("content", ""))); prop.put("mode_page-code", post.get("content", ""));
prop.put("mode_page-code", post.get("content", "")); }
} //end contrib of [MN]
//end contrib of [MN]
else if (post.containsKey("index")) {
else if (post.containsKey("index")) { // view an index
// view an index prop.put("mode", 3); //Index
prop.put("mode", 3); //Index String subject;
String subject; try {
try { Iterator i = switchboard.wikiDB.keys(true);
Iterator i = switchboard.wikiDB.keys(true); wikiBoard.entry entry;
wikiBoard.entry entry; int count=0;
int count=0; while (i.hasNext()) {
while (i.hasNext()) { subject = (String) i.next();
subject = (String) i.next(); entry = switchboard.wikiDB.read(subject);
entry = switchboard.wikiDB.read(subject); prop.put("mode_pages_"+count+"_name",wikiBoard.webalize(subject));
prop.put("mode_pages_"+count+"_name",wikiBoard.webalize(subject)); prop.put("mode_pages_"+count+"_subject", subject);
prop.put("mode_pages_"+count+"_subject", subject); prop.put("mode_pages_"+count+"_date", dateString(entry.date()));
prop.put("mode_pages_"+count+"_date", dateString(entry.date())); prop.put("mode_pages_"+count+"_author", entry.author());
prop.put("mode_pages_"+count+"_author", entry.author()); count++;
count++; }
prop.put("mode_pages", count);
} catch (IOException e) {
prop.put("mode_error", 1); //IO Error reading Wiki
prop.put("mode_error_message", e.getMessage());
} }
prop.put("mode_pages", count); prop.put("mode_pagename", pagename);
} catch (IOException e) { }
prop.put("mode_error", 1); //IO Error reading Wiki
prop.put("mode_error_message", e.getMessage()); else {
wikiCode wikiTransformer=new wikiCode(switchboard);
// show page
prop.put("mode", 0); //viewing
prop.put("mode_pagename", pagename);
prop.put("mode_author", page.author());
prop.put("mode_date", dateString(page.date()));
prop.put("mode_page", wikiTransformer.transform(page.page()));
prop.put("controls", 0);
prop.put("controls_pagename", pagename);
} }
prop.put("mode_pagename", pagename);
} // return rewrite properties
return prop;
else {
wikiCode wikiTransformer=new wikiCode(switchboard);
// show page
prop.put("mode", 0); //viewing
prop.put("mode_pagename", pagename);
prop.put("mode_author", page.author());
prop.put("mode_date", dateString(page.date()));
prop.put("mode_page", wikiTransformer.transform(page.page()));
prop.put("controls", 0);
prop.put("controls_pagename", pagename);
}
// return rewrite properties
return prop;
} }

Loading…
Cancel
Save