Allen Gilliland wrote:
In
my opinion the difficulty of template customization is one of the
biggest weaknesses of Roller as compared to other blogging software I've
worked with (Movable Type and Blogger) So, this is an area where I'd
like to help.
This I am in absolute agreement with and I would be more than happy to
try and work out some ways to improve our templating situation. This is
something that I have marked on my future TODO list, but there are quite
a few other things to do first.
I would definitely be interested in what you had in mind though.
You asked for it...
I'm still trying to learn how the current Roller works before seriously
proposing anything. Further, I think that any serious changes that I
would propose are much more than I'd be able to make as a "Proposal with
commitment". So the following stuff is just a handful of ideas. Some
of the changes are indirectly
related (like virtual hostnames) but I think they are relevant in the
general context of site/template authoring.
Some broad goals (that could be implemented over time) would include:
A) Support virtual hostnames for weblogs, of either of two forms:
i) yourhost.yourdomain.tld (any arbitrary domain)
ii) yourhost.rollerdomain.tld (similar to how Blogger works
with yourblog.blogspot.com)
B) New URLs for blogs pages with backward compatible support for old urls.
i) Blog pages could be at http://virtualdomain/path or
http://non-virtualdomain/handle/path rather than
http://domain/servlet-name/handle/path
ii) Permalinks would not use ?entry=pemalink_name, but something
like /YYMM/permlink_name.html
C) Support pluggable view layers in Page views, Feed views, etc. so view
technologies other than Velocity could be used.
D) I'd love to see a template language like that from Blogger or Movable
Type.
http://help.blogger.com/bin/answer.py?answer=753&topic=39
http://www.sixapart.com/movabletype/docs/3.2/a_template_tag_reference/
I'm a Velocity hacker myself, but I want users to be able to easily
modify/write templates themselves.
E) Create a blog template "View" component that could be re-used by
other Java-based blogs (such as Blojsom or Pebble) -- it could help
create critical mass for a larger library of templates.
F) A template language compatible with Blogger or MovableType.
(Wordpress is popular and has a huge template library but IIRC it uses
php in its templates.)
G) A conversion tool to allow people to convert templates from other
systems.
OK, now for some concrete, implementation-level things we could do:
1) Convert all VelocityServlet-derived classes to be SpringMVC
controllers. The basic SpringMVC Controller is about as simple and
lightweight as VelocityServlet but allows for easier URL path map
configuration and pluggable view implementations. Using SpringMVC would
have two benefits: i) make supporting alternate URLs for content easier
and ii) open the door to templates that don't use Velocity.
I've had good experiences with SpringMVC and would be willing to
contribute to this development. I'm not ready to commit to a schedule
yet. There may be alternatives to SpringMVC that are equivalent/better,
but SpringMVC has worked well for me.
2) Document and possibly change/simplify what objects are in the
VelocityContext/SpringMVC model. Document URLs and what templates must
do to properly support those URLs.
3) Unroll #includes and macros in templates so more of the HTML is
visible in the templates to authors. This complicates maintenance of
the built-in templates, but perhaps a build time process could be used
to minimize duplicate code in templates. (Duplicate code is bad for
Roller maintenance, but good for template authors)
4) Experiment with FreeMarker as a Velocity alternative. Freemarker
supports nested, tag-based macros:
http://freemarker.sourceforge.net/docs/dgui_misc_userdefdir.html
I have not used FreeMarker, but it seems to have a good reputation and
is supported by SpringMVC. There is also a Velocity to FreeMarker
template conversion tool.
5) Define a blog tag language (in FreeMarker?) for Roller (or make it
more generic so other blogs could use it?) Can this map directly to
FreeMarker tags/directives? Could it be compiled to Velocity macros and
variables?
So you could potentially have something like this:
<@entries category="Music">
${entry.title}<br/>
${entry.text}
</@entries>
A pre-processor could easily convert to the above from:
<RollerEntries category="Music>
<$RollerEntryTitle$><br/>
<$RollerEntryText$>
</RollerEntries>
or perhaps it could map directly to velocity/velocimacros?
I don't know if this would work, but it might be a way to create a
tag-based template language without having to write one from scratch.
These are just ideas, and potentially a great deal of work, but I'm
willing to contribute to #2 and might commit to #1 at some point in the
near future.
-- Sean