Re: [Zope3-Users] Re: How to make a new namespace for pagetemplates?
Hi, On Fri, Sep 08, 2006 at 01:45:45PM +0200, Philipp von Weitershausen wrote: [snip] > Write a new TALES expression type (like string: or python:) that constructs > link tags. > This could like: > > > link goes here > > > The link: expression would split the argument string, take the first part as > the URL and > the second one as the link description. Both would be fed through the > PathExpression so > that they're evaluated. > > Custom TALES expression types are components providing > zope.tales.interfaces.ITALESExpression. Look at zope.tales.expressions for > the > implementation of the standard TALES expressions. Perfect :-) . That's what I'll do. Thank you, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: How to make a new namespace for pagetemplates?
On 9/8/06, Philipp von Weitershausen <[EMAIL PROTECTED]> wrote: * Solution outside of Zope. Martijn suggested a JavaScript. If you need it to work for non-JavaScript browsers, I suggest a WSGI middleware that checks for text/html data and transforms elements as needed. You could do the transformation in XSLT or Python (e.g. via elementtree). Or do as zc.resourcelibrary does; implement a subclass of BrowserResponse that does the transformation for you. Then override the default request (so it'll use your response). See http://svn.zope.org/zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py?rev=69889&view=auto and http://svn.zope.org/zc.resourcelibrary/trunk/src/zc/resourcelibrary/configure.zcml?rev=68929&view=auto -- Martijn Pieters ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: How to make a new namespace for pagetemplates?
Philipp von Weitershausen wrote: Martin Aspeli wrote: 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. "Post processing" literally screams WSGI middleware to me. * I'd like to know, how to make a new pagetemplate namespace :-). Be open minded, Frank :). I think you really just want a more convenient spelling for generating URLs -- which is absolutely (forgot to finish sentence) -- which is abolutely fine. There's just not one solution to the problem, and surely not the one you had in mind. Sorry :( ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: How to make a new namespace for pagetemplates?
Martin Aspeli wrote: 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. "Post processing" literally screams WSGI middleware to me. * I'd like to know, how to make a new pagetemplate namespace :-). Be open minded, Frank :). I think you really just want a more convenient spelling for generating URLs -- which is absolutely 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. That's a new TALES expression type. It's not what Frank originally wants (he wants a custom tal/metal/i18n like namespace for PageTemplates which is nearly impossible -- and unnecessary). But the pointer to the zope.contentprovider package is good indeed because in my earlier reply I suggested to write a custom TALES expression type and the zope.contentprovider package sets one up. Philipp ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: How to make a new namespace for pagetemplates?
FB 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. 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? It would involve hacking Page Template sources beyond recoginition :). There are several ways to tackle your problem: * Solution outside of Zope. Martijn suggested a JavaScript. If you need it to work for non-JavaScript browsers, I suggest a WSGI middleware that checks for text/html data and transforms elements as needed. You could do the transformation in XSLT or Python (e.g. via elementtree). * Solution within Page Templates: Write a new TALES expression type (like string: or python:) that constructs link tags. This could like: link goes here The link: expression would split the argument string, take the first part as the URL and the second one as the link description. Both would be fed through the PathExpression so that they're evaluated. Custom TALES expression types are components providing zope.tales.interfaces.ITALESExpression. Look at zope.tales.expressions for the implementation of the standard TALES expressions. * Solution outside Page Templates: Write a view for all objects that you want to generate URLs from. The feasibility of this solution depends on whether you always have objects with 'url' and 'urldescription' attributes (or similar) to generate links from. Then you could write: link goes here The html_link view would generate the whole tag accordingly. If you'd like to keep things flexible, the html_link view would first adapt the context to something like ILinkInformation that has the 'url' and 'urldescription' attributes. HTH Philipp ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users