Hi all,
I'm discovering Sling these days (it's never too late!), and as a
playground I'm trying to implement a blog engine that goes further than
the espblog sample, with support for archive pages, comments and writing
content in different markup languages (html, markdown and asciidoc).
I quite like the resource-centric approach, which makes it easy to
quickly create content and presentation scripts, but I didn't find an
obvious solution for archive pages which are synthetic content resulting
from a query in the content repository. I'd be grateful if you guys
could provide some best practices.
Here's how I implemented it :
- a mapping "/etc/map/year-archive" with properties:
- "sling:match" = ".*/archives/[0-9]+"
- "sling:internalRedirect" = "/archives/year-archive.html"
- a resource "/archive/year-archive" with "sling:resourceType" =
"blog/year-archive"
- a script "/app/blog/year-archive/html.esp" that extracts the year from
request.pathInfo and uses that information to query the repository for
matching posts and builds the archive list.
It works but sounds a bit hacky to me : "/archive/year-archive" is used
only as a bridge between the redirect and the script, and the script has
to re-do pathInfo pattern matching to extract the year number. Is there
a simpler way to implement this ?
Next I'm wondering how to implement multiple markup formats for content:
markdown and asciidoc end up being translated to html and formated using
the same template as raw html content, but how/where to implement the
markup -> html transformation?
From what I understand a content resource cannot be transformed before
being fed to the template script, so I thought to have two separate
areas in the content repository :
- an "authoring" area where the original content is stored
- an observer listens to that area, transforms the markdown/asciidoc
content to html and is stores it in a "publish" area
- the "publish" area is the one that is actually rendered and published
on the web.
Is this the way to go? Also, is it possible to write such an observer as
a script, or does it have to be a Java class packaged in a new bundle?
Thanks in advance for your guidance and sorry for these noob questions :-)
Sylvain
--
Sylvain Wallez - http://bluxte.net