Ticket #914: admin_modify.diff
File admin_modify.diff, 1.4 KB (added by , 18 years ago) |
---|
-
store/django/django/contrib/admin/templatetags/admin_modify.py
15 15 def class_name_to_underscored(name): 16 16 return '_'.join([s.lower() for s in word_re.findall(name)[:-1]]) 17 17 18 _URL_PATTERN = re.compile(r'''(?x)((http|https|ftp)://(\w+[:.]?){2,}(/?|[^ \n\r"']+[\w/!?.=#])(?=[\s\.,>)"'\]]))''') 18 19 def include_admin_script(script_path): 19 20 """ 20 21 Returns an HTML script element for including a script from the admin … … 27 28 could return:: 28 29 29 30 <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"> 30 39 """ 31 40 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) 33 45 include_admin_script = register.simple_tag(include_admin_script) 34 46 35 47 def submit_row(context):