Re: Sightly :: JavaScript Use-API :: what property to use instead of "granite.resource" to access the current resource in JS?

2015-10-17 Thread Vlad Bailescu
Hi Sandro,

I started putting together some documentation at [2] but it's stil WIP.

Vlad

[2] -
https://github.com/vladbailescu/sling-sightly-docs/blob/master/use-api.md


On Sunday, October 18, 2015, Sandro Boehme  wrote:

> Hello,
>
> I would like to access the current resource in the Sightly JavaScript
> Use-API. The docu [1] says I should for example use
> "granite.resource.properties["title"];" to access the "title" property of
> the current resource. But of course "granite" is not available in Sling.
> This is why I'm wondering what variable is available in Sling instead.
>
> Thanks in advance for any hints,
>
> Sandro
>
> [1] -
> http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html
>
> PS: There is no Sling docu for Sightly yet, right?
>


-- 
Sent from mobile


Re: Exception when trying out the fling sample

2016-04-30 Thread Vlad Bailescu
Hi Roy,

It seems Thymeleaf is not handling the HTML scripts, they get processed by
Sightly instead. You could check the configured service ranking of
Thymeleaf, as suggested in
https://sling.apache.org/documentation/bundles/scripting/scripting-thymeleaf.html

Best,
Vlad

On Saturday, 30 April 2016, Roy Teeuwen  wrote:

> Hello all,
>
> When navigating to fling.html after installing the fling samples I get
> following exception, any thought on what is going wrong?
> Parsing error in template /apps/fling/page/simple/html.html at line 20:
> extraneous input '(' expecting {'}', '.', '&&', '||', '[', '@'} for
> expression
> page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)}
> (500)
>
> The requested URL /fling.html resulted in an error in
> /apps/fling/page/simple/html.html.
>
> Exception:
>
> org.apache.sling.scripting.sightly.SightlyException: Parsing error in
> template /apps/fling/page/simple/html.html at line 20: extraneous input '('
> expecting {'}', '.', '&&', '||', '[', '@'} for expression
> page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)}
> at
> org.apache.sling.scripting.sightly.impl.engine.UnitLoader.getSourceCodeForScript(UnitLoader.java:135)
> at
> org.apache.sling.scripting.sightly.impl.engine.UnitLoader.createUnit(UnitLoader.java:100)
> at
> org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluateScript(SightlyScriptEngine.java:91)
>
> The installed bundles that I am using to get the sample active on the
> current Sling 9-SNAPSHOT launchpad are the following:
>
> 
> org.apache.sling.samples
> org.apache.sling.samples.fling
> 0.0.1-SNAPSHOT
> 
> 
> 
> org.apache.sling
> org.apache.sling.query
> 3.0.0
> 
> 
> 
> org.apache.sling
>
> org.apache.sling.jcr.jackrabbit.usermanager
> 2.2.4
> 
> 
> 
> org.apache.sling
> org.apache.sling.scripting.thymeleaf
> 0.0.6
> 
> 
> org.thymeleaf
> thymeleaf
> 3.0.0.BETA02
> 
> 
> org.apache.sling
> org.apache.sling.i18n
> 2.2.10
> 
> 
> org.javassist
> javassist
> 3.18.2-GA
> 
> 
> commons-io
> commons-io
> 2.4
> 
> 
> org.apache.servicemix.bundles
> org.apache.servicemix.bundles.xerces
> 2.11.0_1
> 
> 
> org.apache.servicemix.bundles
>
> org.apache.servicemix.bundles.xmlresolver
> 1.2_5
> 
> 
> 
> org.apache.sling
> org.apache.sling.validation.api
> 1.0.0-SNAPSHOT
> 
> 
> org.apache.sling
> org.apache.sling.validation.core
> 1.0.0-SNAPSHOT
> 
> 
> 
> org.apache.sling
> org.apache.sling.commons.messaging
> 0.0.1-SNAPSHOT
> 
>
> Greetings,
> Roy



-- 
Sent from mobile


Re: Exception when trying out the fling sample

2016-04-30 Thread Vlad Bailescu
On Saturday, 30 April 2016, Oliver Lietz  wrote:

> (service ranking is not honored by Sling's script engine manager, no need
> to try).


Any idea why this is not a bug?

  https://issues.apache.org/jira/browse/SLING-4330
