Skip to content

Instantly share code, notes, and snippets.

@jackrusher
Created November 22, 2018 13:01
Show Gist options
  • Save jackrusher/2a993ed218066823da1b6b24d81b7fa8 to your computer and use it in GitHub Desktop.
Save jackrusher/2a993ed218066823da1b6b24d81b7fa8 to your computer and use it in GitHub Desktop.
(ns livecode.flickr
(:require [datoteka.core :as fs]
[clojure.string :as cs]
[clojure.data.json :as json]
[hiccup.page :as hp]
[hiccup.core :as hc]))
(def json-files
(reduce
(fn [m file]
(assoc m (str file) (json/read (clojure.java.io/reader file) :key-fn keyword)))
{}
(fs/list-dir "data/flickr" "*json")))
(def albums (:albums (get json-files "data/flickr/albums.json")))
(defn photo-id->filename [id]
(str "data/flickr/photo_" id ".json"))
(spit "flickr.html"
(hp/html5
(hc/html
(for [a albums]
[:div
[:h3 (:title a)]
(let [cover (last (cs/split (:cover_photo a) #"/"))]
[:img {:src (:original (json-files (photo-id->filename cover)))}])]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment