- added chunked file transfer for non-yacy clients - SSIs are streamed using chunked transfer, partly delivered pages can be seen in browser before transmission is finished - added client-side network unit identification - cleaned up code git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3926 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
32640044c0
commit
1782ef57e5
Before Width: | Height: | Size: 41 KiB |
@ -1,24 +0,0 @@
|
||||
#(mode)#
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Gettext Locales</title>
|
||||
#%env/templates/metas.template%#
|
||||
</head>
|
||||
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
|
||||
#%env/templates/header.template%#
|
||||
<h2>Gettext Locales</h2>
|
||||
<p>
|
||||
<a href="Gettext_p.html?mode=1">Get empty gettext file</a>
|
||||
<form action="Gettext_p.html" method="GET">
|
||||
<input type="hidden" name="mode" value="1" />
|
||||
old file: <input type="text" name="oldfile" value="DATA/LOCALE" />
|
||||
<input type="submit" value="get updated file" />
|
||||
</form>
|
||||
</p>
|
||||
#%env/templates/footer.template%#
|
||||
</body>
|
||||
</html>
|
||||
::
|
||||
#[gettext]#
|
||||
#(/mode)#
|
@ -1,78 +0,0 @@
|
||||
//Gettext_p.java
|
||||
//------------
|
||||
// part of YACY
|
||||
//
|
||||
// (C) 2006 Alexander Schier
|
||||
//
|
||||
// last change: $LastChangedDate: $ by $LastChangedBy: $
|
||||
// $LastChangedRevision: $
|
||||
//
|
||||
// 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.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import de.anomic.data.gettext;
|
||||
import de.anomic.http.httpHeader;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
|
||||
|
||||
|
||||
public class Gettext_p{
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
serverObjects prop = new serverObjects();
|
||||
|
||||
|
||||
if(post != null && post.get("mode").equals("1")){
|
||||
prop.put("mode", "1");
|
||||
File oldfile=null;
|
||||
String oldfilename;
|
||||
if(post.containsKey("oldfile")){
|
||||
oldfilename=(String) post.get("oldfile");
|
||||
oldfile=new File(env.getRootPath(), oldfilename);
|
||||
if(!oldfile.exists())
|
||||
//TODO: display warning?
|
||||
oldfile=null;
|
||||
}
|
||||
|
||||
String htRootPath = env.getConfig("htRootPath", "htroot");
|
||||
File sourceDir = new File(env.getRootPath(), htRootPath);
|
||||
ArrayList list;
|
||||
try {
|
||||
list = gettext.createGettextRecursive(sourceDir, "html,template,inc", "locale", oldfile);
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO warn the user
|
||||
list = gettext.createGettextRecursive(sourceDir, "html,template,inc", "locale", (Map)null);
|
||||
}
|
||||
Iterator it=list.iterator();
|
||||
String out="";
|
||||
while(it.hasNext()){
|
||||
out+=(String)it.next()+"\n";
|
||||
}
|
||||
//this does not work
|
||||
/*httpHeader outheader=new httpHeader();
|
||||
outheader.put("Content-Type", "text/plain");
|
||||
prop.setOutgoingHeader(outheader);*/
|
||||
prop.put("mode_gettext", out);
|
||||
}
|
||||
|
||||
|
||||
return prop;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<!--HEADER for Lab.html
|
||||
<title>#[clientname]#'s Lab</title>
|
||||
end of HEADER-->
|
||||
<h2>The YaCy Lab</h2>
|
||||
|
||||
<p>
|
||||
This is the place where we try new functions of the YaCy search engine.
|
||||
All these things here are to be considered as probably unstable, and/or experimental.
|
||||
You may try out these things but please do not care about bugs.</p>
|
||||
|
||||
<ul>
|
||||
<li>The <a href="Wiki.html">Wiki</a></li>
|
||||
<li>Advanced <a href="/Config_p.html">Configuration</a></li>
|
||||
</ul>
|
@ -1,13 +0,0 @@
|
||||
import de.anomic.http.httpHeader;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
|
||||
public class Lab {
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
serverObjects prop = new serverObjects();
|
||||
//XXX: Should we use Constants like DEFAULT_PAGE, PAGE_WITHOUT_MENU and so on,
|
||||
//or is it nice enough to set the real path in the servlets?
|
||||
prop.put("SUPERTEMPLATE", "/env/page.html");
|
||||
return prop;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
#[header]#
|
||||
<!--<title>YaCy '#[clientname]#': #[title]#</title>-->
|
||||
<!-- TODO: title cannot be set, yet. -->
|
||||
<!-- clientname needs to be set in page.java (this will remove the code in httpdFileHandler,
|
||||
if we use supertemplates for everything -->
|
||||
#%env/templates/metas.template%#
|
||||
</head>
|
||||
<body>
|
||||
#%env/templates/header.template%#
|
||||
#[page]#
|
||||
#%env/templates/footer.template%#
|
||||
</body>
|
||||
</html>
|
@ -1,41 +0,0 @@
|
||||
//page.java - super template, to allow a scripted layout.
|
||||
//----------------------------------------------------------
|
||||
//part of YaCy
|
||||
//
|
||||
// (C) 2006 by Alexander Schier
|
||||
//
|
||||
// last change: $LastChangedDate: $ by $LastChangedBy: $
|
||||
// $LastChangedRevision: $
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
//note: this isn't useful, yet.
|
||||
//this is only a basic demonstration, what can be done with the supertemplates.
|
||||
import de.anomic.http.httpHeader;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
|
||||
public class page {
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
//plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
|
||||
serverObjects prop = new serverObjects();
|
||||
//prop.put("test1", "testit!");
|
||||
//prop.put("test2", 1);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<!-- aus http://de.selfhtml.org/servercgi/server/ssi.htm -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Dynamisches HTML mit Server Side Includes</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Dynamisches HTML mit Server Side Includes</h1>
|
||||
<!--#include virtual="ssitest.inc" -->
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,7 @@
|
||||
<!-- aus http://de.selfhtml.org/servercgi/server/ssi.htm -->
|
||||
<p>Auf einer Meierei,<br>
|
||||
da lebte einst ein braves Huhn,<br>
|
||||
das legte, wie die HŸhner tun,<br>
|
||||
an jedem Tag ein Ei.<br>
|
||||
Und kakelte, mirakelte, spektakelte,<br>
|
||||
als obs ein Wunder sei.</p>
|
@ -1,333 +0,0 @@
|
||||
//gettext.java - translations in a simplified gettext-format
|
||||
//----------------------------------------------------------
|
||||
//part of YaCy
|
||||
//
|
||||
// (C) 2006 by Alexander Schier
|
||||
//
|
||||
// last change: $LastChangedDate: $ by $LastChangedBy: $
|
||||
// $LastChangedRevision: $
|
||||
//
|
||||
// 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
|
||||
|
||||
package de.anomic.data;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import de.anomic.htmlFilter.htmlFilterContentTransformer;
|
||||
import de.anomic.server.logging.serverLog;
|
||||
|
||||
public class gettext{
|
||||
public static ArrayList createGettextRecursive(File sourceDir, String extensions, String notdir, File oldgettextfile) throws FileNotFoundException{
|
||||
if(oldgettextfile==null)
|
||||
return createGettextRecursive(sourceDir, extensions, notdir, (Map)null); //no old file
|
||||
return createGettextRecursive(sourceDir, extensions, notdir, parseGettext(oldgettextfile));
|
||||
}
|
||||
public static ArrayList createGettextRecursive(File sourceDir, String extensions, String notdir, Map oldgettext){
|
||||
ArrayList list=new ArrayList();
|
||||
ArrayList exts=listManager.string2arraylist(extensions);
|
||||
Iterator it2;
|
||||
String filename;
|
||||
ArrayList filenames=new ArrayList();
|
||||
|
||||
ArrayList dirList=listManager.getDirsRecursive(sourceDir, notdir);
|
||||
dirList.add(sourceDir);
|
||||
Iterator it=dirList.iterator();
|
||||
File dir=null;
|
||||
File[] files;
|
||||
//this looks a lot more complicated, than it is ...
|
||||
while(it.hasNext()){
|
||||
dir=(File)it.next();
|
||||
if(dir.isDirectory() && !dir.getName().equals(notdir)){
|
||||
files=dir.listFiles();
|
||||
for(int i=0;i<files.length;i++){
|
||||
if(!files[i].isDirectory()){
|
||||
it2=exts.iterator();
|
||||
filename=files[i].getName();
|
||||
while(it2.hasNext()){
|
||||
if(filename.endsWith((String)it2.next())){
|
||||
try {
|
||||
filenames.add(files[i].getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list=createGettext(filenames, oldgettext);
|
||||
return list;
|
||||
}
|
||||
private static ArrayList getGettextHeader(){
|
||||
return getGettextHeader("UNKNOWN", "EMAIL");
|
||||
}
|
||||
private static ArrayList getGettextHeader(String translator, String email){
|
||||
ArrayList list=new ArrayList();
|
||||
list.add("#yacy translation");
|
||||
list.add("msgid \"\"");
|
||||
list.add("msgstr \"\"");
|
||||
list.add("\"Content-Type: text/plain; charset=UTF-8\\n\"");
|
||||
list.add("\"Content-Transfer-Encoding: 8bit\\n\"");
|
||||
|
||||
list.add("\"Last-Translator: "+translator+"\\n\"");
|
||||
SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-mm-dd HH:MMZ");
|
||||
list.add("\"PO-Revision-Date: "+dateformat.format(new Date())+"\\n\"");
|
||||
list.add("\"Project-Id-Version: YaCy\\n\"");
|
||||
|
||||
list.add("\"Language-Team: <"+email+">\\n\"");
|
||||
list.add("\"X-Generator: YaCy\\n\"");
|
||||
|
||||
list.add("\"Mime-Version: 1.0\\n\"");
|
||||
list.add("");
|
||||
return list;
|
||||
}
|
||||
public static ArrayList createGettext(ArrayList filenames, File oldgettextfile) throws FileNotFoundException{
|
||||
return createGettext(filenames, parseGettext(oldgettextfile));
|
||||
}
|
||||
/*
|
||||
* create a list of gettext file for some textfiles
|
||||
* @param filenames the ArrayList with the Filenames
|
||||
* @param oldgettextmap a map with the old translations.
|
||||
*/
|
||||
public static ArrayList createGettext(ArrayList filenames, Map oldgettext){
|
||||
ArrayList list=new ArrayList();
|
||||
ArrayList tmp=null;
|
||||
String filename=null;
|
||||
Iterator it=filenames.iterator();
|
||||
list.addAll(getGettextHeader());
|
||||
|
||||
while(it.hasNext()){
|
||||
try {
|
||||
filename=(String)it.next();
|
||||
//TODO: better possibility to switch the behaviour
|
||||
//tmp=getGettextSource(new File(filename), oldgettext);
|
||||
tmp=getGettextSourceFromHTML(new File(filename), oldgettext);
|
||||
serverLog.logFinest("Gettext", "Extracting Strings from: "+filename);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("File \""+filename+"\" not found.");
|
||||
}
|
||||
if(tmp!=null)
|
||||
list.addAll(tmp);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static ArrayList getGettextSource(File inputfile, File oldmapfile) throws FileNotFoundException{
|
||||
if(oldmapfile != null && oldmapfile.exists())
|
||||
return getGettextSource(inputfile, parseGettext(oldmapfile));
|
||||
return getGettextSource(inputfile);
|
||||
}
|
||||
public static ArrayList getGettextSource(File inputfile) throws FileNotFoundException{
|
||||
return getGettextSource(inputfile, new HashMap());
|
||||
}
|
||||
public static ArrayList getGettextSource(File inputfile, Map oldgettextmap) throws FileNotFoundException{
|
||||
ArrayList strings=getGettextItems(inputfile);
|
||||
return getGettextSource(inputfile, oldgettextmap, strings);
|
||||
}
|
||||
public static ArrayList getGettextSourceFromHTML(File inputfile, Map oldgettextmap) throws FileNotFoundException{
|
||||
htmlFilterContentTransformer transformer=new htmlFilterContentTransformer();
|
||||
BufferedReader br=new BufferedReader(new FileReader(inputfile));
|
||||
StringBuffer content=new StringBuffer();
|
||||
String line="";
|
||||
try {
|
||||
while((line=br.readLine())!=null){
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
ArrayList strings = transformer.getStrings(content.toString().getBytes());
|
||||
return getGettextSource(inputfile, oldgettextmap, strings);
|
||||
}
|
||||
public static ArrayList getGettextSource(File inputfile, Map oldgettextmap, ArrayList strings) {
|
||||
if(oldgettextmap==null)
|
||||
oldgettextmap=new HashMap();
|
||||
|
||||
|
||||
ArrayList list=new ArrayList();
|
||||
Iterator it=strings.iterator();
|
||||
if(strings.isEmpty())
|
||||
return null;
|
||||
list.add("#"+inputfile.getName());
|
||||
String key;
|
||||
while(it.hasNext()){
|
||||
key=((String)it.next()).replaceAll("\"", "\\\\\"").replaceAll("\n", "\\\\n");
|
||||
list.add("msgid \""+key+"\"");
|
||||
if(oldgettextmap.containsKey(key))
|
||||
list.add("msgstr \""+oldgettextmap.get(key)+"\"");
|
||||
else
|
||||
list.add("msgstr \"\"");
|
||||
list.add("");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/*
|
||||
* create a list of gettext Strings ( _() ) from a file
|
||||
* @param inputfile the file, which contains the raw Strings.
|
||||
*/
|
||||
public static ArrayList getGettextItems(File inputfile) throws FileNotFoundException{
|
||||
ArrayList list=new ArrayList();
|
||||
int character;
|
||||
InputStreamReader reader;
|
||||
int state=0; //0=no gettext macro 1= _ found, 2= ( found and in the string 3=\ found
|
||||
String untranslatedString="";
|
||||
|
||||
reader = new InputStreamReader(new FileInputStream(inputfile));
|
||||
try {
|
||||
character=reader.read();
|
||||
while(character >=0) {
|
||||
if(state==0 && (char)character=='_')
|
||||
state=1;
|
||||
else if(state==1){
|
||||
if((char)character=='('){
|
||||
state=2;
|
||||
untranslatedString="";
|
||||
}else{
|
||||
state=0;
|
||||
untranslatedString+=(char)character;
|
||||
}
|
||||
}else if(state==2){
|
||||
if((char)character=='\\')
|
||||
state=3;
|
||||
else if((char)character==')'){
|
||||
state=0;
|
||||
list.add(untranslatedString);
|
||||
}else{
|
||||
untranslatedString+=(char)character;
|
||||
}
|
||||
}else if(state==3){
|
||||
state=2;
|
||||
if((char)character==')')
|
||||
untranslatedString+=")";
|
||||
else
|
||||
untranslatedString+="\\"+(char)character;
|
||||
}else{
|
||||
untranslatedString+=(char)character;
|
||||
}
|
||||
character=reader.read();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
return list;
|
||||
}
|
||||
public static HashMap parseGettext(File gettextfile) throws FileNotFoundException{
|
||||
ArrayList gettext=new ArrayList();
|
||||
String line;
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(gettextfile)));
|
||||
try {
|
||||
line = br.readLine();
|
||||
while (line != null) {
|
||||
gettext.add(line);
|
||||
line = br.readLine();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
return parseGettext(gettext);
|
||||
}
|
||||
public static HashMap parseGettext(ArrayList gettext){
|
||||
HashMap map = new HashMap();
|
||||
int mode=0; //1= in msgid, 2= in msgstr
|
||||
String msgid = "", msgstr = "", tmp = "";
|
||||
|
||||
Iterator it=gettext.iterator();
|
||||
while(it.hasNext()){
|
||||
tmp=(String) it.next();
|
||||
if(tmp.startsWith("msgid \"")){
|
||||
if(mode==2)
|
||||
map.put(msgid, msgstr);
|
||||
msgid=tmp.substring(7,tmp.length()-1).replaceAll("\\\"", "\"");
|
||||
msgstr="";
|
||||
mode=1;
|
||||
}else if(tmp.startsWith("msgstr \"")){
|
||||
mode=2;
|
||||
msgstr=tmp.substring(8,tmp.length()-1);
|
||||
}else if(tmp.startsWith("\"")){
|
||||
//multiline strings with "..." on each line
|
||||
if(mode==1){
|
||||
msgid+="\n"+tmp.substring(1,tmp.length()-1).replaceAll("\\\"", "\"");
|
||||
}else if(mode==2){
|
||||
msgstr+="\n"+tmp.substring(1,tmp.length()-1).replaceAll("\\\"", "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put(msgid, msgstr); //the last one cannot be put, on the next msgid ;-)
|
||||
return map;
|
||||
}
|
||||
public static void main(String[] argv){
|
||||
if(argv.length < 2){
|
||||
System.out.println("Syntax: java de.anomic.data.gettext creategettext [inputfile] ... [inputfile]");
|
||||
System.out.println("Syntax: java de.anomic.data.gettext parsegettext [gettextfile]");
|
||||
System.out.println("Syntax: java de.anomic.data.gettext updategettext [gettextfile] [inputfile] ... [inputfile]");
|
||||
System.exit(1);
|
||||
}
|
||||
if(argv[0].equals("creategettext")){
|
||||
ArrayList filelist=new ArrayList();
|
||||
for(int i=1;i<argv.length;i++){
|
||||
filelist.add(argv[i]);
|
||||
}
|
||||
ArrayList list = createGettext(filelist, (Map)null);
|
||||
Iterator it=list.iterator();
|
||||
while(it.hasNext())
|
||||
System.out.println((String)it.next());
|
||||
}else if(argv[0].equals("parsegettext")){
|
||||
if(argv.length >2){
|
||||
System.out.println("only one file allowed for parsegettext");
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
HashMap translations=parseGettext(new File(argv[1]));
|
||||
Iterator it=translations.keySet().iterator();
|
||||
String key="";
|
||||
while(it.hasNext()){
|
||||
key=(String)it.next();
|
||||
System.out.println("key: "+key);
|
||||
System.out.println("value: "+translations.get(key));
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
System.exit(1);
|
||||
}
|
||||
}else if(argv[0].equals("updategettext")){
|
||||
if(argv.length < 3){
|
||||
System.out.println("Too less arguments");
|
||||
System.exit(1);
|
||||
}
|
||||
ArrayList filelist=new ArrayList();
|
||||
for(int i=2;i<argv.length;i++){
|
||||
filelist.add(argv[i]);
|
||||
}
|
||||
try {
|
||||
ArrayList list=createGettext(filelist, new File(argv[1]));
|
||||
Iterator it=list.iterator();
|
||||
while(it.hasNext())
|
||||
System.out.println((String)it.next());
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("File not found.");
|
||||
System.exit(1);
|
||||
}
|
||||
}else{
|
||||
System.out.println("unknown Mode ...");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
//rssReaderItem.java
|
||||
//------------
|
||||
// part of YACY
|
||||
//
|
||||
// (C) 2007 Alexander Schier
|
||||
//
|
||||
// last change: $LastChangedDate: $ by $LastChangedBy: $
|
||||
// $LastChangedRevision: $
|
||||
//
|
||||
// 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
|
||||
|
||||
package de.anomic.data;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
public class rssReaderItem{
|
||||
String creator, title, description;
|
||||
Date date;
|
||||
URL link;
|
||||
int num;
|
||||
public rssReaderItem(int num, URL link, String title, String description, Date date, String creator){
|
||||
this.link=link;
|
||||
this.title=title;
|
||||
this.description=description;
|
||||
this.date=date;
|
||||
this.creator=creator;
|
||||
this.num=num;
|
||||
}
|
||||
public URL getLink(){
|
||||
return link;
|
||||
}
|
||||
public String getTitle(){
|
||||
return (title!=null)? title: "";
|
||||
}
|
||||
public String getDescription(){
|
||||
return (description!=null)? description: "";
|
||||
}
|
||||
public Date getDate(){
|
||||
return (date!=null)? date: new Date();
|
||||
}
|
||||
public String getCreator(){
|
||||
return (creator!=null)? creator: "";
|
||||
}
|
||||
public int getNum(){
|
||||
return num;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
//rssReaderItemComparator.java
|
||||
//------------
|
||||
// part of YACY
|
||||
//
|
||||
// (C) 2007 Alexander Schier
|
||||
//
|
||||
// last change: $LastChangedDate: $ by $LastChangedBy: $
|
||||
// $LastChangedRevision: $
|
||||
//
|
||||
// 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
|
||||
package de.anomic.data;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class rssReaderItemComparator implements Comparator{
|
||||
public int compare(Object o1, Object o2){
|
||||
int num1=((rssReaderItem)o1).getNum();
|
||||
int num2=((rssReaderItem)o2).getNum();
|
||||
return num2-num1;
|
||||
}
|
||||
public boolean equals(Object o1, Object o2){
|
||||
return compare(o1, o2)==0;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
// httpSSI.java
|
||||
// -----------------------------
|
||||
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||||
// first published 26.06.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
|
||||
|
||||
package de.anomic.http;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.anomic.server.serverByteBuffer;
|
||||
|
||||
public class httpSSI {
|
||||
|
||||
public static void writeSSI(File referenceFile, serverByteBuffer in, httpChunkedOutputStream out) throws IOException {
|
||||
writeSSI(referenceFile, in, 0, out);
|
||||
}
|
||||
|
||||
public static void writeSSI(File referenceFile, serverByteBuffer in, int start, httpChunkedOutputStream out) throws IOException {
|
||||
int p = in.indexOf("<!--#".getBytes(), start);
|
||||
if (p == 0) {
|
||||
int q = in.indexOf("-->".getBytes(), start + 10);
|
||||
assert q >= 0;
|
||||
parseSSI(referenceFile, in, start, q + 3 - start, out);
|
||||
writeSSI(referenceFile, in, start + q + 3, out);
|
||||
} else if (p > 0) {
|
||||
int q = in.indexOf("-->".getBytes(), start + 10);
|
||||
out.write(in, start, p - start);
|
||||
parseSSI(referenceFile, in, start + p, q + 3 - start - p, out);
|
||||
writeSSI(referenceFile, in, start + q + 3, out);
|
||||
} else /* p < 0 */ {
|
||||
out.write(in, start, in.length() - start);
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseSSI(File referenceFile, serverByteBuffer in, int start, int length, httpChunkedOutputStream out) {
|
||||
if (in.startsWith("<!--#include virtual=\"".getBytes(), start)) {
|
||||
int q = in.indexOf("\"".getBytes(), start + 22);
|
||||
if (q > 0) {
|
||||
String path = in.toString(start + 22, q);
|
||||
File loadFile = new File(referenceFile.getParentFile(), path);
|
||||
try {
|
||||
out.write(new FileInputStream(loadFile));
|
||||
} catch (FileNotFoundException e) {
|
||||
// do nothing
|
||||
} catch (IOException e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue