diff --git a/.gitignore b/.gitignore index d4541a1..72d03f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ content/.ikiwiki public/ +http-server/ diff --git a/README.md b/README.md index 49dbe46..cf59db1 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,7 @@ To work locally with this project, you'll have to follow the steps below: * [source][] 1. Clone the submodules: `git submodule init && git submodule update` 1. Generate the website: `ikiwiki --setup ikiwiki.setup` -1. Preview your project: open `public/index.html` in a browser - -Note that the link to certain objects (like images, css) will be broken -when testing locally. To test a specific page, please add -`` 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 `./`). +1. Start http-server: ./test-server.sh Read more at ikiwiki's [documentation][]. diff --git a/test-server.sh b/test-server.sh new file mode 100755 index 0000000..4364aad --- /dev/null +++ b/test-server.sh @@ -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