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,12 +44,18 @@ public class StyleSheet extends HttpServlet
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();
if (stylesheet!=null)
{ // send back the stylesheet
response.setContentType("text/css");
response.setContentLength(stylesheet.length());
PrintWriter out = response.getWriter();
out.write(stylesheet);
out.flush();
response.flushBuffer();
} // end if
else // no stylesheet data
response.sendError(HttpServletResponse.SC_NOT_FOUND,"stylesheets not enabled");
} // end doGet

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,26 +136,25 @@ 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.startsWith("/")))
stylesheet_loc = root_file_path + stylesheet_loc;
if (logger.isDebugEnabled())
logger.debug("Stylesheet location: " + stylesheet_loc);
// Test to make sure the stylesheet is actually present.
stylesheet = new File(stylesheet_loc);
if (!(stylesheet.exists() && stylesheet.canRead()))
{ // it's not there - bail out!
logger.fatal("unable to read stylesheet file: " + stylesheet_loc);
throw new ConfigException("stylesheet " + stylesheet_loc + " cannot be read",render_sect);
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())
logger.debug("Stylesheet location: " + stylesheet_loc);
// Test to make sure the stylesheet is actually present.
stylesheet = new File(stylesheet_loc);
if (!(stylesheet.exists() && stylesheet.canRead()))
{ // it's not there - bail out!
logger.fatal("unable to read stylesheet file: " + stylesheet_loc);
throw new ConfigException("stylesheet " + stylesheet_loc + " cannot be read",render_sect);
} // end if
} // end if
else // no stylesheet
stylesheet = null;
Element colors_sect = render_sect_h.getSubElement("colors");
if (colors_sect==null)
@ -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) %>
<LINK REL="stylesheet" HREF="<%= rdat.getEncodedServletPath("stylesheet") %>" TYPE="text/css">
<% 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 %>