From 1fe505f0b09410477b14e22b32c9816b91052b43 Mon Sep 17 00:00:00 2001 From: karlchenofhell Date: Wed, 28 Feb 2007 09:22:31 +0000 Subject: [PATCH] - adapted User_p to general web-interface style (and removed status-only page on changes) - beautified WikiHelp.html + typos - IP hasn't been set correctly in Blog.xml git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3418 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Blog.java | 74 ++++++++++++------------ htroot/User_p.html | 135 +++++++++++++++++++------------------------ htroot/User_p.java | 84 +++++++++++++-------------- htroot/WikiHelp.html | 80 +++++++++++++++---------- 4 files changed, 187 insertions(+), 186 deletions(-) diff --git a/htroot/Blog.java b/htroot/Blog.java index 8f15dde3c..d10f29d94 100644 --- a/htroot/Blog.java +++ b/htroot/Blog.java @@ -60,6 +60,7 @@ import de.anomic.http.httpHeader; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import de.anomic.server.logging.serverLog; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacyNewsRecord; @@ -75,8 +76,8 @@ public class Blog { } public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { - plasmaSwitchboard switchboard = (plasmaSwitchboard) env; - serverObjects prop = new serverObjects(); + final plasmaSwitchboard switchboard = (plasmaSwitchboard) env; + final serverObjects prop = new serverObjects(); blogBoard.entry page = null; boolean hasRights = switchboard.verifyAuthentication(header, true); @@ -99,7 +100,7 @@ public class Blog { final int num = post.getInt("num",20); //indicates how many entries should be shown if(!hasRights){ - userDB.Entry userentry = switchboard.userDB.proxyAuth((String)header.get("Authorization", "xxxxxx")); + final userDB.Entry userentry = switchboard.userDB.proxyAuth((String)header.get("Authorization", "xxxxxx")); if(userentry != null && userentry.hasBlogRight()){ hasRights=true; } else if(post.containsKey("login")) { @@ -109,7 +110,7 @@ public class Blog { } String pagename = post.get("page", DEFAULT_PAGE); - final String ip = post.get("CLIENTIP", "127.0.0.1"); + final String ip = (String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1"); String StrAuthor = post.get("author", ""); @@ -134,7 +135,7 @@ public class Blog { if(hasRights && post.containsKey("delete") && post.get("delete").equals("sure")) { page = switchboard.blogDB.read(pagename); - Iterator i = page.comments().iterator(); + final Iterator i = page.comments().iterator(); while(i.hasNext()) { switchboard.blogCommentDB.delete((String) i.next()); } @@ -165,8 +166,8 @@ public class Blog { comments = page.comments(); date = page.date(); } - String commentMode = post.get("commentMode", "1"); - String StrSubject = post.get("subject", ""); + final String commentMode = post.get("commentMode", "1"); + final String StrSubject = post.get("subject", ""); byte[] subject; try { subject = StrSubject.getBytes("UTF-8"); @@ -177,11 +178,11 @@ public class Blog { switchboard.blogDB.write(switchboard.blogDB.newEntry(pagename, subject, author, ip, date, content, comments, commentMode)); // create a news message - HashMap map = new HashMap(); - map.put("page", pagename); - map.put("subject", StrSubject.replace(',', ' ')); - map.put("author", StrAuthor.replace(',', ' ')); - yacyCore.newsPool.publishMyNews(new yacyNewsRecord("blog_add", map)); + final HashMap map = new HashMap(); + map.put("page", pagename); + map.put("subject", StrSubject.replace(',', ' ')); + map.put("author", StrAuthor.replace(',', ' ')); + yacyCore.newsPool.publishMyNews(new yacyNewsRecord("blog_add", map)); } page = switchboard.blogDB.read(pagename); //maybe "if(page == null)" @@ -264,7 +265,7 @@ public class Blog { else { //only show 1 entry prop.put("mode_entries",1); - putBlogEntry(prop, page, address, 0, xml, hasRights); + putBlogEntry(prop, page, address, 0, hasRights, xml); } } @@ -273,28 +274,29 @@ public class Blog { } private static serverObjects putBlogDefault( - serverObjects prop, - plasmaSwitchboard switchboard, - String address, + final serverObjects prop, + final plasmaSwitchboard switchboard, + final String address, int start, int num, - boolean hasRights, - boolean xml) { + final boolean hasRights, + final boolean xml) { try { - Iterator i = switchboard.blogDB.keys(false); + final Iterator i = switchboard.blogDB.keys(false); String pageid; - blogBoard.entry entry; int count = 0; //counts how many entries are shown to the user if(xml) num = 0; - int nextstart = start+num; //indicates the starting offset for next results - while(i.hasNext()) { - if(count >= num && num > 0) - break; + final int nextstart = start+num; //indicates the starting offset for next results + while(i.hasNext() && (num == 0 || num > count)) { pageid = (String) i.next(); - if(0 < start--) - continue; - entry = switchboard.blogDB.read(pageid); - putBlogEntry(prop, entry, address, count++, xml, hasRights); + if(0 < start--) continue; + putBlogEntry( + prop, + switchboard.blogDB.read(pageid), + address, + count++, + hasRights, + xml); } prop.put("mode_entries",count); @@ -305,7 +307,7 @@ public class Blog { } else { prop.put("moreentries",0); } - } catch (IOException e) { } + } catch (IOException e) { serverLog.logSevere("BLOG", "Error reading blog-DB", e); } return prop; } @@ -314,8 +316,8 @@ public class Blog { final blogBoard.entry entry, final String address, final int number, - final boolean xml, - final boolean hasRights) { + final boolean hasRights, + final boolean xml) { // subject try { @@ -332,7 +334,9 @@ public class Blog { } // comments - if(entry.getCommentMode() != 0) { + if(entry.getCommentMode() == 0) { + prop.put("mode_entries_" + number + "_commentsactive", 0); + } else { prop.put("mode_entries_" + number + "_commentsactive", 1); prop.put("mode_entries_" + number + "_commentsactive_pageid", entry.key()); prop.put("mode_entries_" + number + "_commentsactive_address", address); @@ -341,14 +345,12 @@ public class Blog { } catch (UnsupportedEncodingException e) { prop.put("mode_entries_" + number + "_commentsactive_comments", new String(entry.commentsSize())); } - } else { - prop.put("mode_entries_" + number + "_commentsactive", 0); } - + prop.put("mode_entries_" + number + "_date", dateString(entry.date())); prop.put("mode_entries_" + number + "_pageid", entry.key()); prop.put("mode_entries_" + number + "_address", address); - prop.put("mode_entries_" + number +" _ip", entry.ip()); + prop.put("mode_entries_" + number + "_ip", entry.ip()); if(xml) { prop.putASIS("mode_entries_" + number + "_page", entry.page()); diff --git a/htroot/User_p.html b/htroot/User_p.html index dae3ec7c8..5a49bc587 100644 --- a/htroot/User_p.html +++ b/htroot/User_p.html @@ -2,76 +2,7 @@ #[clientname]#'s User Administration end of HEADER-->

