parameterises postprocess cmd in blog script
This commit is contained in:
+2
-2
@@ -6,12 +6,12 @@ out: microlog blog $(shell find src -type f) $(shell find share -type f) $(shell
|
|||||||
microlog: src/microlog
|
microlog: src/microlog
|
||||||
|
|
||||||
src/microlog: $(shell find -L blogs/microlog -type f) bin/blog
|
src/microlog: $(shell find -L blogs/microlog -type f) bin/blog
|
||||||
./bin/blog -i microlog -l microlog -t
|
./bin/blog -i microlog -l microlog -t -p gmi2upphtml
|
||||||
|
|
||||||
blog: src/blog
|
blog: src/blog
|
||||||
|
|
||||||
src/blog: $(shell find -L blogs/blog -type f) bin/blog
|
src/blog: $(shell find -L blogs/blog -type f) bin/blog
|
||||||
./bin/blog -i blog -l blog
|
./bin/blog -i blog -l blog -p gmi2upphtml
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
Executable → Regular
+13
-4
@@ -7,7 +7,7 @@ export LAYOUTS="$(realpath share/layouts)"
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
>&2 cat << USAGE
|
>&2 cat << USAGE
|
||||||
usage: blog -i LOG [-l LAYOUT] [-t]
|
usage: blog -i LOG [-p POSTPROCESS_CMD] [-l LAYOUT] [-t]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
|
|
||||||
@@ -18,6 +18,10 @@ options:
|
|||||||
If provided, the layout under \$LAYOUTS to use for the generated
|
If provided, the layout under \$LAYOUTS to use for the generated
|
||||||
upphtml files. If not provided, uses the default layout.
|
upphtml files. If not provided, uses the default layout.
|
||||||
|
|
||||||
|
-p POSTPROCESS_CMD
|
||||||
|
If provided, a shell command to post-process the source files into
|
||||||
|
upphtml. The shell will be provided with a variable, POST_TITLE.
|
||||||
|
|
||||||
-t
|
-t
|
||||||
If enabled, use filenames as post titles
|
If enabled, use filenames as post titles
|
||||||
USAGE
|
USAGE
|
||||||
@@ -25,9 +29,10 @@ USAGE
|
|||||||
|
|
||||||
log_name=""
|
log_name=""
|
||||||
layout="default"
|
layout="default"
|
||||||
|
postprocess_cmd="echo"
|
||||||
use_filenames_for_titles=0
|
use_filenames_for_titles=0
|
||||||
|
|
||||||
while getopts "i:l:t" opt
|
while getopts "i:l:p:t" opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
i)
|
i)
|
||||||
@@ -36,6 +41,9 @@ do
|
|||||||
l)
|
l)
|
||||||
layout_name="$OPTARG"
|
layout_name="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
postprocess_cmd="$OPTARG"
|
||||||
|
;;
|
||||||
t)
|
t)
|
||||||
use_filenames_for_titles=1
|
use_filenames_for_titles=1
|
||||||
;;
|
;;
|
||||||
@@ -78,10 +86,11 @@ do
|
|||||||
if [ $use_filenames_for_titles -eq 1 ]
|
if [ $use_filenames_for_titles -eq 1 ]
|
||||||
then
|
then
|
||||||
title="$name"
|
title="$name"
|
||||||
cat "$entry" | gmi2upphtml "$title" > "$dest"
|
cat "$entry" | POST_TITLE="$title" eval "$postprocess_cmd" > "$dest"
|
||||||
else
|
else
|
||||||
title="$(grep --regexp "^\# " --max-count 1 "$entry" | cut -c3-)"
|
title="$(grep --regexp "^\# " --max-count 1 "$entry" | cut -c3-)"
|
||||||
cat "$entry" | grep --regexp "^\# " --invert-match | gmi2upphtml "$title" > "$dest"
|
export POST_TITLE="$title"
|
||||||
|
cat "$entry" | grep --regexp "^\# " --invert-match | eval "$postprocess_cmd" > "$dest"
|
||||||
fi
|
fi
|
||||||
echo "${title}" > "${dest}.args"
|
echo "${title}" > "${dest}.args"
|
||||||
echo "Processed ${entry#$(dirname ${BLOGS})/} to ${dest#$(dirname ${SRC})/}"
|
echo "Processed ${entry#$(dirname ${BLOGS})/} to ${dest#$(dirname ${SRC})/}"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
post_title="${1:-}"
|
post_title="${POST_TITLE:-}"
|
||||||
|
|
||||||
is_in_list=0
|
is_in_list=0
|
||||||
is_in_link_block=0
|
is_in_link_block=0
|
||||||
|
|||||||
Reference in New Issue
Block a user