Proposal: Theme Management#
| Status | In Development |
| Target Release | Roller 1.3 |
| Original Author | Allen Gilliland |
| See also | None |
Abstract#
Roller needs a more elaborate and structured way of dealing with weblog themes which will provide for true theme sharing and ultimately the ability to manage themes via the roller UI. There are a variety of bugs and rfes in jira that suggest the need for this,
ROL-685
and
ROL-614
being most notable.
Requirements#
- allow users to use themes without copying them locally. i.e. shared themes
- enable users to copy themes to their local templates if they wish to hand edit them.
- allow roller admins to specify the specific set of enabled themes which users can choose from
Design#
- themes will be considered a collection of sharable weblog templates.
- if a user chooses to edit the templates for a theme then they will simply receive a copy of all of that themes templates and their theme choice will become "custom". this means that they will no longer be using the shared theme templates.
Implementation#
The implementation will require two major chunks of code.
- new theme management classes which will represent the themes object model
- modifications to existing code to be more "theme smart"
New Theme Management Classes#
In order to properly do theme management we'll need a new set of classes to represent the themes object model. This will be a relatively simple object hierarchy which should first provide the means to access the current set of themes which are retrieved from the filesystem, but should also allow for extendability so that in the future themes can be stored in the database and edited via the Roller UI.
- create a Template interface which represents the abstract concept of a template
- create a ThemeTemplate class which implements Template
- create a Theme class which maintains all properties of a single theme, including a set of ThemeTemplates.
- create a ThemeManager interface to provide accessor methods to Theme objects
- define a ThemeManagerImpl class to do the base implementation of the ThemeManager. this implementation will be capable of reading themes off the filesystem like we currently do.
- for the next upgrade to theme management we can create a HibernateThemeManagerImpl which can store theme data in the db. then we add in the ability to edit themes on the UI.
- create a ThemeResourceLoader class which knows how to lookup templates for a given theme from the ThemeManager and return them for velocity.
Making Existing Code "Theme Smart"#
There are a few places in the current code where we will have to make some changes so that decisions are made dependent on whether a user has chosen a theme.
- modify the current PageData class to implement the Template interface
- modify existing methods which return PageData objects to return "Template" when applicable.
- this may get a little hairy, but this seems like a decent approach. i believe that we should be trying to merge the concept of a user template and theme template into some kind of appropriate object hierarchy and work from there.
- make changes to WebsiteData.getPageByXXX() and PageModel.getPageByXXX() so that they are "theme smart"
- the goal here is to make WebsiteData.getPageByXXX() the only real way to get at a Template that is meant for rendering. We can then control the logic of these methods to ensure that ThemeTemplates are returned when appropriate and user WeblogTemplates are returned as well.
Changes to the Roller UI#
Changes to the UI should be fairly minimal on the first pass.
- add additional text to existing themes chooser page (Website -> Theme) which reminds users that themes are now shared and that theme templates are not editable when a theme has been chosen.
- add new section to the theme chooser page (Website -> Theme) which gives a brief explanation/disclaimer about customizing themes followed by a new button "Customize this theme". when the "Customize this theme" button is pressed it copies down the templates for the chosen theme into the users own page templates and changes the users theme to "Custom".
- note, this is basically what exists now, so we aren't really adding functionality.
- add a reminder section on the user templates page (Website -> Page Templates) that is shown when a user has selected a theme and reminds them that editing their templates does not affect their theme per se. i suppose this is a little wishy washy, but it would be nice to somehow make sure that users are constantly reminded that when they have chosen a theme that they can't actually edit theme templates.
Other Changes#
- move the "users.themes.path" property from the db to roller.properties. do we actually even need this property?
- define a new property which lists what themes are currently enabled.
- define a new property which allows the admin to specify the default theme for newly registered users.
- do we need to confine theme templates to only include certain reserved names like (Weblog and _day) ... this releates specifically to the "cruft" left by switching themes detailed here ROL-685
. i'm still not sure exactly how we can prevent this from happening in cases where a user copies down the templates from a theme and then changes their theme again.