Skip to content

Commit

Permalink
- added generation of news for blog entries
Browse files Browse the repository at this point in the history
- added display of blog banner in Network view
- extended lifetime of blog, wiki and crawl news

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2102 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 15, 2006
1 parent f08e336 commit 19c6e67
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
17 changes: 16 additions & 1 deletion htroot/Blog.java
Expand Up @@ -50,6 +50,7 @@
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;

import de.anomic.data.userDB;
Expand All @@ -59,6 +60,8 @@
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNewsRecord;

public class Blog {

Expand Down Expand Up @@ -131,9 +134,21 @@ else if(post.containsKey("login")){
date = page.date();
}

String subject = wikiCode.replaceHTML(post.get("subject",""));

try {
switchboard.blogDB.write(switchboard.blogDB.newEntry(pagename, post.get("subject",""), author, ip, date, content));
switchboard.blogDB.write(switchboard.blogDB.newEntry(pagename, subject, author, ip, date, content));
} catch (IOException e) {}

// create a news message
HashMap map = new HashMap();
map.put("subject", subject);
map.put("page", pagename);
map.put("author", author);
map.put("ip", ip);
try {
yacyCore.newsPool.publishMyNews(new yacyNewsRecord("blog_add", map));
} catch (IOException e) {}
}

page = switchboard.blogDB.read(pagename); //maybe "if(page == null)"
Expand Down
1 change: 1 addition & 0 deletions htroot/Network.html
Expand Up @@ -72,6 +72,7 @@ <h2>Manually contacting Peer</h2>
<a href="http://#[fullname]#.yacy/Wiki.html" class="small" title="Read and edit wiki on peer #[fullname]#">w</a>&nbsp;&nbsp;
#(updatedProfile)#::<a href="ViewProfile.html?hash=#[hash]#"><img border="0" src="/env/grafics/profile.gif" align="bottom"></a>#(/updatedProfile)#
#(updatedWikiPage)#::<a href="http://#[name]#.yacy/Wiki.html?page=#[page]#"><img border="0" src="/env/grafics/wiki.gif" align="bottom"></a>#(/updatedWikiPage)#
#(updatedBlog)#::<a href="http://#[name]#.yacy/Blog.html?page=#[page]#"><img border="0" src="/env/grafics/blog.gif" align="bottom"></a>#(/updatedBlog)#
#(isCrawling)#::<a href="#[page]#"><img border="0" src="/env/grafics/crawl.gif" align="bottom"></a>#(/isCrawling)#
</td>
<td class="small"><a href="http://www.#[fullname]#.yacy" class="small">#[shortname]#</a></td>
Expand Down
11 changes: 11 additions & 0 deletions htroot/Network.java
Expand Up @@ -242,6 +242,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
// find updated Information using YaCyNews
final HashSet updatedProfile = new HashSet();
final HashMap updatedWiki = new HashMap();
final HashMap updatedBlog = new HashMap();
final HashMap isCrawling = new HashMap();
int availableNews = yacyCore.newsPool.size(yacyNewsPool.INCOMING_DB);
if (availableNews > 300) { availableNews = 300; }
Expand All @@ -255,6 +256,8 @@ record = yacyCore.newsPool.get(yacyNewsPool.INCOMING_DB, c);
updatedProfile.add(record.originator());
} else if (record.category().equals("wiki_upd")) {
updatedWiki.put(record.originator(), record.attributes().get("page"));
} else if (record.category().equals("blog_add")) {
updatedBlog.put(record.originator(), record.attributes().get("page"));
} else if (record.category().equals("crwlstrt")) {
isCrawling.put(record.originator(), record.attributes().get("startURL"));
}
Expand All @@ -274,6 +277,7 @@ record = yacyCore.newsPool.get(yacyNewsPool.INCOMING_DB, c);
int p;
String startURL;
String wikiPage;
String blogPage;
String userAgent, location;
int PPM;
long myValue=0, nextValue=0, prevValue=0, nextPPM=0, myPPM=0;
Expand All @@ -282,6 +286,7 @@ record = yacyCore.newsPool.get(yacyNewsPool.INCOMING_DB, c);
if (seed != null) {
prop.put(STR_TABLE_LIST + conCount + "_updatedProfile", 0);
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", 0);
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
if (conCount >= maxCount) { break; }
if (seed.hash.equals(yacyCore.seedDB.mySeed.hash)) {
Expand Down Expand Up @@ -317,6 +322,12 @@ record = yacyCore.newsPool.get(yacyNewsPool.INCOMING_DB, c);
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage_page", wikiPage);
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage_name", seed.get(yacySeed.NAME, "deadlink"));
}
if ((blogPage = (String) updatedBlog.get(seed.hash)) == null) {
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
} else {
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog_page", blogPage);
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog_name", seed.get(yacySeed.NAME, "deadlink"));
}
try {
PPM = Integer.parseInt(seed.get(yacySeed.ISPEED, "-"));
} catch (NumberFormatException ee) {
Expand Down
4 changes: 0 additions & 4 deletions source/de/anomic/kelondro/kelondroAbstractRA.java
Expand Up @@ -44,11 +44,7 @@

package de.anomic.kelondro;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
Expand Down
16 changes: 10 additions & 6 deletions source/de/anomic/yacy/yacyNewsPool.java
Expand Up @@ -79,8 +79,8 @@ public class yacyNewsPool {
"bkmrkdvt", // a vote and comment on a bookmark delete
"wiki_add", // a wiki page was created
"wiki_upd", // a wiki page was updated
"wiki_del" // a wiki page das deleted
// urlvotes
"wiki_del", // a wiki page das deleted
"blog_add" // a blog entry was added
};
public static HashSet categories;
static {
Expand Down Expand Up @@ -179,15 +179,19 @@ private boolean automaticProcessP(yacyNewsRecord record) {
if (record == null) return false;
if (record.category() == null) return true;
if ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 7) /* 1 Week */) {
// remove everything after 1 week
// remove everything after 1 week
return true;
}
if ((record.category().equals("wiki_upd")) &&
((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {
if (((record.category().equals("wiki_add")) || (record.category().equals("wiki_upd"))) &&
((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 3) /* 3 Days */)) {
return true;
}
if ((record.category().equals("blog_add")) &&
((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 3) /* 3 Days */)) {
return true;
}
if ((record.category().equals("crwlstrt")) &&
((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {
((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 2) /* 2 Days */)) {
yacySeed seed = yacyCore.seedDB.get(record.originator());
if (seed == null) return false;
try {
Expand Down

0 comments on commit 19c6e67

Please sign in to comment.