liferay / generator-liferay-fragments

Yeoman generator for creating and maintaining Liferay Fragment projects
https://www.npmjs.com/package/generator-liferay-fragments
MIT License
30 stars 31 forks source link

Is Generated Configuration file needed? #89

Closed mfreeman-xtivia closed 4 years ago

mfreeman-xtivia commented 4 years ago

Is the configuration.json file that is generated by default when using the sample data needed?

I see that it is referenced by the fragment.json file but otherwise i cannot find any use for it, and cannot find any documentation anywhere for its use?

Can i just delete it and remove the reference to it from the fragment json?

codyhoag commented 4 years ago

Hey @mfreeman-xtivia; that is part of a new feature that we have not officially advertised. It will be part of the upcoming DXP 7.2 SP1 release. You can take a look at the unpublished docs to see how it can be used:

mfreeman-xtivia commented 4 years ago

Thanks So is this different that the kind of configuration i can already do using Liferay Fragment Tags?

codyhoag commented 4 years ago

Yes; this is a separate feature.

mfreeman-xtivia commented 4 years ago

Cody

So i am really intrigued by this, especially the Javascript use case (i.e where I access the configuration from JS and not from Freemarker/HTML). Unfortunately i am struggling a little bit to digest exactly what that would like based on the referenced doco.

Could you provide a brief example of the configuration JSON file and corresponding JS file that would access configuration values set by the user?

------ Original Message ------ From: "Cody Hoag" notifications@github.com To: "liferay/generator-liferay-fragments" generator-liferay-fragments@noreply.github.com Cc: "Mike Freeman" mfreeman@xtivia.com; "Mention" mention@noreply.github.com Sent: 10/2/2019 2:00:34 PM Subject: Re: [liferay/generator-liferay-fragments] Is Generated Configuration file needed? (#89)

Hey @mfreeman-xtivia https://github.com/mfreeman-xtivia; that is part of a new feature that we have not officially advertised. It will be part of the upcoming DXP 7.2 SP1 release. You can take a look at the unpublished docs to see how it can be used:

Making a Fragment Configurable https://github.com/sez11a/liferay-docs/blob/72-SP1/en/developer/frameworks/articles/web-experience-management/02-page-fragments/03-making-a-fragment-configurable.markdownFragment Configuration Types https://github.com/sez11a/liferay-docs/blob/72-SP1/en/developer/reference/articles/02-web-experience-management/02-page-fragments/02-fragment-configuration-types.markdownCollection Format https://github.com/sez11a/liferay-docs/blob/72-SP1/en/developer/frameworks/articles/web-experience-management/02-page-fragments/05-page-fragments-desktop-tools.markdown#collection-format — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/liferay/generator-liferay-fragments/issues/89?email_source=notifications&email_token=ACR4XA4GBYOHZCJ33VXY6XDQMTVVFA5CNFSM4I4WM3SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAF2GPI#issuecomment-537633597, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR4XA2MOND7VHCV7TOLJ4TQMTVVFANCNFSM4I4WM3SA.

--

This e-mail may contain confidential or privileged information. If you believe you have received this e-mail in error, please notify the sender by reply e-mail and then delete this e-mail immediately.

p2kmgcl commented 4 years ago

Hi @mfreeman-xtivia,

The contributed video component uses some configuration from JS (you will see a configuration object in the JS with the configuration values).

As @codyhoag referenced here, a configuration variable is built and sent to the fragments JS, just as the fragmentElement variable.

So is this different that the kind of configuration i can already do using Liferay Fragment Tags?

Finally, to clarify this, the idea is to reduce the need to create new tags/editables, so you can have some dynamic values in your fragments without writing any Java code.

Did you find this feature confusing/unclear/unuseful? I'm glad you're trying this :smile:

mfreeman-xtivia commented 4 years ago

So is this different that the kind of configuration i can already do using Liferay Fragment Tags?

Well at the moment i cannot test it as i dont have access to any Liferay version that has the fix i dont think

As in looking at the code for the video component, it appears that the JS code references 'configuration' as a global. Does that imply that each fragment JS is run in its own sanddbox? by wrapping it inside a function?

p2kmgcl commented 4 years ago

All the JS is wrapped inside an anonymous function to avoid unwanted global variables, but no extra sandbox/frame/environment is generated, we just call it with fragmentElement and configuration variables available.

This is an ugly copy of the generated code:

(function() {
var fragmentElement = document.querySelector('#fragment-37621-ixvt');
var configuration = {"hideControls":false,"bottomSpacing":"3","loop":false,"width":"","mute":true,"align":"flex-start","autoPlay":false,"url":"","height":""};

// Fragment code...

}());
p2kmgcl commented 4 years ago

Closing this for now, feel free to reopen/open another issue if you need to :smile: