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

Discussion corner for Developers of Serendipity.
Post Reply
User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

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

Post by garvinhicking » Wed May 14, 2014 2:47 pm

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.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

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

Post by Timbalu » Wed May 14, 2014 4:44 pm

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?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

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

Post by onli » Wed May 14, 2014 10:00 pm

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).

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

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

Post by garvinhicking » Fri May 16, 2014 2:50 pm

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

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

Post by onli » Fri May 16, 2014 4:20 pm

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?

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

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

Post by garvinhicking » Fri May 16, 2014 4:24 pm

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.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

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

Post by onli » Fri May 16, 2014 4:35 pm

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.

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

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

Post by garvinhicking » Mon May 19, 2014 11:45 am

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Post Reply