This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from scoiatael/refactor/stasis
Refactor/stasis
- Loading branch information
Showing
11 changed files
with
54 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
(ns resume.core | ||
(:require [resume.org :as org] | ||
[cheshire.core :as json] | ||
[resume.resume-json :as resume-json])) | ||
(:require [clojure.java.io :as io] | ||
[selmer.parser :as selmer] | ||
[stasis.core :as stasis] | ||
[resume.pages :as pages])) | ||
|
||
(def experience-source "org/experience.org") | ||
(def resume-json-build "target/resume.json") | ||
(def export-dir "target/dist") | ||
|
||
(defn generate-resume | ||
[] | ||
(->> experience-source | ||
slurp | ||
org/parse | ||
resume-json/export)) | ||
|
||
(defn export-resume-json | ||
"Convert org/experience.org into build/resume.json" | ||
[] | ||
(->> (generate-resume) | ||
(#(json/generate-string % {:pretty true})) | ||
(spit resume-json-build))) | ||
(defn export [] | ||
(selmer/set-resource-path! (io/resource "templates")) | ||
(stasis/empty-directory! export-dir) | ||
(stasis/export-pages pages/all export-dir)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(ns resume.gen | ||
(:require [clojure.java.io :as io] | ||
[resume.org :as org] | ||
[resume.resume-json :as resume-json] | ||
[selmer.parser :as selmer])) | ||
|
||
(def experience-source "org/experience.org") | ||
|
||
(defn resume-json | ||
"Prepare resume.json source" | ||
[] | ||
(->> experience-source | ||
slurp | ||
org/parse | ||
resume-json/export)) | ||
|
||
(defn resume-html | ||
"Prepare resume.html source" | ||
[] | ||
(selmer/render-file "resume.html" {:resume (resume-json) | ||
:css (slurp (io/resource "public/style.css")) | ||
:css-paths ["https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css" | ||
"https://cdnjs.cloudflare.com/ajax/libs/octicons/2.0.2/octicons.min.css"]})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns resume.pages | ||
(:require [cheshire.core :as cheshire] | ||
[resume.gen :as gen])) | ||
|
||
(def all {"/resume.html" (fn [_req] (gen/resume-html)) | ||
"/resume.json" (fn [_req] (-> (gen/resume-json) (cheshire/generate-string {:pretty true})))}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
(ns resume.web | ||
(:require [clojure.java.io :as io] | ||
[resume.core :as core] | ||
[selmer.parser :as selmer] | ||
[resume.pages :as pages] | ||
[stasis.core :as stasis])) | ||
|
||
(defn- resume-page [_request] (selmer/render-file "resume.html" {:resume (core/generate-resume) | ||
:css (slurp (io/resource "public/style.css")) | ||
:css-paths ["https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css" | ||
"https://cdnjs.cloudflare.com/ajax/libs/octicons/2.0.2/octicons.min.css"]})) | ||
|
||
(defn- get-pages [] {"/resume.html" resume-page}) | ||
|
||
(def app (do | ||
(selmer/set-resource-path! (io/resource "templates")) | ||
(stasis/serve-pages get-pages))) | ||
|
||
(def export-dir "target/dist") | ||
|
||
(defn export [] | ||
(stasis/empty-directory! export-dir) | ||
(stasis/export-pages (get-pages) export-dir)) | ||
(stasis/serve-pages pages/all))) |