Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #6 from scoiatael/refactor/stasis
Browse files Browse the repository at this point in the history
Refactor/stasis
  • Loading branch information
scoiatael authored Nov 14, 2019
2 parents dbb9996 + 534b913 commit de046b2
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
- name: Install dependencies
run: lein deps
- name: Run tests
run: lein with-profile test midje
run: lein test
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
- name: Build project
id: build_resume_json
run: |
lein build-resume-json
lein build-resume-html
lein export
echo "##[set-output name=version;]$(cat project.clj | head -n 1 | awk '{ print $3 }' | tr -d '\"')"
- name: Tag Release
Expand All @@ -44,7 +43,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/resume.json
asset_path: ./target/dist/resume.json
asset_name: resume.json
asset_content_type: application/json

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [1.1.1] - 14.11.2019
### Changed
- Internals & CLI entrypoint - now uses `lein export`.

## [1.1.0] - 14.11.2019
### Added
- Exporting to HTML with custom JSON resume theme.
Expand All @@ -10,5 +14,6 @@ All notable changes to this project will be documented in this file. This change
### Added
- Export to [json resume](jsonresume.org).

[1.1.1]: https://github.com/scoiatael/resume/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/scoiatael/resume/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/scoiatael/resume/releases/v1.0.0
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ A Clojure site for buidling my resume
`org/experience.org` serves as data file, to be edited with Emacs org-mode (or any other editor with org-mode support).

Lein tasks can be used to convert into:
- [`resume.json`](https://jsonresume.org) - `lein build-resume-json` - generates `target/resume.json`,
- HTML file - `lein build-resume-html` - generates `target/dist/resume.html`,
- [`resume.json`](https://jsonresume.org) - and then HTML via `lein export`,
- Latex source for PDF [TODO]



## License

Copyright © 2019 Łukasz Czapliński
Expand Down
2 changes: 1 addition & 1 deletion doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ My first attempt uses [JSON](jsonresume.org).

## Doing your own

Open `org/experience.org` in your favourite editor, which hopefully supports Org files. Edit, and then run `lein build-resume.json`. This should give you updated `target/resume.json` in current directory. Now you can upload it, or convert to PDF by yourself.
Open `org/experience.org` in your favourite editor, which hopefully supports Org files. Edit, and then run `lein export`. This should generate files to `target/dist` - HTML and JSON version. PDF coming soon!
6 changes: 3 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject resume "1.1.0"
(defproject resume "1.1.1"
:description "Resume-from-org generator"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand All @@ -8,8 +8,8 @@
[org.clojure/core.match "0.3.0"]
[selmer "1.12.17"]
[stasis "2.5.0"]]
:aliases {"build-resume-json" ["run" "-m" "resume.core/export-resume-json"]
"build-resume-html" ["run" "-m" "resume.web/export"]}
:aliases {"export" ["run" "-m" "resume.core/export"]
"test" ["with-profile" "test" "midje"]}
:repl-options {:init-ns resume.core}
:ring {:handler resume.web/app}
:profiles {:dev {:plugins [[lein-ring "0.12.5"]]
Expand Down
27 changes: 9 additions & 18 deletions src/resume/core.clj
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))
23 changes: 23 additions & 0 deletions src/resume/gen.clj
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"]}))
6 changes: 6 additions & 0 deletions src/resume/pages.clj
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})))})
2 changes: 1 addition & 1 deletion src/resume/resume_json.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@
:skills (->> sections-by-name (#(get % "Skills")) :children (map export-skills))
:awards []
:work (->> sections-by-name (#(get % "Experience")) :children (map export-experience))
:meta {:theme :elegant}}))
:meta {:theme :pumpkin}}))
17 changes: 2 additions & 15 deletions src/resume/web.clj
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)))

0 comments on commit de046b2

Please sign in to comment.