Merge branch 'master' of github.com:yogsototh/apintro

This commit is contained in:
Yann Esposito (Yogsototh) 2015-09-08 06:35:48 +02:00
commit d72129ec98
4 changed files with 52 additions and 41 deletions

View file

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

View file

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

View file

@ -138,13 +138,7 @@
(let [original-text (if (:reshared message) (let [original-text (if (:reshared message)
(get-in message [:retweeted_status :text]) (get-in message [:retweeted_status :text])
(:text message))] (:text message))]
[:p {:style {:cursor "pointer" [:p.text {:style {:line-height "1.2em"}}
: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"}
original-text])) original-text]))
(defn message [message height & params] (defn message [message height & params]

View file

@ -19,6 +19,10 @@
:project-id "vigiglobe-Microsoft" :project-id "vigiglobe-Microsoft"
:msg "Nothing done yet."}) :msg "Nothing done yet."})
(def time-protection 10000)
(def time-period 4000)
(def time-period-margin 15000)
;; ------------------------------------------------------------------------------ ;; ------------------------------------------------------------------------------
;; Tasks ;; Tasks
;; ------------------------------------------------------------------------------ ;; ------------------------------------------------------------------------------
@ -30,9 +34,9 @@
(smart-si (smart-si
(fn [] (fn []
(go (let [now (.getTime (new js/Date)) (go (let [now (.getTime (new js/Date))
from (.toISOString (new js/Date (- now (+ (* 3 interval) (* 40 1000))))) from (.toISOString (new js/Date (- now (+ interval time-protection time-period-margin))))
to (.toISOString (new js/Date (- now (* 40 1000)))) to (.toISOString (new js/Date (- now time-protection)))
response (<! (http/get (str "http://dev.api.vigiglo.be/api" route) response (<! (http/get (str "http://api.vigiglo.be/api" route)
{:query-params (into {:project_id (gets [prefix :project-id]) {:query-params (into {:project_id (gets [prefix :project-id])
:timeFrom from :timeFrom from
:timeTo to} :timeTo to}
@ -45,17 +49,17 @@
(defn get-volume [prefix] (defn get-volume [prefix]
(get-datas-every (get-datas-every
prefix prefix
"/statistics/v1/volume" {} 1000 "/statistics/v1/volume" {} time-period
(fn [res] (fn [res]
(let [new-size (second (first (:messages res)))] (let [new-size (second (first (:messages res)))]
(sets [prefix :msg] (str new-size)) (sets [prefix :msg] (str new-size))
(sets [prefix :volume] new-size))))) (sets [prefix :volume] new-size)))))
(defn get-messages [prefix] (defn get-messages [prefix]
(let [interval 10000] (let [interval time-period]
(get-datas-every (get-datas-every
prefix prefix
"/content/v1/messages" {:limit (* 30 (/ interval 1000))} interval "/content/v1/messages" {:limit (* 30 (/ (+ interval time-period-margin) 1000))} interval
(fn [res] (fn [res]
(let [now (.getTime (new js/Date))] (let [now (.getTime (new js/Date))]
(sets [prefix :msg-time] now) (sets [prefix :msg-time] now)
@ -90,7 +94,7 @@
;; ------------------------------------------------------------------------------ ;; ------------------------------------------------------------------------------
(defn view-tweets [state now e] (defn view-tweets [state now e]
(when (:messages state) (when (:messages state)
(let [from (- now (* 65 1000)) (let [from (- (- now time-protection) time-period)
tweets (:messages state) tweets (:messages state)
tweets-by-sec (clojure.set/index (set tweets) [:pub_date_epoch_ms]) tweets-by-sec (clojure.set/index (set tweets) [:pub_date_epoch_ms])
nb-seconds (count (keys tweets-by-sec)) nb-seconds (count (keys tweets-by-sec))
@ -101,24 +105,33 @@
[:div {:style {:text-align "left" [:div {:style {:text-align "left"
:line-height "2em" :line-height "2em"
:position "relative" :position "relative"
:overflow "hidden" :right (rx (str (* @e tw-width) "vh"))
:height "50vh" :height "50vh"
:font-family "Verdana, sans-serif"}} :font-family "Verdana, sans-serif"}}
(for [tweet-sec (keys tweets-by-sec)] (for [tweet-sec (sort-by :pub_date_epoch_ms (keys tweets-by-sec))]
[:div {:style {:position "absolute" (let [decalage (-
:bottom "0" (/ (+ time-period
:right (rx (- (:pub_date_epoch_ms tweet-sec)
(str (- (* (- (/ (- (:pub_date_epoch_ms tweet-sec) from) from))
1000) @e ) tw-width)) "vh")) 1000))]
:width (str tw-width "vh") [:div {:style {:position "absolute"
} :bottom "0"
} :right (str (* decalage tw-width) "vh")
(for [tweet (get tweets-by-sec tweet-sec)] :width (str tw-width "vh")
[message tweet vh-height ]) }
}
(for [tweet (get tweets-by-sec tweet-sec)]
[message tweet vh-height])
[:div {:style {:font-size ".3em"}} (clojure.string/replace (.toISOString (js/Date. (:pub_date_epoch_ms tweet-sec))) [:div {:style {:font-size ".5em"
#".*T" "")] :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] (defn view-volume [state]
[:div [:div