From 4c42961ee86e355c1748929d21456a95a039b2be Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 25 May 2015 15:11:20 +0200 Subject: [PATCH] Added svg minifying --- assets/badgeTemplate.tpl | 1 - bindata.go | 75 +++++++++++++++++++--------------------- main.go | 8 +++++ 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/assets/badgeTemplate.tpl b/assets/badgeTemplate.tpl index ed279ae..1a2a198 100644 --- a/assets/badgeTemplate.tpl +++ b/assets/badgeTemplate.tpl @@ -1,4 +1,3 @@ - diff --git a/bindata.go b/bindata.go index 4c466dd..72af243 100644 --- a/bindata.go +++ b/bindata.go @@ -27,45 +27,42 @@ func bindata_read(data []byte, name string) ([]byte, error) { func assets_badgetemplate_tpl() ([]byte, error) { return bindata_read([]byte{ - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0x9c, 0x53, - 0x5f, 0x6f, 0xd3, 0x30, 0x10, 0x7f, 0xef, 0xa7, 0x38, 0xdd, 0x84, 0xc4, - 0xa4, 0x26, 0x71, 0xda, 0x55, 0x42, 0x28, 0xee, 0x84, 0x40, 0x8c, 0x17, - 0x9e, 0x18, 0xe3, 0xd9, 0x49, 0x9c, 0xc4, 0xe0, 0xda, 0x95, 0xed, 0x35, - 0xd9, 0xa6, 0x7d, 0x77, 0xec, 0x24, 0x6b, 0x03, 0xa5, 0xa2, 0xa0, 0x3e, - 0xf4, 0x72, 0xfd, 0xfd, 0xbb, 0xbb, 0x26, 0xbb, 0xee, 0x36, 0x12, 0x76, - 0xdc, 0x58, 0xa1, 0x15, 0xc5, 0x34, 0x26, 0x08, 0x5c, 0x15, 0xba, 0x14, - 0xaa, 0xa6, 0xf8, 0xf5, 0xf6, 0x63, 0xf4, 0x06, 0xaf, 0xd7, 0xb3, 0xcc, - 0xee, 0x6a, 0xf0, 0x48, 0x65, 0x29, 0x36, 0xce, 0x6d, 0xdf, 0x26, 0x49, - 0xdb, 0xb6, 0x71, 0xbb, 0x8c, 0xb5, 0xa9, 0x93, 0x05, 0x21, 0x24, 0xf1, - 0x08, 0x84, 0x56, 0x94, 0xae, 0xa1, 0xf8, 0xf4, 0x04, 0xf1, 0xb7, 0x50, - 0xc2, 0xf3, 0x33, 0x42, 0xc3, 0x45, 0xdd, 0x38, 0x8a, 0x0b, 0x82, 0xeb, - 0x19, 0x00, 0x64, 0x52, 0x28, 0xce, 0xcc, 0x8d, 0x61, 0xa5, 0xe0, 0xca, - 0x81, 0x28, 0x29, 0xe6, 0x08, 0xdd, 0x82, 0xa2, 0x77, 0x7f, 0xf0, 0x5f, - 0x29, 0x21, 0xaf, 0x06, 0x6c, 0x80, 0x5b, 0xa7, 0xb7, 0xa0, 0xab, 0xca, - 0x72, 0xd7, 0x23, 0xc2, 0x73, 0x54, 0x68, 0xa9, 0x0d, 0xc5, 0x8b, 0x3c, - 0xcf, 0xc7, 0x8e, 0xde, 0xb2, 0x42, 0xb8, 0x07, 0x8a, 0x71, 0x8a, 0x90, - 0xfc, 0x99, 0x9d, 0x9e, 0xc6, 0x66, 0xc9, 0xaf, 0xb1, 0x86, 0xe6, 0x86, - 0xd9, 0x1f, 0x7d, 0x40, 0x76, 0xc8, 0x63, 0x78, 0xe1, 0xfe, 0x3a, 0x29, - 0x98, 0x8e, 0xe2, 0x12, 0xa1, 0x12, 0x52, 0xfa, 0x98, 0x55, 0x55, 0x1d, - 0x8c, 0x82, 0xe8, 0x50, 0xd6, 0x10, 0x6a, 0x8a, 0xf7, 0x46, 0xbe, 0xbe, - 0x60, 0x97, 0x07, 0x8f, 0x2d, 0xf3, 0x92, 0x23, 0x77, 0xb5, 0x5a, 0x61, - 0x68, 0xfa, 0x14, 0x9f, 0x09, 0x00, 0x81, 0x26, 0xb8, 0xde, 0x0a, 0x27, - 0xf9, 0x8b, 0x35, 0xc0, 0x6e, 0x41, 0xe0, 0x93, 0xff, 0xf5, 0x71, 0x3a, - 0xfb, 0x54, 0x25, 0x70, 0xde, 0x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0x3e, 0x9e, 0x8e, 0x66, 0xf1, 0xd3, 0x3f, 0x4e, + 0xfe, 0x38, 0x2b, 0xdc, 0x1c, 0xb5, 0x41, 0x95, 0x93, 0x48, 0xbc, 0x18, + 0x7f, 0x7b, 0xb9, 0x3a, 0xc4, 0xff, 0xeb, 0x2d, 0x62, 0xfe, 0x15, 0x7e, + 0x7b, 0x4e, 0x9b, 0x0e, 0x95, 0xc7, 0xf7, 0x7c, 0x73, 0xf5, 0x33, 0x00, + 0x00, 0xff, 0xff, 0x72, 0x4c, 0xac, 0x36, 0x10, 0x04, 0x00, 0x00, }, "assets/badgeTemplate.tpl", ) diff --git a/main.go b/main.go index e03f862..d21765d 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,8 @@ import ( "github.com/alecthomas/template" "github.com/gorilla/mux" + "github.com/tdewolff/minify" + "github.com/tdewolff/minify/svg" ) const ( @@ -46,6 +48,12 @@ func generateBadge(res http.ResponseWriter, r *http.Request) { res.Header().Add("Content-Type", "image/svg+xml") res.Header().Add("Cache-Control", "public, max-age=31536000") + + m := minify.New() + m.AddFunc("image/svg+xml", svg.Minify) + + badge, _ = minify.Bytes(m, "image/svg+xml", badge) + res.Write(badge) }