Skip to content
Snippets Groups Projects
Commit 16638ea8 authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

Merge branch 'fix_codemirror_widget_resources_links' into '1.4.x'

Refactor version fingerprinting for code mirror widgets

See merge request !254
parents efec99a5 acac2646
No related branches found
No related tags found
2 merge requests!2551.4.x,!254Refactor version fingerprinting for code mirror widgets
Pipeline #24563 passed
...@@ -125,6 +125,20 @@ class CodeMirrorJSONEncoder(json.JSONEncoder): ...@@ -125,6 +125,20 @@ class CodeMirrorJSONEncoder(json.JSONEncoder):
self.stash = {} self.stash = {}
return encoded return encoded
class FingerPrintedMedia(forms.Media):
"""Subclass that adds version fingerprinting to the Media urls
"""
def absolute_path(self, path):
"""Reimplementation to add version fingerprint to ensure file is served
for the latest version of the application
"""
abs_path = super(FingerPrintedMedia, self).absolute_path(path)
abs_path += '?v={}'.format(__version__)
return abs_path
class CodeMirrorTextarea(forms.Textarea): class CodeMirrorTextarea(forms.Textarea):
u"""Textarea widget render with `CodeMirror` u"""Textarea widget render with `CodeMirror`
...@@ -167,13 +181,8 @@ class CodeMirrorTextarea(forms.Textarea): ...@@ -167,13 +181,8 @@ class CodeMirrorTextarea(forms.Textarea):
"%s/addon/fold/foldgutter.css" % CODEMIRROR_PATH, "%s/addon/fold/foldgutter.css" % CODEMIRROR_PATH,
) )
# adds version fingerprinting to javascript/css files return FingerPrintedMedia(css={'all': css}, js=js)
js = ['%s?v=%s' % (k, __version__) for k in js]
css = ['%s?v=%s' % (k, __version__) for k in css]
return forms.Media(css={'all': css},
js=js
)
def __init__( def __init__(
self, attrs=None, mode=None, theme=None, config=None, size=None, self, attrs=None, mode=None, theme=None, config=None, size=None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment