Internalize previously external libraries and stylesheets

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-05-05 18:09:37 +02:00
parent 1aa968299a
commit 49e7633ca5
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
5 changed files with 38997 additions and 92 deletions

5
.gitignore vendored
View file

@ -1,2 +1,5 @@
ots frontend/css
frontend/js
frontend/locale/*.untranslated.json frontend/locale/*.untranslated.json
frontend/webfonts
ots

View file

@ -1,4 +1,14 @@
generate: l10n VER_BOOTSTRAP=4.0.0
VER_BOOTSWATCH=4.1.1
VER_FONTAWESOME=5.0.12
VER_GIBBERISH_AES=1.0.0
VER_JQUERY=3.3.1
VER_POPPER=1.14.1
default: generate
generate: l10n download_libs
docker run --rm -ti -v $(CURDIR):$(CURDIR) -w $(CURDIR) node \ docker run --rm -ti -v $(CURDIR):$(CURDIR) -w $(CURDIR) node \
bash -c "npm install -g coffeescript && coffee -c frontend/application.coffee && chown -R $(shell id -u) frontend" bash -c "npm install -g coffeescript && coffee -c frontend/application.coffee && chown -R $(shell id -u) frontend"
go generate go generate
@ -9,3 +19,26 @@ l10n:
publish: publish:
curl -sSLo golang.sh https://raw.githubusercontent.com/Luzifer/github-publish/master/golang.sh curl -sSLo golang.sh https://raw.githubusercontent.com/Luzifer/github-publish/master/golang.sh
bash golang.sh bash golang.sh
# -- Download / refresh external libraries --
clean_libs:
rm -rf frontend/css frontend/webfonts frontend/js
download_libs: clean_libs fontawesome libs_js libs_css
fontawesome:
curl -sSfL https://github.com/FortAwesome/Font-Awesome/archive/$(VER_FONTAWESOME).tar.gz | \
tar -C frontend -xz --strip-components=2 --wildcards '*/web-fonts-with-css/css' '*/web-fonts-with-css/webfonts'
libs_css:
mkdir -p frontend/css
curl -sSfLo frontend/css/bootstrap.min.css "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/$(VER_BOOTSTRAP)/css/bootstrap.min.css"
curl -sSfLo frontend/css/bootswatch.min.css "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/$(VER_BOOTSWATCH)/flatly/bootstrap.min.css"
libs_js:
mkdir -p frontend/js
curl -sSfLo frontend/js/jquery.min.js "https://cdnjs.cloudflare.com/ajax/libs/jquery/$(VER_JQUERY)/jquery.min.js"
curl -sSfLo frontend/js/bootstrap.min.js "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/$(VER_BOOTSTRAP)/js/bootstrap.min.js"
curl -sSfLo frontend/js/popper.min.js "https://cdnjs.cloudflare.com/ajax/libs/popper.js/$(VER_POPPER)/popper.min.js"
curl -sSfLo frontend/js/gibberish-aes.min.js "https://cdnjs.cloudflare.com/ajax/libs/gibberish-aes/$(VER_GIBBERISH_AES)/gibberish-aes.min.js"

39018
assets.go

File diff suppressed because it is too large Load diff

View file

@ -6,14 +6,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap --> <link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css" <link rel="stylesheet" href="/css/bootswatch.min.css" />
integrity="sha256-LA89z+k9fjgMKQ/kq4OO2Mrf8VltYml/VES+Rg0fh20=" crossorigin="anonymous" /> <link rel="stylesheet" href="/css/fontawesome-all.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.1.1/flatly/bootstrap.min.css"
integrity="sha256-Aq7aBPqZwiUM2fHchlRaVD7RFsEBto+K77fvREGjnHU=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.12/css/all.css"
integrity="sha384-G0fIWCsCzJIMAVNQPfjH08cyYaUtMwjJwqiRKxxE/rx96Uroj1BtIQ6MLJuheaO9" crossorigin="anonymous">
<title>OTS - One Time Secrets</title> <title>OTS - One Time Secrets</title>
@ -127,16 +122,10 @@
</div> </div>
</div> </div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" <script src="/js/jquery.min.js"></script>
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="/js/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.1/popper.min.js" <script src="/js/bootstrap.min.js"></script>
integrity="sha256-ST2MecrXrJaAsqmfpk9XRQITlDoyMmUtgKBEndDisSc=" crossorigin="anonymous"></script> <script src="/js/gibberish-aes.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha256-5+02zu5UULQkO7w1GIr6vftCgMfFdZcAHeDtFnKZsBs=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gibberish-aes/1.0.0/gibberish-aes.min.js"
integrity="sha256-H9B/XRDijNiF3agVjtiz1ILVi3csEdGz9YBg5TjWouM=" crossorigin="anonymous"></script>
<script src="application.js"></script> <script src="application.js"></script>
</body> </body>
</html> </html>

View file

@ -75,6 +75,12 @@ func assetDelivery(res http.ResponseWriter, r *http.Request) {
res.Header().Set("Content-Type", mime.TypeByExtension(ext)) res.Header().Set("Content-Type", mime.TypeByExtension(ext))
if assetName != "/index.html" {
// Do not use template engine on other files than index.html
res.Write(assetData)
return
}
tpl, err := template.New(assetName).Funcs(getTFuncMap(r)).Parse(string(assetData)) tpl, err := template.New(assetName).Funcs(getTFuncMap(r)).Parse(string(assetData))
if err != nil { if err != nil {