-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (82 loc) · 3.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Configurable variables
REMOTE_HOST := webhost1.hosting.netent.co.nz
REMOTE_PATH := /var/www/html/loudas.com
REMOTE_USER := paul
URL := https://www.loudas.com
BLOGNAME := LoudAs
JSBUNDLE_DIR := assets/js
VENDOR_DIR = assets/vendor
# You should check the "build" section for js files that need to be included in bundle.js
#
# No other changes should be necessary
SHELL := /bin/bash
NPM := /usr/bin/npm
JEKYLL := ~/gems/bin/jekyll
BUNDLE := ~/gems/bin/bundle
SCRIPT_NAME := make
VERSION := "2020-05-22 v1.0"
NURL := $(shell node --eval "console.log(encodeURIComponent('$(URL)'))")
NFEED := $(shell node --eval "console.log(encodeURIComponent('$(URL)/feed.xml'))")
PINGOURL := $(shell printf "http://pingomatic.com/ping/?title=%s&blogurl=%s&rssurl=%s&chk_weblogscom=on&chk_blogs=on&chk_feedburner=on&chk_newsgator=on&chk_myyahoo=on&chk_pubsubcom=on&chk_blogdigger=on&chk_weblogalot=on&chk_newsisfree=on&chk_topicexchange=on&chk_google=on&chk_tailrank=on&chk_skygrid=on&chk_collecta=on&chk_superfeedr=on" "$(BLOGNAME)" "$(NURL)" "$(NFEED)")
GOOGLEURL := $(shell printf "http://www.google.com/webmasters/tools/ping?sitemap=%s" "$(NFEED)")
BINGURL := $(shell printf "http://www.bing.com/webmaster/ping.aspx?siteMap=%s" "$(NFEED)")
.PHONY: all help update build server push
all : install
help:
@echo 'Version $(VERSION) '
@echo 'This is a small Makefile that updates, builds, and serves a local Jekyll project'
@echo 'it can only take one argument at a time.'
@echo ''
@echo 'Usage:'
@echo '$(SCRIPT_NAME) [single option]'
@echo ''
@echo ''
@echo 'Options'
@echo ' help Show this help screen'
@echo ' check an alias for $(BUNDLE) exec $(JEKYLL) doctor'
@echo ' update Update your npm packages ($(NPM) update && $(NPM) install)'
@echo ' build Build your Jekyll project'
@echo ' serve start a local Jekyll server ($(BUNDLE) exec $(JEKYLL) serve)'
@echo ' push push _site to live using rsync'
@echo ' install an alias for "$(SCRIPT_NAME) build && $(SCRIPT_NAME) push"'
check:
@$(BUNDLE) exec $(JEKYLL) doctor
install: build push
update: include-npm-deps
@$(NPM) update
@$(NPM) install
@echo "Maybe run"
@echo " gem update"
@echo " sudo gem update --system"
@echo " $(BUNDLE) update --all"
include-npm-deps:
@if [ ! -d "$(VENDOR_DIR)" ]; then mkdir -p $(VENDOR_DIR); fi
@if [ ! -d "$(JSBUNDLE_DIR)" ]; then mkdir -p $(JSBUNDLE_DIR); fi
@cp node_modules/jquery/dist/jquery.min.js $(VENDOR_DIR)
@cp node_modules/popper.js/dist/umd/popper.min.js $(VENDOR_DIR)
@cp node_modules/bootstrap/dist/js/bootstrap.bundle.min.js $(VENDOR_DIR)
@cp node_modules/datatables.net/js/jquery.dataTables.min.js $(VENDOR_DIR)
@cp node_modules/jquery/dist/jquery.min.map $(JSBUNDLE_DIR)
@cp node_modules/popper.js/dist/umd/popper.min.js.map $(JSBUNDLE_DIR)
@cp node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map $(JSBUNDLE_DIR)
@echo "copying node files into $(VENDOR_DIR) and node map files into $(JSBUNDLE_DIR)"
build: include-npm-deps
@cd assets/js; closure-compile pw.js
@cat $(VENDOR_DIR)/jquery.min.js <(echo) $(VENDOR_DIR)/bootstrap.bundle.min.js <(echo) $(VENDOR_DIR)/jquery.dataTables.min.js <(echo) assets/js/ta_nav.min.js <(echo) assets/js/pw.min.js > $(JSBUNDLE_DIR)/bundle.js
@export JEKYLL_ENV=production
@echo "Building Production _site"
@$(BUNDLE) exec $(JEKYLL) build
serve:
export JEKYLL_ENV=production
$(BUNDLE) exec $(JEKYLL) serve --host=0.0.0.0
rsync:
@if [ ! -d "_site" ]; then echo "_site/ directory does not exist !"; exit 0; fi
@rsync -avz --delete _site/* $(REMOTE_USER)@$(REMOTE_HOST):$(REMOTE_PATH)
@echo "Updating $(REMOTE_PATH)/assets/search.json using $(REMOTE_PATH)/assets/php/json.php"
@ssh $(REMOTE_USER)@$(REMOTE_HOST) "php $(REMOTE_PATH)/assets/php/json.php > $(REMOTE_PATH)/assets/search.json"
PingSearchEngine:
@echo "Pinging ping-o-matic, Google, and Bing"
@$(shell curl --silent "$(PINGOURL)" > /dev/null)
@$(shell curl --silent $(GOOGLEURL) > /dev/null)
@$(shell curl --silent $(BINGURL) > /dev/null)
push: rsync PingSearchEngine