Google Groups Home
Help | Sign in
adding css to custom widgets
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Matías Iturburu  
View profile
 More options Mar 28, 6:22 pm
From: "Matías Iturburu" <maturb...@gmail.com>
Date: Fri, 28 Mar 2008 19:22:51 -0300
Local: Fri, Mar 28 2008 6:22 pm
Subject: Re: adding css to custom widgets

Hi again. I've just founded this thread
http://groups.google.com/group/toscawidgets-discuss/browse_frm/thread...

where alberto gives nice instructions that I've followed and it's working.
Nevertheless I'm suffering the same issue that Chris (having
/toscawidgets/resources appended before to my modules'  path)

For alberto or anyone that knows. How can I prevent that from happening?

On Fri, Mar 28, 2008 at 5:53 PM, Matías Iturburu <maturb...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Horn  
View profile
 More options Mar 28, 7:34 pm
From: "Kevin Horn" <kevin.h...@gmail.com>
Date: Fri, 28 Mar 2008 18:34:07 -0500
Local: Fri, Mar 28 2008 7:34 pm
Subject: Re: [TurboGears] Re: adding css to custom widgets

On Fri, Mar 28, 2008 at 5:22 PM, Matías Iturburu <maturb...@gmail.com>
wrote:

Try this thread:

http://groups.google.com/group/toscawidgets-discuss/browse_frm/thread...

Does that help?

Kevin Horn


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matías Iturburu  
View profile
 More options Mar 28, 7:55 pm
From: "Matías Iturburu" <maturb...@gmail.com>
Date: Fri, 28 Mar 2008 20:55:20 -0300
Local: Fri, Mar 28 2008 7:55 pm
Subject: Re: [TurboGears] Re: adding css to custom widgets

Hi kevin, I've seen that post a little ago.
I'm quite noobish with python and try to avoid getting so low level in the
libraries. That said what I don't realize is how to override the prefix in
toscawidgets.middleware (although I've seen the code). Can you give me an
snipet please?.

What I'm doing to workaround this is to give the <link> right in the
template string but that makes the css link to render right in the middle of
the ul instead of placing it self properly in the head section so I think
it's not a really proper way to go.

Thanks for your feedback.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matías Iturburu  
View profile
 More options Mar 28, 4:53 pm
From: "Matías Iturburu" <maturb...@gmail.com>
Date: Fri, 28 Mar 2008 17:53:48 -0300
Local: Fri, Mar 28 2008 4:53 pm
Subject: adding css to custom widgets

Hi. I'm giving my first steps with toscawidgets and the like.

I've made myself a set of custom widgets, like this one:

class ContactList(Widget):
    params=['contact']
    contact={'title':'Nombre Contacto','phone':'Nombre
Contacto','email':'Nombre Contacto'}
    engine_name = 'genshi'
    template='''
            <div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="
http://genshi.edgewall.org/" py:strip="">
                <ul class="contactList">
                    <li><h3>Contactos</h3></li>
                        <li class="contactData">
                        <dl>
                            <dt><a href="${contact}" py:content="
contact.title">Nombre Contacto</a></dt>
                            <dd><span>Telefono:<span py:content="
contact.phone">2200202</span><br />
                                email:<span py:content="contact.email
">asdasddsd</span></span>
                            </dd>
                        </dl>
                        </li>
                    <li><a href="#">Agregar Contacto</a></li>

                </ul>
            </div>
        '''

and I want to encapsulate a stylesheet that get pulled when the widget is
instantiated.
I've been struggling with the toscawidgets' documentation but this kind of
things are laking or I'm too blind to see :P

Eventually I would like to do the proper with javascript so... is there an
easy way of registering this kind of resources (js, css) from the widget it
self and that those get pulled when the widget is intatiated?

I'm using tg 1.0 and genshi BTW.

Thanks in advance.

Matías Iturburu
Revoluciones Informáticas
www.revolucionesweb.com.ar


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Horn  
View profile
 More options Mar 29, 1:28 pm
From: "Kevin Horn" <kevin.h...@gmail.com>
Date: Sat, 29 Mar 2008 12:28:19 -0500
Local: Sat, Mar 29 2008 1:28 pm
Subject: Re: [TurboGears] Re: adding css to custom widgets

On Fri, Mar 28, 2008 at 6:55 PM, Matías Iturburu <maturb...@gmail.com>
wrote:

> Hi kevin, I've seen that post a little ago.
> I'm quite noobish with python and try to avoid getting so low level in the
> libraries. That said what I don't realize is how to override the prefix in
> toscawidgets.middleware (although I've seen the code). Can you give me an
> snipet please?.

> What I'm doing to workaround this is to give the <link> right in the
> template string but that makes the css link to render right in the middle of
> the ul instead of placing it self properly in the head section so I think
> it's not a really proper way to go.

> Thanks for your feedback.

I haven't dealt much with ToscaWidgets yet, but this bit looked helpful:

'''
As you've said, the /toscawidgets part is easy to override in
TGWidgetsMiddleware, however, the /resources part is trickier, but
possible:
from toscawidgets import resources
resources.registry = resources.ResourcesApp("/another_prefix")
'''

Kevin Horn


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matías Iturburu  
View profile
 More options Mar 29, 5:40 pm
From: "Matías Iturburu" <maturb...@gmail.com>
Date: Sat, 29 Mar 2008 18:40:58 -0300
Local: Sat, Mar 29 2008 5:40 pm
Subject: Re: [TurboGears] Re: adding css to custom widgets

Kevin, everyone:

May be I'm not being enough clear. Let me rewind for a second:

Take for instance a CSSLink daclared like this:

class MyWidget(Widget):
    css = [CSSLink(modname="aji", filename="css/jobList.css")]

that will render an url like this one:

/toscawidgets/resources/aji/css/jobList.css?v=0

where /toscawidgets/resources/ are hardcoded path from toscawidgets it self.
Note that the proper path would be /aji/static/css/jobList.css

if I do something like

resources.registry = resources.ResourcesApp("/static")
then it renders this way:

/toscawidgets/static/aji/css/jobList.css?v=0

my app name (aji) is put after the resources path and the /toscawidgets/ bit
reamins untouched.
From the post that kevin ponted me at. They suggest overriding the
/toscawidgets/ prefix from toscawidget.middleware (from another class I
think as it would brake the other widgets). That's the part I quite dont
understand how to do.

Any whay, having hardcoded paths is a really weird thing.
What should be the best practice in this case, to develop all my widgets
inside the tosca package, so it will share the path with the other widgets?

As I stated before I'm workwaround this issue inserting the link tag right
in my template string, this way:

class MyWidget(Widget):
    engine_name = 'genshi'
    template='''
            <py:strip xmlns="http://www.w3.org/1999/xhtml" xmlns:py="
http://genshi.edgewall.org/">
            <link rel="stylesheet" href="/static/css/jobList.css"
type="text/css" />
....

Which is, IMHO, throwing litter to the DOM. Is there any other way to work
around this issue?.

Thanks again


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google