Skip to content

Commit

Permalink
CDN Preparation - further speed improvement - remove not needed seds …
Browse files Browse the repository at this point in the history
…and basename calls
  • Loading branch information
vavroch2010 committed Jan 8, 2024
1 parent 7c6fbca commit a2e336e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 57 deletions.
21 changes: 11 additions & 10 deletions bin/md-to-html5
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#! /bin/sh
. ./bin/utils.sh

HERE=$(cd $(dirname $0); pwd)
THIS=$(basename $0)
HERE=$(cd $(dirname_custom $0); pwd)
THIS=$(basename_custom $0)

# Our HTML5 template, produced from the default pandoc template with some
# massaging by 'mk-pandoc-template'.
Expand Down Expand Up @@ -87,13 +88,13 @@ done
# output files.
if [ $# -eq 0 ]; then
if [ -z "$output" ]; then
echo >&2 'Output path must be set with -o / --output in this mode'
exit 1
echo >&2 'Output path must be set with -o / --output in this mode'
exit 1
fi

if [ "$(basename "$output" .html)" = "$output" ]; then
echo >&2 'Output path must end with .html'
exit 1
if [ "$(basename_custom "$output" .html)" = "$output" ]; then
echo >&2 'Output path must end with .html'
exit 1
fi

# Set '-' to mean stdin / stdout
Expand All @@ -109,7 +110,7 @@ nofiles=
for f in "$@"; do
[ "$f" = "-" ] && continue

base=$(basename "$f" .md)
base=$(basename_custom "$f" .md)

if [ "$base" = "$f" ]; then
errfiles="$errfiles '$f'"
Expand All @@ -129,14 +130,14 @@ fi

for f in "$@"; do
if [ "$f" != "-" ]; then
base=$(basename "$f" .md)
base=$(basename_custom "$f" .md)
dir=$(dirname "$f")

if [ "$f" = "$base" ]; then
continue;
fi
else
base=$(basename "$output" .html)
base=$(basename_custom "$output" .html)
dir=$(dirname "$output")
fi

Expand Down
12 changes: 7 additions & 5 deletions bin/mk-apropos
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#! /bin/sh
#! /bin/bash
# $1 is the top of the manual page tree to look through
. ./bin/utils.sh

dir=$1
cd $dir || exit

for m in $(find . -name '*.md.tt' | sort); do
description=$(grep '^OSSL-description:' $m | sed -e 's|^[^:]*: *||' -e 's|^ *"||' -e 's|" *||')
# description=$(grep '^OSSL-description:' $m | sed -e 's|^[^:]*: *||' -e 's|^ *"||' -e 's|" *||')
description=$(get_description $m)
# If there isn't a description, it isn't a manpage and should not be
# included
if [ "$description" = "" ]; then
continue
fi
manfile=$(echo $m | sed -e 's|\./||')
manname=$(basename $manfile .md.tt)
origmanfile=$(echo $manfile | sed -e "s|^$subdir|$origsubdir|")
manfile=$(basename_custom $m)
manname=$(basename_custom $manfile .md.tt)
#origmanfile=$(echo $manfile | sed -e "s|^$subdir|$origsubdir|")
echo "| [$manname]($manname.html) | $description |"
done
16 changes: 8 additions & 8 deletions bin/mk-mancross
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/bash

. ./bin/utils.sh

releases="$*"

log () {
Expand All @@ -24,7 +26,9 @@ for r in $releases; do
for f in docs/man$r/man$s/*.md.tt; do
$debug -n '.'
existsin=''
b=$(basename "$f" .md.tt)
#
b=$(basename_custom $f md.tt)

for x in $releases; do
if [ "$x" = "$r" ]; then
continue
Expand All @@ -35,14 +39,10 @@ for r in $releases; do
done
(
if [ "$existsin" != "" ]; then
cat <<EOF
sidebar: |
# This manpage
EOF
echo "sidebar: |"
echo "# This manpage"
for x in $existsin; do
cat <<EOF
- [$x version]([% top %]docs/man$x/man$s/$b.html)
EOF
echo " - [$x version]([% top %]docs/man$x/man$s/$b.html)"
done
fi
) > "docs/man$r/man$s/$b.cross"
Expand Down
8 changes: 3 additions & 5 deletions bin/mk-manhtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/bin/bash
# shellcheck source=job_pool.sh
. ./bin/utils.sh
. ./bin/job_pool.sh


function process_file()
{
t=$1
d=${t%/*}
#echo $DIR
#h="$(basename "$t" .md.tt)";
h1="${t##*/}"
h="${h1%.md.tt}"
d=$(dirname_custom $t)
h="$(basename_custom $t md.tt)"
i=;
if [ "$h" = "index" ]; then i=" -i"; fi;
time_elapsed=$( TIMEFORMAT="%R"; { time ./bin/from-tt -d $d < $d/$h.md.tt | ./bin/md-to-html5$i -o $d/$h.html; } 2>&1 )
Expand Down
29 changes: 0 additions & 29 deletions bin/mk-manpagetts3_process_file

This file was deleted.

39 changes: 39 additions & 0 deletions bin/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# returns basename of filepath and removes extension if specified
function basename_custom {
if [[ -n $1 ]]; then
filepath=$1
file_basename="${filepath##*/}"
if [[ -n $2 ]]; then
file_basename="${file_basename%.$2}"
fi
echo $file_basename
else
exit 1
fi
}

function dirname_custom {
if [[ -n $1 ]]; then
filepath=$1
echo ${filepath%/*}
fi
}

function get_description {
FILE="$1"
TEXT='^OSSL-description:'
i=0
while read line; do

if [[ "$line" =~ ^OSSL-description: ]]; then
line=${line#*'"'}
line=${line%'"'*}
echo "$line"
break
fi
done <"$FILE"
}

# get_descriptiom ../docs/man3.2/man3/BIO_get_rpoll_descriptor.md.tt
# basename_custom docs/manmaster/man3/CMS_SignedData_free.md.tt md.tt

0 comments on commit a2e336e

Please sign in to comment.