Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Octicon SVG spritemap #10107

Merged
merged 38 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5bd9a66
Add octicon SVG sprite
jolheiser Feb 2, 2020
e2249e7
Static prefix
jolheiser Feb 2, 2020
7273e68
SVG for all repo icons
jolheiser Feb 2, 2020
215242b
make vendor
jolheiser Feb 2, 2020
d7d6e68
Swap out octicons
jolheiser Feb 4, 2020
43b858a
Move octicons to top of less imports
jolheiser Feb 4, 2020
6b717dc
Fix JS
jolheiser Feb 5, 2020
85f29d1
Definitely not a search/replace
jolheiser Feb 5, 2020
e690697
Missed regex
jolheiser Feb 5, 2020
084df84
Move to more generic calls and webpack
jolheiser Feb 6, 2020
ee8a100
Merge branch 'master' of github.com:go-gitea/gitea into octicon
jolheiser Feb 6, 2020
5016230
make svg -> make webpack
jolheiser Feb 6, 2020
db1745e
Remove svg-sprite
jolheiser Feb 6, 2020
f61b1a5
Update tests
jolheiser Feb 6, 2020
8144af2
Missed a test
jolheiser Feb 6, 2020
21b92a6
Remove svg from makefile
jolheiser Feb 6, 2020
d4489e8
Suggestions
jolheiser Feb 6, 2020
61e5659
Attempt to fix test
jolheiser Feb 6, 2020
cd6e7b3
Update tests
jolheiser Feb 6, 2020
957b098
Revert timetracking test
jolheiser Feb 6, 2020
10db7dc
Merge branch 'master' into octicon
jolheiser Feb 6, 2020
74f9370
Swap .octicon for .svg in less
jolheiser Feb 6, 2020
7a56b18
Add aria-hidden
jolheiser Feb 6, 2020
cc05fd0
Replace mega-octicon
jolheiser Feb 6, 2020
495df17
Fix webpack globbing on Windows
jolheiser Feb 6, 2020
0df9b40
Revert
jolheiser Feb 6, 2020
8c319f2
Fix octions from upstream
jolheiser Feb 6, 2020
89eb82c
Merge branch 'master' of https://github.com/go-gitea/gitea into octicon
jolheiser Feb 6, 2020
6a37ddc
Merge branch 'octicon' of https://github.com/jolheiser/gitea into oct…
jolheiser Feb 6, 2020
bcf1ef8
Fix Vue and missed JS function
jolheiser Feb 6, 2020
8701f87
Add JS helper and PWA
jolheiser Feb 7, 2020
4fa203e
Preload SVG
jolheiser Feb 7, 2020
f184f24
Merge branch 'master' into octicon
jolheiser Feb 7, 2020
5e5ae63
Merge branch 'master' into octicon
jolheiser Feb 7, 2020
73f4eb9
Merge branch 'master' into octicon
jolheiser Feb 8, 2020
472a8bb
Merge branch 'master' of https://github.com/go-gitea/gitea into octicon
jolheiser Feb 11, 2020
41a8a20
Merge branch 'octicon' of https://github.com/jolheiser/gitea into oct…
jolheiser Feb 11, 2020
ec424cb
Merge branch 'master' into octicon
techknowlogick Feb 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
204 changes: 204 additions & 0 deletions public/img/svg/octicons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions scripts/generate-octicons.go
Original file line number Diff line number Diff line change
@@ -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 := `<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">`
for _, name := range octicon.Icons {
jolheiser marked this conversation as resolved.
Show resolved Hide resolved
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"+`<symbol id="%s"%ssymbol>`, icon.Name, xml.String()[4:len(xml.String())-4])
}
sprite += "\n</svg>"

if err := ioutil.WriteFile(outFile, []byte(sprite), os.ModePerm); err != nil {
return err
}
return nil
}
3 changes: 2 additions & 1 deletion templates/repo/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
<div class="ui huge breadcrumb repo-title">
{{if .RelAvatarLink}}
<img class="ui avatar image" src="{{.RelAvatarLink}}">
{{else if .IsTemplate}}
<svg class="mega-octicon-svg"><use xlink:href="{{AppSubUrl}}/img/svg/octicons.svg#repo-template{{if .IsPrivate}}-private{{end}}" /></svg>
jolheiser marked this conversation as resolved.
Show resolved Hide resolved
{{else}}
<i class="mega-octicon octicon-{{if .IsPrivate}}lock{{else if .IsMirror}}repo-clone{{else if .IsFork}}repo-forked{{else}}repo{{end}}"></i>
{{end}}
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
<div class="divider"> / </div>
<a href="{{$.RepoLink}}">{{.Name}}</a>
{{if and .RelAvatarLink .IsPrivate}}<i class="mega-octicon octicon-lock"></i>{{end}}
{{if .IsTemplate}}<i class="icon fa-copy"></i>{{end}}
{{if .IsArchived}}<i class="archive icon archived-icon"></i>{{end}}
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{if .SanitizedOriginalURL}}{{.SanitizedOriginalURL}}{{else}}{{MirrorAddress $.Mirror}}{{end}}">{{if .SanitizedOriginalURL}}{{.SanitizedOriginalURL}}{{else}}{{MirrorAddress $.Mirror}}{{end}}</a></div>{{end}}
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{SubStr .BaseRepo.RelLink 1 -1}}</a></div>{{end}}
Expand Down
15 changes: 15 additions & 0 deletions web_src/less/_svg.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.octicon-svg {
width: 16px;
height: 16px;
display: inline-block;
vertical-align: text-top;
fill: currentColor;
}

.mega-octicon-svg {
width: 30px;
height: 30px;
display: inline-block;
vertical-align: text-top;
fill: currentColor;
}
jolheiser marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions web_src/less/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
@import "_admin";
@import "_explore";
@import "_review";
@import "_svg";
@import "~highlight.js/styles/github.css";
@import "../css/gitGraph.css";