understanding 2k11 preview_iframe.tpl

Discussion corner for Developers of Serendipity.
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

understanding 2k11 preview_iframe.tpl

Post by Don Chambers »

I took a closer look at this file, and noticed that 2k11 does some things differently than I have seen in the past. So I have some questions.

1. Near the end of <head> is this:

Code: Select all

<style type="text/css">#serendipity_preview_spacer {ldelim}float:none!important;height:0!important;{rdelim}</style>
But in <body> is this:

Code: Select all

<div id="serendipity_preview_spacer" style="float: left; height: 225px"></div>
Why style that id inline, then override it in the head? Is there some circumstance where the embedded style gets overridden?

2. I have never seen $mode before. Other than "preview" and "save", are there any other possible values?

3. What does {$updertHooks} do?

4. What is/triggers {$res}? Looks to be an error message of some kind??

5. What is/triggers {$lastSavedEntry}

6. These classes are backend admin classes, which the preview does not load. Do they exist because there is an intent to not open the preview in an iframe, and therefore impose admin styles on previews? EDIT: Apparantly the admin styles DO load within 2k11's admin iframe.. But they do not seem to be working for me here.

Code: Select all

<span class="msg_success"><span class="icon-ok-circled">
Sorry if all this was discussed before. I'm still playing catch up.
=Don=
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by onli »

First, this is a mess we'd like to get rid of: https://github.com/s9y/Serendipity/issues/218. Perfectly fine to question it.
Don Chambers wrote:5. What is/triggers {$lastSavedEntry}
That is the logic to set the entry editor to the current entry id. You saved an entry, you continue working on it, then that edit should not generate a new entry but just modify the current one. I remember thinking that this should be completely unnecessary and never done by Javascript, I don't remember anymore why the core does not just set the correct id when generating the entry editor.

So, that variabel should be filled when saving an entry
Don Chambers wrote:3. What does {$updertHooks} do?
It's a variable, it only contains text. It contains the text echoed by

Code: Select all

serendipity_updertEntry($entry)

see https://github.com/s9y/Serendipity/blob ... c.php#L816
Don Chambers wrote:4. What is/triggers {$res}? Looks to be an error message of some kind??
It's the return value of

Code: Select all

serendipity_updertEntry($entry)
and should denote the success of saving the entry (better look into that function though).
Don Chambers wrote: 2. I have never seen $mode before. Other than "preview" and "save", are there any other possible values?
No, at least that would lead to doing nothing in serendipity_iframe (I hope that is never expected).
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by Don Chambers »

None of this exists in any other theme's preview_iframe.tpl. Is this all new to 2.0?
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

Don Chambers wrote:1. Near the end of <head> is this:

Code: Select all

<style type="text/css">#serendipity_preview_spacer {ldelim}float:none!important;height:0!important;{rdelim}</style>
But in <body> is this:

Code: Select all

<div id="serendipity_preview_spacer" style="float: left; height: 225px"></div>
Why style that id inline, then override it in the head? Is there some circumstance where the embedded style gets overridden?
This whole stupid #serendipity_preview_spacer has always been a mystery to me, albeit one I never investigated further. I don't know where it is coming from, I don't know what use it has (if any), I just know that it for some reason has to be there and has to be hidden using inline styles. It has been that way ever since I've been doing s9y themes. Also, preview_iframe.tpl is a file I hate with a passion, so I usually just throw the stuff in I know needs to be there for it to work, and then I bang at it until it works.

So the best answer I can give you on this is: I don't know why this is there, but it works. :)
Don Chambers wrote: EDIT: Apparantly the admin styles DO load within 2k11's admin iframe.. But they do not seem to be working for me here.
What's is actually weird about this is: they do work. If they did not work at all, the icon would not be displayed, because the icon font and its classes are part of the backend CSS. What is not working is just the .msg_* classes …

I'll have to take a closer look at this.

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by Don Chambers »

Another bug submitted via Github. I hope I did that correctly.

FYI - I'm not seeing the icon nor is the message class styled.
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

Don Chambers wrote:Another bug submitted via Github. I hope I did that correctly.
Kind of. You did not assign a milestone (since this would be a bugfix, it should be assigned to the 2.0.x milestone) and I'm not sure you actually finished your sentence. But I closed both issues anyway because I think this needs more discussion in the forums first.
Don Chambers wrote:FYI - I'm not seeing the icon nor is the message class styled.
You're right. I was confused because I tested it with a (frontend) theme that uses the exact same icons and classes for this like the 2k11 backend. (Why don't we have a facepalm emoticon in the forums?)

Here's the thing:

* If we need these message classes, they should not be part of the frontend theme's style.css (as you suggested) since the backend theme can be chosen independently from the frontend theme now. The message classes should match the backend theme.
* Both the preview and the save mode of preview_iframe.tpl do not include the backend CSS in the iframe (which is why the messages are not styled).
* Technically, the messages should not even be in the preview (because they are not really part of what needs to be previewed). They should be emitted after the iframe, if possible (which conveniently also would make them use the backend CSS).
* As Don wrote on GitHub, “although 2k11's preview_iframe.tpl is being used to output the message”. That is correct, although I can not explain why. Malte probably know this.

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by Don Chambers »