User Administration

- #(page)# - - - - - -
-
-
- - -
-
-
- - - Current User: #[username]# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Username:
Password:
Password(repeat):
First Name:
Last Name:
Address:
Rights -
-
-
-
-
- - -
:
:
- -
-
- :: + #(text)# :: @@ -81,11 +12,65 @@ #(/text)# #(error)# :: -

Generic error.

+

Generic error.

:: -

Passwords do not match.

+

Passwords do not match.

:: -

Username too short. Username must be >= 4 Characters.

+

Username too short. Username must be >= 4 Characters.

#(/error)# -

If you want to manage more Users, return to the user page.

- #(/page)# + +
+
Select user +
+
:
+
+ +
+
 
+
+ + +
+
+
+
+ +
+
Edit current user: #[username]# + + +
+
:
+
+
:
+
+
:
+
+
:
+
+
:
+
+
:
+
+
Rights:
+
+
+
+
+
+
+
+ +
+
:
+
+
:
+
+
 
+
+
+
+
diff --git a/htroot/User_p.java b/htroot/User_p.java index 8fbabe366..2ce2d660d 100644 --- a/htroot/User_p.java +++ b/htroot/User_p.java @@ -67,23 +67,22 @@ public class User_p { prop.put("SUPERTEMPLATE", "/env/page.html"); //user Supertemplates //default values - prop.put("page", 0); - prop.put("page_current_user", "newuser"); - prop.put("page_username", ""); - prop.put("page_firstname", ""); - prop.put("page_lastname", ""); - prop.put("page_address", ""); - prop.put("page_timelimit", ""); - prop.put("page_timeused", ""); - prop.put("page_timerange", ""); - prop.put("page_proxyRight", 1); - prop.put("page_downloadRight", 0); - prop.put("page_uploadRight", 0); - prop.put("page_adminRight", 0); - prop.put("page_wikiAdminRight", 0); - prop.put("page_bookmarkRight", 0); + prop.put("current_user", "newuser"); + prop.put("username", ""); + prop.put("firstname", ""); + prop.put("lastname", ""); + prop.put("address", ""); + prop.put("timelimit", ""); + prop.put("timeused", ""); + prop.put("timerange", ""); + prop.put("proxyRight", 1); + prop.put("downloadRight", 0); + prop.put("uploadRight", 0); + prop.put("adminRight", 0); + prop.put("wikiAdminRight", 0); + prop.put("bookmarkRight", 0); - prop.put("page_users", 0); + prop.put("users", 0); if(sb.userDB == null) return prop; @@ -102,35 +101,34 @@ public class User_p { // link: "If you want to manage more Users, return to the user page." (parameter "user" is empty) if (entry != null) { //TODO: set username read-only in html - prop.put("page_current_user", post.get("user")); - prop.put("page_username", post.get("user")); - prop.put("page_firstname", entry.getFirstName()); - prop.put("page_lastname", entry.getLastName()); - prop.put("page_address", entry.getAddress()); - prop.put("page_timelimit", entry.getTimeLimit()); - prop.put("page_timeused", entry.getTimeUsed()); - prop.put("page_proxyRight", (entry.hasProxyRight()?1:0)); - prop.put("page_uploadRight", (entry.hasUploadRight()?1:0)); - prop.put("page_downloadRight", (entry.hasDownloadRight()?1:0)); - prop.put("page_adminRight", (entry.hasAdminRight()?1:0)); - prop.put("page_blogRight", (entry.hasBlogRight()?1:0)); - prop.put("page_wikiAdminRight", (entry.hasWikiAdminRight()?1:0)); - prop.put("page_bookmarkRight", (entry.hasBookmarkRight()?1:0)); + prop.put("current_user", post.get("user")); + prop.put("username", post.get("user")); + prop.put("firstname", entry.getFirstName()); + prop.put("lastname", entry.getLastName()); + prop.put("address", entry.getAddress()); + prop.put("timelimit", entry.getTimeLimit()); + prop.put("timeused", entry.getTimeUsed()); + prop.put("proxyRight", (entry.hasProxyRight()?1:0)); + prop.put("uploadRight", (entry.hasUploadRight()?1:0)); + prop.put("downloadRight", (entry.hasDownloadRight()?1:0)); + prop.put("adminRight", (entry.hasAdminRight()?1:0)); + prop.put("blogRight", (entry.hasBlogRight()?1:0)); + prop.put("wikiAdminRight", (entry.hasWikiAdminRight()?1:0)); + prop.put("bookmarkRight", (entry.hasBookmarkRight()?1:0)); } }else if( post.containsKey("delete_user") && !((String)post.get("user")).equals("newuser") ){ sb.userDB.removeEntry((String)post.get("user")); } } else if(post.containsKey("change")) { //New User / edit User - prop.put("page", 1); //results - prop.put("page_text", 0); - prop.put("page_error", 0); + prop.put("text", 0); + prop.put("error", 0); String username=(String)post.get("username"); String pw=(String)post.get("password"); String pw2=(String)post.get("password2"); if(! pw.equals(pw2)){ - prop.put("page_error", 2); //PW does not match + prop.put("error", 2); //PW does not match return prop; } String firstName=(String)post.get("firstname"); @@ -166,10 +164,10 @@ public class User_p { try{ entry=sb.userDB.createEntry(username, mem); sb.userDB.addEntry(entry); - prop.put("page_text_username", username); - prop.put("page_text", 1); + prop.put("text_username", username); + prop.put("text", 1); }catch(IllegalArgumentException e){ - prop.put("page_error", 3); + prop.put("error", 3); } @@ -196,12 +194,12 @@ public class User_p { }catch (IOException e){ } }else{ - prop.put("page_error", 1); + prop.put("error", 1); } - prop.put("page_text_username", username); - prop.put("page_text", 2); + prop.put("text_username", username); + prop.put("text", 2); }//edit user - prop.put("page_username", username); + prop.put("username", username); } //Generate Userlist @@ -209,10 +207,10 @@ public class User_p { int numUsers=0; while(it.hasNext()){ entry = (userDB.Entry)it.next(); - prop.put("page_users_"+numUsers+"_user", entry.getUserName()); + prop.put("users_"+numUsers+"_user", entry.getUserName()); numUsers++; } - prop.put("page_users", numUsers); + prop.put("users", numUsers); // return rewrite properties return prop; diff --git a/htroot/WikiHelp.html b/htroot/WikiHelp.html index 325a3bb34..212c85aef 100644 --- a/htroot/WikiHelp.html +++ b/htroot/WikiHelp.html @@ -5,12 +5,14 @@ #%env/templates/metas.template%# -
-

Index Creation

-
- - +

Wiki-Code

+
This table contains a short description of the tags that can be used in the Wiki and several other servlets of YaCy. For a more detailed description visit the YaCy Wiki.
+ - - - - - - - - - - - - - -
+ This table contains a short description of the tags that can be used in the Wiki and several other servlets + of YaCy. For a more detailed description visit the + YaCy Wiki. +
Code @@ -20,61 +22,65 @@
+ ==headline1==
===headline2===
====headline3====
- This tags create headlines. If a page has three or more headlines, a directory will be created automaticly. + These tags create headlines. If a page has three or more headlines, a directory will be created automaticly.
+ ''text''
'''text'''
'''''text'''''
- This tags create stressed texts. Most browsers will display the texts in italics, bold, and a combination of both. + These tags create stressed texts. The first pair emphasizes the text (most browsers will display it in italics), + the second one emphazises it more strongly (i.e. bold) and the last tags create a combination of both.
+ :text
::text
- Lines will be indented. This tag is supposed to mark citations. + Lines will be indented. This tag is supposed to mark citations, but may as well be used for styling purposes.
+ #point1
##point1.1
##point1.2
#point2
- This tags create a numbered list. + These tags create a numbered list.
+ *something
**another thing
***and yet another
*something else
- This tags create a unnumbered list. + These tags create a unnumbered list.
- ;word 1:definition 1
;word 2:definition 2
;;word 3:definition 3
;word 4:definition 4 +
+ ;word 1:definition 1
+ ;word 2:definition 2
+ ;;word 3:definition 3
+ ;word 4:definition 4
- This tags create a definition list. + These tags create a definition list.
+ ---- @@ -83,8 +89,9 @@
- [[pagename]]
[[pagename|description]] +
+ [[pagename]]
+ [[pagename|description]]
This tag creates links to other pages of the wiki. @@ -92,7 +99,7 @@
+ [url]
[url description]
@@ -101,8 +108,10 @@
- [[Image:url]]
[[Image:url|alt text]]
[[Image:url|align|alt text]] +
+ [[Image:url]]
+ [[Image:url|alt text]]
+ [[Image:url|align|alt text]]
This tag displays an image, it can be aligned left, right or center. @@ -110,34 +119,41 @@
- {|
|-
||row 1, col 1||row 1, col 2
|-
||row 2, col 1||row 2, col 2
|} +
+ {|
+ |-
+ ||row 1, col 1||row 1, col 2
+ |-
+ ||row 2, col 1||row 2, col 2
+ |}
- This tags create a table. + These tags create a table, whereas the first marks the beginning of the table, the second starts + a new line, the third and fourth each create a new cell in the line. The last displayed tag closes + the table.
+ [= text =] - The escape tags will cause all tags in the text between the starting and the closing tag to not be treated as regular text. + The escape tags will cause all tags in the text between the starting and the closing tag to not be treated as wiki-code.
+ <pre> text </pre> - A text between this tags will keep all the spaces and linebreaks in it. Great for ASCII-art and program code. + A text between these tags will keep all the spaces and linebreaks in it. Great for ASCII-art and program code.
+ text
 text
text