#! /bin/bash
. ./bin/utils.sh
-HERE=$(cd $(dirname_custom $0); pwd)
+HERE=$(
+ cd $(dirname_custom $0)
+ pwd
+)
THIS=$(basename_custom $0)
# Our HTML5 template, produced from the default pandoc template with some
# Standard getopt calling sequence
if ! TEMP=$(getopt -o "$shortopts" --long "$longopts" -n $THIS -- "$@"); then
- echo >&2 "$usage"
- exit 1
+ echo >&2 "$usage"
+ exit 1
fi
eval set -- "$TEMP"
unset TEMP
# Check the parsed options
while true; do
- case "$1" in
- '-o' | '--output' )
- output="$2"
- shift 2
- ;;
- '-i' | '--index' )
- index=1
- shift
- ;;
- '-h' | '--help' )
- echo >&2 "$usage"
- exit 0
- ;;
- '--' )
- shift
- break
- ;;
- * )
- echo >&2 'Internal error!'
- echo >&2 "$usage"
- exit 1
- ;;
- esac
+ case "$1" in
+ '-o' | '--output')
+ output="$2"
+ shift 2
+ ;;
+ '-i' | '--index')
+ index=1
+ shift
+ ;;
+ '-h' | '--help')
+ echo >&2 "$usage"
+ exit 0
+ ;;
+ '--')
+ shift
+ break
+ ;;
+ *)
+ echo >&2 'Internal error!'
+ echo >&2 "$usage"
+ exit 1
+ ;;
+ esac
done
######################################################################
# --output. Otherwise, read from the input files and write to corresponding
# 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
- fi
+ if [ -z "$output" ]; then
+ echo >&2 'Output path must be set with -o / --output in this mode'
+ exit 1
+ fi
- if [ "$(basename_custom "$output" .html)" = "$output" ]; then
- echo >&2 'Output path must end with .html'
- exit 1
- fi
+ if [ "$(basename_custom "$output" .html)" = "$output" ]; then
+ echo >&2 'Output path must end with .html'
+ exit 1
+ fi
- # Set '-' to mean stdin / stdout
- set -- -
+ # Set '-' to mean stdin / stdout
+ set -- -
elif [ -n "$output" ]; then
- echo >&2 '-o / --output is confusing in this mode'
- exit 1
+ echo >&2 '-o / --output is confusing in this mode'
+ exit 1
fi
# Check that all the arguments are existing and correctly named files
errfiles=
nofiles=
for f in "$@"; do
- [ "$f" = "-" ] && continue
+ [ "$f" = "-" ] && continue
- base=$(basename_custom "$f" md)
+ base=$(basename_custom "$f" md)
- if [ "$base" = "$f" ]; then
- errfiles="$errfiles '$f'"
- elif [ ! -f "$f" ]; then
- nofiles="$nofiles '$f'"
- fi
+ if [ "$base" = "$f" ]; then
+ errfiles="$errfiles '$f'"
+ elif [ ! -f "$f" ]; then
+ nofiles="$nofiles '$f'"
+ fi
done
if [ -n "$errfiles" ]; then
- echo >&2 "Files not ending with .md:$errfiles"
+ echo >&2 "Files not ending with .md:$errfiles"
fi
if [ -n "$nofiles" ]; then
- echo >&2 "Files no present:$nofiles"
+ echo >&2 "Files no present:$nofiles"
fi
if [ -n "$errfiles" -o -n "$nofiles" ]; then
- exit 1
+ exit 1
fi
-
+title_prefix=""
for f in "$@"; do
- if [ "$f" != "-" ]; then
- base=$(basename_custom "$f" md)
- dir=$(dirname "$f")
-
- if [ "$f" = "$base" ]; then
- continue;
- fi
- else
- base=$(basename_custom "$output" html)
- dir=$(dirname "$output")
- fi
-
- if [ "$dir" = "." -o "$dir" = "" ]; then
- title="/$base.html"
- top=""
- else
- title="/$dir/$base.html"
- top=`echo "$dir" | sed -E -e 's|[^/]+|..|g'`/
+ if [ "$f" != "-" ]; then
+ base=$(basename_custom "$f" md)
+ dir=$(dirname "$f")
+ input=$(grep "breadcrumb: " < $f);
+ prefix=${input#"breadcrumb: "}
+ if [ ! -z "$prefix" ]
+ then
+ title_prefix="[ ${prefix} ] - "
fi
- # is it an index file?
- def_isindex=
- if [ -n "$index" -o "$base" = "index" ]; then
- def_isindex="-M is-index=true"
+ if [ "$f" = "$base" ]; then
+ continue
fi
+ else
+ base=$(basename_custom "$output" html)
+ dir=$(dirname "$output")
+ fi
+
+ if [ "$dir" = "." -o "$dir" = "" ]; then
+ title="/$base.html"
+ top=""
+ else
+ title="$title_prefix/$dir/$base.html"
+ top=$(echo "$dir" | sed -E -e 's|[^/]+|..|g')/
+ fi
+
+ # is it an index file?
+ def_isindex=
+ if [ -n "$index" -o "$base" = "index" ]; then
+ def_isindex="-M is-index=true"
+ fi
+
+ # metadata
+ meta_file=""
+ input_file=""
+ meta="$dir/dirdata.yaml"
+ if [ -f "$meta" ]; then
+ meta_file="$HERE/../$meta"
+ fi
+
+ if [ "$f" = "-" ]; then
+ input_file="-"
+ else
+ input_file="$HERE/../$f"
+ fi
+
+ pandoc -t html5 -f markdown --template="$template" \
+ --highlight-style="$highlightstyle" \
+ --tab-stop=8 --shift-heading-level-by=1 \
+ -M author-meta='OpenSSL Foundation, Inc.' \
+ -M lang=en \
+ -M pagetitle="$title" \
+ $def_isindex -M top="$top" -o "$dir/$base.html" $meta_file $input_file
- (
- # metadata
- meta="$dir/dirdata.yaml"
- if [ -f "$meta" ]; then
- cat $meta
- fi
-
- if [ "$f" = "-" ]; then
- cat
- else
- cat "$f"
- fi
- ) | (
- cd $dir
- pandoc -t html5 -f markdown --template="$template" \
- --highlight-style="$highlightstyle" \
- --tab-stop=8 --shift-heading-level-by=1 \
- -M author-meta='OpenSSL Foundation, Inc.' \
- -M lang=en \
- -M pagetitle="$title" \
- $def_isindex -M top="$top"
- ) | (
- cat > "$dir/$base.html"
- )
done
my %options = ();
GetOptions(
\%options,
- 'name|n', # Show name
- 'email|e', # Show email
- 'locale|l', # Show locale
- 'pgp|p', # Show PGP key ID
- 'activity|a', # Show whether person is active
- 'title|t=s', # Title of the resulting table
- 'help|?', # Help
- 'man', # Full manual
- ) or pod2usage(2);
+ 'name|n', # Show name
+ 'email|e', # Show email
+ 'locale|l', # Show locale
+ 'pgp|p', # Show PGP key ID
+ 'activity|a', # Show whether person is active
+ 'title|t=s', # Title of the resulting table
+ 'help|?', # Help
+ 'man', # Full manual
+) or pod2usage(2);
pod2usage(1) unless $options{title};
pod2usage(1)
unless ($options{name} || $options{email} || $options{locale}
- || $options{activity} || $options{pgp});
+ || $options{activity} || $options{pgp});
pod2usage(1) if $options{help};
pod2usage(-exitval => 0, -verbose => 2) if $options{man};
my $query = OpenSSL::Query->new();
-my %data = (); # Indexed by name, value is a hash table of vals
+my %data = (); # Indexed by name, value is a hash table of vals
foreach my $groupname (@ARGV) {
my @members = $query->members_of($groupname);
foreach my $ids (@members) {
- my $name = (grep m|\s|, @$ids)[0];
- my $email = (grep m|\@openssl\.org$|, @$ids)[0];
- my $locale = $query->find_person_tag($email, 'country');
- my $pgpid = $query->find_person_tag($email, 'pgp');
- $data{$name} = { email => $email, locale => $locale, pgpid => $pgpid,
- active => !!($groupname !~ m|-inactive$|),
- emeritus => !!($groupname =~ m|-emeritus$|) };
+ my $name = (grep m|\s|, @$ids)[0];
+ my $email = (grep m|\@openssl\.org$|, @$ids)[0];
+ my $locale = $query->find_person_tag($email, 'country');
+ my $pgpid = $query->find_person_tag($email, 'pgp');
+ $data{$name} = { email => $email, locale => $locale, pgpid => $pgpid,
+ active => !!($groupname !~ m|-inactive$|),
+ emeritus => !!($groupname =~ m|-emeritus$|) };
}
}
print "<table summary=\"$options{title}\">\n";
print " <tr>\n";
print join(" <th> </th>\n",
- map { " <th>$_</th>\n" } @columns);
+ map {" <th>$_</th>\n"} @columns);
print " </tr>\n";
-foreach my $key (sort { mk_sortable($a) cmp mk_sortable($b) } keys %data) {
+foreach my $key (sort {mk_sortable($a) cmp mk_sortable($b)} keys %data) {
my $pgpurl = $data{$key}->{pgpid} if $options{pgp};
$pgpurl =~ s|\s+||g if $pgpurl;
- $pgpurl =
- "https://keys.openpgp.org/search?q=$pgpurl"
- if $pgpurl;
+ $pgpurl = "https://keys.openpgp.org/search?q=$pgpurl"
+ if $pgpurl;
my @columndata = ();
push @columndata,
- join('',
- $data{$key}->{active} ? "" : "<i>",
- encode_entities($key),
- $data{$key}->{active} ? "" : "</i> (I)",
- $data{$key}->{emeritus} ? " (OMC Emeritus)" : "")
- if $options{name};
+ join('',
+ $data{$key}->{active} ? "" : "<i>",
+ encode_entities($key),
+ $data{$key}->{active} ? "" : "</i> (I)",
+ $data{$key}->{emeritus} ? " (OMC Emeritus)" : "")
+ if $options{name};
push @columndata,
- "<a href='mailto:$data{$key}->{email}'>$data{$key}->{email}</a>"
- if $options{email};
+ "<a href='mailto:$data{$key}->{email}'>$data{$key}->{email}</a>"
+ if $options{email};
push @columndata, $data{$key}->{locale} if $options{locale};
push @columndata,
- $data{$key}->{pgpid}
- ? "<a href='$pgpurl'>$data{$key}->{pgpid}</a>" : ' '
- if $options{pgp};
+ $data{$key}->{pgpid}
+ ? "<a href='$pgpurl'>$data{$key}->{pgpid}</a>" : ' '
+ if $options{pgp};
print " <tr>\n";
print join(" <td> </td>\n",
- map { " <td>$_</td>\n" } @columndata);
+ map {" <td>$_</td>\n"} @columndata);
print " </tr>\n";
}