Ticket #18847: use_static_url_in_formmedia_docs.patch

File use_static_url_in_formmedia_docs.patch, 7.6 KB (added by jamiecurle, 3 years ago)
  • docs/topics/forms/media.txt

    diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt
    index 4399e75..615dd71 100644
    a b through this property:: 
    6565
    6666    >>> w = CalendarWidget()
    6767    >>> print(w.media)
    68     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    69     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
    70     <script type="text/javascript" src="http://media.example.com/actions.js"></script>
     68    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     69    <script type="text/javascript" src="http://static.example.com/animations.js"></script>
     70    <script type="text/javascript" src="http://static.example.com/actions.js"></script>
    7171
    7272Here's a list of all possible ``Media`` options. There are no required options.
    7373
    requirements:: 
    110110
    111111If this last CSS definition were to be rendered, it would become the following HTML::
    112112
    113     <link href="http://media.example.com/pretty.css" type="text/css" media="screen" rel="stylesheet" />
    114     <link href="http://media.example.com/lo_res.css" type="text/css" media="tv,projector" rel="stylesheet" />
    115     <link href="http://media.example.com/newspaper.css" type="text/css" media="print" rel="stylesheet" />
     113    <link href="http://static.example.com/pretty.css" type="text/css" media="screen" rel="stylesheet" />
     114    <link href="http://static.example.com/lo_res.css" type="text/css" media="tv,projector" rel="stylesheet" />
     115    <link href="http://static.example.com/newspaper.css" type="text/css" media="print" rel="stylesheet" />
    116116
    117117``js``
    118118~~~~~~
    basic Calendar widget from the example above:: 
    140140
    141141    >>> w = FancyCalendarWidget()
    142142    >>> print(w.media)
    143     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    144     <link href="http://media.example.com/fancy.css" type="text/css" media="all" rel="stylesheet" />
    145     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
    146     <script type="text/javascript" src="http://media.example.com/actions.js"></script>
    147     <script type="text/javascript" src="http://media.example.com/whizbang.js"></script>
     143    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     144    <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet" />
     145    <script type="text/javascript" src="http://static.example.com/animations.js"></script>
     146    <script type="text/javascript" src="http://static.example.com/actions.js"></script>
     147    <script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
    148148
    149149The FancyCalendar widget inherits all the media from it's parent widget. If
    150150you don't want media to be inherited in this way, add an ``extend=False``
    declaration to the media declaration:: 
    160160
    161161    >>> w = FancyCalendarWidget()
    162162    >>> print(w.media)
    163     <link href="http://media.example.com/fancy.css" type="text/css" media="all" rel="stylesheet" />
    164     <script type="text/javascript" src="http://media.example.com/whizbang.js"></script>
     163    <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet" />
     164    <script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
    165165
    166166If you require even more control over media inheritance, define your media
    167167using a `dynamic property`_. Dynamic properties give you complete control over
    to filter out a medium of interest. For example:: 
    253253
    254254    >>> w = CalendarWidget()
    255255    >>> print(w.media)
    256     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    257     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
    258     <script type="text/javascript" src="http://media.example.com/actions.js"></script>
     256    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     257    <script type="text/javascript" src="http://static.example.com/animations.js"></script>
     258    <script type="text/javascript" src="http://static.example.com/actions.js"></script>
    259259
    260260    >>> print(w.media)['css']
    261     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     261    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    262262
    263263When you use the subscript operator, the value that is returned is a new
    264264Media object -- but one that only contains the media of interest.
    the resulting Media object contains the union of the media from both files:: 
    283283    >>> w1 = CalendarWidget()
    284284    >>> w2 = OtherWidget()
    285285    >>> print(w1.media + w2.media)
    286     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    287     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
    288     <script type="text/javascript" src="http://media.example.com/actions.js"></script>
    289     <script type="text/javascript" src="http://media.example.com/whizbang.js"></script>
     286    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     287    <script type="text/javascript" src="http://static.example.com/animations.js"></script>
     288    <script type="text/javascript" src="http://static.example.com/actions.js"></script>
     289    <script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
    290290
    291291Media on Forms
    292292--------------
    of adding the media definitions for all widgets that are part of the form:: 
    306306
    307307    >>> f = ContactForm()
    308308    >>> f.media
    309     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    310     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
    311     <script type="text/javascript" src="http://media.example.com/actions.js"></script>
    312     <script type="text/javascript" src="http://media.example.com/whizbang.js"></script>
     309    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     310    <script type="text/javascript" src="http://static.example.com/animations.js"></script>
     311    <script type="text/javascript" src="http://static.example.com/actions.js"></script>
     312    <script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
    313313
    314314If you want to associate additional media with a form -- for example, CSS for form
    315315layout -- simply add a media declaration to the form::
    layout -- simply add a media declaration to the form:: 
    325325
    326326    >>> f = ContactForm()
    327327    >>> f.media
    328     <link href="http://media.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
    329     <link href="http://media.example.com/layout.css" type="text/css" media="all" rel="stylesheet" />
    330     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
    331     <script type="text/javascript" src="http://media.example.com/actions.js"></script>
    332     <script type="text/javascript" src="http://media.example.com/whizbang.js"></script>
     328    <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
     329    <link href="http://static.example.com/layout.css" type="text/css" media="all" rel="stylesheet" />
     330    <script type="text/javascript" src="http://static.example.com/animations.js"></script>
     331    <script type="text/javascript" src="http://static.example.com/actions.js"></script>
     332    <script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
Back to Top