diff --git a/build.xml b/build.xml
index 06cd4e4..401b6bf 100644
--- a/build.xml
+++ b/build.xml
@@ -27,7 +27,6 @@
-
@@ -36,10 +35,7 @@
-
-
-
-
+
diff --git a/etc/render-config.xml b/etc/render-config.xml
index 9d3b596..87d6058 100644
--- a/etc/render-config.xml
+++ b/etc/render-config.xml
@@ -41,6 +41,9 @@
Arial, Helvetica
+
+ WEB-INF/template.css
+
@@ -50,6 +53,7 @@
yellow#9999FFblack
+ bluewhiteblack#3333AA
@@ -59,6 +63,7 @@
white#9999FFblack
+ blue#006600white#660000
diff --git a/etc/template.css b/etc/template.css
new file mode 100644
index 0000000..55a86b2
--- /dev/null
+++ b/etc/template.css
@@ -0,0 +1,53 @@
+
diff --git a/etc/web.xml b/etc/web.xml
index fb352fe..2c59ed8 100644
--- a/etc/web.xml
+++ b/etc/web.xml
@@ -32,16 +32,16 @@
Modify as needed to suit your system. -->
logging.config
- /home/erbo/venice/WEB-INF/logging-config.xml
+ WEB-INF/logging-config.xml
- The full path and file name of the LOG4J configuration file, which needs
- to be loaded into LOG4J's DOMConfigurator at start-up.
+ The path and file name, relative to the application root directory, of the LOG4J configuration file,
+ which needs to be loaded into LOG4J's DOMConfigurator at start-up.
venice.config
- /home/erbo/venice/WEB-INF/venice-config.xml
+ WEB-INF/venice-config.xml
The full path and file name of the Venice engine configuration file, which
needs to be loaded into the Venice engine at start-up.
@@ -50,10 +50,10 @@
render.config
- /home/erbo/venice/WEB-INF/render-config.xml
+ WEB-INF/render-config.xml
- The full path and file name of the Venice rendering configuration file, which
- needs to be loaded into the Venice rendering system at start-up.
+ The path and file name, relative to the application root directory, of the Venice rendering
+ configuration file, which needs to be loaded into the Venice rendering system at start-up.
@@ -222,6 +222,14 @@
com.silverwrist.venice.servlets.UserPhoto
+
+ stylesheet
+
+ Generates the stylesheet included by the top-level JSP file).
+
+ com.silverwrist.venice.servlets.StyleSheet
+
+
@@ -335,6 +343,11 @@
/userphoto
+
+ stylesheet
+ /stylesheet
+
+
testformdata
diff --git a/src/com/silverwrist/util/AnyCharMatcher.java b/src/com/silverwrist/util/AnyCharMatcher.java
new file mode 100644
index 0000000..6deca12
--- /dev/null
+++ b/src/com/silverwrist/util/AnyCharMatcher.java
@@ -0,0 +1,86 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at .
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
+ * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * The Original Code is the Venice Web Communities System.
+ *
+ * The Initial Developer of the Original Code is Eric J. Bowersox ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.util;
+
+public final class AnyCharMatcher
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private char[] charset;
+ private int[] locs;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public AnyCharMatcher(char[] charset)
+ {
+ this.charset = charset;
+ this.locs = new int[charset.length];
+
+ } // end constructor
+
+ public AnyCharMatcher(String charset)
+ {
+ this.charset = charset.toCharArray();
+ this.locs = new int[charset.length()];
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public final int get(String str)
+ {
+ int numindexes = 0;
+ int i;
+ for (i=0; i=0)
+ locs[numindexes++] = tmp;
+
+ } // end for
+
+ if (numindexes==0)
+ return -1; // no characters found
+ else if (numindexes==1)
+ return locs[0]; // only one found
+
+ int rc = locs[0];
+ for (i=1; i.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
+ * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * The Original Code is the Venice Web Communities System.
+ *
+ * The Initial Developer of the Original Code is Eric J. Bowersox ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.util;
+
+import java.io.*;
+
+/* Some concepts in here borrowed from Apache Jakarta Avalon Excalibur 4.0 */
+
+public class IOUtil
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ public static int DEFAULT_BUFSIZE = 4096;
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static void shutdown(InputStream stm)
+ {
+ try
+ { // close the stream
+ stm.close();
+
+ } // end try
+ catch (IOException e)
+ { // throw away the exception
+ } // end catch
+
+ } // end shutdown
+
+ public static void shutdown(OutputStream stm)
+ {
+ try
+ { // close the stream
+ stm.close();
+
+ } // end try
+ catch (IOException e)
+ { // throw away the exception
+ } // end catch
+
+ } // end shutdown
+
+ public static void shutdown(Reader rdr)
+ {
+ try
+ { // close the stream
+ rdr.close();
+
+ } // end try
+ catch (IOException e)
+ { // throw away the exception
+ } // end catch
+
+ } // end shutdown
+
+ public static void shutdown(Writer wr)
+ {
+ try
+ { // close the stream
+ wr.close();
+
+ } // end try
+ catch (IOException e)
+ { // throw away the exception
+ } // end catch
+
+ } // end shutdown
+
+ public static void copy(InputStream input, OutputStream output, int bufsize) throws IOException
+ {
+ byte[] buffer = new byte[bufsize];
+ int rd = input.read(buffer);
+ while (rd>=0)
+ { // simple read-write loop to shove data out the door
+ if (rd>0)
+ output.write(buffer,0,rd);
+ rd = input.read(buffer);
+
+ } // end while
+
+ } // end copy
+
+ public static void copy(InputStream input, OutputStream output) throws IOException
+ {
+ copy(input,output,DEFAULT_BUFSIZE);
+
+ } // end copy
+
+ public static void copy(Reader input, Writer output, int bufsize) throws IOException
+ {
+ char[] buffer = new char[bufsize];
+ int rd = input.read(buffer);
+ while (rd>=0)
+ { // simple read-write loop to shove data out the door
+ if (rd>0)
+ output.write(buffer,0,rd);
+ rd = input.read(buffer);
+
+ } // end while
+
+ } // end copy
+
+ public static void copy(Reader input, Writer output) throws IOException
+ {
+ copy(input,output,DEFAULT_BUFSIZE);
+
+ } // end copy
+
+ public static StringBuffer load(Reader input, int bufsize) throws IOException
+ {
+ StringWriter wr = new StringWriter();
+ try
+ { // copy from reader to StringWriter
+ copy(input,wr,bufsize);
+ return wr.getBuffer();
+
+ } // end try
+ finally
+ { // make sure and close the StringWriter before we go
+ shutdown(wr);
+
+ } // end finally
+
+ } // end load
+
+ public static StringBuffer load(Reader input) throws IOException
+ {
+ return load(input,DEFAULT_BUFSIZE);
+
+ } // end load
+
+ public static StringBuffer load(File file, int bufsize) throws IOException
+ {
+ FileReader rdr = new FileReader(file);
+ try
+ { // load from the string reader
+ return load(rdr,bufsize);
+
+ } // end try
+ finally
+ { // make sure and close the reader before we go
+ shutdown(rdr);
+
+ } // end finally
+
+ } // end load
+
+ public static StringBuffer load(File file) throws IOException
+ {
+ return load(file,DEFAULT_BUFSIZE);
+
+ } // end load
+
+} // end class IOUtil
diff --git a/src/com/silverwrist/util/StringUtil.java b/src/com/silverwrist/util/StringUtil.java
index e272f32..583421d 100644
--- a/src/com/silverwrist/util/StringUtil.java
+++ b/src/com/silverwrist/util/StringUtil.java
@@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
- * The Original Code is the Venice Web Community System.
+ * The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@@ -17,8 +17,24 @@
*/
package com.silverwrist.util;
+import java.util.*;
+
public class StringUtil
{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String VAR_START = "${";
+ private static final String VAR_END = "}";
+ private static final char[] HTML_ENCODE_CHARS = { '"', '&', '<', '>' };
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
public static String encodeStringSQL(String str)
{
if (str==null)
@@ -46,10 +62,16 @@ public class StringUtil
{
if (str==null)
return null;
+ AnyCharMatcher nhc = new AnyCharMatcher(HTML_ENCODE_CHARS);
+ int ndx = nhc.get(str);
+ if (ndx<0)
+ return str; // trivial short-circuit case
StringBuffer buf = new StringBuffer();
- for (int i=0; i=0)
+ { // append the matched "head" and then the encoded character
+ if (ndx>0)
+ buf.append(str.substring(0,ndx));
+ switch (str.charAt(ndx++))
{
case '"':
buf.append(""");
@@ -67,14 +89,16 @@ public class StringUtil
buf.append(">");
break;
- default:
- buf.append(str.charAt(i));
- break;
-
} // end switch
- } // end for
+ if (ndx==str.length())
+ return buf.toString(); // munched the entire string - all done!
+ str = str.substring(ndx);
+ ndx = nhc.get(str);
+ } // end while
+
+ buf.append(str); // append the unmatched tail
return buf.toString();
} // end encodeHTML
@@ -101,22 +125,55 @@ public class StringUtil
// break off the tail end
ndx += find.length();
if (ndx==work.length())
- work = null;
- else
- work = work.substring(ndx);
-
- // do the next find
- if (work!=null)
- ndx = work.indexOf(find);
- else
- ndx = -1;
+ return b.toString(); // entire string munched - we're done!
+ work = work.substring(ndx);
+ ndx = work.indexOf(find);
} // end while
- if (work!=null)
- b.append(work);
+ // append the unmatched "tail" of the work string and then return result
+ b.append(work);
return b.toString();
} // end replaceAllInstances
+ public static String replaceAllVariables(String base, Map vars)
+ {
+ String work = base;
+ boolean did_replace, retest;
+
+ retest = true;
+ do
+ { // main loop for replacing all variables
+ did_replace = false;
+ Iterator it = vars.keySet().iterator();
+ while (it.hasNext())
+ { // variable start is there...
+ if (retest)
+ { // only perform this test on the first iteration and after we know we've replaced a variable
+ if (work.indexOf(VAR_START)<0)
+ return work; // no more variables in text - all done!
+ retest = false;
+
+ } // end if
+
+ // get variable name and see if it's present
+ String vname = it.next().toString();
+ if (work.indexOf(VAR_START + vname + VAR_END)>=0)
+ { // OK, this variable is in place
+ work = replaceAllInstances(work,VAR_START + vname + VAR_END,vars.get(vname).toString());
+ did_replace = true;
+ retest = true;
+
+ } // end if
+
+ } // end while
+
+ } while (did_replace); // end do
+
+ return work; // all done!
+
+ } // end replaceAllVariables
+
} // end class StringUtil
+
diff --git a/src/com/silverwrist/venice/servlets/StyleSheet.java b/src/com/silverwrist/venice/servlets/StyleSheet.java
new file mode 100644
index 0000000..f34b19e
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/StyleSheet.java
@@ -0,0 +1,56 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at .
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
+ * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * The Original Code is the Venice Web Communities System.
+ *
+ * The Initial Developer of the Original Code is Eric J. Bowersox ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.venice.servlets;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.venice.servlets.format.RenderConfig;
+import com.silverwrist.venice.servlets.format.RenderData;
+
+public class StyleSheet extends HttpServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getServletInfo()
+ {
+ String rc = "StyleSheet applet - Generates a Cascading Stylesheet for Venice's use\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ ServletContext ctxt = getServletContext();
+ RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
+ String stylesheet = Variables.getStyleSheetData(ctxt,rdat);
+ response.setContentType("text/css");
+ response.setContentLength(stylesheet.length());
+ PrintWriter out = response.getWriter();
+ out.write(stylesheet);
+ out.flush();
+ response.flushBuffer();
+
+ } // end doGet
+
+} // end class StyleSheet
diff --git a/src/com/silverwrist/venice/servlets/Top.java b/src/com/silverwrist/venice/servlets/Top.java
index aafdc17..95634a7 100644
--- a/src/com/silverwrist/venice/servlets/Top.java
+++ b/src/com/silverwrist/venice/servlets/Top.java
@@ -36,9 +36,15 @@ public class Top extends VeniceServlet
{
super.init(config); // required before we do anything else
ServletContext ctxt = config.getServletContext();
+ String root_file_path = ctxt.getRealPath("/");
+ if (!(root_file_path.endsWith("/")))
+ root_file_path += "/";
// Initialize LOG4J logging.
- DOMConfigurator.configure(ctxt.getInitParameter("logging.config"));
+ String lconf = ctxt.getInitParameter("logging.config");
+ if (!(lconf.startsWith("/")))
+ lconf = root_file_path + lconf;
+ DOMConfigurator.configure(lconf);
// Initialize the Venice engine.
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
diff --git a/src/com/silverwrist/venice/servlets/Variables.java b/src/com/silverwrist/venice/servlets/Variables.java
index 6f18b67..cef3412 100644
--- a/src/com/silverwrist/venice/servlets/Variables.java
+++ b/src/com/silverwrist/venice/servlets/Variables.java
@@ -17,6 +17,8 @@
*/
package com.silverwrist.venice.servlets;
+import java.io.*;
+import java.lang.ref.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
@@ -36,6 +38,7 @@ public class Variables
protected static final String ENGINE_ATTRIBUTE = "com.silverwrist.venice.core.Engine";
protected static final String COUNTRYLIST_ATTRIBUTE = "com.silverwrist.venice.db.CountryList";
protected static final String LANGUAGELIST_ATTRIBUTE = "com.silverwrist.venice.db.LanguageList";
+ protected static final String STYLESHEET_ATTRIBUTE = "com.silverwrist.venice.rendering.StyleSheet";
// HttpSession ("session") attributes
protected static final String USERCTXT_ATTRIBUTE = "user.context";
@@ -60,13 +63,19 @@ public class Variables
public static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
{
- synchronized(engine_gate)
+ synchronized (engine_gate)
{ // we must synchronize efforts to access the engine
Object foo = ctxt.getAttribute(ENGINE_ATTRIBUTE);
if (foo!=null)
return (VeniceEngine)foo;
+ String root_file_path = ctxt.getRealPath("/");
+ if (!(root_file_path.endsWith("/")))
+ root_file_path += "/";
+
String cfgfile = ctxt.getInitParameter(ENGINE_INIT_PARAM); // get the config file name
+ if (!(cfgfile.startsWith("/")))
+ cfgfile = root_file_path + cfgfile;
logger.info("Initializing Venice engine using config file: " + cfgfile);
try
@@ -318,4 +327,22 @@ public class Variables
} // end flushCookies
+ public static String getStyleSheetData(ServletContext ctxt, RenderData rdat) throws IOException
+ {
+ String data = null;
+ SoftReference r = (SoftReference)(ctxt.getAttribute(STYLESHEET_ATTRIBUTE));
+ if (r!=null)
+ data = (String)(r.get());
+ if ((data==null) || rdat.hasStyleSheetChanged())
+ { // construct or reconstruct the stylesheet data, save a soft reference to it
+ data = rdat.loadStyleSheetData();
+ r = new SoftReference(data);
+ ctxt.setAttribute(STYLESHEET_ATTRIBUTE,r);
+
+ } // end if
+
+ return data;
+
+ } // end getStyleSheetData
+
} // end class Variables
diff --git a/src/com/silverwrist/venice/servlets/format/AuditDataViewer.java b/src/com/silverwrist/venice/servlets/format/AuditDataViewer.java
index a3db827..dfd4b4a 100644
--- a/src/com/silverwrist/venice/servlets/format/AuditDataViewer.java
+++ b/src/com/silverwrist/venice/servlets/format/AuditDataViewer.java
@@ -91,7 +91,7 @@ public class AuditDataViewer implements ContentRender, ColorSelectors
rdat.writeContentHeader(out,title,null);
// Write the informational and navigational table
- out.write("
"
+ out.write("
"
+ rdat.getStdFontTag(CONTENT_FOREGROUND,2) + "\nDisplaying records " + (offset+1)
+ " to " + last_index + " of " + total_count + "\n"
+ "
\n");
@@ -114,30 +114,30 @@ public class AuditDataViewer implements ContentRender, ColorSelectors
// Start writing the table containing the actual audit records.
String tb_font = rdat.getStdFontTag(CONTENT_FOREGROUND,2);
- out.write("
\n");
- out.write("
\n
" + tb_font + "Date/Time
\n");
- out.write("
" + tb_font + "Description
\n");
- out.write("
" + tb_font + "User
\n");
- out.write("
" + tb_font + "SIG
\n");
- out.write("
" + tb_font + "IP Address
\n");
- out.write("
" + tb_font + "Additional Data
\n
\n");
+ out.write("
\n
\n
"
+ + tb_font + "Date/Time
\n
"
+ + tb_font + "Description
\n
"
+ + tb_font + "User
\n
" + tb_font
+ + "SIG
\n
" + tb_font
+ + "IP Address
\n
"
+ + tb_font + "Additional Data
\n
\n");
Iterator it = audit_list.iterator();
while (it.hasNext())
{ // display each record in turn
AuditData dat = (AuditData)(it.next());
- out.write("