The Artima Developer Community
Sponsored Link

Python Buzz Forum
Extending overlays

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
Extending overlays Posted: Feb 13, 2006 11:04 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: Extending overlays
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

The more I think about the overlay code I mentioned in my previous post the more I want it. But the actual implementation doesn't seem sufficient to me... it's very vague that when ids simply overlap they get merged, and there's no way to indicate an id you mean to be merged and one you want to use for some other purpose. Also, the overlay itself can't pull in external resources, which I want. And lastly, while expressions might not be necessary, I think some form of cascading is good. For instance, if you have an <h1> element that you want to take either the document title or something by the id html-title (which can contain markup), there should be a way to express that.

Now that I think about it, there should also be a way to merge the head elements entirely, probably with some knowledge of the semantics of HTML (like one <title> element).

So, here's an idea:

  • <link rel="overlay" type="text/x-name-of-this-spec" href="..."> enables this. Plus, perhaps, some Javascript in the head (if you aren't doing server-side resolution). That javascript should look like <script src="..." type="text/javascript" overlay="1"></script>, and any server-side processor will strip that out.
  • In the overlay, you can use an attribute slot="id1 id2 ...". This will fill the slow with the content of id1, or id2 if id1 is not present. If no id is present, the content will be left in-tact.
  • In the overlay [or other content?] you can have include="uri#fragment". This includes the given URI. If a fragment is given, then the content of the element by id is included, and the rest is thrown away. [Should the content of the head be kept/merged? Should there be other things besides simple id matching to include bits, like XPath or somesuch?]
  • The contents of <head> are merged. <meta> tags that match (i.e., the http-equiv or name attribute match) are removed. Duplicate titles are removed. I think that's all I care about. The first document (the one that links to the overlay) gets priority, then the overlay, then included content (if included content's head stuff is included at all). Other content, like scripts and styles and links, are all thrown together in the head from all sources.

I think that's it. Damn, that shouldn't be hard to implement. But I must keep myself from implementing it, because I'm really trying to get the last few loose ends together for a Paste 0.4 release. Must... stop... self...

The one pain in the ass part of this is parsing HTML. Easy in Javascript, but not in Python. With parsed markup, this is super-easy to implement.

Read: Extending overlays

Topic: Zope, flames and the Koolaid remark Previous Topic   Next Topic Topic: Break

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use