Skip to content

Commit

Permalink
public Tagview
Browse files Browse the repository at this point in the history
IMPORTANT: Fix for new(empty) Tags when adding/editing bookmarks.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1651 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
allo committed Feb 15, 2006
1 parent 910a709 commit e6c2f70
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
30 changes: 16 additions & 14 deletions htroot/Bookmarks_p.html → htroot/Bookmarks.html
Expand Up @@ -13,10 +13,12 @@ <h2>Bookmarks</h2></p>
<!-- todo: div layout? -->

#(mode)#
<a href="Bookmarks_p.html?mode=add">Add Bookmark</a>
<a href="Bookmarks_p.html?mode=importxml">Import XML Bookmarks</a>
<a href="Bookmarks.html?login=true">Login</a>
::
<form action="Bookmarks_p.html" method="GET">
<a href="Bookmarks.html?mode=add">Add Bookmark</a>
<a href="Bookmarks.html?mode=importxml">Import XML Bookmarks</a>
::
<form action="Bookmarks.html" method="GET">
<table border="0" width="100%" height="100%">
<tr>
<td colspan="2" colspan="2" valign="top" class="TableHeader">#(edit)#<h3>Add Bookmark</h3>::<h3>Edit Bookmark</h3>#(/edit)#</td>
Expand Down Expand Up @@ -57,7 +59,7 @@ <h2>Bookmarks</h2></p>
</table>
</form>
::
<form action="Bookmarks_p.html" method="POST" enctype="multipart/form-data">
<form action="Bookmarks.html" method="POST" enctype="multipart/form-data">
<table border="0" width="100%" height="100%">
<tr>
<td colspan="2" colspan="2" valign="top" class="TableHeader"><h3>Import XML Bookmarks</h3></td>
Expand Down Expand Up @@ -96,30 +98,30 @@ <h2>Bookmarks</h2></p>
#(public)#<img class="bookmarkIcon" src="env/grafics/bookmarkpriv.gif" alt="private bookmark" title="private bookmark">::<img class="bookmarkIcon" src="env/grafics/bookmarkpub.gif" alt="public bookmark" title="public bookmark">#(/public)#
<a href="#[link]#" target="_blank" class="bookmarkTitle">#[title]#</a><br />
<span class="bookmarkDescription">#[description]#</span><br />
Tagged with |&nbsp;#{tags}#<a href="Bookmarks_p.html?tag=#[tag]#" class="bookmarkTags">#[tag]#</a> | #{/tags}#<br />
<a href="Bookmarks_p.html?edit=#[hash]#" class="bookmarkAction">Edit</a> /
<a href="Bookmarks_p.html?delete=#[hash]#" class="bookmarkAction">Delete</a>
Tagged with |&nbsp;#{tags}#<a href="Bookmarks.html?tag=#[tag]#" class="bookmarkTags">#[tag]#</a> | #{/tags}#<br />
<a href="Bookmarks.html?edit=#[hash]#" class="bookmarkAction">Edit</a> /
<a href="Bookmarks.html?delete=#[hash]#" class="bookmarkAction">Delete</a>
</p>
#{/bookmarks}#
<p />
#(prev-page)#
::<a href="Bookmarks_p.html?tag=#[tag]#&start=#[start]#&num=#[num]#">previous page</a>
::<a href="Bookmarks.html?tag=#[tag]#&start=#[start]#&num=#[num]#">previous page</a>
#(/prev-page)#
#(next-page)#
::<a href="Bookmarks_p.html?tag=#[tag]#&start=#[start]#&num=#[num]#">next page</a>
::<a href="Bookmarks.html?tag=#[tag]#&start=#[start]#&num=#[num]#">next page</a>
#(/next-page)#
<br />
Show
<a href="Bookmarks_p.html?tag=#[tag]#&start=#[start]#&num=10">10</a>
<a href="Bookmarks_p.html?tag=#[tag]#&start=#[start]#&num=50">50</a>
<a href="Bookmarks_p.html?tag=#[tag]#&start=#[start]#&num=100">100</a>
<a href="Bookmarks.html?tag=#[tag]#&start=#[start]#&num=10">10</a>
<a href="Bookmarks.html?tag=#[tag]#&start=#[start]#&num=50">50</a>
<a href="Bookmarks.html?tag=#[tag]#&start=#[start]#&num=100">100</a>
Bookmarks per page.
</td>
<td valign="top" style="padding-left: 5px; border-left-style: solid; border-left-width: 1px; border-left-color: black;">
<div style="text-align: right">
<a href="Bookmarks_p.html" class="bookmarkTags">All</a> (#[num-bookmarks]#)<br />
<a href="Bookmarks.html" class="bookmarkTags">All</a> (#[num-bookmarks]#)<br />
#{taglist}#
<a href="Bookmarks_p.html?tag=#[tag]#" class="bookmarkTags">#[name]#</a> (#[num]#)<br />
<a href="Bookmarks.html?tag=#[tag]#" class="bookmarkTags">#[name]#</a> (#[num]#)<br />
#{/taglist}#
</div>
</td>
Expand Down
40 changes: 22 additions & 18 deletions htroot/Bookmarks_p.java → htroot/Bookmarks.java
Expand Up @@ -50,51 +50,56 @@
import java.util.Vector;

import de.anomic.data.bookmarksDB;
import de.anomic.data.listManager;
import de.anomic.data.bookmarksDB.Tag;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaCrawlLURL;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;

public class Bookmarks_p {
public class Bookmarks {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects();
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
int max_count=10;
String tagName="";
int start=0;
boolean isAdmin=switchboard.verifyAuthentication(header, true);

//defaultvalues
prop.put("mode", 0);
if(isAdmin){
prop.put("mode", 1);
}
prop.put("mode_edit", 0);
prop.put("mode_title", "");
prop.put("mode_description", "");
prop.put("mode_url", "");
prop.put("mode_tags", "");
prop.put("mode_public", 1); //1=is public
if(post != null){
if(post.containsKey("mode")){

if(!isAdmin){
if(post.containsKey("login")){
prop.put("AUTHENTICATE","admin log-in");
}
}else if(post.containsKey("mode")){
String mode=(String) post.get("mode");
if(mode.equals("add")){
prop.put("mode", 1);
}else if(mode.equals("importxml")){
prop.put("mode", 2);
}else if(mode.equals("importxml")){
prop.put("mode", 3);
}
}
if(post.containsKey("add")){ //add an Entry
}else if(post.containsKey("add")){ //add an Entry
String url=(String) post.get("url");
String title=(String) post.get("title");
String description=(String) post.get("description");
String tagsString = (String)post.get("tags");
if(tagsString.equals("")){
tagsString="unsorted"; //defaulttag
}
Vector tags=new Vector();
String[] tagsArray=tagsString.split(",");
for(int i=0;i<tagsArray.length; i++){
tags.add(tagsArray[i].trim());
}
Vector tags=listManager.string2vector(tagsString);

bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url);
if(bookmark != null){
Expand All @@ -113,7 +118,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
}
}else if(post.containsKey("edit")){
String urlHash=(String) post.get("edit");
prop.put("mode", 1);
prop.put("mode", 2);
if (urlHash.length() == 0) {
prop.put("mode_edit", 0); // create mode
prop.put("mode_title", (String) post.get("title"));
Expand Down Expand Up @@ -156,12 +161,11 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
isPublic=true;
}
switchboard.bookmarksDB.importFromXML(new String((byte[])post.get("xmlfile$file")), isPublic);
}

if(post.containsKey("delete")){
}else if(post.containsKey("delete")){
String urlHash=(String) post.get("delete");
switchboard.bookmarksDB.removeBookmark(urlHash);
}

if(post.containsKey("tag")){
tagName=(String) post.get("tag");
}
Expand All @@ -172,7 +176,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
max_count=Integer.parseInt((String) post.get("num"));
}
}
Iterator it=switchboard.bookmarksDB.getTagIterator(true);
Iterator it=switchboard.bookmarksDB.getTagIterator(isAdmin);
int count=0;
bookmarksDB.Tag tag;
prop.put("num-bookmarks", switchboard.bookmarksDB.bookmarksSize());
Expand All @@ -186,9 +190,9 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("taglist", count);
count=0;
if(!tagName.equals("")){
it=switchboard.bookmarksDB.getBookmarksIterator(tagName, true);
it=switchboard.bookmarksDB.getBookmarksIterator(tagName, isAdmin);
}else{
it=switchboard.bookmarksDB.getBookmarksIterator(true);
it=switchboard.bookmarksDB.getBookmarksIterator(isAdmin);
}
bookmarksDB.Bookmark bookmark;
//skip the first entries (display next page)
Expand Down
2 changes: 1 addition & 1 deletion htroot/env/templates/header.template
Expand Up @@ -28,7 +28,7 @@
<tr><td class="MenuHeader">&nbsp;Global&nbsp;Index</td></tr>
<tr><td class="MenuItem">&nbsp;<a href="/index.html" accesskey="s" class="MenuItemLink">Search Page</a></td></tr>
<tr><td class="MenuItem">&nbsp;<a href="/DetailedSearch.html" class="MenuItemLink">Detailed Search</a></td></tr>
<tr><td class="MenuItem">&nbsp;<img border="0" src="/env/grafics/lock.gif" align="top">&nbsp;<a href="/Bookmarks_p.html" class="MenuItemLink">Bookmarks</a></td></tr>
<tr><td class="MenuItem">&nbsp;<a href="/Bookmarks.html" class="MenuItemLink">Bookmarks</a></td></tr>
<tr><td class="MenuItem">&nbsp;<a href="/Help.html" class="MenuItemLink">Help</a></td></tr>
<!--<tr><td class="MenuItem">&nbsp;<a href="/Statistics.html" class="MenuItemLink">Statistics</a></td></tr>-->
<tr><td class="MenuSpacer"></td></tr>
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/data/bookmarksDB.java
Expand Up @@ -745,7 +745,7 @@ public void setTags(Vector tags, boolean local){
Iterator it=tags.iterator();
while(it.hasNext()){
String tagName=(String) it.next();
Tag tag=getTag(tagName);
Tag tag=getTag(tagHash(tagName));
if(tag == null){
tag=new Tag(tagName);
}
Expand Down

0 comments on commit e6c2f70

Please sign in to comment.