Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
3f9a3d63
Commit
3f9a3d63
authored
Oct 18, 2015
by
Gero Müller
Browse files
add cache busting
parent
990b7394
Changes
3
Hide whitespace changes
Inline
Side-by-side
conf/vispa.ini.sample
View file @
3f9a3d63
...
...
@@ -63,6 +63,9 @@ enable_guest_login = False
# default workspace action, i.e. a vispa.callbacks channel
workspace_action = openFileBrowser
# cache busting: uuid, mtime:<filename>, string
#cache_bust = uuid
[websockets]
enabled = False
...
...
vispa/controller/root.py
View file @
3f9a3d63
...
...
@@ -5,6 +5,7 @@ import StringIO
import
inspect
import
logging
import
os
import
uuid
from
vispa.controller
import
AbstractController
,
strongly_expire
from
vispa.controller.ajax
import
AjaxController
...
...
@@ -43,6 +44,20 @@ class RootController(AbstractController):
if
not
vispa
.
config
(
"web"
,
"dev_mode"
,
True
):
self
.
error
=
ErrorController
()
self
.
workspace_action
=
vispa
.
config
(
"web"
,
"workspace_action"
,
""
)
self
.
use_websockets
=
vispa
.
config
(
"websockets"
,
"enabled"
,
False
)
self
.
client_log_level
=
vispa
.
config
(
"web"
,
"logging.level"
,
"info"
)
self
.
add_workspaces
=
vispa
.
config
(
"workspace"
,
"add"
,
True
)
self
.
alter_workspaces
=
vispa
.
config
(
"workspace"
,
"alter"
,
True
)
self
.
use_feedback
=
vispa
.
config
(
"web"
,
"feedback.address"
,
""
)
!=
""
self
.
cache_bust
=
vispa
.
config
(
"web"
,
"cache_bust"
,
""
)
if
self
.
cache_bust
==
"uuid"
:
self
.
cache_bust
=
str
(
uuid
.
uuid4
())
elif
self
.
cache_bust
.
startswith
(
"mtime:"
):
self
.
cache_bust
=
str
(
os
.
path
.
getmtime
(
self
.
cache_bust
[
6
:]))
elif
len
(
self
.
cache_bust
)
==
0
:
self
.
cache_bust
=
None
def
mount_extension_controller
(
self
,
mountpoint
,
controller
):
if
hasattr
(
self
.
extensions
,
mountpoint
):
logger
.
warning
(
"Controller mountpoint already exists: %s"
%
mountpoint
)
...
...
@@ -113,28 +128,23 @@ class RootController(AbstractController):
@
cherrypy
.
tools
.
render
(
template
=
"sites/index.mako"
)
@
cherrypy
.
tools
.
method
(
accept
=
"GET"
)
def
index
(
self
,
*
args
,
**
kwargs
):
db
=
cherrypy
.
request
.
db
db
=
cherrypy
.
request
.
db
user
=
cherrypy
.
request
.
user
use_websockets
=
vispa
.
config
(
"websockets"
,
"enabled"
,
False
)
preferences
=
self
.
get_preferences
(
db
,
cherrypy
.
request
.
user
.
id
,
preferences
=
self
.
get_preferences
(
db
,
cherrypy
.
request
.
user
.
id
,
parse_json
=
True
)
client_log_level
=
vispa
.
config
(
"web"
,
"logging.level"
,
"info"
)
add_workspaces
=
vispa
.
config
(
"workspace"
,
"add"
,
True
)
alter_workspaces
=
vispa
.
config
(
"workspace"
,
"alter"
,
True
)
use_feedback
=
vispa
.
config
(
"web"
,
"feedback.address"
,
""
)
!=
""
data
=
{
"username"
:
user
.
name
,
"usermail"
:
user
.
email
,
"use_websockets"
:
use_websockets
,
"add_workspaces"
:
add_workspaces
,
"alter_workspaces"
:
alter_workspaces
,
"log_level"
:
client_log_level
,
"use_feedback"
:
use_feedback
,
"use_websockets"
:
self
.
use_websockets
,
"add_workspaces"
:
self
.
add_workspaces
,
"alter_workspaces"
:
self
.
alter_workspaces
,
"log_level"
:
self
.
client_log_level
,
"use_feedback"
:
self
.
use_feedback
,
"is_guest"
:
cherrypy
.
session
.
get
(
"is_guest"
,
False
),
"workspace_action"
:
vispa
.
config
(
"web"
,
"workspace_action"
,
""
),
"extensions"
:
JSON
.
dumps
(
self
.
_server
.
_extensions
.
keys
())
"workspace_action"
:
self
.
workspace_action
,
"extensions"
:
JSON
.
dumps
(
self
.
_server
.
_extensions
.
keys
()),
"cache_bust"
:
self
.
cache_bust
,
}
data
.
update
(
preferences
)
...
...
@@ -185,7 +195,8 @@ class RootController(AbstractController):
"registration_text"
:
registration_text
,
"forgot_text"
:
forgot_text
,
"disclaimer_text"
:
disclaimer_text
,
"use_forgot"
:
use_forgot
"use_forgot"
:
use_forgot
,
"cache_bust"
:
self
.
cache_bust
,
}
@
cherrypy
.
expose
...
...
vispa/templates/vispa.mako
View file @
3f9a3d63
...
...
@@ -15,7 +15,11 @@
</%block>
<%block name="js_imports_pre">
<script src="${base_static}vendor/requirejs/require.js"></script>
% if cache_bust:
<script src="${base_static}vendor/requirejs/require.js?bust=${cache_bust}"></script>
% else:
<script src="${base_static}vendor/requirejs/require.js"></script>
% endif
</%block>
<%block name="js_inline_post">
...
...
@@ -53,7 +57,11 @@
css: "${base_static}vendor/requirejs/plugins/require-css.js"
}
},
urlArgs: ${"'bust=' + (new Date()).getTime()" if dev_mode else "undefined"}
% if dev_mode:
urlArgs: 'bust=' + (new Date()).getTime()
% elif cache_bust:
urlArgs: 'bust=${cache_bust}'
% endif
});
var deps = [
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment