diff options
-rw-r--r-- | .babelrc | 3 | ||||
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 53 | ||||
-rw-r--r-- | assets_src/js/lib/search.js (renamed from assets_src/js/search.js) | 0 | ||||
-rwxr-xr-x | bin/template.awk | 56 | ||||
-rw-r--r-- | config.mk | 2 | ||||
-rw-r--r-- | package.json.tpl | 10 |
7 files changed, 115 insertions, 12 deletions
diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..7b37dd5 --- /dev/null +++ b/.babelrc | |||
@@ -0,0 +1,3 @@ | |||
1 | { | ||
2 | "presets": ["es2015"] | ||
3 | } | ||
@@ -1,3 +1,6 @@ | |||
1 | grilist.conf | 1 | grilist.conf |
2 | package.json | ||
3 | .npm_update | ||
4 | node_modules/ | ||
2 | assets/* | 5 | assets/* |
3 | 6 | ||
@@ -1,29 +1,58 @@ | |||
1 | CSS_FILES := $(shell find assets_src/css/ -maxdepth 1 -type f -name '*.css') | 1 | include config.mk |
2 | CSS_FILES := $(addprefix assets/, $(CSS_FILES:assets_src/%=%)) | ||
3 | LESS_FILES := $(shell find assets_src/css/ -maxdepth 1 -type f -name '*.less') | ||
4 | LESS_FILES := $(addprefix assets/, $(LESS_FILES:assets_src/%=%)) | ||
5 | LESS_FILES := $(LESS_FILES:.less=.css) | ||
6 | JS_FILES := $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js') | ||
7 | JS_FILES := $(addprefix assets/, $(JS_FILES:assets_src/%=%)) | ||
8 | 2 | ||
9 | all: $(CSS_FILES) $(LESS_FILES) $(JS_FILES) | 3 | CSS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/css/ -type f -name '*.css')) |
4 | LESS_FILES = $(patsubst assets_src/%.less, assets/%.css, $(shell find assets_src/css/ -type f -name '*.less')) | ||
5 | JS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js')) | ||
6 | |||
7 | BROWSERIFY := ./node_modules/browserify/bin/cmd.js | ||
8 | LESSC := ./node_modules/less/bin/lessc | ||
9 | |||
10 | rewrite_imports = "s/(require\([\"'])lib/\1.\/lib/g" | ||
11 | |||
12 | all: .npm_update $(CSS_FILES) $(LESS_FILES) $(JS_FILES) | ||
13 | |||
14 | print_info: | ||
15 | @echo $(CSS_FILES) | ||
16 | @echo $(LESS_FILES) | ||
17 | @echo $(JS_FILES) | ||
18 | |||
19 | .npm_update: package.json | ||
20 | touch $@ | ||
21 | npm install | ||
22 | |||
23 | package.json: package.json.tpl config.mk | ||
24 | export NAME=$(NAME) &&\ | ||
25 | export VERSION=$(VERSION) &&\ | ||
26 | ./bin/template.awk < $< | sh > $@ | ||
10 | 27 | ||
11 | assets/css/%.css: assets_src/css/%.css | 28 | assets/css/%.css: assets_src/css/%.css |
29 | @mkdir -p $(@D) | ||
12 | cp $< $@ | 30 | cp $< $@ |
13 | 31 | ||
14 | assets/css/%.css: assets_src/css/%.less | 32 | assets/css/%.css: assets_src/css/%.less |
15 | lessc $< > $@ | 33 | mkdir -p $(@D) |
34 | @echo lessc $< > $@ | ||
35 | @$(LESSC) $< > $@ | ||
16 | 36 | ||
17 | assets/js/%.js: assets_src/js/%.js | 37 | assets/js/%.js: assets_src/js/%.js .babelrc |
18 | babel $< -o $@ | 38 | @echo browserify $< -o $@ |
39 | @$(BROWSERIFY) --debug $< -o $@ -t babelify | ||
19 | 40 | ||
20 | clean: | 41 | clean: |
21 | -rm -- $(CSS_FILES) | 42 | -rm -- $(CSS_FILES) |
22 | -rm -- $(LESS_FILES) | 43 | -rm -- $(LESS_FILES) |
23 | -rm -- $(JS_FILES) | 44 | -rm -- $(JS_FILES) |
45 | -rm -r -- .jsobj | ||
46 | |||
47 | superclean: clean | ||
48 | -rm -- .npm_last_update | ||
49 | -rm -- package.json | ||
50 | |||
51 | ultraclean: superclean | ||
52 | -rm -r -- node_modules | ||
24 | 53 | ||
25 | run: all | 54 | run: all |
26 | go run *.go | 55 | go run *.go |
27 | 56 | ||
28 | .PHONY: all clear run | 57 | .PHONY: all print_info clean superclean ultraclean run |
29 | 58 | ||
diff --git a/assets_src/js/search.js b/assets_src/js/lib/search.js index 0cb33df..0cb33df 100644 --- a/assets_src/js/search.js +++ b/assets_src/js/lib/search.js | |||
diff --git a/bin/template.awk b/bin/template.awk new file mode 100755 index 0000000..f543506 --- /dev/null +++ b/bin/template.awk | |||
@@ -0,0 +1,56 @@ | |||
1 | #!/usr/bin/awk -f | ||
2 | #taken from werc [http://werc.cat-v.org/] | ||
3 | function pr(str) { | ||
4 | if(lastc !~ "[{(]") | ||
5 | gsub(/'/, "''", str) | ||
6 | printf "%s", str | ||
7 | } | ||
8 | function trans(c) { | ||
9 | printf "%s", end | ||
10 | |||
11 | lastc = c | ||
12 | end = "\n" | ||
13 | if(c == "%") | ||
14 | end = "" | ||
15 | else if(c == "(") | ||
16 | printf "echo -n " | ||
17 | else if(c ~ "[})]") { | ||
18 | end = "'\n" | ||
19 | printf "echo -n '" | ||
20 | } | ||
21 | } | ||
22 | |||
23 | BEGIN { | ||
24 | lastc = "{" | ||
25 | trans("}") | ||
26 | } | ||
27 | END { | ||
28 | print end | ||
29 | } | ||
30 | |||
31 | /^%/ && $0 !~ /^%[{()}%]/ && lastc !~ /[({]/ { | ||
32 | trans("%") | ||
33 | print substr($0, 2) | ||
34 | next | ||
35 | } | ||
36 | { | ||
37 | if(lastc == "%") | ||
38 | trans("}") | ||
39 | n = split($0, a, "%") | ||
40 | pr(a[1]) | ||
41 | for(i=2; i<=n; i++) { | ||
42 | c = substr(a[i], 1, 1) | ||
43 | rest = substr(a[i], 2) | ||
44 | |||
45 | if((lastc !~ "[({]" && c ~ "[({]") || | ||
46 | (lastc == "{" && c == "}") || | ||
47 | (lastc == "(" && c == ")")) | ||
48 | trans(c) | ||
49 | else if(c == "%") | ||
50 | pr("%") | ||
51 | else | ||
52 | pr("%" c) | ||
53 | pr(rest) | ||
54 | } | ||
55 | pr("\n") | ||
56 | } | ||
diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..3a9328c --- /dev/null +++ b/config.mk | |||
@@ -0,0 +1,2 @@ | |||
1 | NAME := grilist | ||
2 | VERSION := 0.0.1 | ||
diff --git a/package.json.tpl b/package.json.tpl new file mode 100644 index 0000000..c2d075b --- /dev/null +++ b/package.json.tpl | |||
@@ -0,0 +1,10 @@ | |||
1 | { | ||
2 | "name": "%($NAME%)", | ||
3 | "version": "%($VERSION%)", | ||
4 | "devDependencies": { | ||
5 | "less": "2.5.3", | ||
6 | "babel-preset-es2015": "6.3.13", | ||
7 | "browserify": "13.0.0", | ||
8 | "babelify": "7.2.0" | ||
9 | } | ||
10 | } | ||