added an "off" switch for the CSS support

This commit is contained in:
Eric J. Bowersox 2001-11-01 02:12:51 +00:00
parent 1133f7ba7d
commit 7bc0584cfd
5 changed files with 51 additions and 25 deletions

View File

@ -44,6 +44,8 @@ public class StyleSheet extends HttpServlet
ServletContext ctxt = getServletContext();
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
String stylesheet = Variables.getStyleSheetData(ctxt,rdat);
if (stylesheet!=null)
{ // send back the stylesheet
response.setContentType("text/css");
response.setContentLength(stylesheet.length());
PrintWriter out = response.getWriter();
@ -51,6 +53,10 @@ public class StyleSheet extends HttpServlet
out.flush();
response.flushBuffer();
} // end if
else // no stylesheet data
response.sendError(HttpServletResponse.SC_NOT_FOUND,"stylesheets not enabled");
} // end doGet
} // end class StyleSheet

View File

@ -329,6 +329,8 @@ public class Variables
public static String getStyleSheetData(ServletContext ctxt, RenderData rdat) throws IOException
{
if (!(rdat.useStyleSheet()))
return null;
String data = null;
SoftReference r = (SoftReference)(ctxt.getAttribute(STYLESHEET_ATTRIBUTE));
if (r!=null)

View File

@ -136,13 +136,8 @@ public class RenderConfig implements ColorSelectors
logger.debug("Font face: " + font_face);
String stylesheet_loc = render_sect_h.getSubElementText("stylesheet");
if (stylesheet_loc==null)
{ // no <stylesheet/> tag - bail out now!
logger.fatal("<rendering/> section has no <stylesheet/> element");
throw new ConfigException("no <stylesheet/> found in <rendering/> section",render_sect);
} // end if
if (stylesheet_loc!=null)
{ // we're using Cascading Stylesheets - load it and test for existence
if (!(stylesheet_loc.startsWith("/")))
stylesheet_loc = root_file_path + stylesheet_loc;
if (logger.isDebugEnabled())
@ -157,6 +152,10 @@ public class RenderConfig implements ColorSelectors
} // end if
} // end if
else // no stylesheet
stylesheet = null;
Element colors_sect = render_sect_h.getSubElement("colors");
if (colors_sect==null)
{ // no <colors/> tag - bail out now!
@ -554,6 +553,9 @@ public class RenderConfig implements ColorSelectors
synchronized String loadStyleSheetData() throws IOException
{
if (stylesheet==null)
return null;
// Load the stylesheet data.
StringBuffer raw_data = IOUtil.loadText(stylesheet);
stylesheet_time = stylesheet.lastModified();
@ -588,10 +590,18 @@ public class RenderConfig implements ColorSelectors
boolean hasStyleSheetChanged()
{
if (stylesheet==null)
return false;
return (stylesheet_time!=stylesheet.lastModified());
} // end hasStyleSheetChanged
boolean useStyleSheet()
{
return (stylesheet!=null);
} // end useStyleSheet
/*--------------------------------------------------------------------------------
* Static operations for use by VeniceServlet
*--------------------------------------------------------------------------------

View File

@ -318,6 +318,12 @@ public class RenderData implements ColorSelectors
} // end hasStyleSheetChanged
public boolean useStyleSheet()
{
return rconf.useStyleSheet();
} // end useStyleSheet
public String formatDateForDisplay(Date date)
{
if (display_date==null)

View File

@ -37,7 +37,9 @@
<HEAD>
<%= rdat.getTitleTag(basedat.getTitle(rdat)) %>
<%= rdat.getStdBaseFontTag(3) %>
<% if (rdat.useStyleSheet()) { %>
<LINK REL="stylesheet" HREF="<%= rdat.getEncodedServletPath("stylesheet") %>" TYPE="text/css">
<% } // end if %>
<% if (rdat.noSmartTags()) { %>
<META NAME="MSSmartTagsPreventParsing" CONTENT="TRUE">
<% } // end if %>