added an "off" switch for the CSS support
This commit is contained in:
		
							parent
							
								
									1133f7ba7d
								
							
						
					
					
						commit
						7bc0584cfd
					
				@ -44,12 +44,18 @@ 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);
 | 
				
			||||||
    response.setContentType("text/css");
 | 
					    if (stylesheet!=null)
 | 
				
			||||||
    response.setContentLength(stylesheet.length());
 | 
					    { // send back the stylesheet
 | 
				
			||||||
    PrintWriter out = response.getWriter();
 | 
					      response.setContentType("text/css");
 | 
				
			||||||
    out.write(stylesheet);
 | 
					      response.setContentLength(stylesheet.length());
 | 
				
			||||||
    out.flush();
 | 
					      PrintWriter out = response.getWriter();
 | 
				
			||||||
    response.flushBuffer();
 | 
					      out.write(stylesheet);
 | 
				
			||||||
 | 
					      out.flush();
 | 
				
			||||||
 | 
					      response.flushBuffer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    } // end if
 | 
				
			||||||
 | 
					    else  // no stylesheet data
 | 
				
			||||||
 | 
					      response.sendError(HttpServletResponse.SC_NOT_FOUND,"stylesheets not enabled");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  } // end doGet
 | 
					  } // end doGet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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,26 +136,25 @@ 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");
 | 
					      if (!(stylesheet_loc.startsWith("/")))
 | 
				
			||||||
      throw new ConfigException("no <stylesheet/> found in <rendering/> section",render_sect);
 | 
						stylesheet_loc = root_file_path + stylesheet_loc;
 | 
				
			||||||
 | 
					      if (logger.isDebugEnabled())
 | 
				
			||||||
    } // end if
 | 
						logger.debug("Stylesheet location: " + stylesheet_loc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(stylesheet_loc.startsWith("/")))
 | 
					      // Test to make sure the stylesheet is actually present.
 | 
				
			||||||
      stylesheet_loc = root_file_path + stylesheet_loc;
 | 
					      stylesheet = new File(stylesheet_loc);
 | 
				
			||||||
    if (logger.isDebugEnabled())
 | 
					      if (!(stylesheet.exists() && stylesheet.canRead()))
 | 
				
			||||||
      logger.debug("Stylesheet location: " + stylesheet_loc);
 | 
					      { // it's not there - bail out!
 | 
				
			||||||
 | 
						logger.fatal("unable to read stylesheet file: " + stylesheet_loc);
 | 
				
			||||||
    // Test to make sure the stylesheet is actually present.
 | 
						throw new ConfigException("stylesheet " + stylesheet_loc + " cannot be read",render_sect);
 | 
				
			||||||
    stylesheet = new File(stylesheet_loc);
 | 
					
 | 
				
			||||||
    if (!(stylesheet.exists() && stylesheet.canRead()))
 | 
					      } // end if
 | 
				
			||||||
    { // 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");
 | 
					    Element colors_sect = render_sect_h.getSubElement("colors");
 | 
				
			||||||
    if (colors_sect==null)
 | 
					    if (colors_sect==null)
 | 
				
			||||||
@ -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) %>
 | 
				
			||||||
  <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()) { %>
 | 
					  <% if (rdat.noSmartTags()) { %>
 | 
				
			||||||
    <META NAME="MSSmartTagsPreventParsing" CONTENT="TRUE">
 | 
					    <META NAME="MSSmartTagsPreventParsing" CONTENT="TRUE">
 | 
				
			||||||
  <% } // end if %>
 | 
					  <% } // end if %>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user