Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-basetheme-bootstrap
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bryan BRANCOTTE
django-basetheme-bootstrap
Commits
ff25747d
Commit
ff25747d
authored
5 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
keep in cache the url computed for sstatic
parent
30bc2dc6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#14211
passed with stage
in 29 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
basetheme_bootstrap/templates/basetheme_bootstrap/basePasteur.html
+5
-6
5 additions, 6 deletions
..._bootstrap/templates/basetheme_bootstrap/basePasteur.html
basetheme_bootstrap/templatetags/sstatic.py
+17
-4
17 additions, 4 deletions
basetheme_bootstrap/templatetags/sstatic.py
with
22 additions
and
10 deletions
basetheme_bootstrap/templates/basetheme_bootstrap/basePasteur.html
+
5
−
6
View file @
ff25747d
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
{% load static %}
{% load sstatic %}
{% load basetheme_bootstrap %}
{% load i18n %}
...
...
@@ -19,9 +18,9 @@
<link
href=
"https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"
rel=
"stylesheet"
>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/10.0.0/css/bootstrap-slider.min.css"
/>
<link
rel=
"stylesheet"
href=
"{% static '/css/bootstrap-multiselect.css' %}"
type=
"text/css"
/>
<link
rel=
"stylesheet"
href=
"{% static '/css/basetheme_bootstrap4_pasteur.css' %}"
/>
<link
rel=
"stylesheet"
href=
"{% static '/css/fonts.css' %}"
/>
<link
rel=
"stylesheet"
href=
"{%
s
static '/css/bootstrap-multiselect.css' %}"
type=
"text/css"
/>
<link
rel=
"stylesheet"
href=
"{%
s
static '/css/basetheme_bootstrap4_pasteur.css' %}"
/>
<link
rel=
"stylesheet"
href=
"{%
s
static '/css/fonts.css' %}"
/>
{% block extra_css %}{% endblock %}
</head>
<body
class=
"d-flex flex-column h-100"
>
...
...
@@ -187,12 +186,12 @@
<script
src=
"https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"
></script>
<script
src=
"https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"
></script>
<script
src=
"https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"
></script>
<script
type=
"text/javascript"
src=
"{% static '/js/bootstrap-multiselect.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{%
s
static '/js/bootstrap-multiselect.js' %}"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"
></script>
<script
src=
"https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"
></script>
<script
src=
"https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"
></script>
<script
src=
"{% static '/js/basetheme_bootstrap.js' %}"
></script>
<script
src=
"{%
s
static '/js/basetheme_bootstrap.js' %}"
></script>
{% block extra_js %}{% endblock %}
</html>
This diff is collapsed.
Click to expand it.
basetheme_bootstrap/templatetags/sstatic.py
+
17
−
4
View file @
ff25747d
...
...
@@ -4,6 +4,7 @@ import string
from
django
import
template
from
django.conf
import
settings
from
django.core.cache
import
cache
# credits : https://bitbucket.org/ad3w/django-sstatic
...
...
@@ -12,15 +13,27 @@ register = template.Library()
@register.simple_tag
def
sstatic
(
path
):
url
=
cache
.
get
(
path
)
if
url
:
return
url
url
=
compute_url_for_path
(
path
)
cache
.
set
(
path
,
url
,
None
)
return
url
def
compute_url_for_path
(
path
):
'''
Returns absolute URL to static file with versioning.
'''
full_path
=
os
.
path
.
join
(
settings
.
STATIC_ROOT
,
path
[
1
:]
if
path
[
0
]
==
'
/
'
else
path
)
try
:
full_path
=
os
.
path
.
join
(
settings
.
STATIC_ROOT
,
path
[
1
:]
if
path
[
0
]
==
'
/
'
else
path
)
# Get file modification time.
mtime
=
os
.
path
.
getmtime
(
full_path
)
return
'
%s%s?%s
'
%
(
settings
.
STATIC_URL
[:
-
1
],
path
,
mtime
)
except
OSError
:
# Returns normal url if this file was not found in filesystem.
return
'
%s%s?%s
'
%
(
settings
.
STATIC_URL
[:
-
1
],
path
,
''
.
join
(
random
.
choice
(
''
.
join
((
string
.
ascii_letters
,
string
.
digits
)))
for
_
in
range
(
32
)))
pass
except
TypeError
:
pass
# Returns normal url if this file was not found in filesystem.
return
'
%s%s?%s
'
%
(
settings
.
STATIC_URL
[:
-
1
],
path
,
''
.
join
(
random
.
choice
(
''
.
join
((
string
.
ascii_letters
,
string
.
digits
)))
for
_
in
range
(
4
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment