<commit_before>;;;; clog.lisp

(in-package #:clog)

;;; "clog" goes here. Hacks and glory await!

;;; config
(defparameter *default-config* `((:source . "/path/to/blog")
                                 (:output . "/path/for/output")
                                 (:remote . "remote.host.com")
                                 (:url . "http://your.blog.url")))
(defparameter *config* nil)

(defun create-config (path)
  (with-open-file (config-file path :direction :output :if-exists :supersede)
    (print *default-config* config-file)
    (terpri config-file)))

(defun read-config (path)
  (when (not (probe-file path))
    (create-config path))
  (with-open-file (f path :direction :input)
    (read f)))

(defun make-a-path (base node)
  (format nil "~A/~A" base node))

(defun make-config-path (key node)
  (make-a-path (assoc-value *config* key) node))

;;; skeleton
;; provide function to write skeleton to disk, MAKE-BLOG or so
;; write lisp functions using cl-who, lass and perhaps parenscript, to generate that skeleton
;; write config tailored to that skeleton too
(defun navbar ()
  (with-html-output-to-string (s nil :indent t)
    (:div :class "navigation"
          (:a :href (make-a-path (assoc-value *config* :url) "") "HOME")
          (:a :href (make-a-path (assoc-value *config* :url) "posts/") "INDEX")
          (:a :href (make-a-path (assoc-value *config* :url) "archive/") "ARCHIVE"))))

(defun footer ()
  (with-html-output-to-string (s nil :indent t)
    (:div :class "footer" "(C) 2016 <NAME>. All rights reserved (for now).")))

(defun add-boilerplate (content)
  "Fill a page template with the content"
  (with-html-output-to-string (s nil :prologue T :indent T)
    (:html
      (:head
       (:link :rel "stylesheet" :href (make-a-path (assoc-value *config* :url) "css/style.css")) ; use LASS
       (:link :rel "stylesheet" :href (make-a-path (assoc-value *config* :url) "css/colorize.css"))
       (:link :rel "stylesheet" :href (make-a-path (assoc-value *config* :url) "css/highlight.css")) ; use LASS
       (:script :src (make-a-path (assoc-value *config* :url) "js/highlight.pack.js"))
       (:script "hljs.initHighlightingOnLoad();")) ; use Parenscript
      (:body (str (navbar))
             (str content)
             (str (footer))))))

;; (defun make-directories (path)
;;   (mapc (lambda (subdir)
;;           (ensure-directories-exist (concatenate 'string path "/" subdir)
;;                                     :mode 755))
;;         '("templates" "styles" "scripts"))
;;   (ensure-directories-exist (concatenate 'string path "/scripts") :mode 755)
;;   (ensure-directories-exist (concatenate 'string path "/styles") :mode 755))

;; (defun make-blog-skeleton (path)
;;   "Create a skeleton, with the default files in the proper places."
;;   (make-directories path)
;;   (make-templates path)
;;   (make-styles path)
;;   (make-scripts path))

;;; exporting<commit_msg>Added the fineprint CSS class to the footer<commit_after>;;;; clog.lisp

(in-package #:clog)

;;; "clog" goes here. Hacks and glory await!

;;; config
(defparameter *default-config* `((:source . "/path/to/blog")
                                 (:output . "/path/for/output")
                                 (:remote . "remote.host.com")
                                 (:url . "http://your.blog.url")))
(defparameter *config* nil)

(defun create-config (path)
  (with-open-file (config-file path :direction :output :if-exists :supersede)
    (print *default-config* config-file)
    (terpri config-file)))

(defun read-config (path)
  (when (not (probe-file path))
    (create-config path))
  (with-open-file (f path :direction :input)
    (read f)))

(defun make-a-path (base node)
  (format nil "~A/~A" base node))

(defun make-config-path (key node)
  (make-a-path (assoc-value *config* key) node))

;;; skeleton
;; provide function to write skeleton to disk, MAKE-BLOG or so
;; write lisp functions using cl-who, lass and perhaps parenscript, to generate that skeleton
;; write config tailored to that skeleton too
(defun navbar ()
  (with-html-output-to-string (s nil :indent t)
    (:div :class "navigation"
          (:a :href (make-a-path (assoc-value *config* :url) "") "HOME")
          (:a :href (make-a-path (assoc-value *config* :url) "posts/") "INDEX")
          (:a :href (make-a-path (assoc-value *config* :url) "archive/") "ARCHIVE"))))

(defun footer ()
  (with-html-output-to-string (s nil :indent t)
    (:div :class "footer fineprint" "(C) 2016 <NAME>. All rights reserved (for now).")))

(defun add-boilerplate (content)
  "Fill a page template with the content"
  (with-html-output-to-string (s nil :prologue T :indent T)
    (:html
      (:head
       (:link :rel "stylesheet" :href (make-a-path (assoc-value *config* :url) "css/style.css")) ; use LASS
       (:link :rel "stylesheet" :href (make-a-path (assoc-value *config* :url) "css/colorize.css"))
       (:link :rel "stylesheet" :href (make-a-path (assoc-value *config* :url) "css/highlight.css")) ; use LASS
       (:script :src (make-a-path (assoc-value *config* :url) "js/highlight.pack.js"))
       (:script "hljs.initHighlightingOnLoad();")) ; use Parenscript
      (:body (str (navbar))
             (str content)
             (str (footer))))))

;; (defun make-directories (path)
;;   (mapc (lambda (subdir)
;;           (ensure-directories-exist (concatenate 'string path "/" subdir)
;;                                     :mode 755))
;;         '("templates" "styles" "scripts"))
;;   (ensure-directories-exist (concatenate 'string path "/scripts") :mode 755)
;;   (ensure-directories-exist (concatenate 'string path "/styles") :mode 755))

;; (defun make-blog-skeleton (path)
;;   "Create a skeleton, with the default files in the proper places."
;;   (make-directories path)
;;   (make-templates path)
;;   (make-styles path)
;;   (make-scripts path))

;;; exporting
{'fraction_non_alphanumeric': 0.17108843537414967, 'fraction_numerical': 0.004421768707482994, 'mean_word_length': 2.9180546302465022, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '552278', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1922, 'n_words': 561}