@ -1,4 +1,4 @@
// Surftip p s.java
// Surftip s.java
// (C) 2006 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
// first published 2006 on http://www.anomic.de
//
@ -44,7 +44,7 @@ import de.anomic.yacy.yacyNewsPool;
import de.anomic.yacy.yacyNewsRecord ;
import de.anomic.yacy.yacySeed ;
public class Surftip p s {
public class Surftip s {
public static serverObjects respond ( httpHeader header , serverObjects post , serverSwitch env ) {
final plasmaSwitchboard sb = ( plasmaSwitchboard ) env ;
@ -56,17 +56,17 @@ public class Surftipps {
boolean showScore = ( ( post ! = null ) & & ( post . containsKey ( "score" ) ) ) ;
boolean surftip p sOn = sb . getConfigBool ( "showSurfti p ps", true ) ;
if ( ( post ! = null ) & & ( post . containsKey ( "surftip p s") ) ) {
boolean surftip sOn = sb . getConfigBool ( "showSurfti ps", true ) ;
if ( ( post ! = null ) & & ( post . containsKey ( "surftip s") ) ) {
if ( ! sb . verifyAuthentication ( header , false ) ) {
prop . put ( "AUTHENTICATE" , "admin log-in" ) ; // force log-in
return prop ;
}
surftip p sOn = post . get ( "surfti p ps", "0" ) . equals ( "1" ) ;
sb . setConfig ( "showSurftip p s", surfti p psOn) ;
surftip sOn = post . get ( "surfti ps", "0" ) . equals ( "1" ) ;
sb . setConfig ( "showSurftip s", surfti psOn) ;
}
if ( surftip p sOn) {
if ( surftip sOn) {
// read voting
String hash ;
@ -98,7 +98,7 @@ public class Surftipps {
yacyCore . newsPool . publishMyNews ( new yacyNewsRecord ( "stippavt" , map ) ) ;
}
// create surftip p s
// create surftip s
HashMap negativeHashes = new HashMap ( ) ; // a mapping from an url hash to Integer (count of votes)
HashMap positiveHashes = new HashMap ( ) ; // a mapping from an url hash to Integer (count of votes)
accumulateVotes ( negativeHashes , positiveHashes , yacyNewsPool . INCOMING_DB ) ;
@ -106,10 +106,10 @@ public class Surftipps {
//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.PUBLISHED_DB);
kelondroMScoreCluster ranking = new kelondroMScoreCluster ( ) ; // score cluster for url hashes
kelondroRow rowdef = new kelondroRow ( "String url-255, String title-120, String description-120, String refid-" + ( yacyCore . universalDateShortPattern . length ( ) + 12 ) ) ;
HashMap surftip p s = new HashMap ( ) ; // a mapping from an url hash to a kelondroRow.Entry with display properties
accumulateSurftip p s( surfti p ps, ranking , rowdef , negativeHashes , positiveHashes , yacyNewsPool . INCOMING_DB ) ;
//accumulateSurftip p s(surftip ps, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);
//accumulateSurftip p s(surftip ps, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.PUBLISHED_DB);
HashMap surftip s = new HashMap ( ) ; // a mapping from an url hash to a kelondroRow.Entry with display properties
accumulateSurftip s( surfti ps, ranking , rowdef , negativeHashes , positiveHashes , yacyNewsPool . INCOMING_DB ) ;
//accumulateSurftip s(surftips, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);
//accumulateSurftip s(surftips, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.PUBLISHED_DB);
// read out surftipp array and create property entries
Iterator k = ranking . scores ( false ) ;
@ -121,7 +121,7 @@ public class Surftipps {
urlhash = ( String ) k . next ( ) ;
if ( urlhash = = null ) continue ;
row = ( kelondroRow . Entry ) surftip p s. get ( urlhash ) ;
row = ( kelondroRow . Entry ) surftip s. get ( urlhash ) ;
if ( row = = null ) continue ;
url = row . getColString ( 0 , null ) ;
@ -135,22 +135,22 @@ public class Surftipps {
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
prop . put ( "surftip p s_results_" + i + "_recommend" , ( voted ) ? 0 : 1 ) ;
prop . put ( "surftip p s_results_" + i + "_recommend_negativeVoteLink" , "/Surfti p ps.html?voteNegative=" + urlhash + "&refid=" + refid + "&display=" + display + ( ( showScore ) ? "&score=" : "" ) ) ; // for negaive votes, we don't send around the bad url again, the hash is enough
prop . put ( "surftip p s_results_" + i + "_recommend_positiveVoteLink" , "/Surfti p ps.html?votePositive=" + urlhash + "&refid=" + refid + "&url=" + crypt . simpleEncode ( url , null , 'b' ) + "&title=" + crypt . simpleEncode ( title , null , 'b' ) + "&description=" + crypt . simpleEncode ( description , null , 'b' ) + "&display=" + display + ( ( showScore ) ? "&score=" : "" ) ) ;
prop . put ( "surftip p s_results_" + i + "_url" , url ) ;
prop . put ( "surftip p s_results_" + i + "_urlname" , nxTools . shortenURLString ( url , 60 ) ) ;
prop . put ( "surftip p s_results_" + i + "_urlhash" , urlhash ) ;
prop . put ( "surftip p s_results_" + i + "_title" , ( showScore ) ? ( "(" + ranking . getScore ( urlhash ) + ") " + title ) : title ) ;
prop . put ( "surftip p s_results_" + i + "_description" , description ) ;
prop . put ( "surftip s_results_" + i + "_recommend" , ( voted ) ? 0 : 1 ) ;
prop . put ( "surftip s_results_" + i + "_recommend_negativeVoteLink" , "/Surfti ps.html?voteNegative=" + urlhash + "&refid=" + refid + "&display=" + display + ( ( showScore ) ? "&score=" : "" ) ) ; // for negaive votes, we don't send around the bad url again, the hash is enough
prop . put ( "surftip s_results_" + i + "_recommend_positiveVoteLink" , "/Surfti ps.html?votePositive=" + urlhash + "&refid=" + refid + "&url=" + crypt . simpleEncode ( url , null , 'b' ) + "&title=" + crypt . simpleEncode ( title , null , 'b' ) + "&description=" + crypt . simpleEncode ( description , null , 'b' ) + "&display=" + display + ( ( showScore ) ? "&score=" : "" ) ) ;
prop . put ( "surftip s_results_" + i + "_url" , url ) ;
prop . put ( "surftip s_results_" + i + "_urlname" , nxTools . shortenURLString ( url , 60 ) ) ;
prop . put ( "surftip s_results_" + i + "_urlhash" , urlhash ) ;
prop . put ( "surftip s_results_" + i + "_title" , ( showScore ) ? ( "(" + ranking . getScore ( urlhash ) + ") " + title ) : title ) ;
prop . put ( "surftip s_results_" + i + "_description" , description ) ;
i + + ;
if ( i > = 50 ) break ;
}
prop . put ( "surftip p s_results", i ) ;
prop . put ( "surftip p s", 1 ) ;
prop . put ( "surftip s_results", i ) ;
prop . put ( "surftip s", 1 ) ;
} else {
prop . put ( "surftip p s", 0 ) ;
prop . put ( "surftip s", 0 ) ;
}
return prop ;
@ -186,8 +186,8 @@ public class Surftipps {
} catch ( IOException e ) { e . printStackTrace ( ) ; }
}
private static void accumulateSurftip p s(
HashMap surftip p s, kelondroMScoreCluster ranking , kelondroRow rowdef ,
private static void accumulateSurftip s(
HashMap surftip s, kelondroMScoreCluster ranking , kelondroRow rowdef ,
HashMap negativeHashes , HashMap positiveHashes , int dbtype ) {
int maxCount = Math . min ( 1000 , yacyCore . newsPool . size ( dbtype ) ) ;
yacyNewsRecord record ;
@ -291,7 +291,7 @@ public class Surftipps {
if ( entry ! = null ) {
urlhash = indexURL . urlHash ( url ) ;
if ( urlhash = = null ) {
System . out . println ( "Surftip p s: bad url '" + url + "' from news record " + record . toString ( ) ) ;
System . out . println ( "Surftip s: bad url '" + url + "' from news record " + record . toString ( ) ) ;
continue ;
}
if ( ( vote = ( Integer ) negativeHashes . get ( urlhash ) ) ! = null ) {
@ -301,11 +301,11 @@ public class Surftipps {
score + = 2 * vote . intValue ( ) ;
}
// consider double-entries
if ( surftip p s. containsKey ( urlhash ) ) {
if ( surftip s. containsKey ( urlhash ) ) {
ranking . addScore ( urlhash , score ) ;
} else {
ranking . setScore ( urlhash , score ) ;
surftip p s. put ( urlhash , entry ) ;
surftip s. put ( urlhash , entry ) ;
}
}