▼ (peek-char t \*sexp-life*) --- Peeking into Symbolic expression life
NAME: blog-menu
SRC lisp :results value raw drawer output :var year="2025"
(ql:quickload '(:unix-cmd) :silent t)
(defpackage :myblog
(:use :cl :unix-cmd)
(:export :main)) (in-package :myblog)
(defstruct person name attribute)
(defun scan (key obj)
(let ((key-len (length key))
(start (search key obj)))
(when start
(values start (+ start key-len)))))
(defun %s (old new obj)
(multiple-value-bind (start end)
(scan old obj)
(if start
(let* ((rest (subseq obj end))
(result (%s old new rest)))
(concatenate 'string (subseq obj 0 start) new result))
obj)))
(defun code->bit (code)
(check-type code string)
(map 'string #'(lambda (x)
(case x (#\. #\0)
(#\- #\1)
(t (error "Contains incorrect code"))))
code))
(defun bit->dec (bit-str)
(parse-integer (code->bit bit-str) :radix 2))
(defun code->name (code)
(loop :for c :in code
:collect (format nil "~a" (code-char (bit->dec c))) :into name
:finally (return (format nil "~{~a~}" name))))
(defparameter b2
(let ((code '("--...-."
"--.-..-"
"--.----"
"--..--."
"--..-.-"
"---..-."
"--.--.-"
"--.-..-"
"--.---."
"--..-.")))
(make-person
:name (code->name code)
:attribute "cl-user"))
"code name")
(defparameter domain-name
(format nil "~{~a~^.~}" (list (person-name b2) "github" "io")))
(defparameter home-dir
(let ((dir (make-pathname :directory (list :relative domain-name "docs"))))
(merge-pathnames dir (user-homedir-pathname))))
(defun hidden-target-linep (line)
(let ((comment "* COMMENT ")
(task "* TASKS"))
(or (search comment line)
(search task line))))
(defun get-titles (org-file)
(with-open-file (in org-file :direction :input)
(loop :for line = (read-line in nil)
:while line
:with titles
:do (unless (hidden-target-linep line)
(cond ((and (> (length line) 2)
(= 1 (count #\* (subseq line 0 2) :test #'equal)))
(push (subseq line 2) titles))
((and (> (length line) 3)
(= 2 (count #\* (subseq line 0 3) :test #'equal)))
(push (subseq line 3) titles))))
:finally (return (reverse titles)))))
(defun make-link (html-file)
(let* ((html-path (merge-pathnames html-file home-dir))
(html->org (make-pathname :type "org" :defaults html-path))
(org-file (if (probe-file html->org)
html->org
(make-pathname :name (%s ".org" ""
(pathname-name html-file))
:type "org" :defaults html-path)))
(titles (get-titles org-file)))
(with-output-to-string (s)
(loop :initially (format s "** [[./~a][~a ]]~%" html-file (string-right-trim
'(#\Space #\Tab) (car titles)))
:for title :in (cdr titles)
:do (format s " - ~a~%" title)))))
(defun menu (html-file)
(cd home-dir)
(format t "~{~a~}"
(mapcar #'(lambda (x) (make-link x))
(reverse (ll html-file)))))
(menu (concatenate 'string year "/*.html"))
SRC
RESULTS: blog-menu
:results:
▽ 2025-02-24 月
– ブログの再開
– hoge
– hoge
▽ 2025-02-19 水
– ブログの再開
– 2025-02-19 水 ROUTINEs [/]
– DONE 2025-02-19 水 14:45 org-tangleについて調べる
– TODO 2025-02-19 水 14:46 org文書をエクスポートする際コメントの非表示化の方法について調べる
– HTML化する testcomment
:end:
CALL: blog-menu(year="2023")
RESULTS:
:results:
▽ 2023-09-01 金
– org-modeのコメント
– ROUTINEs 5/7
– DONE 2023-09-01 金 08:14 水遣り
▽ 2023-08-31 木
– 土とlisp :lisp:
– 密植 :agri:
– ROUTINEs 4/7
– DONE 2023-08-31 木 10:25 畝一本作る :agri:
– DONE 2023-08-31 木 10:26 ゴボウ播種 :agri:
– DONE 2023-08-31 木 10:28 畑の水撒き :agri:
▽ 2023-04-23 日
– dpANSのorg文書化 :lisp:
▽ 2023-03-30 木
– 先日のloopのnamedするかしないかでの挙動の違いについて :lisp:
▽ 2023-03-26 日
– loopのおかしな挙動 :lisp:
▽ 2023-03-24 金
– 配列とハッシュテーブルの違い :lisp:
▽ 2023-02-27 月
– 昨日の続き :lisp:
– janet-langのインストール :lisp:
▽ 2023-02-26 日
– lisptea timeの質問のまとめ :lisp:
▽ 2023-02-19 日
– 湯たんぽ話 :lifehack:
▽ 2023-02-14 火
– the :lisp:
:end:
CALL: blog-menu(year="2022")
RESULTS:
:results:
▽ 2022-12-28 水
– 餅つき
▽ 2022-12-26 月
– 千歯扱き初体験 :agriculture:
▽ 2022-12-17 土
– サツマイモ完食 :agriculture:
▽ 2022-12-13 火
– 猫用出入り口を作る :diy:
▽ 2022-12-10 土
– ubuntuの修復作業
▽ 2022-12-07 水
– org-mode復帰
▽ 2022-12-03
– カブの海水漬け :cooking:
▽ 2022-11-30 水
– menu表示機能を作ってみた :dev:
▽ 2022-11-27 日
– 里芋の収穫 :agriculture:
▽ 2022-11-15 火
– チェーンソーを試す :forestry:
▽ 2022-11-14 月
– jsclを入れてみた :lisp:
– このブログの在り方について
▽ 2022-10-30 日
– 木を切る :forestry:
– substとsublis :lisp:
▽ 2022-10-28 金
– 木を切る :forestry:
– 耕運機を頂く :agriculture:
▽ 2022-10-27 木
– awsにlispをインストール :lisp:
▽ 2022-10-26 水
– アスパラガスと人参の播種 :agriculture:
– ブログ運用での問題点 :lisp:
▽ 2022-10-24 月
– 韮、青紫蘇、南瓜、薩摩芋、落花生、黒豆、青大豆、黒ささげ、ズッキーニ :agriculture:
▽ 2022-10-20 木
– ラッカセイの収穫 :agriculture:
▽ 2022-10-19 水
– クロマメ、アオダイズ、クロササゲ収穫 :agriculture:
▽ 2022-09-30 金
– fusion! :lisp:
▽ 2022-09-27 火
– common lispでの文字列置換2
▽ 2022-09-16 金
– 我が家のlisp本 :lisp:
▽ 2022-09-14 水
– 空芯菜の収穫 :agriculture:
– common-lispでfizzbuzz :lisp:
▽ 2022-09-13 火
– 最近のlisp系の傾向について思う事。 :lisp:
▽ 2022-09-12 月
– このブログのこれからの在り方 :dev:
▽ 2022-09-10 土
– common lispでの文字列置換 :lisp:
▽ 2022-09-09 金
– なぜmarkdown形式ではなくorg-mode形式で書くのか? :lisp:
▽ 2022-09-08 木 org-modeによるgithub pagesの作成2
– あれから
– vimによるhtml化
– emacsでのhtml化
– emacsの配色設定
– 最初は
– org-babelの問題点
– おわり
▽ 2022-09-07 水 org-modeでgithub pagesのサイトを作る
– 個人blogの作成
– orgファイルのhtml化の方法
– 問題点
:end: