Skip to content

Commit

Permalink
53 add date to posts (#54)
Browse files Browse the repository at this point in the history
* Add date intervals and sort posts/vignettes by dates

* Add cljfmt check to CI and format code
  • Loading branch information
skydread1 authored Apr 21, 2024
1 parent 2082858 commit e4f2748
Show file tree
Hide file tree
Showing 34 changed files with 1,009 additions and 985 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
uses: DeLaGuardo/setup-clojure@12.1
with:
cli: latest


- name: Verify code base format
run: clojure -T:cljfmt check

- name: Run the clj tests
run: clojure -A:server/test

Expand All @@ -31,7 +34,7 @@ jobs:

- uses: EndBug/add-and-commit@v9
with:
add: 'resources/public/main.js'
add: "resources/public/main.js"
committer_name: GitHub Action
default_author: github_actions
message: 'Compiled the cljs to the js bundle: main.js'
message: "Compiled the cljs to the js bundle: main.js"
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,19 @@ For development, starting a clj/cljs REPL with `fighweel` allows you to have the

### Organization

Each post has its own markdown files in the folder of the page it belongs to.

For instance, I currently have 2 pages:
Each post has its own markdown file in the folder of the page it belongs to.

For instance:
```
.
├── about
│ └── aboutme.md
└── portfolio
├── blog_django.md
├── flybot_card_games.md
├── flybot_mobile_app.md
├── flybot_website.md
├── magic_nostrand.md
├── mcts.md
├── portfolio_website.md
└── props_recommender.md
├── blog-django.md
├── flybot-website.md
└── props-recommender.md
├── blog
│ └── just-tick-lib.md
```

### Config Clojure map
Expand All @@ -71,16 +67,22 @@ post summary
full post content
```

Here is an example of clojure map for a post:
Following is an example of clojure map for a post config:

```clojure
#:post{:order 0
:page :home
#:post{:date ["2024-02-01" "2024-04-01"]
:page :portfolio
:title "My New Project"
:css-class "my-project"
:image-beside #:image{:src "/assets/some-illustrative-img.png"
:src-dark "/assets/some-illustrative-img-dark.png"
:alt "A logo"}}
```

This map goes at the top of a markdown file like so:

```md
post map here
+++
My project consists in...
+++
Expand Down
25 changes: 16 additions & 9 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{:deps {org.clojure/clojure {:mvn/version "1.11.1"}
metosin/malli {:mvn/version "0.13.0"}
metosin/reitit {:mvn/version "0.7.0-alpha7"}
metosin/muuntaja {:mvn/version "0.6.8"}
sg.flybot/lasagna-pull {:mvn/version "0.4.156"}
com.bhauman/figwheel-main {:mvn/version "0.2.18"}
org.clojure/clojurescript {:mvn/version "1.11.121"}
reagent/reagent {:mvn/version "1.2.0"}
{:deps {com.bhauman/figwheel-main {:mvn/version "0.2.18"}
day8.re-frame/test {:mvn/version "0.1.5"}
cljsjs/highlight {:mvn/version "11.7.0-0"}
cljsjs/js-joda-timezone {:mvn/version "2.2.0-0"}
cljsjs/react {:mvn/version "18.2.0-1"}
cljsjs/react-dom {:mvn/version "18.2.0-1"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.121"}
henryw374/js-joda {:mvn/version "3.2.0-0"}
henryw374/js-joda-locale-en-us {:mvn/version "1.0.0-1"}
markdown-to-hiccup/markdown-to-hiccup {:mvn/version "0.6.2"}
metosin/malli {:mvn/version "0.13.0"}
metosin/muuntaja {:mvn/version "0.6.8"}
metosin/reitit {:mvn/version "0.7.0-alpha7"}
re-frame/re-frame {:mvn/version "1.4.2"}
day8.re-frame/test {:mvn/version "0.1.5"}}
reagent/reagent {:mvn/version "1.2.0"}
sg.flybot/lasagna-pull {:mvn/version "0.4.156"}
tick/tick {:mvn/version "0.7.5"}}
:paths ["src" "resources" "target" "test"]
:aliases
{;; Run clj tests
Expand Down Expand Up @@ -44,6 +48,9 @@
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.6" :git/sha "8e78bcc"}}
:ns-default build}

:cljfmt {:deps {io.github.weavejester/cljfmt {:git/tag "0.11.2", :git/sha "fb26b22"}}
:ns-default cljfmt.tool}

:outdated {;; Note that it is `:deps`, not `:extra-deps`
:deps {com.github.liquidz/antq {:mvn/version "RELEASE"}}
:main-opts ["-m" "antq.core"]}}}
1,792 changes: 898 additions & 894 deletions resources/public/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/loicb/client/core.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns loicb.client.core
(:require [loicb.client.core.dom :refer [app]]
(:require [loicb.client.core.dom :refer [app]]
[loicb.client.core.db]
[loicb.client.core.router :as router]
[reagent.dom :as rdom]
Expand Down
14 changes: 9 additions & 5 deletions src/loicb/client/core/dom/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
[loicb.client.core.dom.common.link :refer [internal-link]]
[re-frame.core :as rf]))

(defn date-str
[dates]
(apply str (interpose " - " dates)))

(defn all-tags
[tags]
(h/post-hiccup
Expand Down Expand Up @@ -66,7 +70,7 @@
[:div.post-body
{:class css-class}
[:h5.info
(str date " | "
(str (date-str date) " | "
(if (= :blog page)
"Blog Article"
(if employer employer "Personal Project")))]
Expand All @@ -91,7 +95,7 @@
title
link-params)]
[:h5.info
(str date " | " (if employer employer "Personal Project"))]
(str (date-str date) " | " (if employer employer "Personal Project"))]
(when src
[:div.image
[:img {:src src :alt alt}]])
Expand All @@ -116,7 +120,7 @@
[:h2 title]]
[:div.info
[:h5.info
(str date " | " "Loic Blanchard")]
(str (date-str date) " | " "Loic Blanchard")]
[all-tags tags]]]]))

