cleaner working version

This commit is contained in:
Yann Esposito 2015-09-01 14:35:50 +02:00
parent c96c1e4bca
commit ecfd91d960
4 changed files with 49 additions and 41 deletions

View file

@ -33,6 +33,7 @@ table {border-collapse: collapse;border-spacing: 0;}
.anchor:hover {opacity:0.9;}
img.userpic { filter: saturate(0); -webkit-filter: saturate(0); }
img.userpic:hover { filter: none; -webkit-filter: none; }
.tweet:hover {cursor:pointer;}
</style>
</head>
<body>

View file

@ -10,8 +10,8 @@
(enable-console-print!)
;; INIT
(init! {:title "I'm the Title"
:subtitle "Atom Sub Title"
(init! {:title "Vigiglobe"
:subtitle "Second Page"
:vgapi vgapi/initial-state
})
@ -27,14 +27,14 @@
(def ease1 (animation/easer 0.0))
(def ease2 (animation/easer 0.3))
(def ease3 (animation/easer 0.0))
(def ease3 (animation/easer 3.14))
(def ease4 (animation/easer 0.0))
(def complex-transition
(animation/easing-chain
[[ease1 0.5 1.0 400 animation/linear]
[ease2 0.3 1.0 400 animation/linear]
[ease3 0.0 360.0 600 animation/linear]
[[ease1 0.5 1.0 1400 animation/linear]
[ease2 0.1 1.0 400 animation/linear]
[ease3 3.14 0.0 600 animation/quad-out]
]))
(def orange "#E67E22")
@ -48,12 +48,10 @@
(defn animated-title [text]
[:h1 {:style
{:font-size (rx (str (* 5 @ease1) "vh"))
{:font-size (rx (str (* 10 @ease1) "vh"))
:padding-top (rx (str (* 10 @ease1) "vh"))
:opacity (rx (str @ease2))
:transform (rx (str "rotate(" @ease3 "deg)"))
:-webkit-transform (rx (str "rotate(" @ease3 "deg)"))
:-ms-transform (rx (str "rotate(" @ease3 "deg)"))
:-webkit-transform (rx (str "translateX(" (* 20 @ease3 (Math/sin (* 30 @ease3))) "px) rotate(" (* 5 (Math/sin (* 30 @ease3))) "deg)"))
:text-align "center"
:text-shadow (str "1px 3px 0 rgba(0,0,0,0.1)")
:line-height "2em"
@ -87,7 +85,7 @@
[:div
[animated-title (gets [:title])]
[:div.project {:style {:font-family "Monaco,monospace" :opacity 0.5}}
(gets [:vgapi :project-id])]
(drop 1 (clojure.string/split (gets [:vgapi :project-id]) "-"))]
[:div
{:style {:opacity (rx (str @ease4))
:-webkit-filter (rx (str "blur(" (* 15 (- 1 @ease4)) "px)"))}

View file

@ -138,29 +138,27 @@
(let [original-text (if (:reshared message)
(get-in message [:retweeted_status :text])
(:text message))]
[:p {:style {:cursor "pointer"
:line-height "1.2em"}
:on-click #(let [target (js/$ (aget % "target"))
el-type (aget target 0 "localName")]
(when-not (= el-type "a")
(open (tweet-url message))))
:class "text"}
[:p.text {:style {:line-height "1.2em"}}
original-text]))
(defn message [message height & params]
"Message component"
(when message
[:div {:style {:height (str height "vh")
:line-height "1.6em"
:width "99%"
; :-webkit-filter "blur(1px)"
:background "rgba(0,0,0,0.9)"
:margin "1px"
:color "rgba(255,255,255,0.8)"
:font-size "0.3em"
:overflow "hidden"
}}
[:div.tweet
{:style {:height (str height "vh")
:line-height "1.6em"
:width "99%"
; :-webkit-filter "blur(1px)"
:background "rgba(0,0,0,0.9)"
:margin "1px"
:color "rgba(255,255,255,0.8)"
:font-size "0.3em"
:overflow "hidden"
}
:on-click #(open (tweet-url message))
}
[user-pic {:message message}]
[user-name message params]
; [user-name message params]
[text message]
[actions-holder message params]]))
; [actions-holder message params]
]))

View file

@ -19,6 +19,10 @@
:project-id "vigiglobe-Microsoft"
:msg "Nothing done yet."})
(def time-protection 10000)
(def time-period 10000)
(def time-period-margin 90000)
;; ------------------------------------------------------------------------------
;; Tasks
;; ------------------------------------------------------------------------------
@ -30,9 +34,9 @@
(smart-si
(fn []
(go (let [now (.getTime (new js/Date))
from (.toISOString (new js/Date (- now (+ (* 3 interval) (* 40 1000)))))
to (.toISOString (new js/Date (- now (* 40 1000))))
response (<! (http/get (str "http://dev.api.vigiglo.be/api" route)
from (.toISOString (new js/Date (- now (+ interval time-protection time-period-margin))))
to (.toISOString (new js/Date (- now time-protection)))
response (<! (http/get (str "http://api.vigiglo.be/api" route)
{:query-params (into {:project_id (gets [prefix :project-id])
:timeFrom from
:timeTo to}
@ -45,17 +49,17 @@
(defn get-volume [prefix]
(get-datas-every
prefix
"/statistics/v1/volume" {} 1000
"/statistics/v1/volume" {} time-period
(fn [res]
(let [new-size (second (first (:messages res)))]
(sets [prefix :msg] (str new-size))
(sets [prefix :volume] new-size)))))
(defn get-messages [prefix]
(let [interval 10000]
(let [interval time-period]
(get-datas-every
prefix
"/content/v1/messages" {:limit (* 30 (/ interval 1000))} interval
"/content/v1/messages" {:limit (* 30 (/ (+ interval time-period-margin) 1000))} interval
(fn [res]
(let [now (.getTime (new js/Date))]
(sets [prefix :msg-time] now)
@ -90,7 +94,7 @@
;; ------------------------------------------------------------------------------
(defn view-tweets [state now e]
(when (:messages state)
(let [from (- now (* 65 1000))
(let [from (- (- now time-protection) time-period)
tweets (:messages state)
tweets-by-sec (clojure.set/index (set tweets) [:pub_date_epoch_ms])
nb-seconds (count (keys tweets-by-sec))
@ -108,16 +112,23 @@
[:div {:style {:position "absolute"
:bottom "0"
:right (rx
(str (- (* (- (/ (- (:pub_date_epoch_ms tweet-sec) from)
1000) @e ) tw-width)) "vh"))
(str (- (* (- (/ (- (:pub_date_epoch_ms tweet-sec) (- time-period) from)
1000) @e ) tw-width)) "vh"))
:width (str tw-width "vh")
}
}
(for [tweet (get tweets-by-sec tweet-sec)]
[message tweet vh-height ])
[:div {:style {:font-size ".5em"}} (clojure.string/replace (.toISOString (js/Date. (:pub_date_epoch_ms tweet-sec)))
#".*T" "")]
[:div {:style {:font-size ".5em"
:text-align "center"
:border 0
:padding 0
:margin 0
:line-height "1.5em"
:text-shadow "0 0 2px rgba(0,0,0,0.5)"
:width "100%"}} (clojure.string/replace (.toISOString (js/Date. (:pub_date_epoch_ms tweet-sec)))
#".*T(.*)\....Z" "$1")]
])])))
(defn view-volume [state]