summaryrefslogtreecommitdiff
path: root/refresh.sh
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-10-04 12:09:34 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-10-04 12:09:34 +0200
commit91cb075a19ee199b7959e9a7e578550d624d462f (patch)
treed69e94e6c918738066875b0b5d82b1db18a32269 /refresh.sh
parent18d860cff5230576e76c80a5cc2d3442165be4a1 (diff)
Cleaning
Diffstat (limited to 'refresh.sh')
-rwxr-xr-xrefresh.sh45
1 files changed, 21 insertions, 24 deletions
diff --git a/refresh.sh b/refresh.sh
index 269708b..66e5b20 100755
--- a/refresh.sh
+++ b/refresh.sh
@@ -1,20 +1,19 @@
#!/usr/bin/env bash
wai=$(dirname $(readlink -f "$0")) # Current script directory
-projects_dir=${wai}/projects
-www_dir=${wai}/public/
-projects_out_dir=${www_dir}/projects/
-template_file=${wai}/template.html
+public=${wai}/public
+projects=${wai}/projects
+template=${wai}/template.html
# Clean before
-rm -f $www_dir/*.html
-rm -fr $projects_out_dir/*
-mkdir -p public/projects
+rm -rf $public/projects
+rm -rf $public/*.html
+mkdir -p $public/projects
# Build links
build_links() {
links=""
- for p in $(find ${projects_dir}/ -maxdepth 1 -mindepth 1 -type d)
+ for p in $(find ${projects}/ -maxdepth 1 -mindepth 1 -type d)
do
name=$(basename $p)
[ $name == $1 ] && active="active" || active=""
@@ -26,24 +25,22 @@ build_links() {
echo $tmp
}
-# Build html
-for p in $(find ${projects_dir}/ -maxdepth 1 -mindepth 1 -type d)
+for p in $(find ${projects}/ -maxdepth 1 -mindepth 1 -type d)
do
name=$(basename $p)
- html=$projects_out_dir/$name/index.html
- js=$projects_out_dir/$name/index.js
- js2=projects/$name/index.js
- page=${www_dir}/${name}.html
- echo $p
- # Create html
- echo $projects_out_dir
- cp -r $p $projects_out_dir/
- cat $template_file |sed "/\${CONTENT}/r $html"|sed '/\${CONTENT}/d' > $page
- sed -i "s#\${JS}#${js2}#g" $page
- sed -i "s#\${project_name}#${name}#g" $page
+ html=${public}/${name}.html
+ js=./projects/$name/index.js
+ content=$p/index.html
- # Add links
+ # Create HTML page
+ cp -r $p $public/projects/
+ cat $template |sed "/\${CONTENT}/r $content"|sed '/\${CONTENT}/d' > $html
+ sed -i "s#\${JS}#${js}#g" $html
+ sed -i "s#\${project_name}#${name}#g" $html
+ echo $html
+
+ # Create links
links_file=$(build_links $name)
- sed -i "/\${LINKS}/r $links_file" $page
- sed -i '/\${LINKS}/d' $page
+ sed -i "/\${LINKS}/r $links_file" $html
+ sed -i '/\${LINKS}/d' $html
done