From 8736cc97b49568ec14a2efb5ecab264ef13d0ac6 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 4 Apr 2015 19:29:33 +1300 Subject: [PATCH] move to multisite-model --- rebuild.php | 40 +++++++----- rebuild.sh | 58 +++++++++++++++--- sites/code.ivysaur.me/config.ini | 8 +++ .../code.ivysaur.me/footer.htm | 0 .../code.ivysaur.me/header.htm | 0 .../code.ivysaur.me/homepage_blurb.htm | 0 .../code.ivysaur.me/static}/favicon.ico | Bin .../code.ivysaur.me/static}/ivysaur24.png | Bin .../code.ivysaur.me/static}/no_image.png | Bin .../code.ivysaur.me/static}/normalize.css | 0 .../code.ivysaur.me/static}/pixel_weave.png | Bin .../static}/pixel_weave_@2X.png | Bin .../code.ivysaur.me/static}/site.js | 0 .../code.ivysaur.me/static}/style.css | 0 14 files changed, 83 insertions(+), 23 deletions(-) create mode 100644 sites/code.ivysaur.me/config.ini rename footer.htm => sites/code.ivysaur.me/footer.htm (100%) rename header.htm => sites/code.ivysaur.me/header.htm (100%) rename homepage_blurb.htm => sites/code.ivysaur.me/homepage_blurb.htm (100%) rename {static => sites/code.ivysaur.me/static}/favicon.ico (100%) rename {static => sites/code.ivysaur.me/static}/ivysaur24.png (100%) rename {static => sites/code.ivysaur.me/static}/no_image.png (100%) rename {static => sites/code.ivysaur.me/static}/normalize.css (100%) rename {static => sites/code.ivysaur.me/static}/pixel_weave.png (100%) rename {static => sites/code.ivysaur.me/static}/pixel_weave_@2X.png (100%) rename {static => sites/code.ivysaur.me/static}/site.js (100%) rename {static => sites/code.ivysaur.me/static}/style.css (100%) diff --git a/rebuild.php b/rebuild.php index deb4da7..5db7c04 100644 --- a/rebuild.php +++ b/rebuild.php @@ -3,16 +3,6 @@ // Code-hosting website // ```````````````````` -// CONFIGURATION -// ````````````` - -define('BASEDIR', __DIR__.'\\'); -define('SITE_TITLE', 'code.ivysaur.me'); -define('PAGE_THUMB_W', 60); -define('PAGE_THUMB_H', 60); -define('INDEX_THUMB_W', 90); -define('INDEX_THUMB_H', 32); // recommend a multiple of the jpg iDCT block size - /** * Create a thumbnail of an image. It overscales, centers, and crops to fit the * target dimensions. @@ -263,7 +253,7 @@ class CProject {

longdesc)?>

