-MAKE="make"
-INSTALL="install"
-TAR="tar"
-GREP="grep"
-NODE="node"
-NPM="npm"
-DESTDIR="./dist"
-PKG_VERSION := $( $(GREP) -Po '(?<="version": ")[^"]*' )
-TMPDIR := $(shell mktemp -d)
-# default modules
-MODULES="php"
-
-all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules
-
-swig:
- $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html
- $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html
- $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > $(CURDIR)/build/tools.html
-
-htmlmin:
- $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/index.html -o $(CURDIR)/build/index.html
- $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/faq.html -o $(CURDIR)/build/faq.html
- $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html
+MAKE = "make"
+INSTALL = "install"
+TAR = "tar"
+GREP = "grep"
+NODE = "node"
+NPM = "npm"
+NODEJQ = "node_modules/node-jq/bin/jq"
+SQLITE = "sqlite3"
+CONF = "src/config.json"
+PHP = "php"
+CURL = "curl"
+DESTDIR = $(shell $(CURDIR)/$(NODEJQ) -r ".dest" $(CURDIR)/$(CONF))
+SITEDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".DOMAIN" $(CURDIR)/$(CONF))
+FILESDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".FILE_DOMAIN" $(CURDIR)/$(CONF))
+MAXSIZE = $(shell $(CURDIR)/$(NODEJQ) -r ".max_upload_size" $(CURDIR)/$(CONF))
+CONTACT_EMAIL = $(shell $(CURDIR)/$(NODEJQ) -r ".infoContact" $(CURDIR)/$(CONF))
+PKG_VERSION = $(shell $(CURDIR)/$(NODEJQ) -r ".version" $(CURDIR)/package.json)
+EXPIRE_TIME = $(shell $(CURDIR)/$(NODEJQ) -r ".expireTime" $(CURDIR)/$(CONF))
+TMPDIR = $(shell mktemp -d)
+DOCKER_IMAGE = "$(shell basename $(CURDIR) | tr [:upper:] [:lower:])"
+DOCKER_TAG = "$(DOCKER_TAG)"
+CONTAINER_NAME = "$(CONTAINER_NAME)"
+pageList = $(shell $(CURDIR)/$(NODEJQ) -r ".pages[]" $(CURDIR)/$(CONF))
+noExt = $(shell echo $(i) | cut -d '.' -f1)
+
+all: builddirs npm_dependencies ejs "node_modules/minify/bin/minify.js"-all copy-img copy-php
+
+ejs:
+ $(foreach i,$(pageList), \
+ "node_modules/ejs/bin/cli.js" -f $(CURDIR)/$(CONF) $(CURDIR)/src/templates/$(i) -o $(CURDIR)/build/html/unmin/$(noExt).html;)
+
+"node_modules/minify/bin/minify.js"-all:
+ "node_modules/minify/bin/minify.js" $(CURDIR)/src/static/js/uguu.js > $(CURDIR)/build/js/uguu.min.js
+ "node_modules/minify/bin/minify.js" $(CURDIR)/src/static/css/uguu.css > $(CURDIR)/build/css/uguu.min.css
+ "node_modules/minify/bin/minify.js" $(CURDIR)/build/html/unmin/faq.html > $(CURDIR)/build/html/min/faq.html
+ "node_modules/minify/bin/minify.js" $(CURDIR)/build/html/unmin/tools.html > $(CURDIR)/build/html/min/tools.html
+ "node_modules/minify/bin/minify.js" $(CURDIR)/build/html/unmin/index.html > $(CURDIR)/build/html/min/index.html
installdirs:
mkdir -p $(DESTDIR)/ $(DESTDIR)/img
mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills
-ifneq (,$(findstring php,$(MODULES)))
- mkdir -p $(DESTDIR)/includes
-endif
-ifneq (,$(findstring moe,$(MODULES)))
- mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
-endif
-
-min-css:
- $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
-
-min-js:
- echo "// @source https://github.com/nokonoko/uguu/tree/master/static/js" > $(CURDIR)/build/uguu.min.js
- echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/uguu.min.js
- $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
- echo "// @license-end" >> $(CURDIR)/build/uguu.min.js
copy-img:
- cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/
- cp -R $(CURDIR)/static/img/grills $(CURDIR)/build/img/
+ "node_modules/imagemin-cli/cli.js" $(CURDIR)/src/static/img/*.png -o=$(CURDIR)/build/img/
+ "node_modules/imagemin-cli/cli.js" $(CURDIR)/src/static/img/grills/*.png --plugin=pngquant -o=$(CURDIR)/build/img/grills/
+
copy-php:
-ifneq ($(wildcard $(CURDIR)/static/php/.),)
- cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
-else
- $(error The php submodule was not found)
-endif
-
-copy-moe:
-ifneq ($(wildcard $(CURDIR)/moe/.),)
- cp -rv $(CURDIR)/moe $(CURDIR)/build/
-else
- $(error The moe submodule was not found)
-endif
+ cp -v $(CURDIR)/src/static/php/*.php $(CURDIR)/build/php/
+ cp -v $(CURDIR)/src/Classes/*.php $(CURDIR)/build/php/Classes/
install: installdirs
cp -rv $(CURDIR)/build/* $(DESTDIR)/
+ cp $(CURDIR)/src/*.json $(DESTDIR)/
+ mv $(DESTDIR)/html/min/* $(DESTDIR)/public/
+ mv $(DESTDIR)/js/* $(DESTDIR)/public/
+ mv $(DESTDIR)/css/* $(DESTDIR)/public/
+ mv $(DESTDIR)/php/* $(DESTDIR)/
+ rm -rf $(DESTDIR)/html
+ rm -rf $(DESTDIR)/css
+ rm -rf $(DESTDIR)/js
+ rm -rf $(DESTDIR)/php
+ mv $(DESTDIR)/img $(DESTDIR)/public/
+ mv $(DESTDIR)/grill.php $(DESTDIR)/public/
+ mv $(DESTDIR)/upload.php $(DESTDIR)/public/
+ cd $(DESTDIR)/ && $(CURL) -o composer-setup.php https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer
+ cd $(DESTDIR)/ && $(PHP) composer-setup.php --quiet
+ cd $(DESTDIR)/ && rm composer-setup.php
+ cd $(DESTDIR)/ && php composer.phar update && php composer.phar install && php composer.phar dump-autoload
dist:
DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
install
$(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
rm -rf $(TMPDIR)
-
+
+
clean:
- rm -rvf $(CURDIR)/node_modules
+ rm -rvf $(CURDIR)/node_modules
rm -rvf $(CURDIR)/build
-
+
+
uninstall:
rm -rvf $(DESTDIR)/
-
+
+
npm_dependencies:
$(NPM) install
+build-container-no-cache:
+ tar --exclude='uguuForDocker.tar.gz' --exclude='vendor' --exclude='node_modules' --exclude='build' --exclude='dist' --exclude='.git' -czf uguuForDocker.tar.gz src docker Makefile package.json package-lock.json
+ mv uguuForDocker.tar.gz docker/
+ docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(CONTACT_EMAIL) --build-arg MAX_SIZE=$(MAXSIZE) --build-arg EXPIRE_TIME=$(EXPIRE_TIME) --no-cache -t uguu:$(PKG_VERSION) .
+
+build-container:
+ tar --exclude='uguuForDocker.tar.gz' --exclude='vendor' --exclude='node_modules' --exclude='build' --exclude='dist' --exclude='.git' -czf uguuForDocker.tar.gz src docker Makefile package.json package-lock.json
+ mv uguuForDocker.tar.gz docker/
+ docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(CONTACT_EMAIL) --build-arg MAX_SIZE=$(MAXSIZE) --build-arg EXPIRE_TIME=$(EXPIRE_TIME) -t uguu:$(PKG_VERSION) .
+
+run-container:
+ docker run --name uguu -d -p 80:80 -p 443:443 uguu:$(PKG_VERSION)
+
+purge-containers:
+ if docker images | grep uguu; then \
+ docker rm -f uguu && docker rmi uguu:$(PKG_VERSION) || true;\
+ fi;
+
+remove-container:
+ docker rm -f uguu
+
builddirs:
- mkdir -p $(CURDIR)/build $(CURDIR)/build/img
-ifneq (,$(findstring php,$(MODULES)))
- mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
-endif
-ifneq (,$(findstring moe,$(MODULES)))
- mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
-endif
-
-submodules:
- $(info The following modules will be enabled: $(MODULES))
-ifneq (,$(findstring php,$(MODULES)))
- $(MAKE) copy-php
-endif
-ifneq (,$(findstring moe,$(MODULES)))
- $(MAKE) copy-moe
-endif
+ mkdir -p $(CURDIR)/build $(CURDIR)/build/img $(CURDIR)/build/html $(CURDIR)/build/html/min $(CURDIR)/build/html/unmin $(CURDIR)/build/js $(CURDIR)/build/css $(CURDIR)/build/php $(CURDIR)/build/php/Classes $(CURDIR)/build/public
+