Re: [Zope3-Users] How to make a new namespace for pagetemplates?
FB wrote: Hi, On Fri, Sep 08, 2006 at 12:54:14PM +0200, Martijn Pieters wrote: On 9/8/06, FB <[EMAIL PROTECTED]> wrote: my employer want to have all external links marked with a small icon telling anonymous users from the internet that everything behind given links is beyond our responsibility. Why not use a piece of javascript to do this? See the linkpopper product on plone.org for a way to process all links in a page and process them. That product makes external links open in a new window, but the code should be easy to alter. Thank you for the hint. But there are several reasons for not using JS: * One of the constraints of that site is javascript being optional. Problem ist: marked links are mandatory - they have to be marked even with javascript turned off. * I'd like to have a tag-postprocessing namespace for some other reasons, too - e.g. for a printing-view that automatically creates a list of links at the end of the page. * I'd like to know, how to make a new pagetemplate namespace :-). As a follow-on to Philipp's comment about WSGI middleware: It could be fairly easy (to be sure, not *really* easy) to do a search-and-replace for link tags and do appropriate alterations in WSGI middleware. If I were doing this, I might re-parse the document in middleware using lxml, then do an xpath query to find the locations in the document that need changing. Then, it would be a matter of using the elementtree API to make the changes. lxml.etree.tounicode() would put the page back together for output. Since outgoing pages generated with ZPT are generally parseable, this might work OK. N.B., You may have to use the DTD at some point with this method. Lxml will attempt to xml-minimize (e.g., ) all tags without text content, so you will have to assure that this does not happen where it shouldn't. If you are not too married to generating pages with ZPT, and if you like the elementtree API, there is also a possibility of a lxml/elementtree (python-only) method for generating pages, which can have a method for post-processing the page, in a manner like the above, except that the document stays in a parsed state until it is output by Zope. I have a working base class for this. I call it XTemplate. It's not-quite-ready-for-prime-time (no docs or tests, yet, and you have to do skinning within this framework), but if there is interest, I should be able to release a preview in the near future. -Jim Washington ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to make a new namespace for pagetemplates?
FB-5 wrote: > >> >my employer want to have all external links marked with a small icon >> telling >> >anonymous users from the internet that everything behind given links is >> >beyond our responsibility. >> >> Why not use a piece of javascript to do this? See the linkpopper >> product on plone.org for a way to process all links in a page and >> process them. That product makes external links open in a new window, >> but the code should be easy to alter. > > Thank you for the hint. > > But there are several reasons for not using JS: >* One of the constraints of that site is javascript being optional. > Problem ist: marked links are mandatory - they have to be marked > even with javascript turned off. >* I'd like to have a tag-postprocessing namespace for some other > reasons, too - e.g. for a printing-view that automatically creates > a list of links at the end of the page. >* I'd like to know, how to make a new pagetemplate namespace :-). > It's fairly annoying to have to change every view that may or may not parse links, though. Think also about the case when links are coming from HTML (possibly transformed from some other format?) inside some content object rendered via a view. Look at zope.contentprovider, though. It sets up the provider: namespace. It's fairly simple. Martin -- View this message in context: http://www.nabble.com/How-to-make-a-new-namespace-for-pagetemplates--tf2238315.html#a6207359 Sent from the Zope3 - users forum at Nabble.com. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to make a new namespace for pagetemplates?
Hi, On Fri, Sep 08, 2006 at 12:54:14PM +0200, Martijn Pieters wrote: > On 9/8/06, FB <[EMAIL PROTECTED]> wrote: > >my employer want to have all external links marked with a small icon telling > >anonymous users from the internet that everything behind given links is > >beyond our responsibility. > > Why not use a piece of javascript to do this? See the linkpopper > product on plone.org for a way to process all links in a page and > process them. That product makes external links open in a new window, > but the code should be easy to alter. Thank you for the hint. But there are several reasons for not using JS: * One of the constraints of that site is javascript being optional. Problem ist: marked links are mandatory - they have to be marked even with javascript turned off. * I'd like to have a tag-postprocessing namespace for some other reasons, too - e.g. for a printing-view that automatically creates a list of links at the end of the page. * I'd like to know, how to make a new pagetemplate namespace :-). Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to make a new namespace for pagetemplates?
On 9/8/06, FB <[EMAIL PROTECTED]> wrote: my employer want to have all external links marked with a small icon telling anonymous users from the internet that everything behind given links is beyond our responsibility. Why not use a piece of javascript to do this? See the linkpopper product on plone.org for a way to process all links in a page and process them. That product makes external links open in a new window, but the code should be easy to alter. -- Martijn Pieters ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] How to make a new namespace for pagetemplates?
Hi, my employer want to have all external links marked with a small icon telling anonymous users from the internet that everything behind given links is beyond our responsibility. Currenty I have to do something like that: ... which doesn't really looks like a nice method to produce i.e. this: http://example.com";>This is an example company The 'linkwriter' chooses the a-tag's class and title according to the domain of the href. I would like to make writing those pagetemplates a bit easier - maybe like that: How complicated is it to write an additional pagetemplate namespace which is able to "postprocess" a tag, after 'tal', 'i18n' and 'metal' did their work? Thank you, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users