forked from nat/natalieee.net
misc improvements for view-thought.hy
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
(do ;; required for arcane scoping
|
(do ;; required for arcane scoping
|
||||||
(defn check-param-exists [param-name]
|
(defn check-param-defined [param-name]
|
||||||
#[f[test "$(echo '{{' '{param-name}' '}}' | sed 's/ //g')" != '{{{param-name}}}']f])
|
#[f[test "$(echo '{{' '{param-name}' '}}' | sed 's/ //g')" != '{{{param-name}}}']f])
|
||||||
|
|
||||||
(defn if-param-then-else [param-name param-defined otherwise [echo True]]
|
(defn if-param-then-else [param-name param-defined otherwise [echo True]]
|
||||||
#[f[ {(check-param-exists param-name)} && {(if echo "echo " "")}{param-defined} || {(if echo "echo " "")}{otherwise} ]f])
|
#[f[ {(check-param-defined param-name)} && {(if echo "echo " "")}{param-defined} || {(if echo "echo " "")}{otherwise} ]f])
|
||||||
|
|
||||||
(defn param-if-param-else [param-name otherwise]
|
(defn param-if-param-else [param-name otherwise]
|
||||||
(if-param-then-else param-name f"'{{{param-name}}}'" otherwise))
|
(if-param-then-else param-name f"'{{{param-name}}}'" otherwise))
|
||||||
@ -18,7 +18,7 @@
|
|||||||
`(a (:href "?filter-tag=${tag}") "${tag}")))
|
`(a (:href "?filter-tag=${tag}") "${tag}")))
|
||||||
|
|
||||||
(setv thought-tag-list-format
|
(setv thought-tag-list-format
|
||||||
#[f[tags: $(while read -r tag{";"} do echo "{thought-tag-format}"{";"} done <<< "${{tags//{#[[;]]}/$'\n'}}")]f])
|
#[f[tags: $(while read -r tag{";"} do echo "{thought-tag-format}"{";"} done <<< "${{tags//;/$'\n'}}")]f])
|
||||||
|
|
||||||
(setv thought-list-entry-format (form->html
|
(setv thought-list-entry-format (form->html
|
||||||
`(div (:id "${file_name}" :class thought-list-entry)
|
`(div (:id "${file_name}" :class thought-list-entry)
|
||||||
@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
(defn thought [[title "empty title"] [description ""] [date "1970-01-01"] [tags []] [content '(p "no content provided")]]
|
(defn thought [[title "empty title"] [description ""] [date "1970-01-01"] [tags []] [content '(p "no content provided")]]
|
||||||
(inherit page-name)
|
(inherit page-name)
|
||||||
|
(when (not-in (get page-name -1) (with [thought-registry (open "../data/thought-registry" "r")] (.read thought-registry)))
|
||||||
(with [thought-registry (open "../data/thought-registry" "a")]
|
(with [thought-registry (open "../data/thought-registry" "a")]
|
||||||
(.write thought-registry f"{(.join #[[;]] tags)}\t{(get page-name -1)}\t{title}\t{date}\t{description}\n"))
|
(.write thought-registry f"{(.join #[[;]] tags)}\t{(get page-name -1)}\t{title}\t{date}\t{description}\n")))
|
||||||
|
|
||||||
(run "echo > /tmp/footnote_count")
|
(run "echo > /tmp/footnote_count")
|
||||||
|
|
||||||
@ -45,21 +46,22 @@
|
|||||||
~(run "put-footnotes")
|
~(run "put-footnotes")
|
||||||
~(comments f"/html/thought/view-thought.html?thought={(get page-name -1)}")))
|
~(comments f"/html/thought/view-thought.html?thought={(get page-name -1)}")))
|
||||||
|
|
||||||
(run "echo -n > ../data/thought-registry")
|
;; (run "echo -n > ../data/thought-registry")
|
||||||
|
|
||||||
(page
|
(page
|
||||||
:title #[f[$[{(param-if-param-else "thought" "natalie thoughts")}]]f]
|
:title f" $[{(param-if-param-else "thought" "natalie thoughts")}] "
|
||||||
:description #[f[
|
:description #[f[
|
||||||
$[{(if-param-then-else "thought" #[f["$({(get-thought-param-field "description")})"]f] #[f[
|
$[{(if-param-then-else "thought"
|
||||||
$({(if-param-then-else
|
#[f["$({(get-thought-param-field "description")})"]f]
|
||||||
"filter-tag"
|
#[f[$({(if-param-then-else "filter-tag"
|
||||||
"'thoughts filtered for "{filter-tag}"'"
|
"'thoughts filtered for "{filter-tag}"'"
|
||||||
"an enumeration of natalie thoughts. it is functionally a blog")})]f])}]]f]
|
"an enumeration of natalie thoughts. it is functionally a blog")})]f])}]]f]
|
||||||
|
|
||||||
`(section
|
`(section
|
||||||
(h1 ~#[f[
|
(h1 ~#[f[
|
||||||
$[{(if-param-then-else "thought" #[f[$({(get-thought-param-field "title")})]f] #[f[
|
$[{(if-param-then-else "thought"
|
||||||
$({(if-param-then-else
|
#[f[$({(get-thought-param-field "title")})]f]
|
||||||
|
#[f[$({(if-param-then-else
|
||||||
"filter-tag"
|
"filter-tag"
|
||||||
"'thoughts filtered for "{filter-tag}"'"
|
"'thoughts filtered for "{filter-tag}"'"
|
||||||
"natalie thoughts. functionally a blog")})]f])}]]f])
|
"natalie thoughts. functionally a blog")})]f])}]]f])
|
||||||
@ -75,6 +77,6 @@
|
|||||||
#[f[cat www/data/thought-registry | eval $({(if-param-then-else
|
#[f[cat www/data/thought-registry | eval $({(if-param-then-else
|
||||||
"filter-tag"
|
"filter-tag"
|
||||||
#[-[grep '{filter-tag}']-]
|
#[-[grep '{filter-tag}']-]
|
||||||
#[-["grep -E '.*'"]-])}) | sort -t$'\t' -k4 -nr | while IFS=$'\t' read -r tags file_name title date description{";"} do echo "{thought-list-entry-format}"{";"} done]f]
|
#[-["grep -E '.*'"]-])}) | sort -t $'\t' -k4{{,.6,.9}}rn | while IFS=$'\t' read -r tags file_name title date description{";"} do echo "{thought-list-entry-format}"{";"} done]f]
|
||||||
:echo False)}]]f]))))
|
:echo False)}]]f]))))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user