(defn post-link
Expand Down Expand Up @@ -150,7 +154,7 @@
db-page-name @(rf/subscribe [:subs/pattern '{:app/current-view {:data {:db-page-name ?x}}}])
post-route @(rf/subscribe [:subs/pattern '{:app/current-view {:data {:post-route ?x}}}])
posts (->> @(rf/subscribe [:subs.post/posts db-page-name])
(sort-by :post/order)
(sort-by #(first (:post/date %)))
reverse)]
[:section.container
{:id (name page-name)
Expand All @@ -171,7 +175,7 @@
(let [page-name @(rf/subscribe [:subs/pattern '{:app/current-view {:data {:name ?x}}}])
db-page-name @(rf/subscribe [:subs/pattern '{:app/current-view {:data {:db-page-name ?x}}}])
posts (->> @(rf/subscribe [:subs.post/posts db-page-name])
(sort-by :post/order)
(sort-by #(first (:post/date %)))
reverse)
active-post-id @(rf/subscribe [:subs/pattern '{:app/current-view {:path-params {:post-id ?x}}}])
active-post (->> posts
Expand Down
19 changes: 16 additions & 3 deletions src/loicb/common/validation.cljc
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
(ns loicb.common.validation
(:require [malli.core :as m]
[malli.util :as mu]))
[malli.util :as mu]
[tick.core :as t]
[tick.alpha.interval :as t.i]))

(defn date-valid?
"Returns true if the given the given coll of `dates` is valid."
[[date1 date2]]
(try
(if date2
(= :precedes (t.i/relation (t/date date1)
(t/date date2)))
(t/date? (t/date date1)))
(catch #?(:clj Exception :cljs js/Error) _ false)))

;;---------- Validation Schemas ----------

(def post-schema
[:map {:closed true}
[:post/id :string]
[:post/order :int]
[:post/page :keyword]
[:post/title :string]
[:post/date :string]
[:post/date [:and
[:vector :string]
[:fn #(date-valid? %)]]]
[:post/employer {:optional true} :string]
[:post/css-class {:optional true} :string]
[:post/md-content :string]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/about/aboutme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "about-me"
:order 0
:page :about
:date "As of 2023"
:date ["2023-12-30"]
:employer "CV"
:repos [["My GitHub" "https://github.com/skydread1"]]
:title "About Me"
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/clj-in-unity.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "clojure-in-unity"
:order 2
:page :blog
:date "2022" ;; 22/04
:date ["2022-04-22"]
:title "Pack, Push and Import Clojure to Unity"
:css-class "blog-clj-in-unity"
:tags ["Clojure" "Compiler" "CLR" "Unity"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/clj-mono-repo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "clojure-mono-repo"
:order 8
:page :blog
:date "2023" ;; 16/02
:date[ "2023-02-16"]
:title "Clojure Mono Repo example : server + 2 clients"
:css-class "blog-mono-repo"
:tags ["Clojure" "Reagent" "Figwheel" "Mono Repo"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/datomic-setup.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "datomic-setup-examples"
:order 3
:page :blog
:date "2022" ;; 02/12
:date ["2022-12-02"]
:title "Datomic Setup examples: embedded, cassandra, docker."
:css-class "blog-datomic-setup"
:tags ["Clojure" "Datomic" "Cassandra" "Docker"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/deploy-clj-app-to-aws.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "deploy-clj-app-to-aws"
:order 6
:page :blog
:date "2023" ;; 20/01
:date ["2023-01-20"]
:title "Deploy full stack Clojure website to AWS"
:css-class "blog-deploy-clj-aws"
:tags ["Clojure" "AWS" "Full-Stack"]
Expand Down
5 changes: 2 additions & 3 deletions src/loicb/server/content/blog/deploy-django-beanstalk.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#:post{:id "deploy-django-aws-beanstalk"
:order 10
:page :blog
:date "2023" ;; 08/08
:title "Deploy Django Blog in AWS Beantalk"
:date ["2023-08-08"]
:title "Deploy Django Blog in AWS Beanstalk"
:css-class "blog-django-aws"
:tags ["Python" "Django" "AWS" "Elastic Beanstalk"]
:image #:image{:src "/assets/loic-blog-logo.png"
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/fun-map-flybot.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "fun-map-applied-to-flybot"
:order 9
:page :blog
:date "2023" ;; 05/08
:date ["2023-05-08"]
:title "Fun-Map applied to flybot.sg"
:css-class "blog-fun-map-flybot"
:tags ["Clojure" "System" "Component" "Deps Injection"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/fun-map.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "fun-map"
:order 5
:page :blog
:date "2022" ;; 04/12
:date ["2022-04-12"]
:title "Fun-Map: a solution to deps injection in Clojure"
:css-class "blog-fun-map"
:tags ["Clojure" "System" "Component" "Deps Injection"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/juxt-tick-lib.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "tick"
:order 12
:page :blog
:date "2024" ;; 04/20
:date ["2024-04-20"]
:title "Time as a value with Tick"
:css-class "juxt-tick"
:tags ["Clojure" "Java 8 time" "Tick" "Duration/Period"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/lasagna-pull-flybot.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "lasagna-pull-applied-to-flybot"
:order 8
:page :blog
:date "2023" ;; 04/08
:date ["2023-04-08"]
:title "Lasagna-pull applied to flybot.sg"
:css-class "blog-lasagna-pull-flybot"
:tags ["Clojure" "Pull Pattern"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/lasagna-pull.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "lasagna-pull"
:order 4
:page :blog
:date "2022" ;; 04/12
:date ["2022-04-12"]
:title "Lasagna Pull: Precisely select from deep nested data"
:css-class "blog-lasagna-pull"
:tags ["Clojure" "Pull Pattern" "Malli"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/mcts-card-games.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "article-mcts"
:order 0
:page :blog
:date "2021" ;; 13/08
:date ["2021-08-13"]
:title "MCTS applied to card games"
:css-class "blog-post-mcts"
:tags ["Clojure" "MCTS"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/port-clj-lib-to-clr.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "port-clj-lib-to-clr"
:order 1
:page :blog
:date "2022" ;; 08/02
:date ["2022-04-08"]
:title "Port your Clojure lib to the CLR with MAGIC"
:css-class "blog-port-clj-lib"
:tags ["Clojure" "Compiler" "CLR" "Unity"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/reagent-native-app.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "reagent-native-app"
:order 7
:page :blog
:date "2023" ;; 03/02
:date ["2023-02-03"]
:title "Reagent React Native Mobile App"
:css-class "blog-reagent-native"
:tags ["Clojure" "React Native" "Reagent" "Figwheel"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/blog/redirect-domain-subdomain.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "redirect-domain-to-subdomain"
:order 11
:page :blog
:date "2023" ;; 09/11
:date ["2023-11-09"]
:title "Redirecting Domain to Subdomain using AWS ALB+NLB"
:css-class "blog-redirect-domain"
:tags ["AWS" "Load Balancers" "DNS" "GoDaddy"]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/portfolio/blog-django.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:post{:id "blog-django"
:order 6
:page :portfolio
:date "2023"
:date ["2023-05-27" "2023-11-12"]
:repos [["Blog" "https://github.com/skydread1/blog"]]
:articles [["Deploy Django Blog in AWS Beanstalk" "../blog/deploy-django-aws-beanstalk"]]
:title "Tech Blog with Django"
Expand Down
5 changes: 2 additions & 3 deletions src/loicb/server/content/portfolio/flybot-card-games.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#:post{:id "card-games-api"
:order 0
:page :portfolio
:employer "Flybot Pte Ltd"
:date "2020-2021"
:employer "Flybot Pte Ltd"
:date ["2020-01-06" "2021-10-29"]
:repos [["Magic" "https://github.com/nasser/magic"]]
:articles [["Port your Clojure lib to the CLR with MAGIC" "../blog/port-clj-lib-to-clr"]]
:title "Clojure Card Games Backend APIs"
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/portfolio/flybot-mobile-app.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#:post{:id "clojure-mobile-app"
:order 4
:page :portfolio
:employer "Flybot Pte Ltd"
:date "2023"
:date ["2023-02-13" "2023-08-08"]
:repos [["Flybot" "https://github.com/skydread1/flybot.sg"]]
:articles [["Reagent React Native Mobile App" "../blog/reagent-native-app"]
["Clojure Mono Repo example : server + 2 clients" "../blog/clojure-mono-repo"]]
Expand Down
3 changes: 1 addition & 2 deletions src/loicb/server/content/portfolio/flybot-website.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#:post{:id "clojure-full-stack-webapp"
:order 3
:page :portfolio
:employer "Flybot Pte Ltd"
:date "2022"
:date ["2022-05-20" "2023-08-04"]
:repos [["Flybot" "https://github.com/skydread1/flybot.sg"]]
:articles [["Deploy full stack Clojure website to AWS" "../blog/deploy-clj-app-to-aws"]
["Lasagna-pull applied to flybot.sg" "../blog/lasagna-pull-applied-to-flybot"]
Expand Down
Loading

0 comments on commit e4f2748

Please sign in to comment.