2.1Beta: Infobox when saving a new article is not shown

Found a bug? Tell us!!
User avatar
onli
Regular
Posts: 2262
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Fri Sep 09, 2016 5:50 pm

yellowled wrote:Can you remind me why we need this in the <head> of the backend preview iframe?
I don't remember anymore oO. I remember there was something, maybe the cache invalidation of the entry editor? But that would be in the core now. Theme specific entry javascript, as in the photo theme?

Would be great if you can test with one or two of the themes whether they needs those files or not.

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Fri Sep 09, 2016 7:27 pm

onli wrote:I don't remember anymore oO. I remember there was something, maybe the cache invalidation of the entry editor? But that would be in the core now. Theme specific entry javascript, as in the photo theme?
I don't, either. And the thing is, these are backend JS assets. Why would we need them in the preview iframe? There is nothing going on in there that is part of the backend theme, all JS that is required in that iframe should be part of the frontend theme.

I stumbled across this because with the correct “routing” of frontend + backend assets, the admin/serendipity_editor.js now throws an error in themes that do not use Modernizr (like clean-blog), so

Code: Select all

if(Modernizr.indexeddb && {$use_autosave})
does not work within the iframe (because Modernizr is not available in the iframe if the theme to be previewed does not include it). And I assume that this might speed up iframe preview a bit considering that those two files are not exactly slim …

Let's see … plugins.js is a combined and minified version of all backend JS plugins, that includes Magnific Popup, the equal heights script, tabs, canvas to Blob, autoscroll, sortable, cookie, details polyfill and accessifyHTML5. If any of those are required, it is because some function from serendipity_editor.js is applied within the preview iframe. Does the whole part concerning {$updertHooks} and messages maybe need something from that file?

serendipity_editor.js is our “backend JS function lib”, most of it is about adding functionality to the editor and/or related to the media db. About the only things I could see being needed here are autosave and cookies …? (But yes, I can and will test this a little.)

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Fri Sep 09, 2016 10:00 pm

There is the entry editor cache when saving entries:

Code: Select all

document.addEventListener("DOMContentLoaded", function() { if (window.parent.Modernizr.indexedDB) { window.parent.serendipity.eraseEntryEditorCache(); } });
It needs Modernizer and our serendipity_editor.js. The latter I'm not actually sure when reading the code, that could be covered as it accesses window.parent, the scope outside of the iframe, where serendipity_editor.js will be already loaded.

Maybe we can also just not do the Modernizer call in the iframe and need then none of our backend js? Edit: Hm, that calls window.parent as well. We should test just removing the js for that, and also use the parent scope for the autosave call.

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Fri Sep 09, 2016 10:26 pm

onli wrote:Maybe we can also just not do the Modernizer call in the iframe and need then none of our backend js?
There are frontend themes that include Modernizr (2k11 and Next), and they do so in the preview_iframe.tpl as well, but those include custom Modernizr builds, which usually do not include the same test as the backend Modernizr build. And I don't think it is an option to have a “global” Modernizr that includes all tests required by any theme and the backend. That's insane and confusing and hard to maintain and ugh.

I'm not 100% sure what to test here exactly, but if I uncomment the admin/*.js files in the preview_iframe.tpl of clean-blog (which does not include Modernizr in the frontend, so the only Modernizr available would be the one included by the backend), clear the tpl cache and preview and entry, there are no console errors. There are no console errors when I hit Save, either. More importantly, if I enter

Code: Select all

if (window.parent.Modernizr) { console.log('Modernizr found!') };
in the console after saving, it returns “Modernizr found!”. That should mean that the backend's Modernizr is available in the iframe, right? (Again, not sure what I'm doing here.)

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Fri Sep 09, 2016 10:37 pm

yellowled wrote:That should mean that the backend's Modernizr is available in the iframe, right? (Again, not sure what I'm doing here.)
Yes. But: `window.parent.Modernizr.indexedDB` does not work for me. You can test this as well: Remove the backend js, enter some text into the editor, wait 10 seconds, save, then click on "new entry". The cache will not be emptied.

Also, when you enter code in the console you are not really executing that from the iframe, which might change stuff. Better to put it into the preview_iframe.tpl and test from there.

Maybe it is picking up the modernizer.js from next theme, and that does not have that check included?

But when I remove the check for indexeddb everything works, also when not embedding plugin.js and serendipity_editor.js in the preview_iframe.tpl. Do we still need that check?

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Sat Sep 10, 2016 12:01 am

onli wrote:But when I remove the check for indexeddb everything works, also when not embedding plugin.js and serendipity_editor.js in the preview_iframe.tpl. Do we still need that check?
I wouldn't know, but I assume we don't. Quite honestly, I'm not sure what the indexedDB actually does in this context, but given the browser support for it …this is autosave, right? Well, I guess IE8/9 users will have to live without autosave.

