Add means to record and display an author
This commit is contained in:
parent
d26ee9923d
commit
0d8a203c3c
|
@ -1,8 +1,11 @@
|
||||||
{
|
{
|
||||||
:first-name nil
|
:card {
|
||||||
:family-name nil
|
:first-name nil
|
||||||
:rel-me []
|
:family-name nil
|
||||||
:job-title nil
|
:rel-me []
|
||||||
:org nil
|
:job-title nil
|
||||||
:photo nil
|
:org nil
|
||||||
|
:photo nil
|
||||||
|
}
|
||||||
|
:password-hash nil
|
||||||
}
|
}
|
||||||
|
|
18
resources/html/h_card.html
Normal file
18
resources/html/h_card.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{% block card %}
|
||||||
|
|
||||||
|
<div class="h-card">
|
||||||
|
<img class="u-photo" src="{{ card.photo }}" width="200" />
|
||||||
|
<p>{{ card.first-name }} {{ card.family-name }}</p>
|
||||||
|
<ul>
|
||||||
|
{% for contact in card.rel-me %}
|
||||||
|
<li>
|
||||||
|
<a class="u-url" rel="me" href="{{ contact.url}}">
|
||||||
|
{{ contact.description }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
24
src/clj/shapey_shifty/authors/author_core.clj
Normal file
24
src/clj/shapey_shifty/authors/author_core.clj
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
(ns shapey-shifty.authors.author-core
|
||||||
|
(:require [clojure.edn :as edn]
|
||||||
|
[clojure.java.io :as io]))
|
||||||
|
|
||||||
|
(def base-path "resources/author")
|
||||||
|
|
||||||
|
(defn create-author []
|
||||||
|
{:card nil :password-hash nil})
|
||||||
|
|
||||||
|
(defn load-author [author-name]
|
||||||
|
(let [path (format "%s/%s" base-path author-name)
|
||||||
|
file (io/file path)]
|
||||||
|
(when (.exists file)
|
||||||
|
(->> file
|
||||||
|
slurp
|
||||||
|
edn/read-string))))
|
||||||
|
|
||||||
|
(defn load-all-authors []
|
||||||
|
(->> base-path
|
||||||
|
io/file
|
||||||
|
file-seq
|
||||||
|
(filter #(.isFile %))
|
||||||
|
(map #(->> % slurp edn/read-string))))
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
[shapey-shifty.posts.core :as posts]
|
[shapey-shifty.posts.core :as posts]
|
||||||
[shapey-shifty.posts.posts-io :as post-io]
|
[shapey-shifty.posts.posts-io :as post-io]
|
||||||
[shapey-shifty.routes.post-router :as post-router]
|
[shapey-shifty.routes.post-router :as post-router]
|
||||||
|
[shapey-shifty.authors.author-core :as author]
|
||||||
[ring.util.http-response :as response]))
|
[ring.util.http-response :as response]))
|
||||||
|
|
||||||
(def p (atom 0))
|
(def p (atom 0))
|
||||||
|
@ -19,12 +20,15 @@
|
||||||
|
|
||||||
(defn post-view [request]
|
(defn post-view [request]
|
||||||
(let [{:keys [path-params query-params body-params]} request
|
(let [{:keys [path-params query-params body-params]} request
|
||||||
{:keys [year month day n]} path-params]
|
{:keys [year month day n]} path-params]
|
||||||
(do (reset! p request)
|
(do (reset! p request)
|
||||||
(layout/render request "post.html" {:post (:properties (post-router/get-post year month day n))}))))
|
(layout/render request "post.html" {:post (:properties (post-router/get-post year month day n))}))))
|
||||||
|
|
||||||
(defn about-page [request]
|
(defn about-page [request]
|
||||||
(layout/render request "about.html"))
|
(layout/render request "h_card.html"
|
||||||
|
{
|
||||||
|
:card (:card (author/load-author (get-in request [:path-params :name])))
|
||||||
|
}))
|
||||||
|
|
||||||
(defn home-routes []
|
(defn home-routes []
|
||||||
[""
|
[""
|
||||||
|
@ -32,5 +36,5 @@
|
||||||
middleware/wrap-formats]}
|
middleware/wrap-formats]}
|
||||||
["/" {:get home-page}]
|
["/" {:get home-page}]
|
||||||
["/blog/:year/:month/:day/:n" {:get post-view}]
|
["/blog/:year/:month/:day/:n" {:get post-view}]
|
||||||
["/about" {:get about-page}]])
|
["/about/:name" {:get about-page}]])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue