Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / solenv / bin / mkdocs_portal.sh
blob852e3448179d4e4bcde1ce0f6f20a9cfb174d27c
1 #!/bin/bash
3 if [ -n "$debug" ] ; then
4 set -x
5 fi
7 SRCDIR="$1"
8 BASE_OUTPUT="$2"
10 pushd "$SRCDIR" > /dev/null
13 function header
15 local title="$1"
16 local breadcrumb="$2"
17 local output="$3"
19 cat - > $output <<EOF
20 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
21 <html>
22 <head>
23 <title>$title</title>
25 <style>
26 * { margin: 0; padding: 0; }
27 body { font-family: sans-serif; font-size: 12px; }
28 #head { padding: 20px; background: #00A500; }
29 #head a { color: #000; }
30 #body { padding: 20px; }
31 #foot { padding: 10px; font-size: 9px; border-top: 1px #18A303 solid; margin-top: 25px; }
32 p { line-height: 1.7em; margin-bottom: 1em; }
33 pre { margin-bottom: 0.5em; }
34 .multi-col { -moz-column-width: 20em; -webkit-column-width: 20em; -moz-column-gap: 1em; -webkit-column-gap: 1em; }
35 h1 { margin-bottom: 0.5em; }
36 h2,h3,h4 { margin: 1.3em 0 0.5em 0; }
37 ul, ol { margin: 0.5em 1.5em; }
38 </style>
39 </head>
40 <body>
41 <div id="head">
42 <h1>${title}</h1>
43 <p>${breadcrumb}</p>
44 </div>
45 <div id="body" style="multi-col">
46 EOF
49 function footer
51 local output="$1"
53 cat - >> $output <<EOF
55 </div>
56 <div id="foot">
57 <small>
58 <p>Generated by Libreoffice CI on $(hostname)</p>
59 <p>Last updated:
60 EOF
62 date '+%F %T' >> $output
63 cat - >> $output <<EOF
64 | <a href="http://www.documentfoundation.org/privacy">Privacy Policy</a> | <a href="http://www.documentfoundation.org/imprint">Impressum (Legal Info)</a>
65 </p>
66 </small>
67 </div>
68 </body>
69 </html>
70 EOF
74 function proc_text
76 # Local links: [[...]]
77 # Git links: [git:...]
78 # Other remote links: [...]
79 # Headings: == bleh ==
80 # Paragraphs: \n\n
81 sed -re ' s/\[\[([-_a-zA-Z0-9]+)\]\]/<a href="\1.html">\1<\/a>/g' - \
82 | sed -re ' s/\[git:([^]]+)\]/<a href="https:\/\/cgit.freedesktop.org\/libreoffice\/core\/tree\/\1">\1<\/a>/g' \
83 | sed -re ' s/\[([^]]+)\]/<a href="\1">\1<\/a>/g' \
84 | sed -re ' s/====([^=]+)====/<h4>\1<\/h4>/g' \
85 | sed -re ' s/===([^=]+)===/<h3>\1<\/h3>/g' \
86 | sed -re ' s/==([^=]+)==/<h2>\1<\/h2>/g' \
87 | sed -re ':a;N;$!ba;s/\n\n/<\/p><p>/g' \
88 | awk 'BEGIN { print "<p>" } { print } END { print "</p>" }'
91 # generate entry page
93 echo "generating index page"
94 header "LibreOffice Modules" " " "$BASE_OUTPUT/index.html"
96 for module_name in *; do
97 if [ -d $module_name ]; then
98 cur_file=
99 if [ -f $module_name/readme.txt ] ; then
100 cur_file="$module_name/readme.txt"
101 elif [ -f $module_name/README ] ; then
102 cur_file="$module_name/README"
104 if [ -n "$cur_file" ]; then
105 # write index.html entry
106 text="<h2><a href=\"${module_name}.html\">${module_name}</a></h2>\n"
107 text="${text}$(head -n1 $cur_file | proc_text )"
108 echo -e $text >> "$BASE_OUTPUT/index.html"
110 # write detailed module content
111 header "$module_name" "<a href=\"index.html\">LibreOffice</a> &raquo; ${module_name}" "$BASE_OUTPUT/${module_name}.html"
112 text="<p><b>View module in:</b>"
113 text="${text} &nbsp; <a href=\"https://cgit.freedesktop.org/libreoffice/core/tree/${module_name}\">cgit</a>"
114 if [ -d ./docs/${module_name} ] ; then
115 text="${text} &nbsp; <a href=\"${module_name}/html/classes.html\">Doxygen</a>"
117 text="${text} </p><p>&nbsp;</p>"
118 echo -e $text >> "$BASE_OUTPUT/${module_name}.html"
119 proc_text < $cur_file >> "$BASE_OUTPUT/${module_name}.html"
120 footer "$BASE_OUTPUT/${module_name}.html"
121 else
122 empty_modules[${#empty_modules[*]}]=$module_name
125 done
127 if [ ${#empty_modules[*]} -gt 0 ]; then
128 echo -e "<p>&nbsp;</p><p>READMEs were not available for these modules:</p><ul>\n" >> "$BASE_OUTPUT/index.html"
129 for module_name in "${empty_modules[@]}"; do
130 echo -e "<li><a href=\"https://cgit.freedesktop.org/libreoffice/core/tree/${module_name}\">${module_name}</a></li>\n" >> "$BASE_OUTPUT/index.html"
131 done
132 echo -e "</ul>\n" >> "$BASE_OUTPUT/index.html"
135 footer "$BASE_OUTPUT/index.html"
137 popd > /dev/null
139 ## done