Invalid code in two plugins

Creating and modifying plugins.
Post Reply
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Invalid code in two plugins

Post by yellowled »

I stumbled across invalid (X)HTML emitted by two plugins today:

First of all, serendipity_plugin_twitter emits an img element which is not self-closing (<img ... />), which is invalid in XHTML doctypes.

The second one is debatable: The JS version of the twitter sidebar plugin emits a <ul> without any <li>, which also is invalid. Since the <ul> is filled with <li> elements using JS later, this is kind of a "technically invalid, practically not". Still, a rather simple solution would be to emit a single <li>, maybe linking to the configured twitter account's page, which would be removed from the DOM before inserting the dynamic elements.

However, I'm not exactly comfortable editing those myself, I just thought I'd mention it. :)

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Invalid code in two plugins

Post by garvinhicking »

Hi!
First of all, serendipity_plugin_twitter emits an img element which is not self-closing (<img ... />), which is invalid in XHTML doctypes.
Where?

About the ul-injection, that's a good idea. :)

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/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Invalid code in two plugins

Post by yellowled »

garvinhicking wrote:
First of all, serendipity_plugin_twitter emits an img element which is not self-closing (<img ... />), which is invalid in XHTML doctypes.
Where?
In the sidebar, at least that's what I tested so far. As far as I can tell, any img element in the plugin is HTML 4.01 style, i.e. not self-closing.

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Invalid code in two plugins

Post by garvinhicking »

Hi!

Do you have an example? Does the img maybe come from twitter itself?!

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/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Invalid code in two plugins

Post by yellowled »

garvinhicking wrote:Do you have an example? Does the img maybe come from twitter itself?!
<mode="janice">Oh. My. God.</mode>

I'm sorry, I meant serendipity_plugin_flickr, not twitter with the img thing. Jeez, I was already wondering why you asked about that ... sorry :)

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Invalid code in two plugins

Post by garvinhicking »

Hi!

Ok, the img thing is fixed. About the ul injection, I put it on my list :)

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/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Invalid code in two plugins

Post by garvinhicking »

Hi!

I updated the twitter plugin to put an empty <li> in there.

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/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Invalid code in two plugins

Post by yellowled »

garvinhicking wrote:I updated the twitter plugin to put an empty <li> in there.
Not sure an empty li is valid, either. It should contain some kind of information. Maybe we could put some text there? 'Requires Javascript' comes to mind.

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

Re: Invalid code in two plugins

Post by yellowled »

garvinhicking wrote:I updated the twitter plugin to put an empty <li> in there.
Here's another idea: The JS "version" of the plugin currently includes 2 JS files right where the plugin code itself is emitted in the sidebar. (I hope you get what I mean by that?)

Not sure whether it's possible, but it would be better in terms of performance to include those files at the bottom of the page, right before the closing </body> tag.

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Invalid code in two plugins

Post by garvinhicking »

HI!

That would only be possible when putting it in the event plugin instead of a sidebar plugin, which would IMHO too much confuse things...

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/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Invalid code in two plugins

Post by yellowled »

garvinhicking wrote:That would only be possible when putting it in the event plugin instead of a sidebar plugin, which would IMHO too much confuse things...
I was aware that this might be your answer. Hm.

Of course, this isn't much of an issue concerning the twitter plugin - if somebody would really be aware of performance issue, they could simply switch to the PHP version of the plugin.

Then again, this might be a good point to tackle possible performance issues. onli has been doing a lot of great stuff with plugins using jQuery, but at least some of those insert <script> elements in the <head>, which isn't ideal, either. There are cases in which <script> has to be in the <head>, but if possible, they should be included right before the </body> tag.

I suppose in the future more and more plugins will require or use javascript. I also use jQuery in templates quite frequently. Maybe we should have some kind of (not really sure of the correct term here, but I'm sure you know what I mean) hook to insert all <script> elements which don't have to be in the head right before </body>.

I realize this might result in some substantial rewriting of plugins already inserting <script> elements as they please, but I'm sure Grandma would really appreciate this. :wink:

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

Re: Invalid code in two plugins

Post by onli »

>but at least some of those insert <script> elements in the <head>, which isn't ideal, either.
Indeed. I used the footer sometimes, but this isn't a really good solution because some templates simply don't print a footer, the footer-event never gets executed.

I don't know if it's really a good idea to mess with that now, async (or better: defer) with html5 should solve the problem with script-tags in the head.
Post Reply