Skip to content

Commit 456fe28

Browse files
Merge branch 'master' of github.com:relevance/clojurescript
2 parents 0691eb7 + cc967d5 commit 456fe28

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

samples/twitterbuzz/src/twitterbuzz/core.cljs

+5-8
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,11 @@
8585
(defn update-graph [graph tweet-maps]
8686
(reduce (fn [acc tweet]
8787
(let [user (:from_user tweet)
88-
mentions (parse-mentions tweet)]
89-
(-> (if-let [existing-node (get acc user)]
90-
(assoc acc user
91-
(assoc existing-node :last-tweet (:text tweet)))
92-
(assoc acc user
93-
{:image-url (:profile_image_url tweet)
94-
:last-tweet (:text tweet)
95-
:mentions {}}))
88+
mentions (parse-mentions tweet)
89+
node (get acc user {:mentions {}})]
90+
(-> (assoc acc user
91+
(assoc node :last-tweet (:text tweet)
92+
:image-url (:profile_image_url tweet)))
9693
(add-mentions user mentions))))
9794
graph
9895
(map #(select-keys % [:text :from_user :profile_image_url]) tweet-maps)))

samples/twitterbuzz/src/twitterbuzz/showgraph.cljs

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
; Drawing configuration
1414
(def avatar-size 32) ; used for both x and y dimensions of avatars
15-
(def edge-widths [0 1 2 3 4]) ; More mentions == thicker edges
1615
(def anneal-skipping 10)
1716
(def cooling 1000)
1817
; fail whale
@@ -25,10 +24,7 @@
2524
; BAD HACK: don't change globals like this -- find a better way:
2625
;(set! anim/TIMEOUT 500)
2726

28-
(def edge-strokes
29-
(vec (map #(graphics/Stroke. % "#009") edge-widths)))
30-
31-
(def max-stroke (peek edge-strokes))
27+
(def edge-stroke (graphics/Stroke. 1 "#009"))
3228

3329
(def g
3430
(doto (graphics/createGraphics "100%" "100%")
@@ -57,7 +53,7 @@
5753
y2 (unit-to-pixel uy2 (.height canvas-size))]
5854
(.drawPath g
5955
(-> (. g (createPath)) (.moveTo x1 y1) (.lineTo x2 y2))
60-
(get edge-strokes mention-count max-stroke) nil))))
56+
edge-stroke nil))))
6157

6258
; Draw avatar nodes
6359
(doseq [[username {:keys [x y] :as foo}] locs]

samples/twitterbuzz/src/twitterbuzz/timeline.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(defn update-timeline [tweets]
2727
(let [status (dom/getElement "tweet-status")]
2828
(do (dom/setTextContent status (str (:tweet-count @buzz/state) " tweets"))
29-
(doseq [tweet tweets]
29+
(doseq [tweet (reverse tweets)]
3030
(add-timeline-tweet tweet)))))
3131

3232
(buzz/register :track-clicked #(buzz/remove-children "timeline-content"))

0 commit comments

Comments
 (0)