Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.Theme


                ThemeManager themeMgr = roller.getThemeManager();
               
                String username = rses.getAuthenticatedUser().getUserName();
               
                try {
                    Theme usersTheme = themeMgr.getTheme(website.getEditorTheme());
                   
                    // only if custom themes are allowed
                    if(RollerRuntimeConfig.getBooleanProperty("themes.customtheme.allowed")) {
                        try {
                            themeMgr.importTheme(website, usersTheme);
View Full Code Here


     * @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

       
        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
                log.error("Problem reading theme " + themenames[i], unexpected);
            }
        }
View Full Code Here

     */
    private Theme loadThemeFromDisk(String theme_name, String themepath) {
       
        log.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()) {
                log.error("Couldn't " + msg);
                continue;
            }
            char[] chars = null;
            int length;
            try {
//                FileReader reader = new FileReader(template_file);
                chars = new char[(int) template_file.length()];
              FileInputStream stream = new FileInputStream(template_file);
              InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
                length = reader.read(chars);           
            } catch (Exception noprob) {
                log.error("Exception while attempting to " + msg);
                if (log.isDebugEnabled()) log.debug(noprob);
                continue;
            }
           
            // Strip "_" from name to form link
            boolean navbar = true;
            String template_link = template_name;
            if (template_name.startsWith("_") && template_name.length() > 1) {
                navbar = false;
                template_link = template_link.substring(1);
                log.debug("--- " + template_link);
            }
           
            String decorator = "_decorator";
            if("_decorator".equals(template_name)) {
                decorator = null;
            }
           
            // construct ThemeTemplate representing this file
            // a few restrictions for now:
            //   - we only allow "velocity" for the template language
            //   - decorator is always "_decorator" or null
            //   - all theme templates are considered not hidden
            theme_template = new ThemeTemplate(
                    theme,
                    theme_name+":"+template_name,
                    template_name,
                    template_name,
                    new String(chars, 0, length),
                    template_link,
                    new Date(template_file.lastModified()),
                    "velocity",
                    false,
                    navbar,
                    decorator);

            // add it to the theme
            theme.setTemplate(template_name, theme_template);
        }
       
        // use the last mod date of the theme dir
        theme.setLastModified(new Date(themedir.lastModified()));
       
        // load up resources as well
        loadThemeResources(theme, themedir, themedir.getAbsolutePath());
       
        return theme;
View Full Code Here

                request.setAttribute("currentTheme", currentTheme);
                request.setAttribute("themesList", themes);
               
                String theme = request.getParameter("theme");
                try {
                    Theme previewTheme = themeMgr.getTheme(theme);
                   
                    if(previewTheme.isEnabled()) {
                        // make sure the view knows what theme to preview
                        request.setAttribute("previewTheme", previewTheme.getName());
                   
                        mLogger.debug("Previewing theme "+previewTheme.getName()+
                                " to "+username);
                    } else {
                        request.setAttribute("previewTheme", currentTheme);
                        errors.add(null, new ActionMessage("Theme not enabled"));
                        saveErrors(request, errors);
View Full Code Here

                // lookup what theme the user wants first
                String theme = request.getParameter("theme");
                try {
                    Roller roller = RollerFactory.getRoller();
                    ThemeManager themeMgr = roller.getThemeManager();
                    Theme previewTheme = themeMgr.getTheme(theme);
                   
                    if(previewTheme.isEnabled()) {
                        newTheme = previewTheme.getName();
                    } else {
                        errors.add(null, new ActionMessage("Theme not enabled"));
                        saveErrors(request, errors);
                    }
                   
View Full Code Here

                ThemeManager themeMgr = roller.getThemeManager();
               
                String username = rses.getAuthenticatedUser().getUserName();
               
                try {
                    Theme usersTheme = themeMgr.getTheme(website.getEditorTheme());
                   
                    // only if custom themes are allowed
                    if(RollerRuntimeConfig.getBooleanProperty("themes.customtheme.allowed")) {
                        try {
                            themeMgr.saveThemePages(website, usersTheme);
View Full Code Here

     * @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

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.