From c96965d3642b2fabbdbb4af520b6e73b8b6759de Mon Sep 17 00:00:00 2001 From: jrandom Date: Sat, 3 Dec 2005 05:41:25 +0000 Subject: [PATCH] 2005-12-03 jrandom * Package up a standalone Syndie install into a "syndie-standalone.zip", buildable with "ant syndie". It extracts into ./syndie/, launches with "java -jar launchsyndie.jar" (or javaw, on windows, to avoid a dos box), running a single user Syndie instance (by default). It also creates a default subscription to syndiemedia without any anonymity (using no proxy). Upgrades can be done by just replacing the syndie.war with the one from I2P. --- apps/syndie/doc/readme-standalone.txt | 3 + apps/syndie/java/build.xml | 53 +++++++- .../java/src/net/i2p/syndie/BlogManager.java | 19 ++- .../src/net/i2p/syndie/web/RunStandalone.java | 50 ++++++++ .../i2p/syndie/web/ViewThreadedServlet.java | 2 +- apps/syndie/jetty-syndie.xml | 114 ++++++++++++++++++ build.xml | 8 +- history.txt | 11 +- 8 files changed, 253 insertions(+), 7 deletions(-) create mode 100644 apps/syndie/doc/readme-standalone.txt create mode 100644 apps/syndie/java/src/net/i2p/syndie/web/RunStandalone.java create mode 100644 apps/syndie/jetty-syndie.xml diff --git a/apps/syndie/doc/readme-standalone.txt b/apps/syndie/doc/readme-standalone.txt new file mode 100644 index 000000000..534612e4d --- /dev/null +++ b/apps/syndie/doc/readme-standalone.txt @@ -0,0 +1,3 @@ +To run Syndie, fire it up with "java -jar launch-syndie.jar" (or, on windows, +to run without the dos box, "javaw -jar launch-syndie.jar"). For further +information, swing to http://localhost:8001/ \ No newline at end of file diff --git a/apps/syndie/java/build.xml b/apps/syndie/java/build.xml index 3a0c16e87..45fc5b6aa 100644 --- a/apps/syndie/java/build.xml +++ b/apps/syndie/java/build.xml @@ -11,7 +11,7 @@ @@ -43,6 +43,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -107,6 +156,8 @@ + + diff --git a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java index 929c37462..26f765454 100644 --- a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java +++ b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java @@ -524,9 +524,22 @@ public class BlogManager { String ok = register(user, getDefaultLogin(), getDefaultPass(), "", "default", "Default Syndie blog", ""); if (User.LOGIN_OK.equals(ok)) { _log.info("Default user created: " + user); - for (int i = 0; i < DEFAULT_SINGLE_USER_ARCHIVES.length; i++) - user.getPetNameDB().add(new PetName("DefaultArchive" + i, "syndie", "syndiearchive", DEFAULT_SINGLE_USER_ARCHIVES[i])); - scheduleSyndication(DEFAULT_SINGLE_USER_ARCHIVES); + String altArchives = _context.getProperty("syndie.defaultSingleUserArchives"); + String archives[] = DEFAULT_SINGLE_USER_ARCHIVES; + if ( (altArchives != null) && (altArchives.trim().length() > 0) ) { + ArrayList list = new ArrayList(); + StringTokenizer tok = new StringTokenizer(altArchives, ",\t "); + while (tok.hasMoreTokens()) + list.add(tok.nextToken()); + if (list.size() > 0) { + archives = new String[list.size()]; + for (int i = 0; i < list.size(); i++) + archives[i] = (String)list.get(i); + } + } + for (int i = 0; i < archives.length; i++) + user.getPetNameDB().add(new PetName("DefaultArchive" + i, "syndie", "syndiearchive", archives[i])); + scheduleSyndication(archives); saveUser(user); return; } else { diff --git a/apps/syndie/java/src/net/i2p/syndie/web/RunStandalone.java b/apps/syndie/java/src/net/i2p/syndie/web/RunStandalone.java new file mode 100644 index 000000000..d5dcea0d1 --- /dev/null +++ b/apps/syndie/java/src/net/i2p/syndie/web/RunStandalone.java @@ -0,0 +1,50 @@ +package net.i2p.syndie.web; + +import java.io.File; + +import net.i2p.util.FileUtil; +import org.mortbay.jetty.Server; + +public class RunStandalone { + private Server _server; + + static { + System.setProperty("org.mortbay.http.Version.paranoid", "true"); + System.setProperty("syndie.rootDir", "."); + System.setProperty("syndie.defaultSingleUserArchives", "http://syndiemedia.i2p.net:8000/archive/archive.txt"); + System.setProperty("syndie.defaultProxyHost", ""); + System.setProperty("syndie.defaultProxyPort", ""); + } + + private RunStandalone(String args[]) {} + + public static void main(String args[]) { + RunStandalone runner = new RunStandalone(args); + runner.start(); + } + + public void start() { + File workDir = new File("work"); + boolean workDirRemoved = FileUtil.rmdir(workDir, false); + if (!workDirRemoved) + System.err.println("ERROR: Unable to remove Jetty temporary work directory"); + boolean workDirCreated = workDir.mkdirs(); + if (!workDirCreated) + System.err.println("ERROR: Unable to create Jetty temporary work directory"); + + try { + _server = new Server("jetty-syndie.xml"); + _server.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void stop() { + try { + _server.stop(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } +} diff --git a/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java index d7414411e..c99820557 100644 --- a/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java +++ b/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java @@ -257,7 +257,7 @@ public class ViewThreadedServlet extends BaseServlet { HeaderReceiver rec = new HeaderReceiver(); parser.parse(entry.getEntry().getText(), rec); String subject = rec.getHeader(HTMLRenderer.HEADER_SUBJECT); - if (subject == null) + if ( (subject == null) || (subject.trim().length() <= 0) ) subject = "(no subject)"; out.write(trim(subject, 40)); //out.write("\n\n"); diff --git a/apps/syndie/jetty-syndie.xml b/apps/syndie/jetty-syndie.xml new file mode 100644 index 000000000..4cf61e494 --- /dev/null +++ b/apps/syndie/jetty-syndie.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + 0.0.0.0 + 8001 + + + 3 + 10 + 30000 + 1000 + 8443 + 8443 + main + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + syndie + + / + syndie.war + + + + + + + + ./logs/yyyy_mm_dd.syndie-request.log + 90 + true + false + false + GMT + + + + + + + 2000 + false + + diff --git a/build.xml b/build.xml index c2f64ebad..ed8ced03a 100644 --- a/build.xml +++ b/build.xml @@ -8,6 +8,7 @@ + @@ -149,7 +150,8 @@ - + + @@ -438,4 +440,8 @@ + + + + diff --git a/history.txt b/history.txt index bbb4d8b5a..172b179cf 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,13 @@ -$Id: history.txt,v 1.340 2005/11/30 20:13:45 jrandom Exp $ +$Id: history.txt,v 1.341 2005/12/01 12:16:53 jrandom Exp $ + +2005-12-03 jrandom + * Package up a standalone Syndie install into a "syndie-standalone.zip", + buildable with "ant syndie". It extracts into ./syndie/, launches with + "java -jar launchsyndie.jar" (or javaw, on windows, to avoid a dos box), + running a single user Syndie instance (by default). It also creates a + default subscription to syndiemedia without any anonymity (using no + proxy). Upgrades can be done by just replacing the syndie.war with the + one from I2P. * 2005-12-01 0.6.1.7 released