Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
Charlotte Allen | fe912249b1 | |
Charlotte Allen | ae976925fb | |
Charlotte Allen | 724d1e9a7f | |
Charlotte Allen | 1c43b84d68 | |
Charlotte Allen | a091a377b0 | |
Charlotte Allen | 84c201c6e1 | |
Charlotte Allen | be0aeeb80d | |
Charlotte Allen | 4f3cfe4728 |
|
@ -18,3 +18,4 @@ profiles.clj
|
|||
resources/posts/
|
||||
/resources/author/
|
||||
resources/index/
|
||||
*.eastwood
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"Userspace functions you can run by default in your local REPL."
|
||||
(:require
|
||||
[shapey-shifty.config :refer [env]]
|
||||
[clojure.pprint]
|
||||
[clojure.spec.alpha :as s]
|
||||
[expound.alpha :as expound]
|
||||
[mount.core :as mount]
|
||||
[shapey-shifty.core :refer [start-app]]))
|
||||
[clojure.pprint]
|
||||
[clojure.spec.alpha :as s]
|
||||
[expound.alpha :as expound]
|
||||
[mount.core :as mount]
|
||||
[shapey-shifty.core :refer [start-app]]))
|
||||
|
||||
(alter-var-root #'s/*explain-out* (constantly expound/printer))
|
||||
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
:resource-paths ["resources"]
|
||||
:target-path "target/%s/"
|
||||
:main ^:skip-aot shapey-shifty.core
|
||||
|
||||
:plugins [ [lein-cljfmt "0.6.6"]
|
||||
]
|
||||
|
||||
:profiles
|
||||
{:uberjar {:omit-source true
|
||||
:aot :all
|
||||
|
@ -58,6 +54,7 @@
|
|||
[ring/ring-devel "1.8.0"]
|
||||
[ring/ring-mock "0.4.0"]]
|
||||
:plugins [[com.jakemccrary/lein-test-refresh "0.24.1"]
|
||||
[lein-cljfmt "0.6.6"]
|
||||
[jonase/eastwood "0.3.5"]]
|
||||
|
||||
:source-paths ["env/dev/clj"]
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
(def base-path "resources/author")
|
||||
|
||||
(defn create-author []
|
||||
(defn create-author []
|
||||
{:card nil :password-hash nil})
|
||||
|
||||
(defn load-author [author-name]
|
||||
(defn load-author [author-name]
|
||||
(let [path (format "%s/%s" base-path author-name)
|
||||
file (io/file path)]
|
||||
(when (.exists file)
|
||||
|
@ -16,9 +16,9 @@
|
|||
edn/read-string))))
|
||||
|
||||
(defn load-all-authors []
|
||||
(->> base-path
|
||||
io/file
|
||||
file-seq
|
||||
(filter #(.isFile %))
|
||||
(map #(->> % slurp edn/read-string))))
|
||||
(->> base-path
|
||||
io/file
|
||||
file-seq
|
||||
(filter #(.isFile %))
|
||||
(map #(->> % slurp edn/read-string))))
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
(ns shapey-shifty.core
|
||||
(:require
|
||||
[shapey-shifty.handler :as handler]
|
||||
[shapey-shifty.nrepl :as nrepl]
|
||||
[luminus.http-server :as http]
|
||||
[shapey-shifty.config :refer [env]]
|
||||
[clojure.tools.cli :refer [parse-opts]]
|
||||
[clojure.tools.logging :as log]
|
||||
[mount.core :as mount])
|
||||
[shapey-shifty.handler :as handler]
|
||||
[shapey-shifty.nrepl :as nrepl]
|
||||
[luminus.http-server :as http]
|
||||
[shapey-shifty.config :refer [env]]
|
||||
[clojure.tools.cli :refer [parse-opts]]
|
||||
[clojure.tools.logging :as log]
|
||||
[mount.core :as mount])
|
||||
(:gen-class))
|
||||
|
||||
;; log uncaught exceptions in threads
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns shapey-shifty.index.index
|
||||
(:require [clucy.core :as clucy]
|
||||
[shapey-shifty.posts.posts-io :as post-io]
|
||||
))
|
||||
[clojure.java.io :as io]
|
||||
[shapey-shifty.posts.posts-io :as post-io]))
|
||||
|
||||
(def index-path (atom "resources/index"))
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
|||
(defn crawl-posts!
|
||||
([path]
|
||||
(crawl-posts! path post-io/read-post))
|
||||
([path parsing-fn]
|
||||
([path parsing-fn]
|
||||
(->> path
|
||||
clojure.java.io/file
|
||||
io/file
|
||||
file-seq
|
||||
(filter #(.isFile %))
|
||||
(mapv #(parsing-fn %))
|
||||
(apply add-post-to-index))))
|
||||
(map #(add-post-to-index %)))))
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
(ns shapey-shifty.posts.posts-io
|
||||
(:require
|
||||
[shapey-shifty.posts.core :as core]
|
||||
[shapey-shifty.authors.author-core :as author]))
|
||||
[shapey-shifty.posts.core :as core]
|
||||
[shapey-shifty.authors.author-core :as author]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.edn :as edn]))
|
||||
|
||||
(def post-filename "post.json")
|
||||
(def post-filename "post.edn")
|
||||
(def base-posts-path "resources/posts")
|
||||
|
||||
(defn create-path-by-date [year month day]
|
||||
{:year year :month month :day day})
|
||||
|
||||
(defn pathmap-to-path [{:keys [year month day]}]
|
||||
(format "%s/%s/%s" year month day))
|
||||
(format "%d/%d/%d" year month day))
|
||||
|
||||
(defn count-posts-in-date [dt-path]
|
||||
(let [path (pathmap-to-path dt-path)
|
||||
final-path (format "%s/%s" base-posts-path path)]
|
||||
(->> final-path
|
||||
clojure.java.io/file
|
||||
io/file
|
||||
file-seq
|
||||
(filter #(.isDirectory %))
|
||||
count
|
||||
|
@ -25,9 +27,9 @@
|
|||
(defn write-post [post dt-path]
|
||||
(let [path (pathmap-to-path dt-path)
|
||||
increment (inc (count-posts-in-date dt-path))
|
||||
final-path (format "%s/%s/%d/%s" base-posts-path path increment post-filename)]
|
||||
(clojure.java.io/make-parents final-path)
|
||||
(spit final-path post)))
|
||||
final-path (format "%s/%s/%s/%s" base-posts-path path increment post-filename)]
|
||||
(io/make-parents final-path)
|
||||
(spit final-path (pr-str post))))
|
||||
|
||||
(defn assoc-author [post]
|
||||
(let [filename (get-in post [:properties :author])
|
||||
|
@ -38,8 +40,18 @@
|
|||
(defn read-post
|
||||
([file]
|
||||
(when (.exists file)
|
||||
(-> file slurp read-string assoc-author)))
|
||||
(-> file slurp edn/read-string assoc-author)))
|
||||
([dt-path n]
|
||||
(let [path (format "%s/%s/%s/%s" base-posts-path (pathmap-to-path dt-path) n post-filename)
|
||||
f (clojure.java.io/file path)]
|
||||
(let [path (format "%s/%s/%d/%s" base-posts-path (pathmap-to-path dt-path) n post-filename)
|
||||
f (io/file path)]
|
||||
(read-post f))))
|
||||
|
||||
(defn read-all-posts
|
||||
([]
|
||||
(read-all-posts base-posts-path))
|
||||
([path]
|
||||
(->> path
|
||||
io/file
|
||||
file-seq
|
||||
(filter #(.isFile %))
|
||||
(map #(read-post %)))))
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
(ns shapey-shifty.routes.home
|
||||
(:require
|
||||
[shapey-shifty.layout :as layout]
|
||||
[clojure.java.io :as io]
|
||||
[shapey-shifty.middleware :as middleware]
|
||||
[ring.util.response]
|
||||
[shapey-shifty.posts.core :as posts]
|
||||
[shapey-shifty.posts.posts-io :as post-io]
|
||||
[shapey-shifty.routes.post-router :as post-router]
|
||||
[shapey-shifty.authors.author-core :as author]
|
||||
[ring.util.http-response :as response]))
|
||||
[shapey-shifty.layout :as layout]
|
||||
[clojure.java.io :as io]
|
||||
[shapey-shifty.middleware :as middleware]
|
||||
[ring.util.response]
|
||||
[shapey-shifty.posts.core :as posts]
|
||||
[shapey-shifty.posts.posts-io :as post-io]
|
||||
[shapey-shifty.routes.post-router :as post-router]
|
||||
[shapey-shifty.authors.author-core :as author]
|
||||
[ring.util.http-response :as response]))
|
||||
|
||||
(defn home-page [request]
|
||||
(layout/render request "home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
|
||||
|
@ -24,10 +24,8 @@
|
|||
:card (:author post)})))
|
||||
|
||||
(defn about-page [request]
|
||||
(layout/render request "h_card.html"
|
||||
{
|
||||
:card (:card (author/load-author (get-in request [:path-params :name])))
|
||||
}))
|
||||
(layout/render request "h_card.html"
|
||||
{:card (:card (author/load-author (get-in request [:path-params :name])))}))
|
||||
|
||||
(defn home-routes []
|
||||
[""
|
||||
|
|
Loading…
Reference in New Issue