From 278d631c43419f9dea3cf5192ec530cecfb9bb06 Mon Sep 17 00:00:00 2001 From: Nils Date: Fri, 26 Jun 2020 21:56:11 +0100 Subject: [PATCH 1/5] Add named link functionality Add `named` to options (4th line of header) --- internal/Makefile | 3 +++ internal/globals.sh | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/Makefile b/internal/Makefile index 8978ae7..e4ef4b1 100644 --- a/internal/Makefile +++ b/internal/Makefile @@ -288,6 +288,9 @@ ifeq ($(MAKE_SHORT_POSTS),yes) else cp $(BUILD_DIR)/404.html $@ endif + if [ -n "$$(op_is_set $(METADATA_DIR)/$*/options named)" ]; then \ + cp $@ $(BUILD_DIR)/$$(cut -d '/' -f 3 <<< $(subst -$*.html,,$(filter %-$*.html,$(BUILT_POSTS)))).html; \ + fi # Short source files, like build/p/abcd1234.bm # This also takes care of regular source files, like diff --git a/internal/globals.sh b/internal/globals.sh index 1c9532e..3bef12e 100644 --- a/internal/globals.sh +++ b/internal/globals.sh @@ -82,6 +82,8 @@ function build_content_header { [[ "${PREFER_SHORT_POSTS}" == "yes" ]] && POST_LINK="${ROOT_URL}/p/${POST}.html" || POST_LINK="${ROOT_URL}/posts/${POST_FILE}" + [ -n "$(op_is_set "${METADATA_DIR}/${POST}/options" named)" ] && + POST_LINK="/${POST_FILE%%-${POST}\.html}.html" (( "${#OPTS[@]}" > 0 )) && [[ " ${OPTS[@]} " =~ " for-preview " ]] && TITLE="${TITLE}" DATE="$(get_date "${HEADERS}")" @@ -534,7 +536,10 @@ function post_markdown { [[ "${PREFER_SHORT_POSTS}" == "yes" ]] && \ LINK="/p/${ID}.html" || \ LINK="/posts/$(get_title "${METADATA_DIR}/${ID}/headers" | title_to_post_url)${TITLE_SEPARATOR_CHAR}${ID}.html" - sed "s|\( "${TMP2}" + + [ -n "$(op_is_set "${METADATA_DIR}/${ID}/options" named)" ] && + LINK="/${POST_FILE%%-${ID}\.html}.html" + sed "s|\( "${TMP2}" else cat "${TMP1}" > "${TMP2}" fi From f43cca027e5cf9745c46d47fcc82f051121fd7be Mon Sep 17 00:00:00 2001 From: Nils Date: Fri, 26 Jun 2020 23:30:52 +0100 Subject: [PATCH 2/5] Enable using named option in named link --- internal/Makefile | 4 ++-- internal/globals.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/Makefile b/internal/Makefile index e4ef4b1..b10bcdb 100644 --- a/internal/Makefile +++ b/internal/Makefile @@ -288,8 +288,8 @@ ifeq ($(MAKE_SHORT_POSTS),yes) else cp $(BUILD_DIR)/404.html $@ endif - if [ -n "$$(op_is_set $(METADATA_DIR)/$*/options named)" ]; then \ - cp $@ $(BUILD_DIR)/$$(cut -d '/' -f 3 <<< $(subst -$*.html,,$(filter %-$*.html,$(BUILT_POSTS)))).html; \ + if [ -n "$$(op_is_set "$(METADATA_DIR)/$*/options" named)" ]; then \ + cp $@ "$(BUILD_DIR)/$$(op_get "$(METADATA_DIR)/$*/options" named).html"; \ fi # Short source files, like build/p/abcd1234.bm diff --git a/internal/globals.sh b/internal/globals.sh index 3bef12e..b0f29e4 100644 --- a/internal/globals.sh +++ b/internal/globals.sh @@ -83,7 +83,7 @@ function build_content_header { POST_LINK="${ROOT_URL}/p/${POST}.html" || POST_LINK="${ROOT_URL}/posts/${POST_FILE}" [ -n "$(op_is_set "${METADATA_DIR}/${POST}/options" named)" ] && - POST_LINK="/${POST_FILE%%-${POST}\.html}.html" + POST_LINK="${ROOT_URL}/$(op_get "${METADATA_DIR}/${POST}/options" named).html" (( "${#OPTS[@]}" > 0 )) && [[ " ${OPTS[@]} " =~ " for-preview " ]] && TITLE="${TITLE}" DATE="$(get_date "${HEADERS}")" @@ -538,7 +538,7 @@ function post_markdown { LINK="/posts/$(get_title "${METADATA_DIR}/${ID}/headers" | title_to_post_url)${TITLE_SEPARATOR_CHAR}${ID}.html" [ -n "$(op_is_set "${METADATA_DIR}/${ID}/options" named)" ] && - LINK="/${POST_FILE%%-${ID}\.html}.html" + LINK="/$(op_get "${METADATA_DIR}/${ID}/options" named).html" sed "s|\( "${TMP2}" else cat "${TMP1}" > "${TMP2}" From 877a6a8939d4bb00b4f4440efdc08bfed828e053 Mon Sep 17 00:00:00 2001 From: Nils Date: Sat, 27 Jun 2020 11:52:03 +0100 Subject: [PATCH 3/5] Add named link signature --- internal/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/Makefile b/internal/Makefile index b10bcdb..7c98405 100644 --- a/internal/Makefile +++ b/internal/Makefile @@ -329,6 +329,9 @@ else mv $@ $(filter %-$*.asc,$(BUILT_SIG_PAGES)) cp $(BUILD_DIR)/404.html $@ endif + if [ -n "$$(op_is_set "$(METADATA_DIR)/$*/options" named)" ]; then \ + cp $@ "$(BUILD_DIR)/$$(op_get "$(METADATA_DIR)/$*/options" named).asc"; \ + fi # Homepage, some number of post previews. Follows the same general formula of # post generation: generate everything in order, pipe through m4, then dump into From 5fdbe922cc28190414cdfa42e90a7ae65d11c131 Mon Sep 17 00:00:00 2001 From: Nils Date: Sat, 27 Jun 2020 18:10:41 +0100 Subject: [PATCH 4/5] Fix signature Remove .html --- internal/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/Makefile b/internal/Makefile index 7c98405..939cbe7 100644 --- a/internal/Makefile +++ b/internal/Makefile @@ -329,8 +329,8 @@ else mv $@ $(filter %-$*.asc,$(BUILT_SIG_PAGES)) cp $(BUILD_DIR)/404.html $@ endif - if [ -n "$$(op_is_set "$(METADATA_DIR)/$*/options" named)" ]; then \ - cp $@ "$(BUILD_DIR)/$$(op_get "$(METADATA_DIR)/$*/options" named).asc"; \ + if [ -n "$$(op_is_set "$(METADATA_DIR)/$(subst .html,,$*)/options" named)" ]; then \ + cp $@ "$(BUILD_DIR)/$$(op_get "$(METADATA_DIR)/$(subst .html,,$*)/options" named).asc"; \ fi # Homepage, some number of post previews. Follows the same general formula of From 398e0fe3d7b449c12c7ce90c66ba12717aa21563 Mon Sep 17 00:00:00 2001 From: Nils Date: Sat, 27 Jun 2020 18:52:04 +0100 Subject: [PATCH 5/5] Add named links for tag, index and permalinks --- internal/globals.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/globals.sh b/internal/globals.sh index b0f29e4..b23facc 100644 --- a/internal/globals.sh +++ b/internal/globals.sh @@ -97,6 +97,8 @@ function build_content_header { [[ "${MAKE_SHORT_POSTS}" == "yes" ]] && PERMALINK="${ROOT_URL}/p/$(get_id "${HEADERS}").html" || PERMALINK= + [ -n "$(op_is_set "${METADATA_DIR}/${POST}/options" named)" ] && + PERMALINK="$POST_LINK" IS_PINNED="$(op_get "${OPTIONS}" pinned)" (( "${#OPTS[@]}" > 0 )) && [[ " ${OPTS[@]} " =~ " for-preview " ]] && [[ "${IS_PINNED}" != "" ]] && @@ -164,8 +166,10 @@ function build_postindex { ID="$(basename $(dirname "${P}"))" TITLE="$(get_title "${P}")" [[ "${PREFER_SHORT_POSTS}" == "yes" ]] && - LINK="/p/${ID}.html" || - LINK="/posts/$(echo "${TITLE}" | title_to_post_url)${TITLE_SEPARATOR_CHAR}${ID}.html" + LINK="${ROOT_URL}/p/${ID}.html" || + LINK="${ROOT_URL}/posts/$(echo "${TITLE}" | title_to_post_url)${TITLE_SEPARATOR_CHAR}${ID}.html" + [ -n "$(op_is_set "${METADATA_DIR}/${ID}/options" named)" ] && + LINK="${ROOT_URL}/$(op_get "${METADATA_DIR}/${ID}/options" named).html" AUTHOR="$(get_author "${P}")" DATE="$(get_date "${P}")" DATE_PRETTY="$(ts_to_date "${DATE_FRMT}" "${DATE}")" @@ -239,6 +243,8 @@ function build_tagindex { else LINK="/posts/$(echo "${TITLE}" | title_to_post_url)${TITLE_SEPARATOR_CHAR}${ID}.html" fi + [ -n "$(op_is_set "${METADATA_DIR}/${ID}/options" named)" ] && + LINK="${ROOT_URL}/$(op_get "${METADATA_DIR}/${ID}/options" named).html" AUTHOR="$(get_author "${HEADERS}")" echo "
  • ${TITLE} by ${AUTHOR} on ${DATE_PRETTY}
  • " | tee -a "${TMP_TAG_FILE}" fi