>
>
I was under the impression SLING-4330 is about using both Sightly and
Thymeleaf in the same running instance; and how to solve which one gets
used on a file/script level.

But for using just one scripting engine (Thymeleaf in this case) for a
given extension we could just use the service ranking.

Best,
Vlad


-- 
Sent from mobile


Re: Including attributes with Sightly/HTL

2016-10-28 Thread Vlad Bailescu
Hi Roy,

HTL does not allow arbitrary inclusion of scripts output. The scripts
output for data-sly-include is appended to the current element content. The
proper way to add attributes would be to use data-sly-attribute and provide
the attributes from a Use API object and not from an external script.

That said, for your example it would probably be nicer to throw a parsing
error instead of simply passing through/ignoring the  fragments.

Vlad

On Fri, Oct 28, 2016 at 3:20 PM, Roy Teeuwen  wrote:

> To clarify further, because a part of the script was missng:
>
> I am doing   >  The following
> output is created (see the wrongly put sly tag):
>
> 
>  data-analytics-page-id=“page id"
>  data-analytics-page-type=“page-type"
> 
>
> Greetings,
> Roy
> > On 28 Oct 2016, at 13:39, Roy Teeuwen  wrote:
> >
> > Hey all,
> >
> > When using HTL, how does one include attributes in a div when it’s
> coming from another script? In jsp we would be able to do it like the
> following:
> >
> >> 
> >>
> >
> > This doesn’t seem possible in sightly in a way I can find?
> >
> > Greetings,
> > Roy
>
>


Re: JS Use API usability or limitations

2017-01-11 Thread Vlad Bailescu
Hi Lance!

The problem is not the JS Use API but the way the JS Iterator is used. One
should do:

for (var [key, res] in Iterator(children)) {
returnObj.content += res.name;
}

Also, Robert is right, you should strive to keep your business logic (use
objects) as light as possible do the iterating and rendering in the HTL
script, if possible.

Best,
Vlad

On Wed, Jan 11, 2017 at 1:00 PM, Robert Munteanu  wrote:

> Hi,
>
> On Tue, 2017-01-10 at 18:29 -0700, lancedolan wrote:
> > All I want to do is print out a resource's children resources.
>
> Using the HTL repl [1] I narrowed down the following way of listing
> child resources:
>
> template.html
> -
>
> 
> 
> ${properties.jcr:title}
> 
> 
> 
>
> My siblings are:
> 
> ${child.name}
> 
> 
>
> 
> 
>
> logic.js
> 
>
> use(function () {
> return {
> siblings: resource.getParent().getChildren()
> };
> });
>
> I don't know enough about the HTL Javascript Use API to see what is
> wrong in your particular example unfortunately.
>
> Robert
>
>
> [1]: http://localhost:8080/htl/repl.html
>


Re: Best Sling samples for a beginner to look at?

2017-03-29 Thread Vlad Bailescu
Hi Greg,

There's also Nate Yolles' Publick blog [5]

Best,
Vlad

[5] https://github.com/nateyolles/publick-sling-blog

On Wed, Mar 29, 2017 at 10:41 AM, Greg Fullard 
wrote:

