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;}
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,12 @@
(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)"))
:transform (rx (str "translateX(" (* 20 @ease3 (Math/sin (* 30 @ease3))) "px) rotate(" (* 5 (Math/sin (* 30 @ease3))) "deg)"))
:-webkit-transform (rx (str "translateX(" (* 20 @ease3 (Math/sin (* 30 @ease3))) "px) rotate(" (* 5 (Math/sin (* 30 @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-shadow (str "1px 3px 0 rgba(0,0,0,0.1)")
:line-height "2em"
@ -87,10 +87,13 @@
[: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)"))}
:-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]
(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)
(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]

View file

@ -19,6 +19,10 @@
:project-id "vigiglobe-Microsoft"
:msg "Nothing done yet."})
(def time-protection 10000)
(def time-period 4000)
(def time-period-margin 15000)
;; ------------------------------------------------------------------------------
;; 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))
@ -101,24 +105,33 @@
[:div {:style {:text-align "left"
:line-height "2em"
:position "relative"
:overflow "hidden"
:right (rx (str (* @e tw-width) "vh"))
:height "50vh"
:font-family "Verdana, sans-serif"}}
(for [tweet-sec (keys tweets-by-sec)]
[:div {:style {:position "absolute"
:bottom "0"
:right (rx
(str (- (* (- (/ (- (:pub_date_epoch_ms tweet-sec) from)
1000) @e ) tw-width)) "vh"))
:width (str tw-width "vh")
}
}
(for [tweet (get tweets-by-sec tweet-sec)]
[message tweet vh-height ])
(for [tweet-sec (sort-by :pub_date_epoch_ms (keys tweets-by-sec))]
(let [decalage (-
(/ (+ time-period
(- (:pub_date_epoch_ms tweet-sec)
from))
1000))]
[:div {:style {:position "absolute"
:bottom "0"
:right (str (* decalage tw-width) "vh")
:width (str tw-width "vh")
}
}
(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)))
#".*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]
[:div