Ticket #914: admin_modify.diff

File admin_modify.diff, 1.4 KB (added by nesh <nesh [at] studioquattro [dot] co [dot] yu>, 18 years ago)

diff against [3411]

  • store/django/django/contrib/admin/templatetags/admin_modify.py

     
    1515def class_name_to_underscored(name):
    1616    return '_'.join([s.lower() for s in word_re.findall(name)[:-1]])
    1717
     18_URL_PATTERN = re.compile(r'''(?x)((http|https|ftp)://(\w+[:.]?){2,}(/?|[^ \n\r"']+[\w/!?.=#])(?=[\s\.,>)"'\]]))''')
    1819def include_admin_script(script_path):
    1920    """
    2021    Returns an HTML script element for including a script from the admin
     
    2728    could return::
    2829
    2930        <script type="text/javascript" src="/media/admin/js/calendar.js">
     31
     32    or (if you use absolute path)::
     33       
     34        {% include_admin_script /myjs/other.js %}
     35
     36    could return::
     37
     38        <script type="text/javascript" src="/myjs/other.js">
    3039    """
    3140
    32     return '<script type="text/javascript" src="%s%s"></script>' % (settings.ADMIN_MEDIA_PREFIX, script_path)
     41    if _URL_PATTERN.match(script_path) or script_path[0] == '/':
     42        return '<script type="text/javascript" src="%s"></script>' % (script_path)
     43    else:
     44        return '<script type="text/javascript" src="%s%s"></script>' % (settings.ADMIN_MEDIA_PREFIX, script_path)
    3345include_admin_script = register.simple_tag(include_admin_script)
    3446
    3547def submit_row(context):
Back to Top