Page 1 of 1

Serendipity 2.0: Problem with serendipity_editor.js / .js.tp

Posted: Wed May 14, 2014 2:47 pm
by garvinhicking
Hi!

Relating to my recent commit to 2.0 for the ability to seperate backend and frontend themes, I just hit an issue with the current implementation and I need help from @onli probably, or someone else who remembers:

In current 2k11/admin/index.tpl there's a getFile reference to serendipity_editor.js. This file does not exist in the 2k11/admin/ directory (only one with a .tpl).

This will lead to default/admin/serendipity_editor.js to be embedded within the head, but this file does not contain i.e. the AJAX image upload features that @onli committed, so this does not work.

Does anyone remember/know how this is supposed to work? Should this file be statically created? I'm confused.

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Wed May 14, 2014 4:44 pm
by Timbalu
Is that still a valid question?
Yes, it is statically AFAIK. And it needs to get precompiled with every change to the origin js.tpl file.
Do we still need this, after your backen template commit?

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Wed May 14, 2014 10:00 pm
by onli
I hope we can now do this better.

It is meant like this:
1. If the currently loaded plugin has a $file.x.tpl in admin, s9y will insert a link to the plugin-api (external_plugin/$file.x). That way, the template can generate the js using smarty in its event hook).

2. If the currently loaded template has no $file.x.tpl in admin, it shall fall back to search for $file.x - which was located in default, for serendipity_editor.js.tpl.
---

We still need the power to react to configuration variables in the js, and potentially to include language costants. But it sure would be nice if we could come up with a more stable approach now.

Best would be a system where a plugin can also use the *.tpl without havong to have the load-code in its own config.inc.php.

*Edit*

I can actually imagine how this could work. We would add the JS as smarty. But in it, we would call smarty-functions to read the confguration variables (and the CONSTS are all available anyway), instead of giving the variables in a prefilled array. Then we could call it from the core regardless of the config.inc.php of the template.
Probably needs a saveguard to not emit security-relevant-settings (and maybe we want to ban it on the frontend, as it should be not very fast - but probably fast enough for the backend).

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Fri May 16, 2014 2:50 pm
by garvinhicking
Hi!

OK, I feel like Jon Snow now. ;)

The issue still stands, currently the backend tpl has some issues (because it uses a non-recent serendipity_editor.js from default/ rather than the compiled one) - for example, onli's ajax image upload feature currently does not work.

It seems, onli, you have a good grip about what would need to be changed? Maybe you can look at it and either propose a diff or just commit a proposal to discuss this further. Then maybe I get it. ;)

Regards,
Garvin

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Fri May 16, 2014 4:20 pm
by onli
That would be https://github.com/s9y/Serendipity/comm ... e5d92cff5b

Please note the introduction of serendipity_getConfigVar to smarty. We don't have a mechanism like that already, do we?

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Fri May 16, 2014 4:24 pm
by garvinhicking
onli wrote:That would be https://github.com/s9y/Serendipity/comm ... e5d92cff5b

Please note the introduction of serendipity_getConfigVar to smarty. We don't have a mechanism like that already, do we?
This looks interesting (can't test until next week) - however I think this might break the installer? I'm not fully sure if we need the getconfigvar method, we might simply use $serendipity.configkey ? But having that might be beneficial for the future.

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Fri May 16, 2014 4:35 pm
by onli
however I think this might break the installer?
I thought so as well, but then wasn't sure how much is available there. We actually are using this mechanism in the installer for serendipity_editor.js - before, falling back to default/serendipity_editor.js, and it would be nice to get rid of that static variant.
I'm not fully sure if we need the getconfigvar method, we might simply use $serendipity.configkey ?
Sure, whatever you like more. I was hesistant to give the full $serendipity array to smarty, but can't really judge the effect. Could be better than accessing the db though.

Re: Serendipity 2.0: Problem with serendipity_editor.js / .j

Posted: Mon May 19, 2014 11:45 am
by garvinhicking
Did you test this patch in the installer already? If that work, that would be fine.

With the current 2.0 snapshot, do your AJAX image resize things work for you?

Regards,
Garvin