Skip to content

Commit 37fa3c2

Browse files
committed
Add view for domain stories
1 parent 0032458 commit 37fa3c2

4 files changed

Lines changed: 29 additions & 24 deletions

File tree

src/main/lobjur/main.cljs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[clojure.string :as str]
88
[lobjur.state :as state]
99
[lobjur.widgets.comments :as comments]
10-
[lobjur.widgets.stories-list-view :as stories-list-view :refer [home-stories]]
10+
[lobjur.widgets.stories-list-view :refer [home-stories stories-list-view]]
1111
[lobjur.widgets.user :as user]
1212
[lobjur.widgets.window :refer [window-content]]
1313
[lobster.core :as lobster]
@@ -25,6 +25,11 @@
2525
(-> s
2626
(assoc :prev-state s)
2727
(assoc :curr-view v))))
28+
(defn push-titled-view [s view title]
29+
(-> s
30+
(push-view view)
31+
(assoc :header-start back-btn)
32+
(assoc :title-widget [Gtk/Label :label title])))
2833
(defn app-transducer [f]
2934
(fn
3035
([s] s)
@@ -37,26 +42,21 @@
3742
[Gtk/StackSwitcher
3843
:stack (:home-stories @state/global-widgets)]))
3944
:push-user
40-
(-> state
41-
(push-view (user/user-view payload))
42-
(assoc :header-start back-btn)
43-
(assoc :title-widget [Gtk/Label :label payload]))
45+
(push-titled-view state (user/user-view payload) payload)
4446
:push-user-stories
45-
(-> state
46-
(push-view
47-
(stories-list-view/stories-list-view (partial lobster/user-stories-newest payload)))
48-
(assoc :header-start back-btn)
49-
(assoc :title-widget [Gtk/Label :label payload]))
47+
(push-titled-view state
48+
(stories-list-view (partial lobster/user-stories-newest payload))
49+
payload)
50+
:push-domain-stories
51+
(push-titled-view state
52+
(stories-list-view (partial lobster/domain-stories payload))
53+
payload)
5054
:push-story
51-
(-> state
52-
(push-view (comments/comments-view payload))
53-
(assoc :title-widget [Gtk/Label :label "Comments"])
54-
(assoc :header-start back-btn))
55+
(push-titled-view state (comments/comments-view payload) "Comments")
5556
:push-tagged-stories
56-
(-> state
57-
(push-view (stories-list-view/stories-list-view (partial lobster/tagged payload)))
58-
(assoc :title-widget [Gtk/Label :label payload])
59-
(assoc :header-start back-btn))
57+
(push-titled-view state
58+
(stories-list-view (partial lobster/tagged payload))
59+
payload)
6060
:pop-main-stack
6161
(do
6262
(doto ^js (:main-stack @state/global-widgets)

src/main/lobjur/widgets/comments.cljs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@
9595
(let [host
9696
; maybe I should get only the base domain...
9797
(.get_host (.parse_relative lobster/base-url url GLib/UriFlags.NONE))]
98-
[Gtk/LinkButton
99-
:css_classes #js ["small" "button" "flat" "caption"]
98+
[Gtk/Button
99+
:.add_css_class (list "small" "button" "flat" "caption")
100100
:halign Gtk/Align.START
101-
:uri (lobster/rel "domain/" host)
101+
:$clicked #(state/send [:push-domain-stories host])
102102
:label host])
103103
:.append
104104
(for [t tags]

src/main/lobjur/widgets/stories_list_view.cljs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
:selection-mode Gtk/SelectionMode.NONE
3636
:.append
3737
(let [host (.get_host (.parse_relative lobster/base-url url GLib/UriFlags.NONE))]
38-
[Gtk/LinkButton
39-
:css_classes #js ["small" "button" "flat" "caption"]
38+
[Gtk/Button
39+
:.add_css_class (list "small" "button" "flat" "caption")
4040
:halign Gtk/Align.START
41-
:uri (lobster/rel "domain/" host)
41+
:$clicked #(state/send [:push-domain-stories host])
4242
:label host])
4343
:.append
4444
(for [t tags]

src/main/lobster/core.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@
4141
(.then
4242
(http/get (rel "newest/" (str username ".json")) {:params params})
4343
parse-json))
44+
45+
(defn domain-stories [domain & {:as params}]
46+
(.then
47+
(http/get (rel "domain/" (str domain ".json")) {:params params})
48+
parse-json))

0 commit comments

Comments
 (0)