Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.Theme


     * @see org.apache.roller.model.ThemeManager#getTheme(java.lang.String)
     */
    public Theme getTheme(String name)
        throws ThemeNotFoundException, RollerException {
       
        Theme theme = (Theme) this.themes.get(name);
        if(theme == null)
            throw new ThemeNotFoundException("Couldn't find theme ["+name+"]");
       
        return theme;
    }
View Full Code Here


        Collection all_themes = this.themes.values();
       
        // make a new list of only the enabled themes
        List enabled_themes = new ArrayList();
        Iterator it = all_themes.iterator();
        Theme theme = null;
        while(it.hasNext()) {
            theme = (Theme) it.next();
            if(theme.isEnabled())
                enabled_themes.add(theme.getName());
        }
               
        // sort 'em ... the natural sorting order for Strings is alphabetical
        Collections.sort(enabled_themes);
       
View Full Code Here

     */
    public ThemeTemplate getTemplate(String theme_name, String template_name)
        throws ThemeNotFoundException, RollerException {
       
        // basically we just try and lookup the theme first, then template
        Theme theme = this.getTheme(theme_name);
       
        return theme.getTemplate(template_name);
    }
View Full Code Here

     */
    public ThemeTemplate getTemplateByLink(String theme_name, String template_link)
        throws ThemeNotFoundException, RollerException {
       
        // basically we just try and lookup the theme first, then template
        Theme theme = this.getTheme(theme_name);
       
        return theme.getTemplateByLink(template_link);
    }
View Full Code Here

       
        if(themenames == null)
            themenames = new String[0];
       
        // now go through each theme and read all it's templates
        Theme theme = null;
        for(int i=0; i < themenames.length; i++) {
            try {
                theme = this.loadThemeFromDisk(themenames[i],
                            themespath + File.separator + themenames[i]);           
                themes.put(theme.getName(), theme);
            } catch (Throwable unexpected) {
                // shouldn't happen, so let's learn why it did
                mLogger.error("Problem reading theme " + themenames[i], unexpected);
            }
        }
View Full Code Here

     */
    private Theme loadThemeFromDisk(String theme_name, String themepath) {
       
        mLogger.info("Loading theme "+theme_name)
       
        Theme theme = new Theme();
        theme.setName(theme_name);
        theme.setAuthor("Roller");
        theme.setLastEditor("Roller");
        theme.setEnabled(true);
       
        // start by getting a list of the .vm files for this theme
        File themedir = new File(themepath);
        FilenameFilter filter = new FilenameFilter()
        {
            public boolean accept(File dir, String name)
            {
                return name.endsWith(".vm");
            }
        };
        String[] templates = themedir.list(filter);
       
        // go through each .vm file and read in its contents to a ThemeTemplate
        String template_name = null;
        ThemeTemplate theme_template = null;
        for (int i=0; i < templates.length; i++) {
            // strip off the .vm part
            template_name = templates[i].substring(0, templates[i].length() - 3);           
            File template_file = new File(themepath + File.separator + templates[i]);
           
            // Continue reading theme even if problem encountered with one file
            String msg = "read theme template file ["+template_file+"]";
            if(!template_file.exists() && !template_file.canRead()) {
                mLogger.error("Couldn't " + msg);
                continue;
            }
            char[] chars = null;
            try {
                FileReader reader = new FileReader(template_file);
                chars = new char[(int) template_file.length()];
                reader.read(chars);           
            } catch (Exception noprob) {
                mLogger.error("Exception while attempting to " + msg);
                if (mLogger.isDebugEnabled()) mLogger.debug(noprob);
                continue;
            }

            // construct ThemeTemplate representing this file
            theme_template = new ThemeTemplate(
                    theme_name+":"+template_name,
                    template_name,
                    template_name,
                    new String(chars),
                    template_name,
                    new Date(template_file.lastModified()));

            // add it to the theme
            theme.setTemplate(template_name, theme_template);
        }
       
        // use the last mod date of the last template file
        // as the last mod date of the theme
        theme.setLastModified(theme_template.getLastModified());
       
        return theme;
    }
View Full Code Here

                    "en_US_WIN",    // locale
                    "America/Los_Angeles" // timezone
                    );
       
        ThemeManager themeMgr = getRoller().getThemeManager();
        Theme usersTheme = themeMgr.getTheme(website.getEditorTheme());
        themeMgr.saveThemePages(website, usersTheme);
       
        return ud;
    }
View Full Code Here

            if(split.length < 2)
                throw new ResourceNotFoundException("Invalid ThemeRL key "+name);
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                throw new ResourceNotFoundException("Template ["+split[1]+
                        "] doesn't seem to be part of theme ["+split[0]+"]");
           
View Full Code Here

            if(split.length < 2)
                return last_mod;
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                return last_mod;
           
            last_mod = template.getLastModified().getTime();
View Full Code Here

    public Template handleRequest( HttpServletRequest request,
                                HttpServletResponse response,
                                Context ctx )
            throws Exception {
       
        Theme previewTheme = null;
       
        // try getting the preview theme
        String themeName = request.getParameter("theme");
        if (themeName != null) {
            try {
                Roller roller = RollerFactory.getRoller();
                ThemeManager themeMgr = roller.getThemeManager();
                previewTheme = themeMgr.getTheme(themeName);
               
            } catch(ThemeNotFoundException tnfe) {
                // bogus theme specified ... don't worry about it
                // possibly "custom", but we'll handle that below
            } catch(RollerException re) {
               
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                request.setAttribute("DisplayException", re);
                mLogger.error("EXCEPTION: in RollerServlet", re);
            }
        }
       
        if((previewTheme == null || !previewTheme.isEnabled()) &&
                !themeName.equals(Theme.CUSTOM)) {
           
            // if we don't have a valid preview theme then
            // leave it up to our parent
            return super.handleRequest(request, response, ctx);
           
        }
       
        Template outty = null;
        RollerRequest rreq = null;
       
        // first off lets parse the incoming request and validate it
        try {
            PageContext pageContext =
                    JspFactory.getDefaultFactory().getPageContext(
                    this, request, response,"", true, 8192, true);
            rreq = RollerRequest.getRollerRequest(pageContext);
        } catch (RollerException e) {
           
            // An error initializing the request is considered to be a 404
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            request.setAttribute("DisplayException", e);
           
            return null;
        }
       
       
        // request appears to be valid, lets render
        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
           
            WebsiteData website = null;
            if (request.getAttribute(RollerRequest.OWNING_WEBSITE) != null)
            {
                UserData user = (UserData)
                    request.getAttribute(RollerRequest.OWNING_WEBSITE);
            }
            else
            {
                website = rreq.getWebsite();
            }
           
            // construct a temporary Website object for this request
            // and set the EditorTheme to our previewTheme
            WebsiteData tmpWebsite = new WebsiteData();
            tmpWebsite.setData(website);
            if(previewTheme != null)
                tmpWebsite.setEditorTheme(previewTheme.getName());
            else
                tmpWebsite.setEditorTheme(Theme.CUSTOM);
           
            org.apache.roller.pojos.Template page = null;
           
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.Theme

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.