Skip to content

Commit

Permalink
- adapted User_p to general web-interface style (and removed status-o…
Browse files Browse the repository at this point in the history
…nly 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
  • Loading branch information
karlchenofhell committed Feb 28, 2007
1 parent 92b6bc0 commit 1fe505f
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 186 deletions.
74 changes: 38 additions & 36 deletions htroot/Blog.java
Expand Up @@ -60,6 +60,7 @@
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;

Expand All @@ -75,8 +76,8 @@ public static String dateString(Date date) {
}

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);
Expand All @@ -99,7 +100,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
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")) {
Expand All @@ -109,7 +110,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
}

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", "");

Expand All @@ -134,7 +135,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve

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());
}
Expand Down Expand Up @@ -165,8 +166,8 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
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");
Expand All @@ -177,11 +178,11 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
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)"
Expand Down Expand Up @@ -264,7 +265,7 @@ else if(post.containsKey("xmlfile")) {
else {
//only show 1 entry
prop.put("mode_entries",1);
putBlogEntry(prop, page, address, 0, xml, hasRights);
putBlogEntry(prop, page, address, 0, hasRights, xml);
}
}

Expand All @@ -273,28 +274,29 @@ else if(post.containsKey("xmlfile")) {
}

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);

Expand All @@ -305,7 +307,7 @@ private static serverObjects putBlogDefault(
} else {
prop.put("moreentries",0);
}
} catch (IOException e) { }
} catch (IOException e) { serverLog.logSevere("BLOG", "Error reading blog-DB", e); }
return prop;
}

