Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
9d91ef5b
Commit
9d91ef5b
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
update the delivery of the index.html page so that we can inject values into it dynamically.
parent
14123646
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/routes.clj
+24
-2
24 additions, 2 deletions
src/metabase/routes.clj
with
24 additions
and
2 deletions
src/metabase/routes.clj
+
24
−
2
View file @
9d91ef5b
...
...
@@ -2,8 +2,28 @@
(
:require
[
compojure.core
:refer
[
context
defroutes
GET
]]
[
compojure.route
:as
route
]
[
ring.util.response
:as
resp
]
[
stencil.core
:as
stencil
]
[
metabase.api.routes
:as
api
]
[
metabase.setup
:as
setup
]))
[
metabase.setup
:as
setup
]
[
metabase.util
:as
u
]))
(
defn-
load-index-template
"Slurp in the Metabase index.html file as a `String`"
[]
(
slurp
(
clojure.java.io/resource
"frontend_client/index.html"
)))
(
def
load-index
"Memoized version of `load-index-template`"
;(memoize load-index-template)
load-index-template
)
(
def
date-format-rfc2616
"Java SimpleDateFormat representing rfc2616 style date used in http headers."
"EEE, dd MMM yyyy HH:mm:ss zzz"
)
(
def
index-page-vars
"Static values that we inject into the index.html page via Mustache."
{
:ga_code
"UA-60817802-1"
})
;; Redirect naughty users who try to visit a page other than setup if setup is not yet complete
(
let
[
redirect-to-setup?
(
fn
[{
:keys
[
uri
]}]
...
...
@@ -11,7 +31,9 @@
(
not
(
re-matches
#
"^/setup/.*$"
uri
))))
index
(
fn
[
request
]
(
if
(
redirect-to-setup?
request
)
(
resp/redirect
(
format
"/setup/init/%s"
(
setup/token-value
)))
(
resp/resource-response
"frontend_client/index.html"
)))]
(
->
(
resp/response
(
stencil/render-string
(
load-index
)
index-page-vars
))
(
resp/content-type
"text/html"
)
(
resp/header
"Last-Modified"
(
u/now-with-format
date-format-rfc2616
)))))]
(
defroutes
routes
(
GET
"/"
[]
index
)
; ^/$ -> index.html
(
GET
"/favicon.ico"
[]
(
resp/resource-response
"frontend_client/favicon.ico"
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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