major upgrade lightbox and usergallery plugins

Creating and modifying plugins.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

yellowled wrote:If the fix is in /templates/default/style_fallback.css, it is still emitted in serendipity.css by the lightbox plugin. I assume that is what you meant. If it is missing in style_fallback.css, it is still emitted by the plugin in serendipity.css.
Yes that was intended to have. Prepend it to serendipity.css for every browser ever. Why should we have a condition?
My question was, "Does it work with FF too?", since you said you already testet webkit browsers.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

Timbalu wrote:Why should we have a condition?
Because it is in style_fallback.css in master. I assumed you wanted to use addToCSS to only emit it in serendipity.css if it is not in style_fallback.css or something, especially since you did not remove it in master.
Timbalu wrote:My question was, "Does it work with FF too?", since you said you already testet webkit browsers.
yellowled wrote:does now work in Chrome 48, Safari 9.0.3 and Firefox 44 on OS X as well as the Safari in iOS 9.2.1
YL
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

yellowled wrote:Because it is in style_fallback.css in master.
Yes, if it now works in the Plugin only for every browser - why should we have it in style_fallback?
I would pled to (you!) remove it there (again). :)
yellowled wrote:I assumed you wanted to use addToCSS to only emit it in serendipity.css if it is not in style_fallback.css or something
No. Why should it, if it is good for all of us...?!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

Timbalu wrote:I would pled to (you!) remove it there (again). :)
I just did.

Sorry, but I was confused by basically everything you stated in your last 5 forum posts. I'm not sure if you're aware how hard it is to follow your train of thought sometimes, especially if you resort to posting one-liners.

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

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

No! :mrgreen:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

It's me again, and I think I have a bug report. :mrgreen:

I use the current lightbox 2.3.0 with Magnific Popup and the load optimization option, which is supposed to only load the lightbox assets if there are actually lightboxable image in the page. That does not work.

Example: http://yellowled.de/archiv/74/LR16-Viel ... Dinge.html does not contain any image that is a link to a larger image (the little portrait of me is not a link), yet the CSS + JS for MP is in the source code. Same thing happens with Colorbox, Lightbox 2 and prettyPhoto, though.

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

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

Hmm, strange... I would assume everything is fine.

This option should work if header_optimization is set to true AND foundImageLink returns false AND serendipity_plugin_imagesidebar is not installed OR is set to placement 'hide'.
In this case(s) the scripts should not show up.

If that all is the case and it still does not work, you could try to replace this (~L195)

Code: Select all

                    // If no imagelink was processed, don't add css or js files to the header! (configurable optimization)
                    if (serendipity_db_bool($this->get_config('header_optimization', 'false')) && !$this->foundImageLink && empty($cisb)) {
                        return true;
                    }
with this

Code: Select all

                    // If no imagelink was processed, don't add css or js files to the header! (configurable optimization)
                    if (true === (serendipity_db_bool($this->get_config('header_optimization', 'false')) && !$this->foundImageLink && empty($cisb))) {
                        break;
                    }
and report here.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

Timbalu wrote:This option should work if header_optimization is set to true AND foundImageLink returns false AND serendipity_plugin_imagesidebar is not installed OR is set to placement 'hide'.
I already said that I have that option set to “Yes”, I do not use imagesidebar and I used this to test foundImageLink:

Code: Select all

elseif ($type == 'magnific') {
    if ($headcss) {
    // …
    } else {
    // …
    echo '    <script type="text/javascript" src="' . $pluginDir . '/magnific-popup/jquery.magnific-popup.min.js" charset="utf-8" data-link="' . $this->foundImageLink .'"></script>' . "\n";
    // …
    }
}
Assuming that this does what it's supposed to do, foundImageLink is empty (it emits »data-link=""«) on pages that do not contain image links and 1 on pages that do contain image links. I assumed that empty is probably PHP's version of undefined, so I changed the line you specified.

That does not change anything, the lightbox assets are still referenced on pages without image links.

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

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

sometimes its hard to follow your thoughts... :wink:

The code part you pasted has nothing to with it.
The break is done by my pasted code part and checks variables defined globally or directly before.
yellowled wrote:foundImageLink is empty (it emits »data-link=""«) on pages that do not contain image links and 1 on pages that do contain image links
Where did you check this output in detail?

It is unusual, since foundImageLink should only be false or true, defined by the count of regex replacements. It expects links to be in a certain condition!

If you have links that are written in an unsual condition, eg by adding extended attributes to a link like »data-link=""« this would IMHO need to change the regex part, since that changes the replacement order*. I can not see how we could do this, since not knowing what people might add in future themes. I would pled to have image links like ever, and add additional attributes on clients site by JS, maybe.

The empty() is the better isset(), since !isset('') is false and empty('') or empty(null) is true, and includes isset, see http://php.net/manual/en/types.comparisons.php

(*) Where exactly did you add the additional attributes and how does the link look like in entry?

