roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Björn Berg <bjoern.b...@gmx.de>
Subject Re: Where to put Velocity Macros while providing an extension
Date Sun, 31 Jan 2016 18:39:41 GMT
Hi,

sorry for the late response but I was experimenting a little bit.
There is no need for an extension of Roller’s core. Any plugin can overwrite or extend the
settings of the integrated Velocity engine:

protected void extendVelocityEngine(VelocityEngine engine) {
		log.info("adding additional resource loader: github");
		engine.addProperty(VelocityEngine.RESOURCE_LOADER, "github");
		engine.addProperty("github.resource.loader.class", ClasspathResourceLoader.class.getName());
		engine.addProperty("github.resource.loader.cache", false);
		engine.addProperty("github.resource.loader.path", ".");
		engine.addProperty(Velocity.VM_LIBRARY, "github.vm");
		log.info("restarting engine");
		engine.init();
}

If you do not init the engine again, the template providing a macro can be used with #parse
in any template.

The whole example can be seen here:
https://github.com/rollinhand/roller-github-plugin/blob/master/src/main/java/org/kivio/roller/plugins/github/GitHubModel.java

I do not know, if this is wanted by the Roller developers but it works for me.

Regards,
Björn


> Am 25.01.2016 um 23:56 schrieb Kohei Nozaki <kyle@bridge9.sakura.ne.jp>:
> 
> Hi Björn,
> 
> Oh I see, unfortunately I think it can't be achieved with current Roller.
> 
> Could you file it as a feature request to our issue tracker?
> https://issues.apache.org/jira/browse/ROL
> 
> Thanks.
> 
> On 1/25/16 02:11, Björn Berg wrote:
>> Hi,
>> 
>> I think I was not precise enough with my question. I know how to assemble my plugin
and bring it to run inside Roller.
>> 
>> For more comfort in templates I want to provide Velocity macros (http://people.apache.org/~henning/velocity/html/ch07.html)
with my plugin and was looking for a way how to make them available easily.
>> 
>> It seems that roller-custom.vm inside WEB-INF/velocity is the place to put custom
Velocity macros but that would mean one has to edit macros itself and the cannot be automatically
provided by the plugin. Is there some Classloader magic how this can be done?
>> 
>> Björn
>> 
>> 
>>> Am 24.01.2016 um 01:36 schrieb Kohei Nozaki <kyle@bridge9.sakura.ne.jp>:
>>> 
>>> Hi Björn,
>>> 
>>> You can put your JAR file which contains your extension/plugin classes, into
WEB-INF/lib inside your Roller deployment.
>>> 
>>> Don't forget to list FQCN of your custom classes in "rendering.pageModels" entry
of roller-custom.properties.
>>> 
>>> Also this Ant script may help you making custom Roller WAR file which contains
your additional extension/plugin JARs:
>>> https://github.com/lbtc-xxx/rollersetup
>>> 
>>> Hope this helps,
>>> 
>>> Kohei
>>> 
>>> On 1/24/16 01:36, Björn Berg wrote:
>>>> Hi,
>>>> 
>>>> I am writing my first extension/plugin of a PageModel for Apache Roller.
This works very well.
>>>> 
>>>> But for a better convenience in page templates I want to provide Macros for
the Velocity engine in my JAR file. Where do I have to put them and make them available so
they can be used in Roller?
>>>> 
>>>> Kind regards,
>>>> Björn
>>>> 
>> 
>> Björn Berg
>> Mobil:	(0163) 699 23 74
>> E-Mail: 	bjoern.berg@gmx.de
>> 
>> 
>> 
>> 

Björn Berg
Mobil:	(0163) 699 23 74
E-Mail: 	bjoern.berg@gmx.de





Mime
View raw message