Expand All @@ -314,8 +316,8 @@ private static serverObjects putBlogEntry(
final blogBoard.entry entry,
final String address,
final int number,
final boolean xml,
final boolean hasRights) {
final boolean hasRights,
final boolean xml) {

// subject
try {
Expand All @@ -332,7 +334,9 @@ private static serverObjects putBlogEntry(
}

// 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);
Expand All @@ -341,14 +345,12 @@ private static serverObjects putBlogEntry(
} 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());
Expand Down
135 changes: 60 additions & 75 deletions htroot/User_p.html
Expand Up @@ -2,76 +2,7 @@
<title>#[clientname]#'s User Administration</title>
end of HEADER-->
<h2>User Administration</h2>
#(page)#
<table>
<tr>
<td valign="top">
<form action="User_p.html">
<select name="user">
<option value="newuser">new User</option>#{users}#
<option>#[user]#</option>#{/users}#
</select><br />
<input type="submit" name="change_user" value="Edit User" />
<input type="submit" name="delete_user" value="Delete User" />
</form>
</td>
<td width="100%">
<form action="User_p.html" method="POST">
<!-- Hidden(text for debugging): <input type="text" name="current_user" value="#[current_user]#" readonly> -->
<input type="hidden" name="current_user" value="#[current_user]#" />
Current User: #[username]#
<table border="1">
<tr>
<td>Username: </td>
<td><input type="text" name="username" value="#[username]#"></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>Password(repeat): </td>
<td><input type="password" name="password2"></td>
</tr>
<tr>
<td>First Name: </td>
<td><input type="text" name="firstname" value="#[firstname]#"></td>
</tr>
<tr>
<td>Last Name: </td>
<td><input type="text" name="lastname" value="#[lastname]#"></td>
</tr>
<tr>
<td>Address: </td>
<td><input type="text" name="address" value="#[address]#"></td>
</tr>
<tr>
<td>Rights</td>
<td>
<input type="checkbox" id="proxy" name="proxyRight"#(proxyRight)#:: checked="checked"#(/proxyRight)# /><label for="proxy">Proxy</label><br />
<input type="checkbox" id="admin" name="adminRight"#(adminRight)#:: checked="checked"#(/adminRight)# /><label for="admin">Admin</label><br />
<input type="checkbox" id="share" name="uploadRight"#(uploadRight)#:: checked="checked"#(/uploadRight)# /><label for="share">Fileshare-Upload</label><br />
<input type="checkbox" id="dwnld" name="downloadRight"#(downloadRight)#:: checked="checked"#(/downloadRight)# /><label for="dwnld">Fileshare-Download</label><br />
<input type="checkbox" id="blog" name="blogRight"#(blogRight)#:: checked="checked"#(/blogRight)# /><label for="blog">Blog</label><br />
<input type="checkbox" id="wiki" name="wikiAdminRight"#(wikiAdminRight)#:: checked="checked"#(/wikiAdminRight)# /><label for="wiki">Wiki Admin</label>
<input type="checkbox" id="wiki" name="bookmarkRight"#(bookmarkRight)#:: checked="checked"#(/bookmarkRight)# /><label for="wiki">Bookmarks</label>
</td>
</tr>
<tr>
<td><label for="tlimit">Timelimit</label>:</td>
<td><input type="text" id="tlimit" name="timelimit" value="#[timelimit]#" /></td>
</tr>
<tr>
<td><label for="tused">Time used</label>:</td>
<td><input type="text" id="tused" name="timeused" value="#[timeused]#" /></td>
</tr>
</table>
<input type="submit" name="change" value="Save User" />
</form>
</td>
</tr>
</table>
::

<!-- Page 1: Results -->
#(text)#
::
Expand All @@ -81,11 +12,65 @@ <h2>User Administration</h2>
#(/text)#
#(error)#
::
<p>Generic error.</p>
<p class="error">Generic error.</p>
::
<p>Passwords do not match.</p>
<p class="error">Passwords do not match.</p>
::
<p>Username too short. Username must be >= 4 Characters.</p>
<p class="error">Username too short. Username must be >= 4 Characters.</p>
#(/error)#
<p>If you want to manage more Users, return to the <a href="User_p.html?change_user=true&amp;user=#[username]#">user</a> page.</p>
#(/page)#

<form action="User_p.html">
<fieldset><legend>Select user</legend>
<dl>
<dt><label for="user">Select user</label>:</dt>
<dd>
<select name="user" id="user">
<option value="newuser">New user</option>#{users}#
<option>#[user]#</option>#{/users}#
</select>
</dd>
<dt>&nbsp;</dt>
<dd>
<input type="submit" name="change_user" value="Edit User" />
<input type="submit" name="delete_user" value="Delete User" />
</dd>
</dl>
</fieldset>
</form>

<form action="User_p.html" method="post">
<fieldset><legend>Edit current user: #[username]#</legend>
<!-- Hidden(text for debugging): <input type="text" name="current_user" value="#[current_user]#" readonly> -->
<input type="hidden" name="current_user" value="#[current_user]#" />
<dl>
<dt><label for="username">Username</label>:</dt>
<dd><input type="text" id="username" name="username" value="#[username]#" /></dd>
<dt><label for="password">Password</label>:</dt>
<dd><input type="password" id="password" name="password" /></dd>
<dt><label for="password2">Repeat password</label>:</dt>
<dd><input type="password" id="password2" name="password2" /></dd>
<dt><label for="firstname">First name</label>:</dt>
<dd><input type="text" id="firstname" name="firstname" value="#[firstname]#" /></dd>
<dt><label for="lastname">Last name</label>:</dt>
<dd><input type="text" id="lastname" name="lastname" value="#[lastname]#" /></dd>
<dt><label for="address">Address</label>:</dt>
<dd><input type="text" id="address" name="address" value="#[address]#" /></dd>
<dt>Rights:</dt>
<dd>
<input type="checkbox" id="proxy" name="proxyRight"#(proxyRight)#:: checked="checked"#(/proxyRight)# /><label for="proxy">Proxy</label><br />
<input type="checkbox" id="admin" name="adminRight"#(adminRight)#:: checked="checked"#(/adminRight)# /><label for="admin">Admin</label><br />
<input type="checkbox" id="share" name="uploadRight"#(uploadRight)#:: checked="checked"#(/uploadRight)# /><label for="share">Fileshare-Upload</label><br />
<input type="checkbox" id="dwnld" name="downloadRight"#(downloadRight)#:: checked="checked"#(/downloadRight)# /><label for="dwnld">Fileshare-Download</label><br />
<input type="checkbox" id="blog" name="blogRight"#(blogRight)#:: checked="checked"#(/blogRight)# /><label for="blog">Blog</label><br />
<input type="checkbox" id="wiki" name="wikiAdminRight"#(wikiAdminRight)#:: checked="checked"#(/wikiAdminRight)# /><label for="wiki">Wiki Admin</label><br />
<input type="checkbox" id="bkmark" name="bookmarkRight"#(bookmarkRight)#:: checked="checked"#(/bookmarkRight)# /><label for="bkmark">Bookmarks</label>
</dd>
<dt><label for="tlimit">Timelimit</label>:</dt>
<dd><input type="text" id="tlimit" name="timelimit" value="#[timelimit]#" /></dd>
<dt><label for="tused">Time used</label>:</dt>
<dd><input type="text" id="tused" name="timeused" value="#[timeused]#" /></dd>
<dt>&nbsp;</dt>
<dd><input type="submit" name="change" value="Save User" /></dd>
</dl>
</fieldset>
</form>

0 comments on commit 1fe505f

Please sign in to comment.