nrepl, linting, refactoring

This commit is contained in:
rdiedrich 2020-06-24 16:06:31 +02:00
parent b837fa5a7d
commit 1ef117de29
3 changed files with 29 additions and 27 deletions

View File

@ -10,7 +10,8 @@
[hickory "0.7.1"] [hickory "0.7.1"]
[environ "1.1.0"]] [environ "1.1.0"]]
:plugins [[lein-ring "0.12.5"]] :plugins [[lein-ring "0.12.5"]]
:ring {:handler clojsa.handler/app} :ring {:handler clojsa.handler/app
:nrepl {:start? true :port 9000}}
:uberjar-name "clojsa-standalone.jar" :uberjar-name "clojsa-standalone.jar"
:profiles :profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"] {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]

View File

@ -1,6 +1,5 @@
(ns clojsa.saclient (ns clojsa.saclient
(:require [clojure.string :as string] (:require [http.async.client :as http]))
[http.async.client :as http]))
(def url "https://forums.somethingawful.com/") (def url "https://forums.somethingawful.com/")

View File

@ -1,8 +1,6 @@
(ns clojsa.views (ns clojsa.views
(:use [hiccup core page]) (:use [hiccup core page])
(:require [clojure.string :as string] (:require [clojure.pprint]
[clojure.pprint]
[clojure.java.io :as io]
[ring.util.anti-forgery :refer [anti-forgery-field]])) [ring.util.anti-forgery :refer [anti-forgery-field]]))
@ -46,38 +44,42 @@
[:label.label {:for "username"} [:label.label {:for "username"}
"username"] "username"]
[:div.control [:div.control
[:input#username.input {:name "username" :type "text" :placeholder "enter your username"}]]] [:input#username.input {:name "username" :type "text"
:placeholder "enter your username"}]]]
[:div.field [:div.field
[:label.label {:for "password"} [:label.label {:for "password"}
"password"] "password"]
[:div.control [:div.control
[:input#password.input {:name "password" :type "password" :placeholder "enter your password"}]]] [:input#password.input {:name "password" :type "password"
:placeholder "enter your password"}]]]
[:div.field [:div.field
[:div.control [:div.control
[:button.button.is-primary "Submit"]]]]])) [:button.button.is-primary "Submit"]]]]]))
(defn paginate [base cur last] (defn paginate [base cur last]
(let [page-fstring "%s?page=%d"
href (partial format page-fstring base)]
[:nav.container.box.pagination {:hx-boot "false"} [:nav.container.box.pagination {:hx-boot "false"}
[:a.pagination-previous [:a.pagination-previous
{:href (format "%s?page=%d" base (dec cur))} "<"] {:href (href (dec cur))} "<"]
[:a.pagination-next [:a.pagination-next
{:href (format "%s?page=%d" base (inc cur))} ">"] {:href (href (inc cur))} ">"]
[:ul.pagination-list [:ul.pagination-list
[:li [:li
[:a.pagination-link [:a.pagination-link
{:href (format "%s?page=%d" base 1)} (str 1)]] {:href (href 1)} (str 1)]]
[:li [:li
[:span.pagination-ellipsis "&hellip;"]] [:span.pagination-ellipsis "&hellip;"]]
(for [i (range (- cur 2) (+ cur 3))] (for [i (range (- cur 2) (+ cur 3))]
[:li [:li
[:a.pagination-link [:a.pagination-link
{:href (format "%s?page=%d" base i) {:href (href i)
:class (when (= i cur) "is-current")} (str i)]]) :class (when (= i cur) "is-current")} (str i)]])
[:li [:li
[:span.pagination-ellipsis "&hellip;"]] [:span.pagination-ellipsis "&hellip;"]]
[:li [:li
[:a.pagination-link [:a.pagination-link
{:href (format "%s?page=%d" base last)} (str last)]]]]) {:href (href last)} (str last)]]]]))
(defn thread-page [thread] (defn thread-page [thread]
(let [{:keys [id title page page-count content]} thread] (let [{:keys [id title page page-count content]} thread]