Adding files

This commit is contained in:
Scott C. MacCallum 2025-01-28 18:28:09 +00:00
commit b843766f30
2 changed files with 164 additions and 0 deletions

31
cleanup.sh Executable file
View File

@ -0,0 +1,31 @@
#!/usr/pkg/bin/bash
# Copyright (c) 2024, 2025, Scott C. MacCallum (scm@sdf.org).
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Change this variable to the group that should be informed of a need to
# charge the battery. On GNU/Linux distributions users are often part of
# a group that is the same as their login name, which works well if you only
# want your user to be informed on the console.
WebDir="/sdf/arpa/ns/s/scm/html/text"
rm $WebDir/index.html-01
rm $WebDir/index.html-02
rm $WebDir/index.html-03
rm $WebDir/index.html-04
rm $WebDir/index.html-05
exit 0

133
convert-website.sh Executable file
View File

@ -0,0 +1,133 @@
#!/usr/pkg/bin/bash
# convert-website.sh
# Copyright (c) 2024, 2025, Scott C. MacCallum (scm@sdf.org).
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Change this variable to the group that should be informed of a need to
# charge the battery. On GNU/Linux distributions users are often part of
# a group that is the same as their login name, which works well if you only
# want your user to be informed on the console.
GopherDir="$GopherDir"
WebDir="/sdf/arpa/ns/s/scm/html/text"
ls $WebDir
echo -n "Directory where the index.html is located ('top' for top level): "
read dir
# Make a backup of index.html in the user specified source directory
if [[ $dir == "top" ]]; then
cp $WebDir/index.html $WebDir/index.html.old
else
cp $WebDir/$dir/index.html $WebDir/$dir/index.html.old
fi
# Where there are blank lines in index.html insert the <br> HTML tag
if [[ $dir == "top" ]]; then
sed 's/^$/<br>/' $WebDir/index.html > $WebDir/index.html-01
else
sed 's/^$/<br>/' $WebDir/$dir/index.html > $WebDir/$dir/index.html-01
fi
# Convert the modified index.html file to a text file
if [[ $dir == "top" ]]; then
html2text -o $WebDir/index.html-02 $WebDir/index.html-01
else
html2text -o $WebDir/$dir/index.html-02 $WebDir/$dir/index.html-01
fi
# Remove the control characters from the text file
if [[ $dir == "top" ]]; then
cat $WebDir/index.html-02 | col -b -x > $WebDir/index.html-03
else
cat $WebDir/$dir/index.html-02 | col -b -x > $WebDir/$dir/index.html-03
fi
# Remove the underlines from the text file
if [[ $dir == "top" ]]; then
sed 's/_/ /g' $WebDir/index.html-03 > $WebDir/index.html-04
else
sed 's/_/ /g' $WebDir/$dir/index.html-03 > $WebDir/$dir/index.html-04
fi
# Remove the blank lines from the top of the text file
if [[ $dir == "top" ]]; then
sed -i "1d;2d;3d;4d" $WebDir/index.html-04
else
sed -i "1d;2d;3d" $WebDir/$dir/index.html-04
fi
# Write the Gopher file
if [[ $dir == "top" ]]; then
cat $WebDir/index.html-04 > $GopherDir/index
else
cat $WebDir/$dir/index.html-04 > $GopherDir/$dir/index
fi
# Remove the asterisks from the text file
if [[ $dir == "top" ]]; then
sed 's/*/ /g' $WebDir/index.html-04 > $WebDir/index.html-05
else
sed 's/*/ /g' $WebDir/$dir/index.html-04 > $WebDir/$dir/index.html-05
fi
# Add the Gemini link to S C M Guru
if [[ $dir == "top" ]]; then
sed -i '11 s/^/=> gemini:\/\/sdf.org\/scm\/scmguru\/index.gmi /' $WebDir/index.html-05
fi
# Write the Gemini file
if [[ $dir == "top" ]]; then
cat $WebDir/index.html-05 > $GopherDir/index.gmi
else
cat $WebDir/$dir/index.html-05 > $GopherDir/$dir/index.gmi
fi
# Write the dot plan file from the top level of the Gopher file to my home directory on SDF
cat $GopherDir/index > $HOME/.plan-01
sed -i "3d;4d;5d;6d" $HOME/.plan-01
cat $HOME/.plan-01 > $HOME/.plan
# Write the dot plan file from the top level of the Gopher directory to my home directory on Meta
scp $GopherDir/index scm@ma.sdf.org:/meta/s/scm/.plan
# Set the correct WWW permissios
mkhomepg -p
# Set the correct Gopher and Gemini permissions
chmod -R 754 $GopherDir
# Clean up
./$HOME/website-to-other/cleanup.sh
exit 0