Преглед изворни кода

Combine riot tags in distribution

Now the only thing left to do is find if there are any shellscripts that
can do obfuscation of javascript to reduce the size further.
Weiyi Lou пре 9 година
родитељ
комит
b89b1a785e
2 измењених фајлова са 17 додато и 5 уклоњено
  1. 16 5
      Makefile
  2. 1 0
      index.html

+ 16 - 5
Makefile

@@ -13,20 +13,31 @@ dist: ## Create a distribution for live usage
 	@mkdir -p dist/css dist/js dist/tags
 	# --- Combine CSS ---
 	@for file in $$(cat css/app.css | sed "$(CSS_FILES)"); do \
-		cat css/$$file >> dist/css/app.css; \
+	  cat css/$$file >> dist/css/app.css; \
 	done
 	# --- Combine Javascript ---
 	@for file in $$(grep "$(JS_TAGS)" index.html | sed "$(JS_FILES)"); do \
-		cat $$file >> dist/js/app.js; \
+	  cat $$file >> dist/js/app.js; \
+	done
+	# --- Combine Riot Tags ---
+	@for file in $$(grep "$(RIOT_TAGS)" index.html | sed "$(RIOT_FILES)"); do \
+	  cat $$file >> dist/tags/app.tag; \
 	done
-	# --- Copy Riot Tags ---
-	@cp tags/*.tag dist/tags/
 	# --- Modify Index Page ---
-	@sed "/$(JS_TAGS)/D" index.html | sed "s|$(APPJS_PH)|$(APPJS_TAG)|" > dist/index.html
+	@# Output is piped/redirected as BSD and GNU `sed -i` differ.
+	@cp index.html dist/temp.html
+	@sed "/$(JS_TAGS)/D" dist/temp.html | sed "s|$(APPJS_PH)|$(APPJS_TAG)|" > dist/index.html
+	@cp dist/index.html dist/temp.html
+	@sed "/$(RIOT_TAGS)/D" dist/temp.html | sed "s|$(APPTAG_PH)|$(APPTAG_TAG)|" > dist/index.html
+	@rm dist/temp.html
 	@echo "All Done!"
 
 CSS_FILES = s|@import.*[\'\"]\(.*\)[\'\"].*|\1|
 JS_TAGS = <script .*src=[\'\"].*\.js[\'\"]
 JS_FILES = s|.*src=[\'\"]\(.*\.js\)[\'\"].*|\1|
+RIOT_TAGS = <script .*src=[\'\"].*\.tag[\'\"]
+RIOT_FILES = s|.*src=[\'\"]\(.*\.tag\)[\'\"].*|\1|
 APPJS_PH = <!-- appjsplaceholder -->
 APPJS_TAG = <script type='text/javascript' src='js/app.js'></script>
+APPTAG_PH = <!-- apptagplaceholder -->
+APPTAG_TAG = <script type='riot/tag' src='tags/app.tag'></script>

+ 1 - 0
index.html

@@ -28,6 +28,7 @@
     <script type='text/javascript' src='js/vendor/riot+compiler.min.js'></script>
     <script type='text/javascript' src='js/vendor/highlight.pack.js'></script>
     <script type='text/javascript' src='js/pgsh.js'></script>
+    <!-- apptagplaceholder -->
     <script type='riot/tag' src='tags/terminal-ui.tag'></script>
     <script>riot.mount('*')</script>
   </body>