- + downloads)) { ?> @@ -317,7 +307,7 @@ function template($title, $content) {
- +
@@ -436,8 +426,30 @@ function buildcommon() { } function main($args) { - $total = $args[0]; - $pos = $args[1]; + $basedir = './'; //$args[0]; + $total = $args[0]; + $pos = $args[1]; + + // Parse configuration + + $config = @parse_ini_file( + $basedir . 'config.ini', + true, + INI_SCANNER_RAW + ); + + if ($config === false) { + die("[FATAL] Couldn't load '${basedir}/config.ini'!\n"); + } + + define('BASEDIR', $basedir); + define('SITE_TITLE', trim($config['codesite']['title'])); + define('PAGE_THUMB_W', intval($config['codesite']['page_thumb_w'])); + define('PAGE_THUMB_H', intval($config['codesite']['page_thumb_h'])); + define('INDEX_THUMB_W', intval($config['codesite']['index_thumb_w'])); + define('INDEX_THUMB_H', intval($config['codesite']['index_thumb_h'])); + + // Perform build tasks if ($pos == 0) { buildcommon(); diff --git a/rebuild.sh b/rebuild.sh index abbe305..4557bfb 100644 --- a/rebuild.sh +++ b/rebuild.sh @@ -2,18 +2,58 @@ set -eu PHP=/cygdrive/c/bin/php/php.exe +THREADS=4 -echo Cleaning target directory... +buildsite() { -rm -r wwwroot -mkdir -p wwwroot/srv -cp static/* wwwroot + local rebuild="$(realpath ./rebuild.php)" + + if [[ "$(uname -o)" == "Cygwin" ]] ; then + rebuild="$(cygpath -w "$rebuild")" + fi -echo Building pages... + echo "Site: ${1}" -for i in $(seq 0 4) ; do - $PHP rebuild.php 4 "$i" & -done -wait + pushd "$1" >/dev/null + + echo "Cleaning target directory..." + + if [[ -d wwwroot ]] ; then + rm -r wwwroot + fi + + mkdir -p wwwroot/srv + + if [[ ! -d static ]] ; then + mkdir static + fi + cp static/* wwwroot || true + + for htm in footer header homepage_blurb ; do + if [[ ! -f "${htm}.htm" ]] ; then + touch "${htm}.htm" + fi + done + + echo "Building pages..." + + for i in $(seq 0 "$THREADS") ; do + $PHP "$rebuild" "$THREADS" "$i" & + done + wait + + echo "Site: ${1} finished." + echo "" + + popd >/dev/null +} + +main() { + for site in sites/* ; do + buildsite "$site" + done +} + +main "$@" read -p "Press any key to continue..." diff --git a/sites/code.ivysaur.me/config.ini b/sites/code.ivysaur.me/config.ini new file mode 100644 index 0000000..065f416 --- /dev/null +++ b/sites/code.ivysaur.me/config.ini @@ -0,0 +1,8 @@ +[codesite] +title=code.ivysaur.me +page_thumb_w=60 +page_thumb_h=60 +index_thumb_w=90 +index_thumb_h=32 + +; n.b. Recommend a multiple of the JPEG iDCT block size for index_thumb_h diff --git a/footer.htm b/sites/code.ivysaur.me/footer.htm similarity index 100% rename from footer.htm rename to sites/code.ivysaur.me/footer.htm diff --git a/header.htm b/sites/code.ivysaur.me/header.htm similarity index 100% rename from header.htm rename to sites/code.ivysaur.me/header.htm diff --git a/homepage_blurb.htm b/sites/code.ivysaur.me/homepage_blurb.htm similarity index 100% rename from homepage_blurb.htm rename to sites/code.ivysaur.me/homepage_blurb.htm diff --git a/static/favicon.ico b/sites/code.ivysaur.me/static/favicon.ico similarity index 100% rename from static/favicon.ico rename to sites/code.ivysaur.me/static/favicon.ico diff --git a/static/ivysaur24.png b/sites/code.ivysaur.me/static/ivysaur24.png similarity index 100% rename from static/ivysaur24.png rename to sites/code.ivysaur.me/static/ivysaur24.png diff --git a/static/no_image.png b/sites/code.ivysaur.me/static/no_image.png similarity index 100% rename from static/no_image.png rename to sites/code.ivysaur.me/static/no_image.png diff --git a/static/normalize.css b/sites/code.ivysaur.me/static/normalize.css similarity index 100% rename from static/normalize.css rename to sites/code.ivysaur.me/static/normalize.css diff --git a/static/pixel_weave.png b/sites/code.ivysaur.me/static/pixel_weave.png similarity index 100% rename from static/pixel_weave.png rename to sites/code.ivysaur.me/static/pixel_weave.png diff --git a/static/pixel_weave_@2X.png b/sites/code.ivysaur.me/static/pixel_weave_@2X.png similarity index 100% rename from static/pixel_weave_@2X.png rename to sites/code.ivysaur.me/static/pixel_weave_@2X.png diff --git a/static/site.js b/sites/code.ivysaur.me/static/site.js similarity index 100% rename from static/site.js rename to sites/code.ivysaur.me/static/site.js diff --git a/static/style.css b/sites/code.ivysaur.me/static/style.css similarity index 100% rename from static/style.css rename to sites/code.ivysaur.me/static/style.css