This whole iframe shit has gotta go. But I just don't have the skills to propose an alternative.. So you coders come up with a better solution! :mrgreen: :mrgreen: :mrgreen:

IF a message is being emitted by preview_iframe.tpl, then I personally feel:

1) It should be emitted via that theme's preview_iframe.tpl, and
2) backend admin styles should NOT be imposed on the preview for reasons I said on Github:
Loading the admin stylesheet for an entry preview runs the risk of introducing styles that override or otherwise conflict with the frontend.
That being said, I agree with YL:
yellowled wrote:* Technically, the messages should not even be in the preview (because they are not really part of what needs to be previewed). They should be emitted after the iframe, if possible (which conveniently also would make them use the backend CSS).
At the moment, I suspect the reason messages are using 2k11's preview_iframe.tpl, and not the theme's version, is the same theme inheritance issue recently mentioned about default header images and the backend_templates folder for staticpages.... but that is just a guess.
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

I'm not sure this
Don Chambers wrote:1) It should be emitted via that theme's preview_iframe.tpl
will work with this
yellowled wrote:* Technically, the messages should not even be in the preview (because they are not really part of what needs to be previewed). They should be emitted after the iframe, if possible (which conveniently also would make them use the backend CSS).
because the contents of preview_iframe.tpl are the contents of the iframe.

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

So I investigated this further, and now I am utterly confused.

To reference the theme's (primary) stylesheet in preview_iframe.tpl, BP uses

Code: Select all

<link rel="stylesheet" type="text/css" href="{$head_link_stylesheet}" />
2k11, default as well as now next use

Code: Select all

<link rel="stylesheet" href="{$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css">
and that seems to be wrong/confuse the preview in 2.0. Out of these, only BP's preview is working correctly for me at the moment. All the others (2k11, default and next) all include next's style.css in the preview (which really confuses me, because, you know – why next's?).

I remember that we switched something around here during development, but I do not remember why. Should this be reverted to {$head_link_stylesheet}? For all of them?

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

yellowled wrote:I remember that we switched something around here during development, but I do not remember why. Should this be reverted to {$head_link_stylesheet}? For all of them?
Relevant commit for reference

YL
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by onli »

So, we/I changed this to get the frontent css. If $head_link_stylesheet now contains the fontent-styles anyway because of changes of how the whole frontend/backend-separation works, it would ineed be good to change. Just make sure that it works in all of the previews (editor, entry list).
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

onli wrote:If $head_link_stylesheet now contains the fontent-styles anyway because of changes of how the whole frontend/backend-separation works, it would ineed be good to change. Just make sure that it works in all of the previews (editor, entry list).
It does not. I tested this for all templates in the core that have a preview_iframe.tpl:

* if I exchange this to {$head_link_stylesheet} in 2k11's preview_iframe.tpl, it still includes the backend stylesheet
* in bulletproof, it works correctly with {$head_link_stylesheet}
* in default, it emits 2k11's backend stylesheet
* in next, it emits 2k11's backend stylesheet

So apparently, neither {$head_link_stylesheet} nor {$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css work correctly, the only exception is Bulletproof. Which is kind of interesting because BP has “engine: default” in its info.txt. So I tested exchanging that with {$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css just for fun.

In BP, even {$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css work properly in preview_iframe.tpl. Or {$head_link_stylesheet}, doesn't make a difference for the preview. So I'm guessing this has something to do with the template fallback chain …? The difference seems to be that {$head_link_stylesheet} always emit the current backend stylesheet whereas {$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css always emits … erm … not sure what, but not the right one. :?

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by Don Chambers »

In the theme I am developing right now, I am using

Code: Select all

    <link rel="stylesheet" href="{$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css">
Because I saw that change in 2k11. And the only styles I am getting in preview_iframe.tpl are my theme's frontend styles. I am not getting 2k11's styles - frontend or admin.

So next, I switched my theme to coffee cup (competition folder)... It has no preview_iframe.tpl. The styles it loaded in preview were the styles from the theme I am developing!!!

But then I did a hard refresh, and it loaded coffe cup's styles correctly. So is this just a cache issue?
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

Don Chambers wrote:So next, I switched my theme to coffee cup (competition folder)... It has no preview_iframe.tpl. The styles it loaded in preview were the styles from the theme I am developing!!!
I did experience the same thing in my tests.
Don Chambers wrote:But then I did a hard refresh, and it loaded coffe cup's styles correctly. So is this just a cache issue?
Don't know. Even if so, it is still something that needs to be fixed. We can not expect end users to even know what a hard refresh is. This should work without the need to do that.

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: understanding 2k11 preview_iframe.tpl

Post by yellowled »

I think it is a caching issue. That woud also explain why it works in BP, but not in 2k11 (for instance).

BP uses {$head_link_stylesheet}, which has a cache busting versioning string added to the stylesheet href (you know, the "?v=1423854769" at the end of it). {$serendipityHTTPPath}{$serendipityRewritePrefix}serendipity.css obviously does not have that, which is (probably) why it needs a hard refresh (after which it does works as expected).

YL
Post Reply