added an "off" switch for the CSS support
This commit is contained in:
parent
1133f7ba7d
commit
7bc0584cfd
|
@ -44,6 +44,8 @@ public class StyleSheet extends HttpServlet
|
||||||
ServletContext ctxt = getServletContext();
|
ServletContext ctxt = getServletContext();
|
||||||
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
|
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
|
||||||
String stylesheet = Variables.getStyleSheetData(ctxt,rdat);
|
String stylesheet = Variables.getStyleSheetData(ctxt,rdat);
|
||||||
|
if (stylesheet!=null)
|
||||||
|
{ // send back the stylesheet
|
||||||
response.setContentType("text/css");
|
response.setContentType("text/css");
|
||||||
response.setContentLength(stylesheet.length());
|
response.setContentLength(stylesheet.length());
|
||||||
PrintWriter out = response.getWriter();
|
PrintWriter out = response.getWriter();
|
||||||
|
@ -51,6 +53,10 @@ public class StyleSheet extends HttpServlet
|
||||||
out.flush();
|
out.flush();
|
||||||
response.flushBuffer();
|
response.flushBuffer();
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
else // no stylesheet data
|
||||||
|
response.sendError(HttpServletResponse.SC_NOT_FOUND,"stylesheets not enabled");
|
||||||
|
|
||||||
} // end doGet
|
} // end doGet
|
||||||
|
|
||||||
} // end class StyleSheet
|
} // end class StyleSheet
|
||||||
|
|
|
@ -329,6 +329,8 @@ public class Variables
|
||||||
|
|
||||||
public static String getStyleSheetData(ServletContext ctxt, RenderData rdat) throws IOException
|
public static String getStyleSheetData(ServletContext ctxt, RenderData rdat) throws IOException
|
||||||
{
|
{
|
||||||
|
if (!(rdat.useStyleSheet()))
|
||||||
|
return null;
|
||||||
String data = null;
|
String data = null;
|
||||||
SoftReference r = (SoftReference)(ctxt.getAttribute(STYLESHEET_ATTRIBUTE));
|
SoftReference r = (SoftReference)(ctxt.getAttribute(STYLESHEET_ATTRIBUTE));
|
||||||
if (r!=null)
|
if (r!=null)
|
||||||
|
|
|
@ -136,13 +136,8 @@ public class RenderConfig implements ColorSelectors
|
||||||
logger.debug("Font face: " + font_face);
|
logger.debug("Font face: " + font_face);
|
||||||
|
|
||||||
String stylesheet_loc = render_sect_h.getSubElementText("stylesheet");
|
String stylesheet_loc = render_sect_h.getSubElementText("stylesheet");
|
||||||
if (stylesheet_loc==null)
|
if (stylesheet_loc!=null)
|
||||||
{ // no <stylesheet/> tag - bail out now!
|
{ // we're using Cascading Stylesheets - load it and test for existence
|
||||||
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("/")))
|
if (!(stylesheet_loc.startsWith("/")))
|
||||||
stylesheet_loc = root_file_path + stylesheet_loc;
|
stylesheet_loc = root_file_path + stylesheet_loc;
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
|
@ -157,6 +152,10 @@ public class RenderConfig implements ColorSelectors
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
else // no stylesheet
|
||||||
|
stylesheet = null;
|
||||||
|
|
||||||
Element colors_sect = render_sect_h.getSubElement("colors");
|
Element colors_sect = render_sect_h.getSubElement("colors");
|
||||||
if (colors_sect==null)
|
if (colors_sect==null)
|
||||||
{ // no <colors/> tag - bail out now!
|
{ // no <colors/> tag - bail out now!
|
||||||
|
@ -554,6 +553,9 @@ public class RenderConfig implements ColorSelectors
|
||||||
|
|
||||||
synchronized String loadStyleSheetData() throws IOException
|
synchronized String loadStyleSheetData() throws IOException
|
||||||
{
|
{
|
||||||
|
if (stylesheet==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
// Load the stylesheet data.
|
// Load the stylesheet data.
|
||||||
StringBuffer raw_data = IOUtil.loadText(stylesheet);
|
StringBuffer raw_data = IOUtil.loadText(stylesheet);
|
||||||
stylesheet_time = stylesheet.lastModified();
|
stylesheet_time = stylesheet.lastModified();
|
||||||
|
@ -588,10 +590,18 @@ public class RenderConfig implements ColorSelectors
|
||||||
|
|
||||||
boolean hasStyleSheetChanged()
|
boolean hasStyleSheetChanged()
|
||||||
{
|
{
|
||||||
|
if (stylesheet==null)
|
||||||
|
return false;
|
||||||
return (stylesheet_time!=stylesheet.lastModified());
|
return (stylesheet_time!=stylesheet.lastModified());
|
||||||
|
|
||||||
} // end hasStyleSheetChanged
|
} // end hasStyleSheetChanged
|
||||||
|
|
||||||
|
boolean useStyleSheet()
|
||||||
|
{
|
||||||
|
return (stylesheet!=null);
|
||||||
|
|
||||||
|
} // end useStyleSheet
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Static operations for use by VeniceServlet
|
* Static operations for use by VeniceServlet
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -318,6 +318,12 @@ public class RenderData implements ColorSelectors
|
||||||
|
|
||||||
} // end hasStyleSheetChanged
|
} // end hasStyleSheetChanged
|
||||||
|
|
||||||
|
public boolean useStyleSheet()
|
||||||
|
{
|
||||||
|
return rconf.useStyleSheet();
|
||||||
|
|
||||||
|
} // end useStyleSheet
|
||||||
|
|
||||||
public String formatDateForDisplay(Date date)
|
public String formatDateForDisplay(Date date)
|
||||||
{
|
{
|
||||||
if (display_date==null)
|
if (display_date==null)
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<%= rdat.getTitleTag(basedat.getTitle(rdat)) %>
|
<%= rdat.getTitleTag(basedat.getTitle(rdat)) %>
|
||||||
<%= rdat.getStdBaseFontTag(3) %>
|
<%= rdat.getStdBaseFontTag(3) %>
|
||||||
|
<% if (rdat.useStyleSheet()) { %>
|
||||||
<LINK REL="stylesheet" HREF="<%= rdat.getEncodedServletPath("stylesheet") %>" TYPE="text/css">
|
<LINK REL="stylesheet" HREF="<%= rdat.getEncodedServletPath("stylesheet") %>" TYPE="text/css">
|
||||||
|
<% } // end if %>
|
||||||
<% if (rdat.noSmartTags()) { %>
|
<% if (rdat.noSmartTags()) { %>
|
||||||
<META NAME="MSSmartTagsPreventParsing" CONTENT="TRUE">
|
<META NAME="MSSmartTagsPreventParsing" CONTENT="TRUE">
|
||||||
<% } // end if %>
|
<% } // end if %>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user