summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile19
-rwxr-xr-xbuild/stamp.sh14
-rw-r--r--src/web/core/core.php5
-rw-r--r--src/web/index.php3
5 files changed, 37 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index b9d6a5b..8084040 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
src/public/css/*.css
!src/public/css/prism.css
+src/web/stamp.php
data
diff --git a/Makefile b/Makefile
index b8d5407..3184a9a 100644
--- a/Makefile
+++ b/Makefile
@@ -3,18 +3,31 @@ MIXINS = $(shell find src/scss -name "_*.scss")
SCSS = $(shell find src/scss -name "*.scss" -not -name "_*")
CSS = $(patsubst src/scss/%.scss,src/public/css/%.css,$(SCSS))
-.PHONY: all css clean
+.PHONY: all clean css stamp
-css: $(CSS)
+all: clean css stamp
clean:
+ @# clean scss
@printf "\033[31m RM \033[0m%s\n" src/public/css
@rm -f src/public/css/*.css
+ @git stash -- src/public/css/prism.css > /dev/null
+
+ @# clean stamps
+ @printf "\033[31m RM \033[0m%s\n" src/web/stamp.php
+ @rm -f src/web/stamp.php
-all: clean css
+# =============================================== COMPILE SCSS ==
+
+css: $(CSS)
$(CSS): src/public/css/%.css : src/scss/%.scss $(MIXINS)
@printf "\033[33m SCSS \033[0m%s\n" $<
@mkdir -p $(@D)
@sassc --style compressed $< $@
+# ============================================ GENERATE STAMPS ==
+
+stamp:
+ @printf "\033[32m STMP \033[0m%s\n" src/web/stamp.php
+ @./build/stamp.sh
diff --git a/build/stamp.sh b/build/stamp.sh
new file mode 100755
index 0000000..3b19b04
--- /dev/null
+++ b/build/stamp.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+out="./src/web/stamp.php"
+public="./src/public"
+files=$(find "$public" -type f -printf %P\\n)
+
+printf "<?php\n\$__stamps = array();\n" > "$out"
+for file in $files; do
+ stamp=$(date +%s -r "$public/$file")
+ echo "\$__stamps['public/$file'] = $stamp;" >> "$out";
+done
+echo "define('FILE_TIMES', \$__stamps);" >> "$out"
+echo "unset(\$__stamps);" >> "$out"
+
diff --git a/src/web/core/core.php b/src/web/core/core.php
index f1ce07e..feaecdf 100644
--- a/src/web/core/core.php
+++ b/src/web/core/core.php
@@ -25,8 +25,9 @@ abstract class Core {
{
if (ENVIRONMENT == 'devlopment')
return time();
- $path = PHP_ROOT . '/' . $path;
- return @filemtime($path);
+ if (isset(FILE_TIMES[$path]))
+ return FILE_TIMES[$path];
+ return 0;
}
/**
diff --git a/src/web/index.php b/src/web/index.php
index 63e5b61..577bc60 100644
--- a/src/web/index.php
+++ b/src/web/index.php
@@ -48,6 +48,9 @@ require(WEB_ROOT . '/core/controller.php');
require(WEB_ROOT . '/core/model.php');
require(WEB_ROOT . '/core/router.php');
+// load file stamps
+require(WEB_ROOT . '/stamp.php');
+
// ============================== START ==
function __init() {