PS. Where does the data-link come from...? Maybe you should test without these sidebars social sprite widgets once.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

Timbalu wrote:sometimes its hard to follow your thoughts... :wink:
Yeah, well, if you don't tell me how to check the value of foundImageLink, I'll try it myself. (I even stated that I only attempted to find out the value and wasn't sure if it was correct.)
Timbalu wrote:Where did you check this output in detail?
I though that

Code: Select all

data-link="' . $this->foundImageLink .'">
would emit the value of foundImageLink for the current page (as the value of that data-attribute, which I added myself since I did not know where or how to emit it). The results of this (meaning the value of data-link) are either 1 or nothing, but not true or false.
Timbalu wrote:It is unusual, since foundImageLink should only be false or true, defined by the count of regex replacements.
According to your last post the whole thing “should work”. But it does not.
Timbalu wrote:If you have links that are written in an unsual condition, eg by adding extended attributes to a link like »data-link=""« this would IMHO need to change the regex part, since that changes the replacement order*.
I have no idea what you're talking about. The only thing I did was append a data-attribute to the script element that includes magnific popup to have a place to (what I assumed to be) foundImageLink. I did not add anything to the image links.

To make this as clear as possible: I added some code to serendipity_event_lightbox.php that changes

Code: Select all

<script type="text/javascript" src="/plugins/serendipity_event_lightbox/magnific-popup/jquery.magnific-popup.min.js" charset="utf-8"></script>
to

Code: Select all

<script type="text/javascript" src="/plugins/serendipity_event_lightbox/magnific-popup/jquery.magnific-popup.min.js" charset="utf-8" data-link="<VALUE>"></script>
where <VALUE> is $this->foundImageLink. <VALUE> is either 1 or empty.
Timbalu wrote:PS. Where does the data-link come from...? Maybe you should test without these sidebars social sprite widgets once.
A. I just told you where it comes from. It was added by me to find a way to check the value of foundImageLink.
B. I already tested all this with 2k11, Next and clean-blog which do not emit the social icons at all (because they're part of my theme). It has nothing to do with that, the lightbox assets are still emitted.

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

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

The tone of this answer sounds like you are charging me... for something...
yellowled wrote:<VALUE> is $this->foundImageLink. <VALUE> is either 1 or empty
Thats right. foundImageLink is a true boolean, which, when echoed, gives you 1 or NOTHING.

For debugging output you would need to do

Code: Select all

echo $this->foundImageLink ? 'true' : 'false';
I assumed you added data-link="" to some entry links maybe, but now - after your explanation - I see where it comes from. :) Thats not the way you should place debug output.

And this

Code: Select all

                    // If no imagelink was processed, don't add css or js files to the header or footer! (configurable plugin option)
                    if (true === (serendipity_db_bool($this->get_config('header_optimization', 'false')) && !$this->foundImageLink && empty($cisb))) {
                        break;
                    }
you said, does not really help you?!

Then please replace

Code: Select all

$cisb = $check_imagesidebar['placement'] != 'hide' ? $check_imagesidebar : null;
with

Code: Select all

$cisb = (is_array($check_imagesidebar) && $check_imagesidebar[0]['placement'] != 'right') ? $check_imagesidebar : null;
and see what it gives to you.

For debugging you could use

Code: Select all

                    if (serendipity_db_bool($this->get_config('header_optimization', 'false'))) {
                        echo 'option header_optimization is true<br>';
                        if ($this->foundImageLink === false) {
                            echo "foundImageLink is false / No Links replaced<br>";
                            if (empty($cisb)) {
                                echo "check imagesidebar is empty";
                                break;
                            }
                        }
                    }
instead of the other break thing I posted above.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

Timbalu wrote:Thats not the way you should place debug output.
I don't know where to place PHP debug output, I am not a PHP coder.
Timbalu wrote:And this […] you said, does not really help you?!
I said it did not do anything different, meaning the CSS/JS assets were still emitted on pages that did not have image links. I just checked again, still emitting CSS/JS on pages without image links. I even switched to 2k11 – same result, still with CSS/JS on pages without image links.
Timbalu wrote:Then please replace […] and see what it gives to you.
Dingdingding. With that code replaced, it does not emit lightbox CSS/JS on pages that do not have image links (but does so on pages that do contain image links).

Also, to double-check that for you, it works as expected with the SVG sprite sidebar in my theme.

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

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

In that case I will update the plugin.
Thanks for the finding!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: major upgrade lightbox and usergallery plugins

Post by Timbalu »

Ops sorry, it has to hide - not right!

Code: Select all

$cisb = (is_array($check_imagesidebar) && $check_imagesidebar[0]['placement'] != 'hide') ? $check_imagesidebar : null;
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: major upgrade lightbox and usergallery plugins

Post by yellowled »

Timbalu wrote:Ops sorry, it has to hide - not right!
Still works the way we want it to work – no CSS/JS on pages without image links, but CSS/JS on pages that do have image links.

YL
Post Reply