Skip to content

Commit

Permalink
- old versions may be reviewed and restored
Browse files Browse the repository at this point in the history
- removed explicit replacement of '<' and '>', fix for first bug in: http://www.yacy-forum.de/viewtopic.php?t=3485

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3329 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
karlchenofhell committed Feb 3, 2007
1 parent bf8f120 commit 6667930
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 8 deletions.
52 changes: 50 additions & 2 deletions htroot/Wiki.html
Expand Up @@ -23,7 +23,10 @@ <h2 class="PostSubject">YaCyWiki page: #[pagename]#</h2>
<a href="Wiki.html">Start Page</a> -
<a href="Wiki.html?index=Index">Index</a> -
<a href="Wiki.html?page=#[pagename]#&amp;diff=">Versions</a> -
#(access)#<a href="Wiki.html?access=all">Grant Write Access to Everybody</a>::<a href="Wiki.html?access=admin">Grant Write Access to Admin only</a>#(/access)#
<form method="post" action="Wiki.html">
<label for="access">Grant Write Access to</label>
#(access)#<input type="submit" name="access" value="all" />::<input type="submit" name="access" value="admin" />#(/access)#
</form>
</p>
::
<!-- 1: edit -->
Expand Down Expand Up @@ -117,12 +120,14 @@ <h2>Edit</h2>
<form method="get" action="Wiki.html">
<fieldset><legend>Select versions of page '#[page]#</legend>
<input type="hidden" name="page" value="#[page]#" />
<input type="hidden" name="diff" value="" />
<dl>
<dt><label for="old">Compare version from</label>:</dt>
<dd>
<select id="old" name="old">#{versions}#
<option value="#[date]#"#(oldselected)#:: selected="selected"#(/oldselected)#>#[fdate]#</option>#{/versions}#
</select>
<input type="submit" name="viewold" value="Show" />
</dd>
<dt><label for="new">with version from</label>:</dt>
<dd>
Expand All @@ -131,15 +136,58 @@ <h2>Edit</h2>
<option value="#[date]#"#(newselected)#:: selected="selected"#(/newselected)#>#[fdate]#</option>#{/versions}#
</select>
</dd>
<dt><input type="submit" name="diff" value="Compare" /></dt>
<dt><input type="submit" name="compare" value="Compare" /></dt>
</dl>
</fieldset>
</form>
::<!-- IO error -->
<p class="error">IO Error reading wiki database: #[message]#</p>
::<!-- no entries available for #[name]# -->
#(/error)#
#(versioning)#
::<!-- 1: View diff -->
#[diff]#
::<!-- 2: View selected version -->
<h2>Preview</h2>
<p>No changes have been submitted so far!</p>
<div class="Post">
<h2 class="PostSubject">YaCyWiki page: #[pagename]#</h2>
<div class="PostBody">
#[page]#
</div>
<p class="PostInfo">
last edited by #[author]# | change date #[date]#
</p>
</div>
<form action="Wiki.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<fieldset>
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="view" value="Discard" />
</fieldset>
<h2>Edit</h2>
<fieldset>
<dl>
<dt><label for="author">Author:</label></dt>
<dd>
<input name="author" id="author" type="text" size="80" maxlength="80" value="#[author]#" />
</dd>
<dt><label for="content">Text:</label></dt>
<dd>
<textarea name="content" id="content" cols="80" rows="24">#[page-code]#</textarea>
</dd>
</dl>
<p class="help">
You can use
<a href="WikiHelp.html" onclick="window.open('WikiHelp.html','WikiHelp','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480');return false;">Wiki Code</a> here.
</p>
<input type="hidden" name="page" value="#[pagename]#" />
<input type="hidden" name="reason" value="edit" />
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="preview" value="Preview" />
<input type="submit" name="view" value="Discard" />
</fieldset>
</form>
#(/versioning)#
<p class="Navigation">
<a href="Wiki.html">Start Page</a> -
<a href="Wiki.html?page=#[page]#">Return to #[page]#</a>
Expand Down
19 changes: 13 additions & 6 deletions htroot/Wiki.java
Expand Up @@ -143,7 +143,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
try {
prop.put("mode", 1); //edit
prop.put("mode_author", author);
prop.put("mode_page-code", new String(page.page(), "UTF-8").replaceAll("<","&lt;").replaceAll(">","&gt;"));
prop.put("mode_page-code", new String(page.page(), "UTF-8"));
prop.put("mode_pagename", pagename);
} catch (UnsupportedEncodingException e) {}
}
Expand Down Expand Up @@ -186,6 +186,7 @@ else if (post.containsKey("index")) {
}

else if (post.containsKey("diff")) {
// Diff
prop.put("mode", 4);
prop.put("mode_page", pagename);
prop.put("mode_error_page", pagename);
Expand Down Expand Up @@ -232,14 +233,20 @@ else if (post.containsKey("diff")) {
}

if (nentry == null) nentry = entry;
if (post.get("diff", "").length() > 0 && oentry != null && nentry != null) {
if (post.containsKey("compare") && oentry != null && nentry != null) {
// TODO: split into paragraphs and compare them with the same diff-algo
Diff diff = new Diff(
new String(oentry.page(), "UTF-8"),
new String(nentry.page(), "UTF-8"), 5);
prop.putASIS("mode_diff", Diff.toHTML(new Diff[] { diff }));
} else {
prop.put("mode_diff", "");
new String(nentry.page(), "UTF-8"), 3);
prop.putASIS("mode_versioning_diff", Diff.toHTML(new Diff[] { diff }));
prop.put("mode_versioning", 1);
} else if (post.containsKey("viewold") && oentry != null) {
prop.put("mode_versioning", 2);
prop.put("mode_versioning_pagename", pagename);
prop.put("mode_versioning_author", oentry.author());
prop.put("mode_versioning_date", dateString(oentry.date()));
prop.putWiki("mode_versioning_page", oentry.page());
prop.put("mode_versioning_page-code", new String(oentry.page(), "UTF-8"));
}
} catch (IOException e) {
prop.put("mode_error", 1); //IO Error reading Wiki
Expand Down

0 comments on commit 6667930

Please sign in to comment.