preview and serendipity_getFile

Discussion corner for Developers of Serendipity.
User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

preview and serendipity_getFile

Post by Timbalu » Sun Oct 13, 2013 12:28 pm

Devs, I need a quick discussion on this.

Since previewing draft and future entries in 2.0 opens in the same window as new page, I would like to revert this for the 1.7 Series too, since there they currently open as a "_blank" new window without sidebar and banners. Ok?

Twiddling with this, I found a funny behaviour:
The file preview_iframe.tpl does have access to the current templates config, and knows about template_config setters for example, but does not access

Code: Select all

{serendipity_getFile file="foo.ext"}
. This has to get changed for bulletproof and 2k11 preview_iframe.tpl, to

Code: Select all

{$serendipityHTTPPath}templates/{$template}/foo.ext
. This happens to the user.css and modernizr call. (Template /default preview tpl did wisely not access any files by this.)

This sounds easy to manage on first view. Playing with that, I found all the functions to build and access iframed previews and the nature of serendipity_getFile to be far more detailled and finetuned, than a first look really offers. (*)
I tried to find out why serendipity_getFile does not work there, maybe as an result from Smarty3 scoping, but this seems to do in 2.0. (Why?)
As a minor: Also the .css and js call do behave different, when being called by this, since the first writes "user.css" and does only return a 404 not found and the second errors empty "", but with a syntax error in console.

My local tests on this returned, that this seems not to be attributed to the Smarty3 scope, since also happens in my local test 1.6 Series install. Can anyone of you verify this for old 1.6 and current 1.7 Series too, please! (Since I don't really have clean releases. Open iframe page source code to check)

Then it would be nice to know, if we can make serendipity_getFile happen to work in 1.7x too or rename the path builder in both files and both branches as showed above to make sure.

What do you think?

(*) This, btw, is what I often experience with S9y. Easy and old looking code (remember the "kiddy"... ;-)) often offers far more, than you can see, coming from one certain point of view. Knowing this, I try to be very careful before I change code.
Regards,
Ian

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

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

Re: preview and serendipity_getFile

Post by onli » Mon Oct 14, 2013 1:34 pm

Since previewing draft and future entries in 2.0 opens in the same window as new page, I would like to revert this for the 1.7 Series too, since there they currently open as a "_blank" new window without sidebar and banners. Ok?
That is what I didn't get on Github, I think now I did. You are correct, while 2.0 opens the preview in the backend in an iframe, so that the navigation menu is visible, 1.7 uses a different approach (opening the entry as admin in the frontend, using taget=_blank). While the newer approach sure is nicer, I don't see why that should be backported? The old system works fine, and all the preview stuff is a bit complex and messy, I wouldn't change that if I were you if I didn't have to.

serendipity_getFile - this functionality I think I changed for 2.0 quite a bit, as it needed to take the new smartified js-files into account. Smarty shouldn't be responsible for stuff like this, as this function just maps to a serendipity-function. What exactly is the bug in 1.7? That it doesn't find files which are present in the template, but only when called in preview_iframe.tpl?

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

Re: preview and serendipity_getFile

Post by Timbalu » Mon Oct 14, 2013 2:26 pm

onli wrote:What exactly is the bug in 1.7? That it doesn't find files which are present in the template, but only when called in preview_iframe.tpl?
Yes. Meaning, the fallback chain does not work there as expected.
That it does in 2.0, can be associated to your changes, but may also have to do with 2k11 being the $serendipity['defaultTemplate'] = '2k11'; including also being the default backend fallback.
I "assume" in 1.7x the {serendipity_getFile...} chain search falls directly into templates/default (I assume because of engine: default) and therefore cannot find a user.css and modernizer.js file. (This would open other possibilities to fix this issue.) All that said to the iframe_preview.tpl call only, since outside of the normal "scope".

Both branches open a new window, but 1.7 in a "_blank", seperate one, which also disables sidebar and banner. The entry preview in an iframe is the same.
Regards,
Ian

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

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

Re: preview and serendipity_getFile

Post by onli » Mon Oct 14, 2013 2:58 pm

Could be the fallback chain, or it could be due to neither being in the backend nor the frontend (there were some strange path conditions in serendipity_smarty_init).

Are you looking for help in debugging that, are you stuck?

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

Re: preview and serendipity_getFile

Post by Timbalu » Mon Oct 14, 2013 3:26 pm

Not exactly.

There were 4 questions I wanted to have discussed:
  • is this reproducable at all?
  • shall we handle that preview popup in 1.7 to work like in 2.0? (easy to solve)
  • if we change to use {$serendipityHTTPPath}templates/{$template}/foo path builds, w/o fixing this serendipity_getFile issue for these special cases (are there others?), don't we have to do that in 2.0, too, to not lose consistency?!
  • how would we need and want to fix serendipity_getFile in 1.7, to work with special files like this? (see possibilities)
Regards,
Ian

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

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

Re: preview and serendipity_getFile

Post by onli » Mon Oct 14, 2013 8:26 pm

Alright.
Timbalu wrote:is this reproducable at all?
I could surely test that. Please confirm the testcase: In 1.7.3, place a file foo.img in /templates/$template/, and see what is the output of

Code: Select all

