Skip to content
Snippets Groups Projects
Commit 0794f5cb authored by Tom Robinson's avatar Tom Robinson
Browse files

Merge branch 'fix_angular_bootstrap' of github.com:metabase/metabase-init into direct_manipulation

parents be7c101b 4620e5a5
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@
[org.clojure/core.memoize "0.5.7"] ; needed by core.match; has useful FIFO, LRU, etc. caching mechanisms
[org.clojure/data.csv "0.1.2"] ; CSV parsing / generation
[org.clojure/java.classpath "0.2.2"]
[org.clojure/java.jdbc "0.3.7"] ; basic jdbc access from clojure
[org.clojure/java.jdbc "0.4.1"] ; basic jdbc access from clojure
[org.clojure/math.numeric-tower "0.0.4"] ; math functions like `ceil`
[org.clojure/tools.logging "0.3.1"] ; logging framework
[org.clojure/tools.macro "0.1.5"] ; tools for writing macros
......
......@@ -23,7 +23,7 @@
</div>
<div class="Form-field">
<ul class="Checkbox-group Form-offset">
<ul class="Form-offset">
<input name="remember" type="checkbox" ng-init="remember_me = true" ng-model="remember_me" checked> <label class="inline-block">Remember Me:</label>
</ul>
</div>
......
......@@ -13,11 +13,11 @@ import 'angular-route';
import 'angular-sanitize';
// angular 3rd-party:
import 'angular-bootstrap';
import 'angular-cookie';
import 'angular-gridster';
import 'angular-http-auth'; // currently pulled from unofficial fork: https://github.com/witoldsz/angular-http-auth/pull/100
import 'angular-readable-time';
import 'angular-ui-bootstrap';
import 'angular-xeditable';
import 'ng-sortable';
import 'angularytics';
......
......@@ -46,11 +46,11 @@
(s/replace #"/$" "")) ; strip off trailing slash if one was included
(-site-url (or origin host))))
(def app
"The primary entry point to the HTTP server"
(-> routes/routes
(log-api-call :request :response)
add-security-headers ; [METABASE] Add HTTP headers to API responses to prevent them from being cached
format-response ; [METABASE] Do formatting before converting to JSON so serializer doesn't barf
(wrap-json-body ; extracts json POST body and makes it avaliable on request
{:keywords? true})
......
......@@ -3,6 +3,7 @@
(cheshire factory
[generate :refer [add-encoder encode-str]])
[medley.core :refer [filter-vals map-vals]]
[metabase.middleware.log-api-call :refer [api-call?]]
[metabase.models.interface :refer [api-serialize]]
[metabase.util :as util]))
......@@ -32,6 +33,15 @@
(add-encoder java.sql.Date (fn [^java.sql.Date date ^com.fasterxml.jackson.core.JsonGenerator json-generator]
(.writeString json-generator (.toString date))))
(defn add-security-headers
"Add HTTP headers to tell browsers not to cache API responses."
[handler]
(fn [request]
(let [response (handler request)]
(update response :headers merge (when (api-call? request)
{"Cache-Control" "max-age=0, no-cache, must-revalidate, proxy-revalidate"
"Expires" "Tue, 03 Jul 2001 06:00:00 GMT" ; rando date in the past
"Last-Modified" "{now} GMT"})))))
;; ## FORMAT RESPONSE MIDDLEWARE
(defn format-response
......
......@@ -50,7 +50,7 @@
(log-response request response elapsed-time))
response))))))
(defn- api-call?
(defn api-call?
"Is this ring request an API call (does path start with `/api`)?"
[{:keys [^String uri]}]
(and (>= (count uri) 4)
......
......@@ -72,7 +72,7 @@ module.exports = {
'angular-route': __dirname + '/node_modules/angular-route/angular-route.min.js',
'angular-sanitize': __dirname + '/node_modules/angular-sanitize/angular-sanitize.min.js',
// angular 3rd-party
'angular-bootstrap': __dirname + '/node_modules/angular-bootstrap/dist/ui-bootstrap-tpls.min.js',
'angular-ui-bootstrap': __dirname + '/node_modules/angular-ui-bootstrap/ui-bootstrap-tpls.min.js',
'angular-cookie': __dirname + '/node_modules/angular-cookie/angular-cookie.min.js',
'angular-gridster': __dirname + '/node_modules/angular-gridster/dist/angular-gridster.min.js',
'angular-http-auth': __dirname + '/node_modules/angular-http-auth/src/http-auth-interceptor.js',
......
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