diff --git a/project.clj b/project.clj index 408db4a..8130d1e 100644 --- a/project.clj +++ b/project.clj @@ -126,7 +126,7 @@ [directory-naming/naming-java "0.8"]] :plugins [[com.jakemccrary/lein-test-refresh "0.14.0"] [lein-doo "0.1.7"] - [lein-figwheel "0.5.8"] + [lein-figwheel "0.5.9"] [org.clojure/clojurescript "1.9.229"]] :cljsbuild {:builds diff --git a/resources/public/img/clojure-icon.gif b/resources/public/img/clojure-icon.gif new file mode 100644 index 0000000..84eee16 Binary files /dev/null and b/resources/public/img/clojure-icon.gif differ diff --git a/resources/public/img/github-logo-transparent.png b/resources/public/img/github-logo-transparent.png new file mode 100644 index 0000000..6a37959 Binary files /dev/null and b/resources/public/img/github-logo-transparent.png differ diff --git a/resources/public/img/gnu.small.png b/resources/public/img/gnu.small.png new file mode 100644 index 0000000..04177f6 Binary files /dev/null and b/resources/public/img/gnu.small.png differ diff --git a/resources/public/img/ric-logo.png b/resources/public/img/ric-logo.png new file mode 100644 index 0000000..050b70d Binary files /dev/null and b/resources/public/img/ric-logo.png differ diff --git a/src/cljs/youyesyet/core.cljs b/src/cljs/youyesyet/core.cljs index 1e28d4b..bbc546b 100644 --- a/src/cljs/youyesyet/core.cljs +++ b/src/cljs/youyesyet/core.cljs @@ -9,67 +9,23 @@ [youyesyet.ajax :refer [load-interceptors!]] [youyesyet.handlers] [youyesyet.subscriptions] + [youyesyet.ui-utils :as ui] + [youyesyet.views.about :as about] + [youyesyet.views.home :as home] [youyesyet.views.map :as maps]) (:import goog.History)) -(defn nav-link [uri title page collapsed?] - (let [selected-page (rf/subscribe [:page])] - [:li.nav-item - {:class (when (= page @selected-page) "active")} - [:a.nav-link - {:href uri - :on-click #(reset! collapsed? true)} title]])) - - -(defn navbar [] - (r/with-let [collapsed? (r/atom true)] - [:div {:id "nav"} - [:img {:id "nav-icon" - :src "img/threelines.png" - :on-click #(swap! collapsed? not)}] - [:menu.nav {:id "nav-menu" :class (if @collapsed? "hidden" "shown")} - (nav-link "#/" "Home" :home collapsed?) - (nav-link "#/library" "Library" :library collapsed?) - (nav-link "#/register" "Register" :register collapsed?) - (nav-link "#/login" "Login" :login collapsed?) - (nav-link "#/about" "About" :about collapsed?)]])) - - -(defn back-link [] - [:div.back-link-container {:id "back-link-container"} - [:a {:href "javascript:history.back()" :id "back-link"} "Back"]]) - - -(defn big-link [text target] - [:div.big-link-container - [:a.big-link {:href target} text]]) - - (defn about-page [] - [:div.container {:id "main-container"} - (back-link) - [:div.row - [:div.col-md-12 - "this is the story of youyesyet... work in progress"]]]) + (about/panel)) (defn home-page [] - [:div.container {:id "main-container"} - (big-link "About" "#/about") - (big-link "Map" "#/map") - [:div.jumbotron - [:h1 "Welcome to youyesyet"] - [:p "Time to start building your site!"] - [:p [:a.btn.btn-primary.btn-lg {:href "http://luminusweb.net"} "Learn more »"]]]]) - (when-let [docs @(rf/subscribe [:docs])] - [:div.row - [:div.col-md-12 - [:div {:dangerouslySetInnerHTML - {:__html (md->html docs)}}]]]) + (home/panel)) + (defn map-page [] - (maps/map-div)) + (maps/panel)) (def pages {:home #'home-page @@ -79,7 +35,7 @@ (defn page [] [:div [:header - [navbar] + [ui/navbar] [:h1 "You yes yet?"]] [(pages @(rf/subscribe [:page]))]]) @@ -93,7 +49,6 @@ (secretary/defroute "/about" [] (rf/dispatch [:set-active-page :about])) - (secretary/defroute "/map" [] (rf/dispatch [:set-active-page :map])) diff --git a/src/cljs/youyesyet/ui_utils.cljs b/src/cljs/youyesyet/ui_utils.cljs new file mode 100644 index 0000000..2f651dd --- /dev/null +++ b/src/cljs/youyesyet/ui_utils.cljs @@ -0,0 +1,59 @@ +(ns youyesyet.ui-utils + (:require [reagent.core :as r] + [re-frame.core :as rf])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; +;;;; youyesyet.ui-utils: User interface stuff common to many views. +;;;; +;;;; This program is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU General Public License +;;;; as published by the Free Software Foundation; either version 2 +;;;; of the License, or (at your option) any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this program; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;;; USA. +;;;; +;;;; Copyright (C) 2016 Simon Brooke for Radical Independence Campaign +;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defn back-link [] + [:div.back-link-container {:id "back-link-container"} + [:a {:href "javascript:history.back()" :id "back-link"} "Back"]]) + + +(defn big-link [text target] + [:div.big-link-container + [:a.big-link {:href target} text]]) + + +(defn nav-link [uri title page collapsed?] + (let [selected-page (rf/subscribe [:page])] + [:li.nav-item + {:class (when (= page @selected-page) "active")} + [:a.nav-link + {:href uri + :on-click #(reset! collapsed? true)} title]])) + + +(defn navbar [] + (r/with-let [collapsed? (r/atom true)] + [:div {:id "nav"} + [:img {:id "nav-icon" + :src "img/threelines.png" + :on-click #(swap! collapsed? not)}] + [:menu.nav {:id "nav-menu" :class (if @collapsed? "hidden" "shown")} + (nav-link "#/" "Home" :home collapsed?) + (nav-link "#/library" "Library" :library collapsed?) + (nav-link "#/register" "Register" :register collapsed?) + (nav-link "#/login" "Login" :login collapsed?) + (nav-link "#/about" "About" :about collapsed?)]])) diff --git a/src/cljs/youyesyet/views/about.cljs b/src/cljs/youyesyet/views/about.cljs new file mode 100644 index 0000000..cbfcc7a --- /dev/null +++ b/src/cljs/youyesyet/views/about.cljs @@ -0,0 +1,54 @@ +(ns youyesyet.views.about + (:require [re-frame.core :refer [reg-sub]] + [youyesyet.ui-utils :as ui])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; +;;;; youyesyet.views.electors: about/credits view for youyesyet. +;;;; +;;;; This program is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU General Public License +;;;; as published by the Free Software Foundation; either version 2 +;;;; of the License, or (at your option) any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this program; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;;; USA. +;;;; +;;;; Copyright (C) 2016 Simon Brooke for Radical Independence Campaign +;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;; The pattern from the re-com demo (https://github.com/Day8/re-com) is to have +;;; one source file/namespace per view. Each namespace contains a function 'panel' +;;; whose output is an enlive-style specification of the view to be redered. + +(defn panel + "Generate the about panel." + [] + [:div.container {:id "main-container"} + [:h2 "Pre-alpha/proof of concept"] + [:p {:class "centre"} + [:img {:src "img/ric-logo.png" :width "24" :height "24"}] + " A project of the " + [:a {:href "https://radical.scot/"} "Radical Independence Campaign"]] + [:p {:class "centre"} + [:img {:src "img/clojure-icon.gif" :alt "Clojure" :height "24" :width "24"}] + " Powered by " + [:a {:href "http://clojure.org"} "Clojure"]] + [:p {:class "centre"} + [:img {:src "img/github-logo-transparent.png" :alt "GitHub" :height "24" :width "24"}] + " Find me/fork me on " + [:a {:href "https://github.com/simon-brooke/youyesyet"} "GitHub"]] + [:p {:class "centre"} + [:img {:src "img/gnu.small.png" :alt "Free Software Foundation" :height "24" :width "24"}] + " Licensed under the " + [:a {:href "http://www.gnu.org/licenses/gpl-2.0.html"} + "GNU General Public License v2.0"]]]) diff --git a/src/cljs/youyesyet/views/home.cljs b/src/cljs/youyesyet/views/home.cljs new file mode 100644 index 0000000..e877315 --- /dev/null +++ b/src/cljs/youyesyet/views/home.cljs @@ -0,0 +1,49 @@ +(ns youyesyet.views.home + (:require [re-frame.core :as rf] + [markdown.core :refer [md->html]] + [youyesyet.ui-utils :as ui])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; +;;;; youyesyet.views.electors: home view for youyesyet. +;;;; +;;;; This program is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU General Public License +;;;; as published by the Free Software Foundation; either version 2 +;;;; of the License, or (at your option) any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this program; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;;; USA. +;;;; +;;;; Copyright (C) 2016 Simon Brooke for Radical Independence Campaign +;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;; The pattern from the re-com demo (https://github.com/Day8/re-com) is to have +;;; one source file/namespace per view. Each namespace contains a function 'panel' +;;; whose output is an enlive-style specification of the view to be redered. +;;; I propose to follow this pattern. This file will provide the home view. + +(defn panel + "Generate the home panel." + [] + [:div.container {:id "main-container"} + (ui/big-link "About" "#/about") + (ui/big-link "Map" "#/map") + [:div.jumbotron + [:h1 "You Yes Yet?"] + [:p "Time to start building your site!"] + [:p [:a.btn.btn-primary.btn-lg {:href "http://luminusweb.net"} "Learn more »"]]]]) + (when-let [docs @(rf/subscribe [:docs])] + [:div.row + [:div.col-md-12 + [:div {:dangerouslySetInnerHTML + {:__html (md->html docs)}}]]]) diff --git a/src/cljs/youyesyet/views/map.cljs b/src/cljs/youyesyet/views/map.cljs index 5705b40..d926295 100644 --- a/src/cljs/youyesyet/views/map.cljs +++ b/src/cljs/youyesyet/views/map.cljs @@ -86,7 +86,7 @@ [:div#map {:style {:height "500px"}}]) -(defn map-div +(defn panel "A reagent class for the map object." [] (reagent/create-class {:reagent-render map-render