From 5bd9a6626b7027e3e0b5c9211357ed3ded292035 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sun, 2 Feb 2020 00:44:19 -0600 Subject: [PATCH 01/28] Add octicon SVG sprite Signed-off-by: jolheiser --- go.mod | 2 +- go.sum | 4 +- public/img/svg/octicons.svg | 204 +++++++++++++++++++++++++++++++++++ scripts/generate-octicons.go | 60 +++++++++++ templates/repo/header.tmpl | 3 +- web_src/less/_svg.less | 15 +++ web_src/less/index.less | 1 + 7 files changed, 285 insertions(+), 4 deletions(-) create mode 100755 public/img/svg/octicons.svg create mode 100644 scripts/generate-octicons.go create mode 100644 web_src/less/_svg.less diff --git a/go.mod b/go.mod index cb1dca4b5d759..86188c680f375 100644 --- a/go.mod +++ b/go.mod @@ -97,7 +97,7 @@ require ( github.com/yuin/goldmark v1.1.19 go.etcd.io/bbolt v1.3.3 // indirect golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 - golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9 + golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2 golang.org/x/text v0.3.2 diff --git a/go.sum b/go.sum index 13ffa77502227..0ead3b9e0d944 100644 --- a/go.sum +++ b/go.sum @@ -616,8 +616,8 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9 h1:DPz9iiH3YoKiKhX/ijjoZvT0VFwK2c6CWYWQ7Zyr8TU= -golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180620175406-ef147856a6dd/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/public/img/svg/octicons.svg b/public/img/svg/octicons.svg new file mode 100755 index 0000000000000..e2ea394c99950 --- /dev/null +++ b/public/img/svg/octicons.svg @@ -0,0 +1,204 @@ + +alert +archive +arrow-both +arrow-down +arrow-left +arrow-right +arrow-small-down +arrow-small-left +arrow-small-right +arrow-small-up +arrow-up +beaker +bell +bold +book +bookmark +briefcase +broadcast +browser +bug +calendar +check +checklist +chevron-down +chevron-left +chevron-right +chevron-up +circle-slash +circuit-board +clippy +clock +cloud-download +cloud-upload +code +comment +comment-discussion +credit-card +dash +dashboard +database +dependent +desktop-download +device-camera +device-camera-video +device-desktop +device-mobile +diff +diff-added +diff-ignored +diff-modified +diff-removed +diff-renamed +ellipsis +eye +eye-closed +file +file-binary +file-code +file-directory +file-media +file-pdf +file-submodule +file-symlink-directory +file-symlink-file +file-zip +flame +fold +fold-down +fold-up +gear +gift +gist +gist-secret +git-branch +git-commit +git-compare +git-merge +git-pull-request +github-action +globe +grabber +graph +heart +heart-outline +history +home +horizontal-rule +hubot +inbox +infinity +info +issue-closed +issue-opened +issue-reopened +italic +jersey +kebab-horizontal +kebab-vertical +key +keyboard +law +light-bulb +line-arrow-down +line-arrow-left +line-arrow-right +line-arrow-up +link +link-external +list-ordered +list-unordered +location +lock +logo-gist +logo-github +mail +mail-read +mark-github +markdown +megaphone +mention +milestone +mirror +mortar-board +mute +no-newline +note +octoface +organization +package +paintcan +pencil +person +pin +play +plug +plus +plus-small +primitive-dot +primitive-dot-stroke +primitive-square +project +pulse +question +quote +radio-tower +reply +repo +repo-clone +repo-force-push +repo-forked +repo-pull +repo-push +repo-template +repo-template-private +report +request-changes +rocket +rss +ruby +saved +screen-full +screen-normal +search +server +settings +shield +shield-check +shield-lock +shield-x +sign-in +sign-out +skip +smiley +squirrel +star +stop +sync +tag +tasklist +telescope +terminal +text-size +three-bars +thumbsdown +thumbsup +tools +trashcan +triangle-down +triangle-left +triangle-right +triangle-up +unfold +unmute +unsaved +unverified +verified +versions +watch +workflow +workflow-all +x +zap + \ No newline at end of file diff --git a/scripts/generate-octicons.go b/scripts/generate-octicons.go new file mode 100644 index 0000000000000..ecb51885ee036 --- /dev/null +++ b/scripts/generate-octicons.go @@ -0,0 +1,60 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "strings" + + "gitea.com/jolheiser/octicon" + + "golang.org/x/net/html" +) + +const outFile = "public/img/svg/octicons.svg" + +func main() { + if err := generateOcticons(); err != nil { + fmt.Printf("could not generate Octicons: %v\n", err) + } +} + +func generateOcticons() error { + sprite := `` + for _, name := range octicon.Icons { + icon := octicon.Icon(name) + + page, err := html.Parse(bytes.NewBufferString(icon.XML)) + if err != nil { + return err + } + node := page.FirstChild.LastChild.FirstChild + + var viewBox html.Attribute + for _, attr := range node.Attr { + if attr.Key == "viewBox" { + viewBox = attr + } + } + node.Attr = []html.Attribute{viewBox} + xml := &strings.Builder{} + if err := html.Render(xml, node); err != nil { + return err + } + + sprite += fmt.Sprintf("\n"+``, icon.Name, xml.String()[4:len(xml.String())-4]) + } + sprite += "\n" + + if err := ioutil.WriteFile(outFile, []byte(sprite), os.ModePerm); err != nil { + return err + } + return nil +} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index b3757b2764beb..024c21e877413 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -5,6 +5,8 @@