{serendipity_getFile file="foo.img"}
when placing that code in preview_iframe.tpl?
Timbalu wrote:shall we handle that preview popup in 1.7 to work like in 2.0? (easy to solve)
I think that 2.0 is near enough to better not change stuff like that in 1.x anymore.
Timbalu wrote:don't we have to do that in 2.0, too, to not lose consistency
If in both cases the file is found: No, the method which calls that file should be of no consequence. 2.0 is allowed to break consistency. And: there are already cases where we had to change the method from serendipity_getFile to a manual path build.
how would we need and want to fix serendipity_getFile in 1.7
I'll come back to that after the issue got confirmed.

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

Re: preview and serendipity_getFile

Post by Timbalu » Wed Oct 30, 2013 10:47 am

This is still pending! What about means of Garvin and Yellowled?
Regards,
Ian

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

User avatar
yellowled
Regular
Posts: 7007
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: preview and serendipity_getFile

Post by yellowled » Wed Oct 30, 2013 12:34 pm

TL;DR. I don't see the point in backporting it, but if you don't have anything else to do, I'm not opposed, either.

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

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

Re: preview and serendipity_getFile

Post by onli » Wed Oct 30, 2013 3:23 pm

Timbalu wrote:This is still pending!
Yes, but it's your turn ;)
onli wrote:Please confirm the testcase: ...

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

Re: preview and serendipity_getFile

Post by Timbalu » Wed Oct 30, 2013 9:36 pm

onli wrote:Yes, but it's your turn ;)
onli wrote:Please confirm the testcase: ...
No need! The only testcase needed is the actual files state of BP and 2k11, which I have wrote about three times and saying it again or replying to TL;DR answers will not make it any better.

Since this superficially surface "bug" (serendipity_getFile usage in preview_iframe) and its different fixing solutions isn't falling on too much discussible interest, I will make a proposal on this, to keep it simple.

This will give us at least a temporary fix for 1.7.4, since solving all its strange surrounding issues will make a tiny thing need a big workaround, while this in deep is a little more complicated.

If then anybody wants to do it better we can discuss that.
Regards,
Ian

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

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

Re: preview and serendipity_getFile

Post by Timbalu » Sat Nov 02, 2013 4:43 pm

Ok!
I dived into this a little more and it turned out to be some bad nesting, local setting bug and sticky cache behaviour.

I am happy to say that there is no problem with the serendipity_getFile and preview_iframe.tpl, how I first suggested. The issue (making me think it did not work) happend, when I used my PoC Dashboard, which internally changed the default template path.

Switching themes and accessing draft previews was/is something that badly interacts with theme compiles caching. We had this before in another thread, getting funny results switching themes!
The preview is a very sticky one, since serendipity.css seemed to not catch up the new templates/style.css settings. It turned out, that I needed to run [Ctrl] [R] at least 3 times shortly after another to get the right file bundled into serendipity.css and also reset the browser cache.

After all that, there are just two minor( question)s left:

1. Shall we open the backend entry summary page preview link on _self or _blank in new 1.7.4?

2. @Yellowled please add into 2k11/preview_iframe.tpl (both branches)

Code: Select all

    <style type="text/css">
    <!--
    /* ... reset previews entry #content width to no-sidebar full view ... */
    #content {
        width: 99.8%;
    }
    -->
    </style>
before the modernizr call or add something like that to your styles.css file.
Regards,
Ian

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

User avatar
yellowled
Regular
Posts: 7007
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: preview and serendipity_getFile

Post by yellowled » Sat Nov 02, 2013 9:19 pm

Timbalu wrote:2. @Yellowled please add into 2k11/preview_iframe.tpl (both branches)

Code: Select all

    <style type="text/css">
    <!--
    /* ... reset previews entry #content width to no-sidebar full view ... */
    #content {
        width: 99.8%;
    }
    -->
    </style>
before the modernizr call or add something like that to your styles.css file.
Why?

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

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

Re: preview and serendipity_getFile

Post by Timbalu » Sat Nov 02, 2013 9:30 pm

As I wrote, while this reset previews entry #content width (68%?) to no-sidebar full view (~100%).
Regards,
Ian

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

User avatar
yellowled
Regular
Posts: 7007
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: preview and serendipity_getFile

Post by yellowled » Sun Nov 03, 2013 11:50 am

Sure, but

a) Why 99.8% and not 100%? Do you have a specific reason for that?

b) Why would you want to have the preview in full width if it's not in full width in the frontend? That's irritating, if only for the different line length.

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

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

Re: preview and serendipity_getFile

Post by Timbalu » Sun Nov 03, 2013 1:23 pm

yellowled wrote:a) Why 99.8% and not 100%? Do you have a specific reason for that?
I tested that with a border, AFAIR. And with full 100%, the right border was outside element.
yellowled wrote:) Why would you want to have the preview in full width if it's not in full width in the frontend? That's irritating, if only for the different line length.
Take a look at that 2.0 testblogs "Entry draft with a very long entry title and also content" entry. This looks like a wordwraped break, but is a breakless text. So if you don't know this is a text without any newlines (ENTERS), inner-orientating at the 2k11 markup columns, you do not get the real to eyes, as far you don't mark this part as being a 2/3 column by a border, or something else. That is why I think, using a near 100% is better here, since this preview does not screenshot the blog frontpage with sidebar itself, than just a part - the entry content - of it.
Regards,
Ian

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

Post Reply