Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ lib/Makefile

# npm module
node_modules/robotskirt/build
.installation
47 changes: 20 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ SOURCE_DIR=./source/public
DEPLOY_DIR=./_deploy
PUBLIC_DIR=./_public

init: initialize setup gh-pages init-data guide
all:
./h-get

init:
./h-get init

guide:
clear
cat ./lib/haroopress/QUICK.markdown

initialize:
npm install -g node-gyp
git submodule update --init --recursive
cd ./node_modules/robotskirt;node-gyp rebuild
cd ./node_modules/locally/;npm install
./h-get guide

update:
@echo "========================================"
Expand All @@ -25,61 +23,56 @@ init-data:
@echo "========================================"
@echo "= create default data set"
@echo "========================================"
./bin/init.js
./h-get init-data

setup:
@echo "========================================"
@echo "= configurate haroopress"
@echo "========================================"
./bin/setup.js
./h-get setup

gh-pages: clear
gh-pages:
@echo "========================================"
@echo "= setup repository for deployment"
@echo "========================================"
cd ./bin/;./gh-pages.js
./h-get gh-pages

clear:
@echo "========================================"
@echo "= clear public & deployment directories"
@echo "========================================"
./bin/clear.js
./h-get clear

gen: clear
gen:
@echo "========================================"
@echo "= generate to static page"
@echo "========================================"
./bin/gen.js
mkdir -p ${PUBLIC_DIR}/slides/@asserts
cp -R ./lib/shower/themes ${PUBLIC_DIR}/slides/@asserts
cp -R ./lib/shower/scripts ${PUBLIC_DIR}/slides/@asserts
cp -R ./lib/bootstrap/* ${PUBLIC_DIR}
./h-get gen

preview: gen
preview:
@echo "========================================"
@echo "= preview static page"
@echo "========================================"
./bin/preview.js
./h-get preview

deploy: gen
deploy:
@echo "========================================"
@echo "= deploy to github"
@echo "========================================"
cd ./bin;./deploy.js "${msg}"

new-post:
cd ./bin;./new-post.js
./h-get new-post

new-page:
cd ./bin;./new-page.js
./h-get new-page

new-slide:
cd ./bin;./new-slide.js
./h-get new-slide

octopress:
@echo "========================================"
@echo "= convert from octopress"
@echo "========================================"
cd ./bin/convert/;./octopress.js
./h-get octopress

.PHONY: init update build clear
84 changes: 50 additions & 34 deletions h-get
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
#!/usr/bin/env bash
__PWD="$PWD"
__version="0.9" #TODO: to be automatic
__version="`awk '/version: / {print $2}' $PWD/_config.js | sed "s/[,']//g"`"
__author='Rhiokim <[email protected]>'
__process_header="Haroopress $__version $__author"
__pid=$$
__instance="haroopress[$__pid]"
__LOCKFILE="${PWD}/.h-get.lock"

__CHKDIR="${PWD}/.installation"
__LOCKFILE="${__CHKDIR}/.h-get.lock"

__INIT_DONE="${__CHKDIR}/.init.done"
__INIT_GIT_SUBMODULES="${__CHKDIR}/.init-git-submodules.done"
__INIT_LOCALLY="${__CHKDIR}/.init-install-locally.done"
__INIT_PYTHON_MODULES="${__CHKDIR}/.init-install-python-modules.done"
__INIT_NODE_MODULES="${__CHKDIR}/.init-rebuild-node-modules.done"
__INIT_SETUP="${__CHKDIR}/.setup.done"
__INIT_GH_PAGES="${__CHKDIR}/.gh-pages.done"

__migrate_chk_files ()
{
IFS=" "
for chk in .init.done .init-git-submodules.done .init-install-locally.done .init-install-python-modules.done .init-rebuild-node-modules.done .setup.done .gh-pages.done; do
if [ -e "${__PWD}/$chk" ]; then
mv -f "${__PWD}/$chk" ${__CHKDIR}/
fi
done
}
# prefix(__) is removed for compatibility
SOURCE_DIR="${PWD}/source/public"
DEPLOY_DIR="${PWD}/_deploy"
Expand All @@ -19,15 +37,18 @@ __HCMD=$1
trap "{ __cleanup; }" SIGINT SIGTERM SIGHUP SIGQUIT

# for secure processing, multiple process is not allowed.
[ -f $__LOCKFILE ] && echo "another h-get process is running. quit" && exit 0
[ -f $__LOCKFILE ] && echo "another h-get process is running. quit" && exit 1
touch $__LOCKFILE

if [ ! -e $__CHKDIR ]; then
mkdir -p $__CHKDIR
fi

__cleanup ()
{
echo ${__instance} -- got an Interrupt.
__remove_lock
exit 0
exit 1
}

__remove_lock ()
Expand Down Expand Up @@ -65,7 +86,7 @@ __stop ()
{
if [ "$*" != "0" ]; then
__log "[ STOP! ]"
__remove_lock; exit 0
__remove_lock; exit 1
fi
}
__guide ()
Expand All @@ -75,80 +96,80 @@ __guide ()

__initialize ()
{
if [ -e "${__PWD}/.init.done" ]; then
if [ -e ${__INIT_DONE} ]; then
echo " -- init process is already done"
return
fi
__log "start: initilizing"
cd $__PWD; ./bin/init.js
__stop $?
touch ${__PWD}/.init.done
touch ${__INIT_DONE}
__log "end: initilizing"
}

__init_update_git_submodules ()
{
if [ -e "${__PWD}/.init-git-submodules.done" ]; then
if [ -e $__INIT_GIT_SUBMODULES ]; then
echo " -- git submodule update is already done"
return
fi
__log "start: updating git submodules"
cd $__PWD; git submodule update --init --recursive
__stop $?
touch ${__PWD}/.init-git-submodules.done
touch $__INIT_GIT_SUBMODULES
__log "end: updating git submodules"
}

__init_install_locally ()
{
if [ -e "${__PWD}/.init-install-locally.done" ]; then
if [ -e $__INIT_LOCALLY ]; then
echo " -- locally installation is already done"
return
fi
__log "start: updating locally"
cd $__PWD; cd ./node_modules/locally/; npm install
__stop $?
touch ${__PWD}/.init-install-locally.done
touch $__INIT_LOCALLY
__log "end: updating locally"
}

__init_install_python_modules ()
{
if [ -e "${__PWD}/.init-install-python-modules.done" ]; then
if [ -e $__INIT_PYTHON_MODULES ]; then
echo " -- python modules installation is already done"
return
fi
__log "start: updating python modules"
cd $__PWD; python ./lib/highlight.js/tools/build.py
__stop $?
touch ${__PWD}/.init-install-python-modules.done
touch $__INIT_PYTHON_MODULES
__log "end: updating python modules"
}

__rebuild_node_modules ()
{
if [ -e "${__PWD}/.init-rebuild-node-modules.done" ]; then
if [ -e $__INIT_NODE_MODULES ]; then
echo " -- updating node modules is already done"
return
fi
__log "start: updating node modules"
cd $__PWD/node_modules/robotskirt/
node-gyp rebuild
__stop $?
touch ${__PWD}/.init-rebuild-node-modules.done
touch $__INIT_NODE_MODULES
__log "end: updating node modules"
}


__setup ()
{
if [ -e "${__PWD}/.setup.done" ]; then
if [ -e $__INIT_SETUP ]; then
echo " -- setup procedure is already done"
return
fi
cd $__PWD; ./bin/setup.js
__stop $?
touch ${__PWD}/.setup.done
touch $__INIT_SETUP
}

__clear ()
Expand All @@ -159,15 +180,15 @@ __clear ()

__gh_pages ()
{
if [ -e "${__PWD}/.gh-pages.done" ]; then
if [ -e $__INIT_GH_PAGES ]; then
echo " -- gh-pages process is already done"
return
fi
__log "start: gh-pages"
__clear
cd $__PWD/bin; ./gh-pages.js
__stop $?
touch ${__PWD}/.gh-pages.done
touch $__INIT_GH_PAGES
__log "end: gh-pages"
}

Expand Down Expand Up @@ -197,16 +218,6 @@ __guide_install_nodegyp ()
echo
}

__guide_install_python ()
{
__log "[ python ] missing"
}

__guide_install_java ()
{
__log "[ java ] missing"
}

__guide_install_git ()
{
__log "[ git ] missing"
Expand All @@ -228,8 +239,6 @@ __chk_pre_requisites ()
{
__assert node -v || __guide_install_nodejs
__assert node-gyp -v || __guide_install_nodegyp
__assert python --version || __guide_install_python
__assert java -version || __guide_install_java
__assert git --version || __guide_install_git
__assert g++ -v || __guide_install_gpp
__assert gcc -v || __guide_install_gpp
Expand All @@ -238,7 +247,7 @@ __chk_pre_requisites ()
echo
echo "[STOP] You need to install $__pre_requisite_not_found package(s) first! (See INSTALL.pre-requisites)"
echo
__remove_lock; exit 0
__remove_lock; exit 1
fi

#TODO: robotskirt gyp module, PGP key for pushing at github
Expand Down Expand Up @@ -269,7 +278,7 @@ __preview ()
__deploy ()
{
__log "start: deploy"
cd $__PWD/bin; ./deploy.js "${msg}" # where is comes from ?
cd $__PWD/bin; ./deploy.js "${msg}" # make deploy msg="commit message"
__log "end: deploy"
}

Expand All @@ -280,6 +289,8 @@ __main ()
return;
fi

__migrate_chk_files

if [[ "$__HCMD" == "guide" ]] || [[ "$__HCMD" == "help" ]]; then
__guide
return
Expand Down Expand Up @@ -326,6 +337,11 @@ __main ()
return;
fi

if [[ "$__HCMD" == "init-data" ]]; then
__chk_pre_requisites
__initialize
return;
fi

if [[ "$__HCMD" == "init" ]] || [[ "$__HCMD" == "install" ]]; then
__chk_pre_requisites
Expand Down