I'll try to do some more testing tomorrow.

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Sat Sep 10, 2016 12:05 am

We use indexeddb to save the entry editor cache. In a browser that does not support that the js would fail later, and if the JS fails without having set the entry id in the editor subsequent saves would create new entries, instead of editing the current one.

But maybe there is a better way to do the check inside of the function and without modernizer, or maybe by now all relevant browser support indexeddb.

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Sat Sep 10, 2016 11:13 am

onli wrote:But maybe there is a better way to do the check inside of the function and without modernizer, or maybe by now all relevant browser support indexeddb.
Apart from Opera Mini and older versions of some mobile browsers, only IE 8 and 9 don't support indexedDB at all. There even is a polyfill, but I think we already discussed it and deemed it too large to include.

Are IE 8 and 9 still relevant? Yes. In fact, IE 9 has far more usage now than IE 10.

I don't know if there is a smaller test we could use instead of Modernizr – doesn't really matter anyway since we'd have to include the serendipity_editor.js as well, so either there is a way to use the backend assets from within the iframe or we'll have to include them twice, don't we?

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Sun Sep 11, 2016 3:40 pm

We can test inside serendipity_editor.js.tpl. I added the test now, removed the backend js from the preview_iframe.tpl of the next theme, and removed the Modernizer test from the core. See https://github.com/s9y/Serendipity/comm ... 6915be9a05.

Please test it :) I only could test whether it still works in FF. We could then remove the backend js also from the other preview_iframe.tpls.

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Sun Sep 11, 2016 10:19 pm

onli wrote:Please test it :) I only could test whether it still works in FF. We could then remove the backend js also from the other preview_iframe.tpls.
Not sure if I'm testing what I'm supposed to test here, but it does correctly autosave the contents of the entry editor (did not test the extended one) the way it's supposed to. Is that already it? If so, I just tested that successfully in:

* Chrome (which means it will probably also work in Opera, but I don't want to install Opera)
* Safari/Mac
* Safari/iOS
* IE 10
* IE 11
* Edge 13

IE 8 + 9 don't support indexedDB at all, so I did not test those. I won't go through the ordeal of testing this on Chrome for Android on my old Android test device, though.

Sooooo … can we remove the thing from the preview_iframe.tpls now? :mrgreen:

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Sun Sep 11, 2016 10:33 pm

It needs to autosave and, important, also delete the cache when an entry is saved.

It would be great if you could test whether writing an entry and saving it still works in IE8 or 9, especially that when you save an entry and then edit it directly after saving, on the same page, it does not create a second entry. That would basically test whether the `if (typeof indexedDB !== 'undefined')` works.

If it does we can remove all the backend js from all preview_iframe.tpls :)

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Sun Sep 11, 2016 11:14 pm

onli wrote:It needs to autosave and, important, also delete the cache when an entry is saved.
That does work in Chrome, Safari/Mac and Safari/iOS. Unfortunately, it does not seem to work in IE 11, the cache is not deleted (meaning the text is still in the entry editor textarea after saving). I'd like to test that again in the IE 11 on my Windows machine, this was in my IE 11 VM, and that seems to act weird sometimes.
onli wrote:It would be great if you could test whether writing an entry and saving it still works in IE8 or 9, especially that when you save an entry and then edit it directly after saving, on the same page, it does not create a second entry.
Tested in IE 8 and IE 9, it does indeed not create a second entry. Yay!

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by onli » Sun Sep 11, 2016 11:20 pm

In IE11 the text stays, but in IE8 and IE9 there is no error?

Then it could be that just the function to replace the cache content with an empty string does not work in IE11. That would be nice, because then we can already start with replacing the backend js from the preview_iframe.tpl, and can treat the IE11 issue as a separate bug.

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Sun Sep 11, 2016 11:31 pm

yellowled wrote:
onli wrote:It needs to autosave and, important, also delete the cache when an entry is saved.
I'd like to test that again in the IE 11 on my Windows machine, this was in my IE 11 VM, and that seems to act weird sometimes.
Huh, interesting – it does autosave properly, it does not create a second entry after editing a saved entry, but it also does not clear the cache/entry editor textarea after saving and creating a new entry. This is in IE 10 (which is neglectable), IE 11 (which is the most used of the three) and Edge 13.

Especially the fact that it does not work properly in Edge 13 makes me think that maybe there is a tiny error in the JS that the other browsers just skip and IE/Edge maybe picks up on it? However, I have no idea what part of the code that would be.

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

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

Re: 2.1Beta: Infobox when saving a new article is not shown

Post by yellowled » Sun Sep 11, 2016 11:32 pm

onli wrote:In IE11 the text stays, but in IE8 and IE9 there is no error?
See above: yes. (Assuming I'm testing correctly.)

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

Post Reply