This file contains hidden or 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
| (ns my-blog.pages | |
| (:require [my-blog.components :as c])) | |
| (defn error [error] | |
| (let [message (.getMessage error)] | |
| (c/layout | |
| (c/center | |
| message)))) | |
| (defn not-found [] |
This file contains hidden or 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
| (ns my-blog.components | |
| (:require [hiccup.page :refer [html5 include-css include-js]])) | |
| (defn layout [& content] | |
| (html5 | |
| [:head | |
| [:meta {:name "viewport" :content "width=device-width, initial-scale=1"}] | |
| (include-css "//unpkg.com/[email protected]/css/tachyons.min.css")] | |
| [:body | |
| content |
This file contains hidden or 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
| (ns checkered.routes | |
| (:require [compojure.core :refer [defroutes GET POST wrap-routes]] | |
| [compojure.route :refer [not-found]] | |
| [checkered.controllers.sessions :as sessions] | |
| [checkered.controllers.users :as users] | |
| [checkered.controllers.home :as home] | |
| [checkered.pages :as pages])) | |
| (defroutes protected | |
| (GET "/" [] home/index) |
This file contains hidden or 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
| (ns my-blog.server | |
| (:require [org.httpkit.server :as http] | |
| [clojure.tools.namespace.repl :as tn] | |
| [environ.core :as environ] | |
| [my-blog.utils :as utils])) | |
| (defonce server (atom nil)) | |
| (defn app [req] | |
| {:status 200 |
This file contains hidden or 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
| (ns my-blog.utils | |
| (:import (java.util Date))) | |
| (defn now [] | |
| (new Date)) |
This file contains hidden or 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
| {:up [ | |
| "create table users ( | |
| id uuid primary key, | |
| email varchar(255) not null, | |
| password varchar(255) not null, | |
| created_at timestamp without time zone default (now() at time zone 'utc'), | |
| constraint unique_email unique(email));"] | |
| :down ["drop table users;"]} |
This file contains hidden or 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
| (defproject my-blog "0.1.0-SNAPSHOT" | |
| :description "FIXME: write description" | |
| :url "http://example.com/FIXME" | |
| :license {:name "Eclipse Public License" | |
| :url "http://www.eclipse.org/legal/epl-v10.html"} | |
| :dependencies [[org.clojure/clojure "1.8.0"] | |
| [org.clojure/tools.namespace "0.2.11"] | |
| [ring/ring-core "1.5.0"] | |
| [ring/ring-devel "1.5.0"] | |
| [ring/ring-defaults "0.2.3"] |
This file contains hidden or 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
| {:dev {:env {:database-url "postgres://my_blog:pw@localhost:5432/my_blog_dev" | |
| :secret "dSAOGNWnBHhePi8W" | |
| :port "1337"}} | |
| :test {:env {:database-url "postgres://my_blog:pw@localhost:5432/my_blog_test" | |
| :secret "iQzpWFbLVb28kheE" | |
| :port "1337"}}} |
This file contains hidden or 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
| (ns my-blog.migrations | |
| (:require [ragtime.jdbc :as jdbc] | |
| [ragtime.repl :as repl] | |
| [clojure.string :as string] | |
| [clojure.java.io :as io] | |
| [my-blog.db :as db] | |
| [my-blog.utils :as utils]) | |
| (:import (java.text SimpleDateFormat) | |
| (java.util Date))) |
This file contains hidden or 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
| (ns my-blog.db | |
| (:require [clojure.java.io :as io] | |
| [clojure.string :as string] | |
| [environ.core :as environ] | |
| [yesql.core :as yesql])) | |
| (defn jdbc-conn | |
| ([s] | |
| (let [conn (->> (re-seq #"\/\/(.+):(.+)?@(.+):(.+)\/(.+)" s) | |
| (first) |