diff --git a/.classpath b/.classpath index db4fbca7f..e35603f33 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,11 @@ - + - + + diff --git a/htroot/yacy/user/default.css b/htroot/yacy/user/default.css new file mode 100755 index 000000000..7e46dfed3 --- /dev/null +++ b/htroot/yacy/user/default.css @@ -0,0 +1,530 @@ +/* +Design by Free CSS Templates +http://www.freecsstemplates.org +Released for free under a Creative Commons Attribution 2.5 License + +extended with material from YaCy developers (was: base.css) +*/ + +* { + margin: 0; + padding: 0; +} + +body { + background: #FFFFFF url(images/background.gif) repeat-x; + font: normal small Arial, Helvetica, sans-serif; + color: #808080; +} + +form { +} + +fieldset { + border: none; +} + +legend { + display: none; +} + +h1, h2, h3 { + margin-top: 0em; + margin: 0; + color: #239AFF; +} + +h2 { + margin-bottom: .6em; + font-size: 1.8em; +} + +h3 { + margin-bottom: 0em; + font-size: 1em; + line-height: 1.2em; +} + +p, blockquote, ul, ol { + margin-bottom: 1.5em; + line-height: 1.2em; +} + +p { +} + +blockquote { +} + +ul { + margin-left: 2em; + list-style: square; +} + +ul li { +} + +ol { + margin-left: 2em; + list-style: lower-roman; +} + +ol li { +} + +a { + color: #FFA020; +} + +a:hover { + text-decoration: none; + color: #20A020; +} + +img { + border: none; +} + +/* Boxed Style */ + +.boxed { + margin-bottom: 1em; + background: #F7F7F7; + border: 1px solid #F0F0F0; +} + +.boxed .title { + height: 29px; + padding: 10px 0 0 27px; + background: #239AFF url(images/arrow2.gif) no-repeat 10px 50%; + text-transform: uppercase; + font-size: 1.2em; + color: #FFFFFF; +} + +.boxed .content { + padding: 9px; +} + +/* Header */ + +#header { + width: 92%; + height: 60px; + margin: 0 auto; + background: #239AFF; +} + +/* Header > Logo */ + +#logo { + float: left; + padding: 5px 0 0 0; +} + +#logo h1 { + text-transform: uppercase; + font-size: 2em; +} + +#logo h2 { + margin: 0; + text-transform: uppercase; + font-size: 1.2em; +} + +#logo a { + text-decoration: none; + color: #FFFFFF; +} + +/* Header > Top Menu */ + +#topmenu { + float: right; +} + +#topmenu ul { + margin: 0; + padding: 40px 0 0 0; + list-style: none; + line-height: normal; +} + +#topmenu li { + display: inline +} + +#topmenu a { + display: block; + float: left; + margin: 0 0 0 16px; + padding: 0 0 0 12px; + text-transform: uppercase; + text-decoration: none; + font-size: x-small; + font-weight: bold; + color: #FFFFFF; +} + +#topmenu a:hover { + text-decoration: underline +} + +#topmenuhome { + background: url(images/house.gif) no-repeat left center; +} + +#topmenutree { + background: url(images/tree.gif) no-repeat left center; +} + +#topmenucontact { + background: url(images/letter.gif) no-repeat left center; +} + +/* Menu */ + +#menu { + width: 92%; + height: 40px; + margin: 0 auto; +} + +#menu ul { + margin: 0; + list-style: none; + line-height: normal; +} + +#menu li { + display: inline; +} + +#menu a { + display: block; + float: left; + height: 26px; + padding: 14px 18px 0 20px; + text-transform: uppercase; + text-decoration: none; + font-weight: bold; + color: #20A020; +} + +#menu a:hover { + text-decoration: underline; +} + +#menu .first a { + padding-left: 0; + background: none; +} + +/* Content */ + +#content { + width: 92%; + padding-left: 10px; + margin: 0 auto; + padding: 20px 0; +} + +/* Content > Main */ + +#main { + float: left; + width: 70%; +} + +/* Content > Main > Example */ + +#example { +} + +/* Content > Main > Welcome */ + +#welcome { + margin: 0 0 1em 0; + padding: 10px 0 1.5em 0; + /* border-bottom: 1px solid #CCCCCC; */ +} + +#searchtext { + width: 400px; + margin-bottom: .5em; + padding: 2px 5px; + border: 1px solid #CCCCCC; + font: normal small Arial, Helvetica, sans-serif; + color: #999999; +} + +#searchbutton { + width: 100px; + margin-bottom: .5em; + padding: 2px 5px; + border: 1px solid #CCCCCC; + font: normal small Arial, Helvetica, sans-serif; + color: #999999; +} + + +/* Content > Sidebar */ + +#sidebar { + float: right; + width: 220px; +} + +/* Content > Sidebar > Login */ + +#login { +} + +#login label { + display: block; +} + +#login #inputtext1, #login #inputtext2 { + width: 180px; + margin-bottom: .5em; + padding: 2px 5px; + border: 1px solid #CCCCCC; + font: normal small Arial, Helvetica, sans-serif; + color: #999999; +} + +#login #inputsubmit1 { + float: right; + width: 60px; + margin-right: 7px; + border: 1px solid #CCCCCC; + border-top-color: #FFFFFF; + border-left-color: #FFFFFF; + font: normal small Arial, Helvetica, sans-serif; +} + +#login p { + margin: 0; + padding-top: .2em; + font-size: x-small; +} + +/* Content > Sidebar > Updates*/ + +#updates { +} + +#updates ul { + margin: 0; + list-style: none; +} + +#updates li { + margin-bottom: 1em; +} + +#updates h3 { + margin: 0; + padding: 0 0 0 10px; + background: url(images/arrow1.gif) no-repeat left center; + font-size: x-small; +} + +#updates p { + margin: 0; + padding: 0 0 0 10px; + line-height: normal; + font-size: .85em; +} + +#updates a { + text-decoration: none; +} + +/* Content > Sidebar > Partners*/ + +#partners { +} + +/* Footer */ + +#footer { + clear: both; + width: 92%; + margin: 0 auto 2em auto; + background: #F7F7F7; + border: 1px solid #F0F0F0; +} + +/* Footer > Legal */ + +#legal { + margin: 0; + padding: 8px; + text-align: center; + color: #808080; +} + +#legal a { + font-weight: bold; + color: #808080; +} + +/* Footer > Links */ + +#links { + margin: 0; + padding: 10px; + text-align: center; +} + + +/* YaCy additions */ + +div.searchresults { + padding-top:0.4em; + margin-bottom:0.4em; +} + +div.searchresults.hidden { + display:none; +} + +h3.linktitle { + margin:2px; + padding-left: 20px; +} + +img.favicon{ + margin: 0px 4px 0px -20px; + width: 16px; + height: 16px; + float: left; +} + +div.urlactions { + float:left; + clear:left; + margin: 0px 6px 0px 2px; +} + +div.urlactions a { + display:block; + width: 12px; + height: 12px; + margin: 2px 0px; +} + +a.bookmarkTags { + font-weight:bold; + white-space:nowrap; +} + +a.bookmarkTitle { + font-size:17px; + font-weight:bold; +} + +a.BookmarkLink { + background:url(/env/grafics/addlink.png) left center no-repeat; + padding-left:15px; +} + +a.bookmarklink:hover, div.searchresults:hover a.bookmarklink, div.searchresults.hover a.bookmarklink { + background:url(/env/grafics/bookmark.gif) center center no-repeat; +} + +a.recommendlink:hover, div.searchresults:hover a.recommendlink, div.searchresults.hover a.recommendlink { + background:url(/env/grafics/plus.gif) center center no-repeat; +} + +a.deletelink:hover, div.searchresults:hover a.deletelink, div.searchresults.hover a.deletelink { + background:url(/env/grafics/minus.gif) center center no-repeat; +} + +img.deleteIcon, img.recommendIcon { + height: 11px; + width: 11px; +} + +img.bookmarkIcon { + height: 18px; + width: 18px; +} + +.snippet { + font-style:italic; + color: #808080; + line-height: 1.2em; + margin-bottom:0em; + margin-left:22px; +} + +.snippet b { + color: black; +} + +.searchresults .linktitle a { + color:#239AFF; + text-decoration:none; +} + +.searchresults .url { + line-height: 1.2em; + margin-bottom:0.6em; + margin-left:22px; +} + +.searchresults .url a { + color:#20A020; + text-decoration:none; +} + +div.ProgressBarCaption { + float:left; + width:70px; +} + +div.ProgressBar { + float:left; + width:100px; + height:10px; +} + +div.ProgressBarFill { + margin:0px; + padding:0px; + height:100%; /*not valid value for Netscape 8*/ +} + +#resCounter { + /* left part of the progress bar */ + position: absolute; + left: 1em; +} + +#resProgBar { + height: 1.5em; + margin: 1em auto; + position: relative; /* for "relative" absolute pos of children */ + text-align: left; + width: 100%; + float: none; +} + +#resNav { + /* right part of the progress bar */ + position: absolute; + right: 1em; +} + +#resNav a { + color:#239AFF; +} + +#resProgFill { + position: absolute; + left: 0px; + top: 0px; +} diff --git a/htroot/yacy/user/license.txt b/htroot/yacy/user/license.txt new file mode 100755 index 000000000..7f9442eca --- /dev/null +++ b/htroot/yacy/user/license.txt @@ -0,0 +1,243 @@ +Creative Commons + +Creative Commons Legal Code + +*Attribution 2.5* + +CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE +LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN +ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION +ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE +INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM +ITS USE. + +/License/ + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE +RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS +AND CONDITIONS. + +*1. Definitions* + + 1. *"Collective Work"* means a work, such as a periodical issue, + anthology or encyclopedia, in which the Work in its entirety in + unmodified form, along with a number of other contributions, + constituting separate and independent works in themselves, are + assembled into a collective whole. A work that constitutes a + Collective Work will not be considered a Derivative Work (as + defined below) for the purposes of this License. + 2. *"Derivative Work"* means a work based upon the Work or upon the + Work and other pre-existing works, such as a translation, musical + arrangement, dramatization, fictionalization, motion picture + version, sound recording, art reproduction, abridgment, + condensation, or any other form in which the Work may be recast, + transformed, or adapted, except that a work that constitutes a + Collective Work will not be considered a Derivative Work for the + purpose of this License. For the avoidance of doubt, where the + Work is a musical composition or sound recording, the + synchronization of the Work in timed-relation with a moving image + ("synching") will be considered a Derivative Work for the purpose + of this License. + 3. *"Licensor"* means the individual or entity that offers the Work + under the terms of this License. + 4. *"Original Author"* means the individual or entity who created the + Work. + 5. *"Work"* means the copyrightable work of authorship offered under + the terms of this License. + 6. *"You"* means an individual or entity exercising rights under this + License who has not previously violated the terms of this License + with respect to the Work, or who has received express permission + from the Licensor to exercise rights under this License despite a + previous violation. + +*2. Fair Use Rights.* Nothing in this license is intended to reduce, +limit, or restrict any rights arising from fair use, first sale or other +limitations on the exclusive rights of the copyright owner under +copyright law or other applicable laws. + +*3. License Grant.* Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + 1. to reproduce the Work, to incorporate the Work into one or more + Collective Works, and to reproduce the Work as incorporated in the + Collective Works; + 2. to create and reproduce Derivative Works; + 3. to distribute copies or phonorecords of, display publicly, perform + publicly, and perform publicly by means of a digital audio + transmission the Work including as incorporated in Collective Works; + 4. to distribute copies or phonorecords of, display publicly, perform + publicly, and perform publicly by means of a digital audio + transmission Derivative Works. + 5. + + For the avoidance of doubt, where the work is a musical composition: + + 1. *Performance Royalties Under Blanket Licenses*. Licensor + waives the exclusive right to collect, whether individually + or via a performance rights society (e.g. ASCAP, BMI, + SESAC), royalties for the public performance or public + digital performance (e.g. webcast) of the Work. + 2. *Mechanical Rights and Statutory Royalties*. Licensor waives + the exclusive right to collect, whether individually or via + a music rights agency or designated agent (e.g. Harry Fox + Agency), royalties for any phonorecord You create from the + Work ("cover version") and distribute, subject to the + compulsory license created by 17 USC Section 115 of the US + Copyright Act (or the equivalent in other jurisdictions). + 6. *Webcasting Rights and Statutory Royalties*. For the avoidance of + doubt, where the Work is a sound recording, Licensor waives the + exclusive right to collect, whether individually or via a + performance-rights society (e.g. SoundExchange), royalties for the + public digital performance (e.g. webcast) of the Work, subject to + the compulsory license created by 17 USC Section 114 of the US + Copyright Act (or the equivalent in other jurisdictions). + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights +in other media and formats. All rights not expressly granted by Licensor +are hereby reserved. + +*4. Restrictions.*The license granted in Section 3 above is expressly +made subject to and limited by the following restrictions: + + 1. You may distribute, publicly display, publicly perform, or + publicly digitally perform the Work only under the terms of this + License, and You must include a copy of, or the Uniform Resource + Identifier for, this License with every copy or phonorecord of the + Work You distribute, publicly display, publicly perform, or + publicly digitally perform. You may not offer or impose any terms + on the Work that alter or restrict the terms of this License or + the recipients' exercise of the rights granted hereunder. You may + not sublicense the Work. You must keep intact all notices that + refer to this License and to the disclaimer of warranties. You may + not distribute, publicly display, publicly perform, or publicly + digitally perform the Work with any technological measures that + control access or use of the Work in a manner inconsistent with + the terms of this License Agreement. The above applies to the Work + as incorporated in a Collective Work, but this does not require + the Collective Work apart from the Work itself to be made subject + to the terms of this License. If You create a Collective Work, + upon notice from any Licensor You must, to the extent practicable, + remove from the Collective Work any credit as required by clause + 4(b), as requested. If You create a Derivative Work, upon notice + from any Licensor You must, to the extent practicable, remove from + the Derivative Work any credit as required by clause 4(b), as + requested. + 2. If you distribute, publicly display, publicly perform, or publicly + digitally perform the Work or any Derivative Works or Collective + Works, You must keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) + the name of the Original Author (or pseudonym, if applicable) if + supplied, and/or (ii) if the Original Author and/or Licensor + designate another party or parties (e.g. a sponsor institute, + publishing entity, journal) for attribution in Licensor's + copyright notice, terms of service or by other reasonable means, + the name of such party or parties; the title of the Work if + supplied; to the extent reasonably practicable, the Uniform + Resource Identifier, if any, that Licensor specifies to be + associated with the Work, unless such URI does not refer to the + copyright notice or licensing information for the Work; and in the + case of a Derivative Work, a credit identifying the use of the + Work in the Derivative Work (e.g., "French translation of the Work + by Original Author," or "Screenplay based on original Work by + Original Author"). Such credit may be implemented in any + reasonable manner; provided, however, that in the case of a + Derivative Work or Collective Work, at a minimum such credit will + appear where any other comparable authorship credit appears and in + a manner at least as prominent as such other comparable authorship + credit. + +*5. Representations, Warranties and Disclaimer* + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +*6. Limitation on Liability.* EXCEPT TO THE EXTENT REQUIRED BY +APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL +THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY +DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF +LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +*7. Termination* + + 1. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Derivative Works or + Collective Works from You under this License, however, will not + have their licenses terminated provided such individuals or + entities remain in full compliance with those licenses. Sections + 1, 2, 5, 6, 7, and 8 will survive any termination of this License. + 2. Subject to the above terms and conditions, the license granted + here is perpetual (for the duration of the applicable copyright in + the Work). Notwithstanding the above, Licensor reserves the right + to release the Work under different license terms or to stop + distributing the Work at any time; provided, however that any such + election will not serve to withdraw this License (or any other + license that has been, or is required to be, granted under the + terms of this License), and this License will continue in full + force and effect unless terminated as stated above. + +*8. Miscellaneous* + + 1. Each time You distribute or publicly digitally perform the Work or + a Collective Work, the Licensor offers to the recipient a license + to the Work on the same terms and conditions as the license + granted to You under this License. + 2. Each time You distribute or publicly digitally perform a + Derivative Work, Licensor offers to the recipient a license to the + original Work on the same terms and conditions as the license + granted to You under this License. + 3. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability + of the remainder of the terms of this License, and without further + action by the parties to this agreement, such provision shall be + reformed to the minimum extent necessary to make such provision + valid and enforceable. + 4. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in + writing and signed by the party to be charged with such waiver or + consent. + 5. This License constitutes the entire agreement between the parties + with respect to the Work licensed here. There are no + understandings, agreements or representations with respect to the + Work not specified here. Licensor shall not be bound by any + additional provisions that may appear in any communication from + You. This License may not be modified without the mutual written + agreement of the Licensor and You. + +Creative Commons is not a party to this License, and makes no warranty +whatsoever in connection with the Work. Creative Commons will not be +liable to You or any party on any legal theory for any damages +whatsoever, including without limitation any general, special, +incidental or consequential damages arising in connection to this +license. Notwithstanding the foregoing two (2) sentences, if Creative +Commons has expressly identified itself as the Licensor hereunder, it +shall have all rights and obligations of Licensor. + +Except for the limited purpose of indicating to the public that the Work +is licensed under the CCPL, neither party will use the trademark +"Creative Commons" or any related trademark or logo of Creative Commons +without the prior written consent of Creative Commons. Any permitted use +will be in compliance with Creative Commons' then-current trademark +usage guidelines, as may be published on its website or otherwise made +available upon request from time to time. + +Creative Commons may be contacted at http://creativecommons.org/ +. + +« Back to Commons Deed <./> diff --git a/htroot/yacy/user/ysearch.html b/htroot/yacy/user/ysearch.html new file mode 100755 index 000000000..edebd1ace --- /dev/null +++ b/htroot/yacy/user/ysearch.html @@ -0,0 +1,148 @@ + + + + + +YaCy '#[clientname]#': Search Page + + + + + + + + + + + + +
+
+
+

Welcome to YaCy P2P Web Search!

+ + #(input)# + :: + + :: + + #(/input)# +
+ +#(searchagain)# +:: + +#(/searchagain)# + + +#(excluded)# + :: +

The following words are stop-words and had been excluded from the search: #[stopwords]#.

+#(/excluded)# + + +#(num-results)# + :: +

No Results.

+ :: +

No Results. (length of search words must be at least 3 characters)

+ :: +
+ Results #[offset]#-#[itemscount]# from #[totalcount]# total#(globalresults)#.:: (#[localResourceSize]# local, #[remoteResourceSize]# remote), #[remoteIndexCount]# links from #[remotePeerCount]# other YaCy peers.#(/globalresults)# + #[resnav]# + :: +

Searching the web with this peer is disabled for unauthorized users. Please log in as administrator to use the search function

+#(/num-results)# + + + + + +#(resultTable)#::#(/resultTable)# +#{results}# + +#{/results}# +#(resultTable)#::
MediaURL
#(/resultTable)# + +
+
+ + + + diff --git a/htroot/yacy/user/ysearch.java b/htroot/yacy/user/ysearch.java new file mode 100644 index 000000000..186932fb6 --- /dev/null +++ b/htroot/yacy/user/ysearch.java @@ -0,0 +1,423 @@ +// ysearch.java +// ----------------------- +// part of the AnomicHTTPD caching proxy +// (C) by Michael Peter Christen; mc@anomic.de +// first published on http://www.anomic.de +// Frankfurt, Germany, 2004 +// +// $LastChangedDate: 2008-02-07 22:16:36 +0000 (Do, 07 Feb 2008) $ +// $LastChangedRevision: 4459 $ +// $LastChangedBy: orbiter $ +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// Using this software in any meaning (reading, learning, copying, compiling, +// running) means that you agree that the Author(s) is (are) not responsible +// for cost, loss of data or any harm that may be caused directly or indirectly +// by usage of this softare or this documentation. The usage of this software +// is on your own risk. The installation and usage (starting/running) of this +// software may allow other people or application to access your computer and +// any attached devices and is highly dependent on the configuration of the +// software which must be done by the user of the software; the author(s) is +// (are) also not responsible for proper configuration and usage of the +// software, even if provoked by documentation provided together with +// the software. +// +// Any changes to this file according to the GPL as documented in the file +// gpl.txt aside this file in the shipment you received can be done to the +// lines that follows this copyright notice here, but changes must not be +// done inside the copyright notive above. A re-distribution must contain +// the intact and unchanged copyright notice. +// Contributions and changes to the program code must be marked as such. +// +// You must compile this file with +// javac -classpath .:../classes yacysearch.java +// if the shell's current path is HTROOT + +import java.util.HashMap; +import java.util.TreeSet; + +import de.anomic.http.httpHeader; +import de.anomic.index.indexURLEntry; +import de.anomic.kelondro.kelondroBitfield; +import de.anomic.kelondro.kelondroMSetTools; +import de.anomic.plasma.plasmaCondenser; +import de.anomic.plasma.plasmaParserDocument; +import de.anomic.plasma.plasmaSearchEvent; +import de.anomic.plasma.plasmaSearchQuery; +import de.anomic.plasma.plasmaSearchRankingProfile; +import de.anomic.plasma.plasmaSnippetCache; +import de.anomic.plasma.plasmaSwitchboard; +import de.anomic.server.serverCore; +import de.anomic.server.serverObjects; +import de.anomic.server.serverSwitch; +import de.anomic.server.logging.serverLog; +import de.anomic.tools.yFormatter; +import de.anomic.yacy.yacyCore; +import de.anomic.yacy.yacyNewsPool; +import de.anomic.yacy.yacyNewsRecord; +import de.anomic.yacy.yacyURL; + +public class ysearch { + + public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { + final plasmaSwitchboard sb = (plasmaSwitchboard) env; + sb.localSearchLastAccess = System.currentTimeMillis(); + + boolean searchAllowed = sb.getConfigBool("publicSearchpage", true) || sb.verifyAuthentication(header, false); + + boolean authenticated = sb.adminAuthenticated(header) >= 2; + int display = (post == null) ? 0 : post.getInt("display", 0); + if ((display == 1) && (!authenticated)) display = 0; + int input = (post == null) ? 2 : post.getInt("input", 2); + String promoteSearchPageGreeting = env.getConfig("promoteSearchPageGreeting", ""); + if (env.getConfigBool("promoteSearchPageGreeting.useNetworkName", false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", ""); + if (promoteSearchPageGreeting.length() == 0) promoteSearchPageGreeting = "P2P WEB SEARCH"; + + // get query + String querystring = (post == null) ? "" : post.get("search", "").trim(); + + boolean rss = (post == null) ? false : post.get("rss", "false").equals("true"); + if ((post == null) || (env == null) || (querystring.length() == 0) || (!searchAllowed)) { + // we create empty entries for template strings + final serverObjects prop = new serverObjects(); + prop.put("searchagain", "0"); + prop.put("input", input); + prop.put("display", display); + prop.put("input_input", input); + prop.put("input_display", display); + prop.put("promoteSearchPageGreeting", promoteSearchPageGreeting); + prop.put("input_former", ""); + prop.put("former", ""); + prop.put("input_count", "10"); + prop.put("input_offset", "0"); + prop.put("input_resource", "global"); + prop.put("input_urlmaskfilter", ".*"); + prop.put("input_prefermaskfilter", ""); + prop.put("input_indexof", "off"); + prop.put("input_constraint", ""); + prop.put("input_cat", "href"); + prop.put("input_depth", "0"); + prop.put("input_contentdom", "text"); + prop.put("input_contentdomCheckText", "1"); + prop.put("input_contentdomCheckAudio", "0"); + prop.put("input_contentdomCheckVideo", "0"); + prop.put("input_contentdomCheckImage", "0"); + prop.put("input_contentdomCheckApp", "0"); + prop.put("excluded", "0"); + prop.put("results", ""); + prop.put("resultTable", "0"); + prop.put("num-results", searchAllowed ? "0" : "4"); + + return prop; + } + + // collect search attributes + int maxDistance = Integer.MAX_VALUE; + + if ((querystring.length() > 2) && (querystring.charAt(0) == '"') && (querystring.charAt(querystring.length() - 1) == '"')) { + querystring = querystring.substring(1, querystring.length() - 1).trim(); + maxDistance = 1; + } + if (sb.facilityDB != null) try { sb.facilityDB.update("zeitgeist", querystring, post); } catch (Exception e) {} + + int itemsPerPage = post.getInt("count", 10); + int offset = post.getInt("offset", 0); + boolean global = (post == null) ? true : post.get("resource", "global").equals("global"); + final boolean indexof = post.get("indexof","").equals("on"); + String urlmask = ""; + if (post.containsKey("urlmask") && post.get("urlmask").equals("no")) { + urlmask = ".*"; + } else { + urlmask = (post.containsKey("urlmaskfilter")) ? (String) post.get("urlmaskfilter") : ".*"; + } + String prefermask = post.get("prefermaskfilter", ""); + if ((prefermask.length() > 0) && (prefermask.indexOf(".*") < 0)) prefermask = ".*" + prefermask + ".*"; + + kelondroBitfield constraint = ((post.containsKey("constraint")) && (post.get("constraint", "").length() > 0)) ? new kelondroBitfield(4, post.get("constraint", "______")) : null; + if (indexof) { + constraint = new kelondroBitfield(4); + constraint.set(plasmaCondenser.flag_cat_indexof, true); + } + + // SEARCH + //final boolean indexDistributeGranted = sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, "true").equals("true"); + //final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true"); + //final boolean offline = yacyCore.seedDB.mySeed().isVirgin(); + final boolean clustersearch = sb.isRobinsonMode() && + (sb.getConfig("cluster.mode", "").equals("privatecluster") || + sb.getConfig("cluster.mode", "").equals("publiccluster")); + //if (offline || !indexDistributeGranted || !indexReceiveGranted) { global = false; } + if (clustersearch) global = true; // switches search on, but search target is limited to cluster nodes + + // find search domain + int contentdomCode = plasmaSearchQuery.contentdomParser(post.get("contentdom", "text")); + + // patch until better search profiles are available + if ((contentdomCode != plasmaSearchQuery.CONTENTDOM_TEXT) && (itemsPerPage <= 30)) itemsPerPage = 30; + + serverObjects prop = new serverObjects(); + if (post.get("cat", "href").equals("href")) { + + final TreeSet[] query = plasmaSearchQuery.cleanQuery(querystring); // converts also umlaute + boolean near = (query[0].contains("near")) && (querystring.indexOf("NEAR") >= 0); + if (near) { + query[0].remove("near"); + } + plasmaSearchRankingProfile ranking = sb.getRanking(); + if (near) { + ranking.coeff_worddistance = plasmaSearchRankingProfile.COEFF_MAX; + } + + // filter out stopwords + final TreeSet filtered = kelondroMSetTools.joinConstructive(query[0], plasmaSwitchboard.stopwords); + if (filtered.size() > 0) { + kelondroMSetTools.excludeDestructive(query[0], plasmaSwitchboard.stopwords); + } + + // if a minus-button was hit, remove a special reference first + if (post.containsKey("deleteref")) { + if (!sb.verifyAuthentication(header, true)) { + prop.put("AUTHENTICATE", "admin log-in"); // force log-in + return prop; + } + + // delete the index entry locally + final String delHash = post.get("deleteref", ""); // urlhash + sb.wordIndex.removeWordReferences(query[0], delHash); + + // make new news message with negative voting + HashMap map = new HashMap(); + map.put("urlhash", delHash); + map.put("vote", "negative"); + map.put("refid", ""); + yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map)); + } + + // if a plus-button was hit, create new voting message + if (post.containsKey("recommendref")) { + if (!sb.verifyAuthentication(header, true)) { + prop.put("AUTHENTICATE", "admin log-in"); // force log-in + return prop; + } + final String recommendHash = post.get("recommendref", ""); // urlhash + indexURLEntry urlentry = sb.wordIndex.loadedURL.load(recommendHash, null, 0); + if (urlentry != null) { + indexURLEntry.Components comp = urlentry.comp(); + plasmaParserDocument document; + document = plasmaSnippetCache.retrieveDocument(comp.url(), true, 5000, true); + if (document != null) { + // create a news message + HashMap map = new HashMap(); + map.put("url", comp.url().toNormalform(false, true).replace(',', '|')); + map.put("title", comp.dc_title().replace(',', ' ')); + map.put("description", ((document == null) ? comp.dc_title() : document.dc_title()).replace(',', ' ')); + map.put("author", ((document == null) ? "" : document.dc_creator())); + map.put("tags", ((document == null) ? "" : document.dc_subject(' '))); + yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_ADD, map)); + document.close(); + } + } + } + + // prepare search properties + final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed() != null) && (yacyCore.seedDB.mySeed().getPublicAddress() != null)); + final boolean globalsearch = (global) && (yacyonline) && (sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false)); + + // do the search + TreeSet queryHashes = plasmaCondenser.words2hashes(query[0]); + plasmaSearchQuery theQuery = new plasmaSearchQuery( + querystring, + queryHashes, + plasmaCondenser.words2hashes(query[1]), + ranking, + maxDistance, + prefermask, + contentdomCode, + true, + itemsPerPage, + offset, + urlmask, + (clustersearch && globalsearch) ? plasmaSearchQuery.SEARCHDOM_CLUSTERALL : + ((globalsearch) ? plasmaSearchQuery.SEARCHDOM_GLOBALDHT : plasmaSearchQuery.SEARCHDOM_LOCAL), + "", + 20, + constraint, + true); + + String client = (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search + + // tell all threads to do nothing for a specific time + sb.intermissionAllThreads(10000); + + // filter out words that appear in bluelist + theQuery.filterOut(plasmaSwitchboard.blueList); + + // log + serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + theQuery.queryString + ":" + theQuery.queryHashes + " - " + theQuery.neededResults() + " links to be computed, " + theQuery.displayResults() + " lines to be displayed"); + long timestamp = System.currentTimeMillis(); + + // create a new search event + if (plasmaSearchEvent.getEvent(theQuery.id(false)) == null) { + theQuery.setOffset(0); // in case that this is a new search, always start without a offset + offset = 0; + } + plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(theQuery, ranking, sb.wordIndex, (sb.isRobinsonMode()) ? sb.clusterhashes : null, false); + + // generate result object + serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER ORDERING OF SEARCH RESULTS: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); + serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER RESULT PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); + + // calc some more cross-reference + serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER XREF PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); + + // log + serverLog.logInfo("LOCAL_SEARCH", "EXIT WORD SEARCH: " + theQuery.queryString + " - " + + (theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize()) + " links found, " + + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); + + // prepare search statistics + Long trackerHandle = new Long(System.currentTimeMillis()); + HashMap searchProfile = theQuery.resultProfile(theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize(), System.currentTimeMillis() - timestamp, theSearch.getURLRetrievalTime(), theSearch.getSnippetComputationTime()); + searchProfile.put("querystring", theQuery.queryString); + searchProfile.put("time", trackerHandle); + searchProfile.put("host", client); + searchProfile.put("offset", new Integer(0)); + sb.localSearches.add(searchProfile); + TreeSet handles = sb.localSearchTracker.get(client); + if (handles == null) handles = new TreeSet(); + handles.add(trackerHandle); + sb.localSearchTracker.put(client, handles); + + prop = new serverObjects(); + int totalcount = theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize(); + prop.put("num-results_offset", offset); + prop.put("num-results_itemscount", "0"); + prop.put("num-results_itemsPerPage", itemsPerPage); + prop.put("num-results_totalcount", yFormatter.number(totalcount, !rss)); + prop.put("num-results_globalresults", (globalsearch) ? "1" : "0"); + prop.put("num-results_globalresults_localResourceSize", yFormatter.number(theSearch.getRankingResult().getLocalResourceSize(), !rss)); + prop.put("num-results_globalresults_remoteResourceSize", yFormatter.number(theSearch.getRankingResult().getRemoteResourceSize(), !rss)); + prop.put("num-results_globalresults_remoteIndexCount", yFormatter.number(theSearch.getRankingResult().getRemoteIndexCount(), !rss)); + prop.put("num-results_globalresults_remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), !rss)); + + // compose page navigation + StringBuffer resnav = new StringBuffer(); + int thispage = offset / theQuery.displayResults(); + if (thispage == 0) resnav.append("< "); else { + resnav.append(navurla(thispage - 1, display, theQuery)); + resnav.append("< "); + } + int numberofpages = Math.min(10, Math.max(thispage + 2, totalcount / theQuery.displayResults())); + for (int i = 0; i < numberofpages; i++) { + if (i == thispage) { + resnav.append(""); + resnav.append(i + 1); + resnav.append(" "); + } else { + resnav.append(navurla(i, display, theQuery)); + resnav.append(i + 1); + resnav.append(" "); + } + } + if (thispage >= numberofpages) resnav.append(">"); else { + resnav.append(navurla(thispage + 1, display, theQuery)); + resnav.append(">"); + } + prop.put("num-results_resnav", resnav.toString()); + + // generate the search result lines; they will be produced by another servlet + for (int i = 0; i < theQuery.displayResults(); i++) { + prop.put("results_" + i + "_item", offset + i); + prop.put("results_" + i + "_eventID", theQuery.id(false)); + } + prop.put("results", theQuery.displayResults()); + prop.put("resultTable", (contentdomCode <= 1) ? "0" : "1"); + prop.put("eventID", theQuery.id(false)); // for bottomline + + // process result of search + if (filtered.size() > 0) { + prop.put("excluded", "1"); + prop.putHTML("excluded_stopwords", filtered.toString()); + } else { + prop.put("excluded", "0"); + } + + if (prop == null || prop.size() == 0) { + if (post.get("search", "").length() < 3) { + prop.put("num-results", "2"); // no results - at least 3 chars + } else { + prop.put("num-results", "1"); // no results + } + } else { + prop.put("num-results", "3"); + } + + prop.put("input_cat", "href"); + prop.put("input_depth", "0"); + + // adding some additional properties needed for the rss feed + String hostName = (String) header.get("Host", "localhost"); + if (hostName.indexOf(":") == -1) hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8080")); + prop.put("searchBaseURL", "http://" + hostName + "/yacysearch.html"); + prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif"); + } + + prop.put("searchagain", global ? "1" : "0"); + prop.put("input", input); + prop.put("display", display); + prop.put("input_input", input); + prop.put("input_display", display); + prop.put("promoteSearchPageGreeting", promoteSearchPageGreeting); + prop.putHTML("input_former", querystring); + //prop.put("former", post.get("search", "")); + prop.put("input_count", itemsPerPage); + prop.put("input_offset", offset); + prop.put("input_resource", global ? "global" : "local"); + prop.putHTML("input_urlmaskfilter", urlmask); + prop.putHTML("input_prefermaskfilter", prefermask); + prop.put("input_indexof", (indexof) ? "on" : "off"); + prop.put("input_constraint", (constraint == null) ? "" : constraint.exportB64()); + prop.put("input_contentdom", post.get("contentdom", "text")); + prop.put("input_contentdomCheckText", (contentdomCode == plasmaSearchQuery.CONTENTDOM_TEXT) ? "1" : "0"); + prop.put("input_contentdomCheckAudio", (contentdomCode == plasmaSearchQuery.CONTENTDOM_AUDIO) ? "1" : "0"); + prop.put("input_contentdomCheckVideo", (contentdomCode == plasmaSearchQuery.CONTENTDOM_VIDEO) ? "1" : "0"); + prop.put("input_contentdomCheckImage", (contentdomCode == plasmaSearchQuery.CONTENTDOM_IMAGE) ? "1" : "0"); + prop.put("input_contentdomCheckApp", (contentdomCode == plasmaSearchQuery.CONTENTDOM_APP) ? "1" : "0"); + + // for RSS: don't HTML encode some elements + prop.putHTML("rss_query", querystring, true); + prop.put("rss_queryenc", yacyURL.escape(querystring.replace(' ', '+'))); + + sb.localSearchLastAccess = System.currentTimeMillis(); + + // return rewrite properties + return prop; + } + + private static String navurla(int page, int display, plasmaSearchQuery theQuery) { + return + ""; + } +} diff --git a/htroot/yacy/user/ysearchitem.html b/htroot/yacy/user/ysearchitem.html new file mode 100644 index 000000000..07c3bf768 --- /dev/null +++ b/htroot/yacy/user/ysearchitem.html @@ -0,0 +1,56 @@ +#(content)#:: + + :: + #{items}# +
+ #[name]# + +
+ #{/items}# + :: + #{items}# + #[name]##[hrefshort]# + #{/items}# + :: + #{items}# + #[name]##[hrefshort]# + #{/items}# + :: + #{items}# + #[name]##[hrefshort]# + #{/items}# +#(/content)# +#(rss)#:: + +#[title]# +#[link]# +#[description]# +#[date]# +#[urlhash]# + +#(/rss)# +#(references)#:: +

Topwords: +#{words}# #[word]# |#{/words}# +

+#(/references)# +#(rssreferences)#:: + +#{words}# +#[word]# +#{/words}# + +#(/rssreferences)# +#(dynamic)#:: + +#(/dynamic)# + diff --git a/htroot/yacy/user/ysearchitem.java b/htroot/yacy/user/ysearchitem.java new file mode 100644 index 000000000..9e9921971 --- /dev/null +++ b/htroot/yacy/user/ysearchitem.java @@ -0,0 +1,289 @@ +// ysearchitem.java +// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany +// first published 28.08.2007 on http://yacy.net +// +// This is a part of YaCy, a peer-to-peer based web search engine +// +// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $ +// $LastChangedRevision: 1986 $ +// $LastChangedBy: orbiter $ +// +// LICENSE +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeSet; + +import de.anomic.http.httpHeader; +import de.anomic.kelondro.kelondroMSetTools; +import de.anomic.kelondro.kelondroNaturalOrder; +import de.anomic.plasma.plasmaSearchEvent; +import de.anomic.plasma.plasmaSearchQuery; +import de.anomic.plasma.plasmaSearchRankingProcess; +import de.anomic.plasma.plasmaSnippetCache; +import de.anomic.plasma.plasmaSwitchboard; +import de.anomic.server.serverObjects; +import de.anomic.server.serverSwitch; +import de.anomic.tools.crypt; +import de.anomic.tools.nxTools; +import de.anomic.tools.yFormatter; +import de.anomic.yacy.yacyCore; +import de.anomic.yacy.yacyNewsPool; +import de.anomic.yacy.yacySeed; +import de.anomic.yacy.yacyURL; + +public class ysearchitem { + + private static boolean col = true; + private static final int namelength = 60; + private static final int urllength = 120; + private static final int MAX_TOPWORDS = 24; + + public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { + final plasmaSwitchboard sb = (plasmaSwitchboard) env; + final serverObjects prop = new serverObjects(); + + String eventID = post.get("eventID", ""); + boolean bottomline = post.get("bottomline", "false").equals("true"); + boolean rss = post.get("rss", "false").equals("true"); + boolean authenticated = sb.adminAuthenticated(header) >= 2; + int item = post.getInt("item", -1); + + // default settings for blank item + prop.put("content", "0"); + prop.put("rss", "0"); + prop.put("references", "0"); + prop.put("rssreferences", "0"); + prop.put("dynamic", "0"); + + // find search event + plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(eventID); + if (theSearch == null) { + // the event does not exist, show empty page + return prop; + } + plasmaSearchQuery theQuery = theSearch.getQuery(); + + // dynamically update count values + if (!rss) { + int offset = theQuery.neededResults() - theQuery.displayResults() + 1; + prop.put("dynamic_offset", offset); + prop.put("dynamic_itemscount", (item < 0) ? theQuery.neededResults() : item + 1); + prop.put("dynamic_totalcount", yFormatter.number(theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize(), !rss)); + prop.put("dynamic_localResourceSize", yFormatter.number(theSearch.getRankingResult().getLocalResourceSize(), !rss)); + prop.put("dynamic_remoteResourceSize", yFormatter.number(theSearch.getRankingResult().getRemoteResourceSize(), !rss)); + prop.put("dynamic_remoteIndexCount", yFormatter.number(theSearch.getRankingResult().getRemoteIndexCount(), !rss)); + prop.put("dynamic_remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), !rss)); + prop.put("dynamic", "1"); + } + + if (bottomline) { + // attach the bottom line with search references (topwords) + final Set references = theSearch.references(20); + if (references.size() > 0) { + // get the topwords + final TreeSet topwords = new TreeSet(kelondroNaturalOrder.naturalComparator); + String tmp = ""; + Iterator i = references.iterator(); + while (i.hasNext()) { + tmp = i.next(); + if (tmp.matches("[a-z]+")) { + topwords.add(tmp); + } + } + + // filter out the badwords + final TreeSet filteredtopwords = kelondroMSetTools.joinConstructive(topwords, plasmaSwitchboard.badwords); + if (filteredtopwords.size() > 0) { + kelondroMSetTools.excludeDestructive(topwords, plasmaSwitchboard.badwords); + } + + // avoid stopwords being topwords + if (env.getConfig("filterOutStopwordsFromTopwords", "true").equals("true")) { + if ((plasmaSwitchboard.stopwords != null) && (plasmaSwitchboard.stopwords.size() > 0)) { + kelondroMSetTools.excludeDestructive(topwords, plasmaSwitchboard.stopwords); + } + } + + if (rss) { + String word; + int hintcount = 0; + final Iterator iter = topwords.iterator(); + while (iter.hasNext()) { + word = (String) iter.next(); + if (word != null) { + prop.putHTML("rssreferences_words_" + hintcount + "_word", word); + } + prop.put("rssreferences_words", hintcount); + if (hintcount++ > MAX_TOPWORDS) { + break; + } + } + prop.put("rssreferences", "1"); + } else { + String word; + int hintcount = 0; + final Iterator iter = topwords.iterator(); + while (iter.hasNext()) { + word = (String) iter.next(); + if ((theQuery == null) || (theQuery.queryString == null)) break; + if (word != null) { + prop.putHTML("references_words_" + hintcount + "_word", word); + prop.putHTML("references_words_" + hintcount + "_newsearch", theQuery.queryString.replace(' ', '+') + "+" + word); + prop.put("references_words_" + hintcount + "_count", theQuery.displayResults()); + prop.put("references_words_" + hintcount + "_offset", "0"); + prop.put("references_words_" + hintcount + "_contentdom", theQuery.contentdom()); + prop.put("references_words_" + hintcount + "_resource", theQuery.searchdom()); + } + prop.put("references_words", hintcount); + if (hintcount++ > MAX_TOPWORDS) { + break; + } + } + prop.put("references", "1"); + } + } + + return prop; + } + + // generate result object + plasmaSearchEvent.ResultEntry result = theSearch.oneResult(item); + + if (result == null) { + // no content + return prop; + } + + if (rss) { + // text search for rss output + prop.put("rss", "1"); // switch on specific content + prop.putHTML("rss_title", result.title(), true); + prop.putHTML("rss_description", result.textSnippet().getLineRaw(), true); + prop.putHTML("rss_link", result.urlstring(), true); + prop.put("rss_urlhash", result.hash()); + prop.put("rss_date", plasmaSwitchboard.dateString822(result.modified())); + return prop; + } + + prop.put("rss", "0"); + + if (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_TEXT) { + // text search + prop.put("content", theQuery.contentdom + 1); // switch on specific content + prop.put("content_authorized", authenticated ? "1" : "0"); + prop.put("content_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? "1" : "0"); + prop.put("content_authorized_recommend_deletelink", "/ysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + result.hash() + "&urlmaskfilter=.*"); + prop.put("content_authorized_recommend_recommendlink", "/ysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + result.hash() + "&urlmaskfilter=.*"); + prop.put("content_authorized_urlhash", result.hash()); + prop.putHTML("content_description", result.title()); + prop.put("content_url", result.urlstring()); + + int port=result.url().getPort(); + yacyURL faviconURL; + try { + faviconURL = new yacyURL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico", null); + } catch (MalformedURLException e1) { + faviconURL = null; + } + + prop.putHTML("content_faviconCode", sb.licensedURLs.aquireLicense(faviconURL)); // aquire license for favicon url loading + prop.put("content_urlhash", result.hash()); + prop.put("content_urlhexhash", yacySeed.b64Hash2hexHash(result.hash())); + prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), urllength)); + prop.put("content_date", plasmaSwitchboard.dateString(result.modified())); + prop.put("content_ybr", plasmaSearchRankingProcess.ybr(result.hash())); + prop.putNum("content_size", result.filesize()); + + TreeSet[] query = theQuery.queryWords(); + yacyURL wordURL = null; + try { + prop.putHTML("content_words", URLEncoder.encode(query[0].toString(),"UTF-8")); + } catch (UnsupportedEncodingException e) {} + prop.putHTML("content_former", theQuery.queryString); + prop.put("content_rankingprops", result.word().toPropertyForm() + ", domLengthEstimated=" + yacyURL.domLengthEstimation(result.hash()) + + ((yacyURL.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") + + (((wordURL = yacyURL.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : "")); + plasmaSnippetCache.TextSnippet snippet = result.textSnippet(); + prop.put("content_snippet", (snippet == null) ? "(snippet not found)" : snippet.getLineMarked(theQuery.queryHashes)); + return prop; + } + + if (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_IMAGE) { + // image search; shows thumbnails + // iterate over all images in the result + prop.put("content", theQuery.contentdom + 1); // switch on specific content + ArrayList images = result.mediaSnippets(); + if (images != null) { + plasmaSnippetCache.MediaSnippet ms; + int c = 0; + for (int i = 0; i < images.size(); i++) { + ms = (plasmaSnippetCache.MediaSnippet) images.get(i); + prop.putHTML("content_items_" + i + "_href", ms.href.toNormalform(true, false)); + prop.put("content_items_" + i + "_code", sb.licensedURLs.aquireLicense(ms.href)); + prop.putHTML("content_items_" + i + "_name", shorten(ms.name, namelength)); + prop.put("content_items_" + i + "_attr", ms.attr); // attributes, here: original size of image + c++; + } + prop.put("content_items", c); + } else { + prop.put("content_items", "0"); + } + return prop; + } + + if ((theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_AUDIO) || + (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_VIDEO) || + (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_APP)) { + // any other media content + prop.put("content", theQuery.contentdom + 1); // switch on specific content + ArrayList media = result.mediaSnippets(); + if (item == 0) col = true; + if (media != null) { + plasmaSnippetCache.MediaSnippet ms; + int c = 0; + for (int i = 0; i < media.size(); i++) { + ms = (plasmaSnippetCache.MediaSnippet) media.get(i); + prop.putHTML("content_items_" + i + "_href", ms.href.toNormalform(true, false)); + prop.putHTML("content_items_" + i + "_hrefshort", nxTools.shortenURLString(ms.href.toNormalform(true, false), urllength)); + prop.putHTML("content_items_" + i + "_name", shorten(ms.name, namelength)); + prop.put("content_items_" + i + "_col", (col) ? "0" : "1"); + c++; + col = !col; + } + prop.put("content_items", c); + } else { + prop.put("content_items", "0"); + } + return prop; + } + + return prop; + } + + private static String shorten(String s, int length) { + if (s.length() <= length) return s; + int p = s.lastIndexOf('.'); + if (p < 0) return s.substring(0, length - 3) + "..."; + return s.substring(0, length - (s.length() - p) - 3) + "..." + s.substring(p); + } + +} diff --git a/htroot/yacysearch/images/arrow1.gif b/htroot/yacysearch/images/arrow1.gif new file mode 100755 index 000000000..a3709d0ad Binary files /dev/null and b/htroot/yacysearch/images/arrow1.gif differ diff --git a/htroot/yacysearch/images/arrow2.gif b/htroot/yacysearch/images/arrow2.gif new file mode 100755 index 000000000..7bc205745 Binary files /dev/null and b/htroot/yacysearch/images/arrow2.gif differ diff --git a/htroot/yacysearch/images/background.gif b/htroot/yacysearch/images/background.gif new file mode 100755 index 000000000..69f05846e Binary files /dev/null and b/htroot/yacysearch/images/background.gif differ diff --git a/htroot/yacysearch/images/house.gif b/htroot/yacysearch/images/house.gif new file mode 100755 index 000000000..8f0371531 Binary files /dev/null and b/htroot/yacysearch/images/house.gif differ diff --git a/htroot/yacysearch/images/letter.gif b/htroot/yacysearch/images/letter.gif new file mode 100755 index 000000000..dcb8ed56b Binary files /dev/null and b/htroot/yacysearch/images/letter.gif differ diff --git a/htroot/yacysearch/images/tree.gif b/htroot/yacysearch/images/tree.gif new file mode 100755 index 000000000..85377af26 Binary files /dev/null and b/htroot/yacysearch/images/tree.gif differ