1
0
Fork 0
forked from ilot/ilot-io

README: add test-server.sh script to facilitate development

This commit is contained in:
Antoine Martin 2024-06-18 21:01:18 -04:00
parent 7de5b4bd77
commit a9fef01ee0
Signed by: ayakael
GPG key ID: D62A472A4AA7D541
3 changed files with 38 additions and 7 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
content/.ikiwiki content/.ikiwiki
public/ public/
http-server/

View file

@ -28,13 +28,7 @@ To work locally with this project, you'll have to follow the steps below:
* [source][] * [source][]
1. Clone the submodules: `git submodule init && git submodule update` 1. Clone the submodules: `git submodule init && git submodule update`
1. Generate the website: `ikiwiki --setup ikiwiki.setup` 1. Generate the website: `ikiwiki --setup ikiwiki.setup`
1. Preview your project: open `public/index.html` in a browser 1. Start http-server: ./test-server.sh
Note that the link to certain objects (like images, css) will be broken
when testing locally. To test a specific page, please add
`<base href="/full/path/to/public" />` at the top of the html file
that you want to preview. You may have to adjust absolute links
to point to relative links (i.e, make `/` into `./`).
Read more at ikiwiki's [documentation][]. Read more at ikiwiki's [documentation][].

36
test-server.sh Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/env bash
for i in node npm git; do
if ! command -v $i &> /dev/null; then
echo ">> $i could not be found, please install"
exit
fi
done
# http-server not pulled, pulling
if [ ! -d "./http-server" ]; then
echo ">> This script will pull a lightweight nodejs http-server from https://github.com/http-party/http-server and make ./public avaiable as local http service, are you okay with this?"
read -p "Continue (y/n)?" choice
case "$choice" in
y|Y ) echo "yes";;
n|N ) echo "no";;
* ) echo "invalid";;
esac
git clone https://github.com/http-party/http-server
fi
# http-server depends not pulled, pulling
if [ ! -d "http-server/node_modules/" ]; then
echo ">> http-server dependencies not pulled, pulling"
npm --prefix ./http-server i
fi
# website not built, building
if [ ! -d "./public" ]; then
echo ">> website not build, building"
ikiwiki --setup ./ikiwiki.setup
fi
# starting server
echo ">> starting http server"
node ./http-server/bin/http-server -c-1 ./public