> Tx Chris, Bertrand, Andreas
>
> I think that gives me a good starting point.
>
> I'll keep a mini-journal of my experiences which might give some insights
> into where the learning curve gets a bit steep.
>
> Perhaps it even turns into a tutorial of sorts.
>
> Cheers
>
> Greg
>
>
>
> On Tue, Mar 28, 2017 at 7:15 PM, Andreas Schaefer Sr. 
> wrote:
>
> > Slingshot and Chris’ Slick are good examples as far as I can tell.
> >
> > That said in Sling there are so many ways to do the same thing
> > that it is very difficult to figure out what is currently the best way.
> >
> > Slingbucks is ok but it is outdated (as far as I can tell) using ESPs
> > and not using HTL and Sling Models.
> >
> > To understand what is going on you probably need to know (sooner
> > or later) what is in your JCR tree. For that I would recommend using
> > Composum (comes with Sling 9) otherwise you need to install it
> > into Sling 8.
> >
> > I would start with generating a Sling Initial Content Bundle using the
> > Sling Maven Archetype. Then, as Chris mentioned, adding new
> > stuff to it one by one making sure you understand what is going on
> > in the background.
> >
> > If you have questions then post them here.
> >
> > Cheers - Andy Schaefer
> >
> > > On Mar 28, 2017, at 1:56 AM, Bertrand Delacretaz <
> bdelacre...@apache.org>
> > wrote:
> > >
> > > Hi Greg,
> > >
> > > On Tue, Mar 28, 2017 at 6:21 AM, Greg Fullard 
> > wrote:
> > >> ...The only ones that have been touched in the last year are:
> > >> - Slingshot
> > >> - Slingbucks
> > >> - Fling (the one Andy mentioned) ...
> > >
> > > I can really only speak about Slingbucks - that one is relevant and up
> > > to date, it's a small thing but demonstrates important basic concepts.
> > >
> > > -Bertrand
> >
> >
>
>
> --
>
> GREG FULLARD
> ARCHITECT ON CALL ///
> [image: 8 Bit Platoon Logo]
>
> CELL +27 82 783 3204
> EMAIL gr...@8bitplatoon.com
>
> WEB 8bitplatoon.com
>
>
> This email is protected by our email disclaimer
> .
> [image: Facebook]  [image: Twitter]
>  [image: LinkedIn]
>  tyah=idx%3A1-1-1%2CtarId%3A1425035050240%2Ctas%3A8+bit+platoon>
>
> --
>
>
> --
> *Unlock Interaction*
> CIC = Correspondence, Interactions & Communications
>
>
> *8 BIT PLATOON disclaimer*
> This e-mail transmission contains confidential information, which is the
> property of EOH Holdings Limited and its subsidiaries (“EOH”). No person,
> other than the recipient (so indicated by the sender) may use or disclose
> the contents of this message, links or attachments hereto, to any person
> whatsoever. Unauthorised disclosure and/or use may result in civil and
> criminal liability.
> Any views expressed in this message are those of the individual sender,
> except where the message states otherwise and the sender is authorised to
> state them to be the views of any such entity.
> The disclaimer forms part of the content of this e-mail in terms of section
> 11 of the Electronic Communications and Transactions Act, 25 of 2002. Refer
> to http://www.eoh.co.za/disclaimer
> --
>
>
>


Re: Flexible adaptable not resulting in instantiation of correct model

2019-06-12 Thread Vlad Bailescu
Hi Liam,

AFAIK, the mentioned pattern is not designed to work with Sling Models. It
simply uses the adaptTo pattern to transform the adaptable to the given
class.

Best,
Vlad


On Tue, Jun 11, 2019 at 9:00 PM Liam C  wrote:

> Hello,
>
> Is anyone able to replicate this, or to confirm that they have been
> able to get something similar to { 'com.example.ModelClass' @
> adaptable=item} working in their projects, please?
>
> Failing this, is there some workaround that could be used within
> Sightly/HTL to adapt a specified resource to a Model class? Although
> it is possible to access resource properties (e.g. item.myProperty),
> some business logic is contained within models that requires access
> via getters rather than via the resource properties.
>
> Thanks for any guidance.
>
> Liam
>
> On 2019/04/01 12:13:43, Liam C  wrote:
> > Hello everyone,
> >
> > In SLING-6504 (https://issues.apache.org/jira/browse/SLING-6504),
> > functionality was added to allow adapting a resource that is different
> > to the underlying page resource. Feike Visser's example
> > (
> https://github.com/heervisscher/htl-examples/commit/93666b5eebdeb36c25adf2e310f55049ec3767ce
> )
> > suggests that it is possible and simple, but I haven't managed to
> > succesfully implement it. In my experience so far, the adaptable is
> > ignored.
> >
> > If I use the following code in my Sling Model:
> >
> > @Self
> > Resource adaptable;
> > public Resource getAdaptableSelf()
> > {
> > return adaptable;
> > }
> >
> > ...it reveals that the adaptable that reaches the model is null.
> >
> > I wondered if this might have to do with the fact that the code in
> > SLING-6504 modified the JavaUseProvider, but the
> > SlingModelsUseProvider handles the instantiation before the
> > JavaUseProvider can be reached.
> >
> > Can anyone confirm whether this option is still working in Sling 11?
> >
> > Thanks,
> >
> > Liam
> >
>