meso-web

Sources of the |Méso|Star> website
git clone git://git.meso-star.fr/meso-web.git
Log | Files | Refs | README | LICENSE

commit fe683a21ade57fee9f398feb93c19675475be4e2
parent 33ae2f27e0a75d4e0b33c253ffdf8f0d5b283a7a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 28 Aug 2025 09:41:38 +0200

Add a URL and external directory to the menu definition

Now, a menu entry can target not only local content, but also a URL to
external resources or a remote directory managed elsewhere (i.e. a
directory on the installation target).

In other words, it is now possible to create a link in the menu to an
external website or other server-managed content, such as an HTML
interface to git repositories.

Diffstat:
Mscripts/generate_header.sh | 23+++++++++++++++++------
Mscripts/meso-web.sh | 6+++++-
2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/scripts/generate_header.sh b/scripts/generate_header.sh @@ -73,23 +73,34 @@ print_menu1() _separator="" strip_dummy < "${worktree}/menu.tsv" | while read -r _i; do - # Retrieve the menu label and its associated directory + # Retrieve the menu label and its associated target _label="$(echo "${_i}" | cut -d' ' -f1)" - _directory="$(echo "${_i}" | cut -d' ' -f2)" + _target="$(echo "${_i}" | cut -d' ' -f2)" echo "${_separator}" && _separator=' &emsp13;|&emsp13;' - if [ "${_directory}" = "${section}" ]; then + if [ "${_target}" = "${section}" ]; then printf ' %s\n' "${_label}" - else + elif [ -f "${worktree}/${_target}/index.tsv" ]; then # Get the default page of the section, i.e., the first entry in # its index. The menu is a link to it. - _uri="$(indexed_content < "${worktree}/${_directory}/index.tsv" \ + _uri="$(indexed_content < "${worktree}/${_target}/index.tsv" \ | head -1 | cut -d' ' -f2)" printf ' <a href="%s%s/%s">%s</a>\n' \ - "${root}" "${_directory}" "${_uri}" "${_label}" + "${root}" "${_target}" "${_uri}" "${_label}" + + # The target is an URL + elif echo "${_target}" | grep -qe "^[^:]\{1,\}://"; then + printf ' <a href="%s">%s</a>\n' "${_target}" "${_label}" + + # The target is neither a local directory nor a URL. Let's assume + # it is a remote directory, still relative to the current root once + # the local content is installed, but managed elsewhere. + else + printf ' <a href="%s%s">%s</a>\n' \ + "${root}" "${_target}" "${_label}" fi done diff --git a/scripts/meso-web.sh b/scripts/meso-web.sh @@ -34,7 +34,11 @@ sections() # - Protect spaces in the section name strip_dummy < menu.tsv \ | cut -d' ' -f2 \ - | sed -e 's/[[:space:]]/\\ /g' + | sed -e 's/[[:space:]]/\\ /g' \ + | xargs -I{} sh -c \ + "if [ -f \"\$1/index.tsv\" ]; then \ + printf '%s\n' \"\$1\"; \ + fi" -- {} } # Print the absolute dir of the input file