Hi Matteo,

On 22 Dec 2010, at 16:49, Matteo Pelucco wrote:

> 
> Hi Magnolians,
> I have some doubts about "resources" and "templates" workspace.
> 
> I know that I can use those workspaces to store ftl, css..
> 
> What is not so clear is the "loading" mechanism.
> 
> E.g.:
> a templatePath like "/templating-kit/some/path" will load in this order:
> 1. from webapp folder (so, /templates/.. will work)
> 2. from "jar" file (but from which assumption?)
> 3. from from "template" workspace, only if the checkbox "bypass" is checked. 
> (what happen if I add here a /templates folder?)
> 
> Is this correct? I'm missing something?

For FreeMarker templates, you can look at 
configuration:/server/rendering/freemarker/templateLoaders. The default loading 
order is thus:
1. from the repository (if the template is "enabled")
2. from the webapp folder
3. from the classpath (which is not registered in the configuration, but 
*always* added at the end of the chain of loaders)

For resources, it's slightly different, in part because we're then talking 
about URLs, not configured paths. By default:
* http://<magnolia-root>/resources/.. points to the "resources" repository. If 
the resource is bypassed: falls back to the classpath, using the "extension" 
property is set correctly.
* http://<magnolia-root>/.resources/.. (note the "dot") points to sub paths of 
/mgnl-resources/ in the classpath. 

> In this scenario, a developer can write on filesystem and then having that 
> ftls automatically loaded into template?

Yes.
You can also load templates from a different location that the webapp, by 
adding another templateLoader: use 
info.magnolia.freemarker.loaders.LazyFileTemplateLoader and set its basePath to 
the path of your choice on your filesystem.

> Is there a particular install task available?

For templates: 
info.magnolia.module.inplacetemplating.setup.TemplatesInstallTask - assumes the 
same path in the repository and your classpath, installs (or overwrites if 
"autoImport" is checked) templates based on a regex pattern 
("/myModule/.*\\.ftl" for example).
For resources: info.magnolia.module.resources.setup.InstallResourceTask - 
assumes the same path in the repository and your classpath.

> Next.
> The same assumption for CSS / JS files.
> When a theme or a template loads a css/js list they will find e.g.:
> 
> link: "/resources/templating-kit/themes/pop/css/styles.css"
> 
> In this case, what the loader will do?

This is handled by a different template renderer: 
info.magnolia.module.resources.renderers.ResourcesTextTemplateRenderer

Note that with STK, there's also a couple of virtual URIs coming into play for 
resources.

> I assume something similar to templates, but, again, we (developers) can 
> avoid to manually port css and js inside resources?

If you "bypass", it falls back to the classpath... the truth is, it falls back 
to the regular Freemarker renderer... which means you can trick it and add a 
template loader for this too :)

If you use an IDE though, you should be able to configure it so that classpath 
resources are reloaded from your source folders without touching the 
Magnolia-FreeMarker configuration.

> The resource workspace can be even used for images (separating DMS --> 
> content images with resource --> layout images)?

That's something we'd like, yes. For some reason, I can't seem to find the Jira 
issue for this - feel free to create one at MGNLRES.

> Sorry for the wide coverage topic, but it was on my TO-ASK list from more 
> than 1 year..

Well, glad you asked! It's one of those dark uncovered areas that are under 
exploited ! :)

> 
> Thanks for any consideration you might add / comment..
> 
> Matteo
> 
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to