Return-Path: X-Original-To: apmail-roller-commits-archive@www.apache.org Delivered-To: apmail-roller-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CE99310E93 for ; Fri, 11 Oct 2013 13:07:01 +0000 (UTC) Received: (qmail 39877 invoked by uid 500); 11 Oct 2013 13:07:01 -0000 Delivered-To: apmail-roller-commits-archive@roller.apache.org Received: (qmail 39850 invoked by uid 500); 11 Oct 2013 13:07:00 -0000 Mailing-List: contact commits-help@roller.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@roller.apache.org Delivered-To: mailing list commits@roller.apache.org Received: (qmail 39838 invoked by uid 99); 11 Oct 2013 13:06:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Oct 2013 13:06:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Oct 2013 13:06:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C57DD2388868; Fri, 11 Oct 2013 13:06:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1531282 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/business/themes/ java/org/apache/roller/weblogger/ui/rendering/velocity/ resources/ webapp/WEB-INF/velocity/ webapp/WEB-INF/velocity/templates/ webapp/themes/basic/ Date: Fri, 11 Oct 2013 13:06:34 -0000 To: commits@roller.apache.org From: ghuber@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131011130634.C57DD2388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ghuber Date: Fri Oct 11 13:06:33 2013 New Revision: 1531282 URL: http://svn.apache.org/r1531282 Log: jQuery mobile rocks.. Added: roller/trunk/app/src/main/webapp/themes/basic/basic-mobile-custom.css Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.java roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/ThemeResourceLoader.java roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer.java roller/trunk/app/src/main/resources/ApplicationResources.properties roller/trunk/app/src/main/webapp/WEB-INF/velocity/templates/error-parse.vm roller/trunk/app/src/main/webapp/WEB-INF/velocity/weblog.vm roller/trunk/app/src/main/webapp/themes/basic/_day-mobile.vm roller/trunk/app/src/main/webapp/themes/basic/permalink-mobile.vm roller/trunk/app/src/main/webapp/themes/basic/searchresults-mobile.vm roller/trunk/app/src/main/webapp/themes/basic/theme.xml roller/trunk/app/src/main/webapp/themes/basic/weblog-mobile.vm Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java?rev=1531282&r1=1531281&r2=1531282&view=diff ============================================================================== --- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java (original) +++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java Fri Oct 11 13:06:33 2013 @@ -32,52 +32,49 @@ import org.apache.roller.weblogger.pojos import org.apache.roller.weblogger.pojos.ThemeTemplate; import org.apache.roller.weblogger.pojos.WeblogTemplate; - /** - * The Theme object encapsulates all elements of a single weblog theme. It - * is used mostly to contain all the templates for a theme, but does contain - * other theme related attributes such as name, last modifed date, etc. + * The Theme object encapsulates all elements of a single weblog theme. It is + * used mostly to contain all the templates for a theme, but does contain other + * theme related attributes such as name, last modifed date, etc. */ public class SharedThemeFromDir extends SharedTheme { - + private static Log log = LogFactory.getLog(SharedThemeFromDir.class); - + // the filesystem directory where we should read this theme from private String themeDir = null; - + // the theme preview image private ThemeResource previewImage = null; - + // the theme stylesheet private ThemeTemplate stylesheet = null; - + // we keep templates in a Map for faster lookups by name // the Map contains ... (template name, ThemeTemplate) private Map templatesByName = new HashMap(); - + // we keep templates in a Map for faster lookups by link // the Map contains ... (template link, List) private Map templatesByLink = new HashMap(); - + // we keep templates in a Map for faster lookups by action // the Map contains ... (template action, ThemeTemplate) private Map templatesByAction = new HashMap(); - + // we keep resources in a Map for faster lookups by path // the Map contains ... (resource path, ThemeResource) private Map resources = new HashMap(); - - - public SharedThemeFromDir(String themeDirPath) + + public SharedThemeFromDir(String themeDirPath) throws ThemeInitializationException { - + this.themeDir = themeDirPath; - + // load the theme elements and cache 'em loadThemeFromDisk(); } - /** * Get a resource representing the preview image for this theme. */ @@ -85,320 +82,333 @@ public class SharedThemeFromDir extends return this.previewImage; } - /** * Get the collection of all templates associated with this Theme. */ public List getTemplates() { return new ArrayList(this.templatesByName.values()); } - - + /** - * Lookup the stylesheet. - * Returns null if no stylesheet defined. + * Lookup the stylesheet. Returns null if no stylesheet defined. */ public ThemeTemplate getStylesheet() { return this.stylesheet; } - - + /** - * Looup the default template, action = weblog. - * Returns null if the template cannot be found. + * Looup the default template, action = weblog. Returns null if the template + * cannot be found. */ public ThemeTemplate getDefaultTemplate() { - return (ThemeTemplate) this.templatesByAction.get(ThemeTemplate.ACTION_WEBLOG); + return (ThemeTemplate) this.templatesByAction + .get(ThemeTemplate.ACTION_WEBLOG); } - - + /** - * Lookup the specified template by name. - * Returns null if the template cannot be found. + * Lookup the specified template by name. Returns null if the template + * cannot be found. */ public ThemeTemplate getTemplateByName(String name) { return (ThemeTemplate) this.templatesByName.get(name); } - - + /** - * Lookup the specified template by link. - * Returns null if the template cannot be found. + * Lookup the specified template by link. Returns null if the template + * cannot be found. */ - public ThemeTemplate getTemplateByLink(String link) { + public ThemeTemplate getTemplateByLink(String link) { return (ThemeTemplate) this.templatesByLink.get(link); } - - + /** - * Lookup the specified template by action. - * Returns null if the template cannot be found. + * Lookup the specified template by action. Returns null if the template + * cannot be found. */ public ThemeTemplate getTemplateByAction(String action) { return (ThemeTemplate) this.templatesByAction.get(action); } - - + /** * Get the collection of all resources associated with this Theme. - * + * * It is assured that the resources are returned sorted by pathname. */ public List getResources() { - + // make sure resources are sorted. List myResources = new ArrayList(this.resources.values()); Collections.sort(myResources); - + return myResources; } - - + /** - * Lookup the specified resource by path. - * Returns null if the resource cannot be found. + * Lookup the specified resource by path. Returns null if the resource + * cannot be found. */ public ThemeResource getResource(String path) { return (ThemeResource) this.resources.get(path); } - - + public String toString() { StringBuffer sb = new StringBuffer(); sb.append(name); sb.append("\n"); - + Iterator it = this.templatesByName.values().iterator(); - while(it.hasNext()) { + while (it.hasNext()) { sb.append(it.next()); sb.append("\n"); } - + return sb.toString(); - + } - - - /** - * Load all the elements of this theme from disk and cache them. - */ - private void loadThemeFromDisk() throws ThemeInitializationException { - - log.debug("Parsing theme descriptor for " + this.themeDir); - - ThemeMetadata themeMetadata = null; - try { - // lookup theme descriptor and parse it - ThemeMetadataParser parser = new ThemeMetadataParser(); - InputStream is = new FileInputStream(this.themeDir + File.separator + "theme.xml"); - themeMetadata = parser.unmarshall(is); - } catch (Exception ex) { - throw new ThemeInitializationException("Unable to parse theme descriptor for theme " + this.themeDir, ex); - } - - log.debug("Loading Theme " + themeMetadata.getName()); - - // use parsed theme descriptor to load Theme data - setId(themeMetadata.getId()); - setName(themeMetadata.getName()); - setDescription(themeMetadata.getName()); - setType(themeMetadata.getType()); - setAuthor(themeMetadata.getAuthor()); - setLastModified(null); - setEnabled(true); - - // load resource representing preview image - File previewFile = new File(this.themeDir + File.separator + themeMetadata.getPreviewImage()); - if (!previewFile.exists() || !previewFile.canRead()) { - log.warn("Couldn't read theme [" + this.getName() + "] preview image file [" + themeMetadata.getPreviewImage() + "]"); - } else { - this.previewImage = new SharedThemeResourceFromDir(themeMetadata.getPreviewImage(), previewFile); - } - - //avaialble types in the Roller - List availableTypesList = new ArrayList(); - availableTypesList.add("standard"); - availableTypesList.add("mobile"); - - // load stylesheet if possible - if (themeMetadata.getStylesheet() != null) { - - ThemeMetadataTemplate stylesheetTmpl = themeMetadata.getStylesheet(); - // getting the template codes for available types - ThemeMetadataTemplateCode standardTemplateCode = stylesheetTmpl.getTemplateCodeTable().get("standard"); - ThemeMetadataTemplateCode mobileTemplateCode = stylesheetTmpl.getTemplateCodeTable().get("mobile"); - - // If no template code present for any type - if (standardTemplateCode == null && mobileTemplateCode == null) { - throw new ThemeInitializationException("Error in getting template codes for template"); - } else if (mobileTemplateCode == null) { - //cloning the standard template code if no mobile is present - mobileTemplateCode = new ThemeMetadataTemplateCode(); - mobileTemplateCode.setContentsFile(standardTemplateCode.getContentsFile()); - mobileTemplateCode.setContentType(standardTemplateCode.getContentType()); - mobileTemplateCode.setTemplateLang(standardTemplateCode.getTemplateLang()); - mobileTemplateCode.setType("mobile"); - - stylesheetTmpl.addTemplateCode("mobile", mobileTemplateCode); - } - - - // construct File object from path - // we are getting the file path from standard as the default and load it to initially. - File templateFile = new File(this.themeDir + File.separator - + standardTemplateCode.getContentsFile()); - - // read stylesheet contents - String contents = loadTemplateFile(templateFile); - if (contents == null) { - // if we don't have any contents then skip this one - log.error("Couldn't load stylesheet theme [" + this.getName() + "] template file [" + templateFile + "]"); - } else { - - // construct ThemeTemplate representing this file - // here we set content and template language from standard template code assuming it is the default - SharedThemeTemplate theme_template = new SharedThemeTemplate( - this, - themeMetadata.getId() + ":" + stylesheetTmpl.getName(), - WeblogTemplate.ACTION_CUSTOM, - stylesheetTmpl.getName(), - stylesheetTmpl.getDescription(), - contents, - stylesheetTmpl.getLink(), - new Date(templateFile.lastModified()), - standardTemplateCode.getTemplateLang(), - false, - false); - - - for (String type : availableTypesList) { - TemplateCode templateCode = createTemplateCode(theme_template.getId(), stylesheetTmpl.getTemplateCode(type)); - - theme_template.addTemplateCode(type, templateCode); - - // Set Last Modified - Date lstModified = theme_template.getLastModified(); - if (getLastModified() == null - || lstModified.after(getLastModified())) { - setLastModified(lstModified); - } - } - // store it - this.stylesheet = theme_template; - - addTemplate(theme_template); - } - - } - - // go through static resources and add them to the theme - String resourcePath = null; - Iterator resourcesIter = themeMetadata.getResources().iterator(); - while (resourcesIter.hasNext()) { - resourcePath = (String) resourcesIter.next(); - - // construct ThemeResource object from resource - File resourceFile = new File(this.themeDir + File.separator + resourcePath); - - // Continue reading theme even if problem encountered with one file - if (!resourceFile.exists() || !resourceFile.canRead()) { - log.warn("Couldn't read theme [" + this.getName() + "] resource file [" + resourcePath + "]"); - continue; - } - - // add it to the theme - setResource(resourcePath, new SharedThemeResourceFromDir(resourcePath, resourceFile)); - - // Set Last Modified - Date lstModified = new Date(resourceFile.lastModified()); - if (getLastModified() == null - || lstModified.after(getLastModified())) { - setLastModified(lstModified); - } - - } - - // go through templates and read in contents to a ThemeTemplate - SharedThemeTemplate theme_template = null; - ThemeMetadataTemplate templateMetadata = null; - Iterator templatesIter = themeMetadata.getTemplates().iterator(); - while (templatesIter.hasNext()) { - templateMetadata = (ThemeMetadataTemplate) templatesIter.next(); - - //getting the template codes for available types - ThemeMetadataTemplateCode standardTemplateCode = templateMetadata.getTemplateCodeTable().get("standard"); - ThemeMetadataTemplateCode mobileTemplateCode = templateMetadata.getTemplateCodeTable().get("mobile"); - - //If no template code present for any type - if (standardTemplateCode == null && mobileTemplateCode == null) { - throw new ThemeInitializationException("Error in getting template codes for template"); - } else if (mobileTemplateCode == null) { - //cloning the standard template code if no mobile is present - mobileTemplateCode = new ThemeMetadataTemplateCode(); - mobileTemplateCode.setContentsFile(standardTemplateCode.getContentsFile()); - mobileTemplateCode.setContentType(standardTemplateCode.getContentType()); - mobileTemplateCode.setTemplateLang(standardTemplateCode.getTemplateLang()); - mobileTemplateCode.setType("mobile"); - - templateMetadata.addTemplateCode("mobile", mobileTemplateCode); - } - - // construct File object from path - File templateFile = new File(this.themeDir + File.separator - + standardTemplateCode.getContentsFile()); - - String contents = loadTemplateFile(templateFile); - if (contents == null) { - // if we don't have any contents then skip this one - throw new ThemeInitializationException("Couldn't load theme [" + this.getName() + "] template file [" + templateFile + "]"); - } - - // construct ThemeTemplate representing this file - theme_template = new SharedThemeTemplate( - this, - themeMetadata.getId() + ":" + templateMetadata.getName(), - templateMetadata.getAction(), - templateMetadata.getName(), - templateMetadata.getDescription(), - contents, - templateMetadata.getLink(), - new Date(templateFile.lastModified()), - standardTemplateCode.getTemplateLang(), - templateMetadata.isHidden(), - templateMetadata.isNavbar()); - - for (String type : availableTypesList) { - SharedThemeTemplateCode templateCode = createTemplateCode(theme_template.getId(), - templateMetadata.getTemplateCode(type)); - - theme_template.addTemplateCode(type, templateCode); - - // Set Last Modified - Date lstModified = templateCode.getLastModified(); - if (getLastModified() == null - || lstModified.after(getLastModified())) { - setLastModified(lstModified); - } - } - - theme_template.setLastModified(getLastModified()); - - // add it to the theme - addTemplate(theme_template); - - } - } - - + + /** + * Load all the elements of this theme from disk and cache them. + */ + private void loadThemeFromDisk() throws ThemeInitializationException { + + log.debug("Parsing theme descriptor for " + this.themeDir); + + ThemeMetadata themeMetadata = null; + try { + // lookup theme descriptor and parse it + ThemeMetadataParser parser = new ThemeMetadataParser(); + InputStream is = new FileInputStream(this.themeDir + File.separator + + "theme.xml"); + themeMetadata = parser.unmarshall(is); + } catch (Exception ex) { + throw new ThemeInitializationException( + "Unable to parse theme descriptor for theme " + + this.themeDir, ex); + } + + log.debug("Loading Theme " + themeMetadata.getName()); + + // use parsed theme descriptor to load Theme data + setId(themeMetadata.getId()); + setName(themeMetadata.getName()); + setDescription(themeMetadata.getName()); + setType(themeMetadata.getType()); + setAuthor(themeMetadata.getAuthor()); + setLastModified(null); + setEnabled(true); + + // load resource representing preview image + File previewFile = new File(this.themeDir + File.separator + + themeMetadata.getPreviewImage()); + if (!previewFile.exists() || !previewFile.canRead()) { + log.warn("Couldn't read theme [" + this.getName() + + "] preview image file [" + + themeMetadata.getPreviewImage() + "]"); + } else { + this.previewImage = new SharedThemeResourceFromDir( + themeMetadata.getPreviewImage(), previewFile); + } + + // avaialble types in the Roller + List availableTypesList = new ArrayList(); + availableTypesList.add("standard"); + availableTypesList.add("mobile"); + + // load stylesheet if possible + if (themeMetadata.getStylesheet() != null) { + + ThemeMetadataTemplate stylesheetTmpl = themeMetadata + .getStylesheet(); + // getting the template codes for available types + ThemeMetadataTemplateCode standardTemplateCode = stylesheetTmpl + .getTemplateCodeTable().get("standard"); + ThemeMetadataTemplateCode mobileTemplateCode = stylesheetTmpl + .getTemplateCodeTable().get("mobile"); + + // If no template code present for any type + if (standardTemplateCode == null && mobileTemplateCode == null) { + throw new ThemeInitializationException( + "Error in getting template codes for template"); + } else if (mobileTemplateCode == null) { + // cloning the standard template code if no mobile is present + mobileTemplateCode = new ThemeMetadataTemplateCode(); + mobileTemplateCode.setContentsFile(standardTemplateCode + .getContentsFile()); + mobileTemplateCode.setContentType(standardTemplateCode + .getContentType()); + mobileTemplateCode.setTemplateLang(standardTemplateCode + .getTemplateLang()); + mobileTemplateCode.setType("mobile"); + + stylesheetTmpl.addTemplateCode("mobile", mobileTemplateCode); + } + + // construct File object from path + // we are getting the file path from standard as the default and + // load it to initially. + File templateFile = new File(this.themeDir + File.separator + + standardTemplateCode.getContentsFile()); + + // read stylesheet contents + String contents = loadTemplateFile(templateFile); + if (contents == null) { + // if we don't have any contents then skip this one + log.error("Couldn't load stylesheet theme [" + this.getName() + + "] template file [" + templateFile + "]"); + } else { + + // construct ThemeTemplate representing this file + // here we set content and template language from standard + // template code assuming it is the default + SharedThemeTemplate theme_template = new SharedThemeTemplate( + this, themeMetadata.getId() + ":" + + stylesheetTmpl.getName(), + WeblogTemplate.ACTION_CUSTOM, stylesheetTmpl.getName(), + stylesheetTmpl.getDescription(), contents, + stylesheetTmpl.getLink(), new Date( + templateFile.lastModified()), + standardTemplateCode.getTemplateLang(), false, false); + + for (String type : availableTypesList) { + SharedThemeTemplateCode templateCode = createTemplateCode( + theme_template.getId(), + stylesheetTmpl.getTemplateCode(type)); + + theme_template.addTemplateCode(type, templateCode); + + // Set Last Modified + Date lstModified = templateCode.getLastModified(); + if (getLastModified() == null + || lstModified.after(getLastModified())) { + setLastModified(lstModified); + } + } + // store it + this.stylesheet = theme_template; + + // Update last modified + theme_template.setLastModified(getLastModified()); + + addTemplate(theme_template); + } + + } + + // go through static resources and add them to the theme + String resourcePath = null; + Iterator resourcesIter = themeMetadata.getResources().iterator(); + while (resourcesIter.hasNext()) { + resourcePath = (String) resourcesIter.next(); + + // construct ThemeResource object from resource + File resourceFile = new File(this.themeDir + File.separator + + resourcePath); + + // Continue reading theme even if problem encountered with one file + if (!resourceFile.exists() || !resourceFile.canRead()) { + log.warn("Couldn't read theme [" + this.getName() + + "] resource file [" + resourcePath + "]"); + continue; + } + + // add it to the theme + setResource(resourcePath, new SharedThemeResourceFromDir( + resourcePath, resourceFile)); + + // Set Last Modified + Date lstModified = new Date(resourceFile.lastModified()); + if (getLastModified() == null + || lstModified.after(getLastModified())) { + setLastModified(lstModified); + } + + } + + // go through templates and read in contents to a ThemeTemplate + SharedThemeTemplate theme_template = null; + ThemeMetadataTemplate templateMetadata = null; + Iterator templatesIter = themeMetadata.getTemplates().iterator(); + while (templatesIter.hasNext()) { + templateMetadata = (ThemeMetadataTemplate) templatesIter.next(); + + // getting the template codes for available types + ThemeMetadataTemplateCode standardTemplateCode = templateMetadata + .getTemplateCodeTable().get("standard"); + ThemeMetadataTemplateCode mobileTemplateCode = templateMetadata + .getTemplateCodeTable().get("mobile"); + + // If no template code present for any type + if (standardTemplateCode == null && mobileTemplateCode == null) { + throw new ThemeInitializationException( + "Error in getting template codes for template"); + } else if (mobileTemplateCode == null) { + // cloning the standard template code if no mobile is present + mobileTemplateCode = new ThemeMetadataTemplateCode(); + mobileTemplateCode.setContentsFile(standardTemplateCode + .getContentsFile()); + mobileTemplateCode.setContentType(standardTemplateCode + .getContentType()); + mobileTemplateCode.setTemplateLang(standardTemplateCode + .getTemplateLang()); + mobileTemplateCode.setType("mobile"); + + templateMetadata.addTemplateCode("mobile", mobileTemplateCode); + } + + // construct File object from path + File templateFile = new File(this.themeDir + File.separator + + standardTemplateCode.getContentsFile()); + + String contents = loadTemplateFile(templateFile); + if (contents == null) { + // if we don't have any contents then skip this one + throw new ThemeInitializationException("Couldn't load theme [" + + this.getName() + "] template file [" + templateFile + + "]"); + } + + // construct ThemeTemplate representing this file + theme_template = new SharedThemeTemplate(this, + themeMetadata.getId() + ":" + templateMetadata.getName(), + templateMetadata.getAction(), templateMetadata.getName(), + templateMetadata.getDescription(), contents, + templateMetadata.getLink(), new Date( + templateFile.lastModified()), + standardTemplateCode.getTemplateLang(), + templateMetadata.isHidden(), templateMetadata.isNavbar()); + + for (String type : availableTypesList) { + SharedThemeTemplateCode templateCode = createTemplateCode( + theme_template.getId(), + templateMetadata.getTemplateCode(type)); + + theme_template.addTemplateCode(type, templateCode); + + // Set Last Modified + Date lstModified = templateCode.getLastModified(); + if (getLastModified() == null + || lstModified.after(getLastModified())) { + setLastModified(lstModified); + } + } + + theme_template.setLastModified(getLastModified()); + + // add it to the theme + addTemplate(theme_template); + + } + } + /** * Load a single template file as a string, returns null if can't read file. */ private String loadTemplateFile(File templateFile) { // Continue reading theme even if problem encountered with one file - if(!templateFile.exists() && !templateFile.canRead()) { + if (!templateFile.exists() && !templateFile.canRead()) { return null; } - + char[] chars = null; int length; try { @@ -407,29 +417,28 @@ public class SharedThemeFromDir extends InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); length = reader.read(chars); } catch (Exception noprob) { - log.error("Exception reading theme [" + this.getName() + "] template file ["+templateFile+"]"); + log.error("Exception reading theme [" + this.getName() + + "] template file [" + templateFile + "]"); if (log.isDebugEnabled()) { log.debug(noprob); } return null; } - + return new String(chars, 0, length); } - - - /** + + /** * Set the value for a given template name. */ private void addTemplate(ThemeTemplate template) { this.templatesByName.put(template.getName(), template); this.templatesByLink.put(template.getLink(), template); - if(!ThemeTemplate.ACTION_CUSTOM.equals(template.getAction())) { + if (!ThemeTemplate.ACTION_CUSTOM.equals(template.getAction())) { this.templatesByAction.put(template.getAction(), template); } } - - + /** * Set the value for a given resource path. */ @@ -439,29 +448,32 @@ public class SharedThemeFromDir extends this.resources.put(normalizedPath, resource); } - private SharedThemeTemplateCode createTemplateCode(String templateId, ThemeMetadataTemplateCode templateCodeMetadata) { - SharedThemeTemplateCode templateCode = new SharedThemeTemplateCode(); + private SharedThemeTemplateCode createTemplateCode(String templateId, + ThemeMetadataTemplateCode templateCodeMetadata) { + SharedThemeTemplateCode templateCode = new SharedThemeTemplateCode(); + + // construct File object from path + File templateFile = new File(this.themeDir + File.separator + + templateCodeMetadata.getContentsFile()); + + // read stylesheet contents + String contents = loadTemplateFile(templateFile); + if (contents == null) { + // if we don't have any contents then load no string + contents = ""; + log.error("Couldn't load stylesheet theme [" + this.getName() + + "] template file [" + templateFile + "]"); + } - // construct File object from path - File templateFile = new File(this.themeDir + File.separator - + templateCodeMetadata.getContentsFile()); - - // read stylesheet contents - String contents = loadTemplateFile(templateFile); - if (contents == null) { - // if we don't have any contents then load no string - contents = ""; - log.error("Couldn't load stylesheet theme [" + this.getName() + "] template file [" + templateFile + "]"); - } - - templateCode.setTemplateId(templateId); - templateCode.setTemplate(contents); - templateCode.setTemplateLanguage(templateCodeMetadata.getTemplateLang()); - templateCode.setType(templateCodeMetadata.getType()); - templateCode.setContentType(templateCodeMetadata.getContentType()); - templateCode.setLastModified(new Date(templateFile.lastModified())); + templateCode.setTemplateId(templateId); + templateCode.setTemplate(contents); + templateCode + .setTemplateLanguage(templateCodeMetadata.getTemplateLang()); + templateCode.setType(templateCodeMetadata.getType()); + templateCode.setContentType(templateCodeMetadata.getContentType()); + templateCode.setLastModified(new Date(templateFile.lastModified())); - return templateCode; - } + return templateCode; + } } Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.java URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.java?rev=1531282&r1=1531281&r2=1531282&view=diff ============================================================================== --- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.java (original) +++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.java Fri Oct 11 13:06:33 2013 @@ -65,6 +65,7 @@ public class RollerVelocity { // Override for theme reloading if (themeReload) { velocityProps.setProperty("class.resource.loader.cache", "false"); + velocityProps.setProperty("class.resource.loader.modificationCheckInterval", "2"); velocityProps.setProperty("webapp.resource.loader.cache", "false"); velocityProps.setProperty("webapp.resource.loader.modificationCheckInterval", "2"); velocityProps.setProperty("velocimacro.library.autoreload", "true"); Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/ThemeResourceLoader.java URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/ThemeResourceLoader.java?rev=1531282&r1=1531281&r2=1531282&view=diff ============================================================================== --- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/ThemeResourceLoader.java (original) +++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/ThemeResourceLoader.java Fri Oct 11 13:06:33 2013 @@ -47,96 +47,99 @@ import org.apache.roller.weblogger.pojos */ public class ThemeResourceLoader extends ResourceLoader { - private static Log logger = LogFactory.getFactory().getInstance( - ThemeResourceLoader.class); + private static Log logger = LogFactory.getFactory().getInstance( + ThemeResourceLoader.class); - public void init(ExtendedProperties configuration) { - logger.debug(configuration); - } - - public InputStream getResourceStream(String name) - throws ResourceNotFoundException { - - logger.debug("Looking for: " + name); - - if (name == null || name.length() < 1) { - throw new ResourceNotFoundException( - "Need to specify a template name!"); - } - - String deviceType = "standard"; - if (name.contains("|")) { - String[] pair = name.split("\\|"); - name = pair[0]; - deviceType = pair[1]; - } - - try { - // parse the name ... theme templates name are - // :