Final polishing

This commit is contained in:
Aaron Mueller 2014-03-25 23:41:56 +01:00
parent e3714f87ff
commit 5c4d0d897a
2 changed files with 44 additions and 14 deletions

View file

@ -6,9 +6,6 @@
[clojure.java.io :as io]
[me.raynes.fs :as fs]))
(def *config* {:books-url "https://raw.github.com/CTHN/wiki-data/master/pages/projects/buch_des_monats.mkd"
:target-dir (io/file "public" "book-covers")})
(defn imgurl->bytes [lovelybooks-url]
(-> (java.net.URL. lovelybooks-url)
html/html-resource
@ -21,8 +18,10 @@
(defn url->file [lovelybooks-url target-dir]
(let [[_ author title] (re-find #".\/autor\/([^\/]+)\/(.+)-([0-9]+)-.\/$" lovelybooks-url)]
(io/file target-dir
(str/lower-case (str author "_" title ".jpg")))))
(-> (str author "_" title ".jpg")
str/lower-case
(str/replace #"[^a-z0-9-_.]" "")
(#(io/file target-dir %)))))
(defn scrape-book-urls [github-url]
(->> (http-client/get github-url)
@ -47,8 +46,8 @@
(html/deftemplate index-template "buchdesmonats/layout.html"
[cover-urls]
[:#covers] (html/content (map
#(cover-item-model % "To LovelyBooks")
[:#covers] (html/content
(map #(cover-item-model % "zu Lovely Books")
cover-urls)))
(defn generate-html [book-urls target-dir]
@ -57,9 +56,10 @@
(.write out content))))
(defn -main [& args]
(fs/mkdirs (:target-dir *config*))
;;; TODO: refactor the whole config shit
(generate-html (scrape-book-urls (:books-url *config*)) "public")
(doall (pmap #(scrape-book-cover % (:target-dir *config*))
(find-missing-covers (:books-url *config*) (:target-dir *config*))))
true)
(let [github-url "https://raw.github.com/CTHN/wiki-data/master/pages/projects/buch_des_monats.mkd"
target-dir (io/file "public" "book-covers")]
(fs/mkdirs target-dir)
(generate-html (scrape-book-urls github-url) "public")
(doall (pmap #(scrape-book-cover % target-dir)
(find-missing-covers github-url target-dir)))
true))

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>cthn.de -- Buch des Monats</title>
<link rel="stylesheet" href="styles.css">
<script src="vendors/jquery-2.1.0.min.js"></script>
<script src="vendors/masonry-3.1.5.pkgd.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<h1>Buch des Monats</h1>
<p>Handerlesen und für gut befunden seit 2010
von <a href="https://twitter.com/mezzomix22" rel="author">Michael
Reutter</a>. Jeden Monat ein neues Buch aus seiner Sammlung zu den
Themengebieten Netzkultur, Geektum, Computerspiele und
Cyberpunk. Als <a href="http://cthn.de/projects/buch_des_monats">CTHN-Projekt</a>
begonnen ist diese Bücherliste mittlerweile Anlaufstelle für so manchen
Leser der nach neuem Stoff sucht. Die Buchcover stammen
von <a href="http://lovelybooks.de/">Lovely Books</a>, <a href="https://github.com/aaronmueller/buchdesmonats">der Code</a>
von <a href="https://aaron-mueller.de/">Aaron Mueller</a>.</p>
<div id="covers">
<div class="cover-item">
<a href="#">
<img src="#" alt="LovelyBooks cover" title="Book title">
</a>
</div>
</body>
</html>