Skip to content

Commit

Permalink
Merge pull request #220 from primer/release-7.3.0
Browse files Browse the repository at this point in the history
Release 7.3.0
  • Loading branch information
jonrohan authored May 9, 2018
2 parents abb8abb + 48dbee4 commit abaeaa0
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 68 deletions.
2 changes: 2 additions & 0 deletions .svgo.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
multipass: true
plugins:
- removeTitle: true
- removeViewBox: false
Expand All @@ -20,3 +21,4 @@ plugins:
- removeEditorsNSData: true
- removeEmptyAttrs: true
- removeHiddenElems: true
- collapseGroups: true
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
### HEAD
# 7.3.0

* Fix for heart icon https://github.com/primer/octicons/pull/211

* Adding an archive icon created by @colinkeany
Fixes https://github.com/primer/octicons/issues/182

* Fixed versioning strategy https://github.com/primer/octicons/pull/#208


### Octicons_node 7.0.0

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"lib/octicons_helper",
"lib/jekyll-octicons"
],
"version": "independent"
"version": "7.3.0"
}
2 changes: 1 addition & 1 deletion lib/jekyll-octicons/jekyll-octicons.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

s.add_dependency "jekyll", "~> 3.1"
s.add_dependency "octicons", "5.3.0"
s.add_dependency "octicons", "7.3.0"
end
2 changes: 1 addition & 1 deletion lib/jekyll-octicons/lib/jekyll-octicons/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module Liquid; class Tag; end; end

module Jekyll
class Octicons < Liquid::Tag
VERSION = "4.3.0".freeze
VERSION = "7.3.0".freeze
end
end
4 changes: 2 additions & 2 deletions lib/jekyll-octicons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jekyll-octicons",
"version": "4.3.0",
"version": "7.3.0",
"description": "A jekyll liquid plugin that makes including svg Octicons simple.",
"scripts": {
"version": "../../script/rubyversion ./lib/jekyll-octicons/version.rb",
Expand All @@ -21,6 +21,6 @@
"rubygems": "jekyll-octicons",
"homepage": "https://github.com/primer/octicons#readme",
"dependencies": {
"octicons_gem": "5.3.0"
"octicons_gem": "7.3.0"
}
}
2 changes: 1 addition & 1 deletion lib/octicons_gem/lib/octicons/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Octicons
VERSION = "5.3.0".freeze
VERSION = "7.3.0".freeze
end
2 changes: 1 addition & 1 deletion lib/octicons_gem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "octicons_gem",
"version": "5.3.0",
"version": "7.3.0",
"description": "Don't install",
"scripts": {
"postinstall": "bundle install --path vendor/bundle",
Expand Down
2 changes: 1 addition & 1 deletion lib/octicons_helper/lib/octicons_helper/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module OcticonsHelper
VERSION = "4.3.0".freeze
VERSION = "7.3.0".freeze
end
2 changes: 1 addition & 1 deletion lib/octicons_helper/octicons_helper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Gem::Specification.new do |s|

s.require_paths = ["lib"]

s.add_dependency "octicons", "5.3.0"
s.add_dependency "octicons", "7.3.0"
s.add_dependency "rails"
end
4 changes: 2 additions & 2 deletions lib/octicons_helper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "octicons_helper",
"version": "4.3.0",
"version": "7.3.0",
"description": "A rails helper that makes including svg Octicons simple.",
"scripts": {
"version": "../../script/rubyversion ./lib/octicons_helper/version.rb",
Expand All @@ -21,6 +21,6 @@
"rubygems": "octicons_helper",
"homepage": "https://github.com/primer/octicons#readme",
"dependencies": {
"octicons_gem": "5.3.0"
"octicons_gem": "7.3.0"
}
}
2 changes: 1 addition & 1 deletion lib/octicons_node/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "7.2.0",
"version": "7.3.0",
"name": "octicons",
"description": "A scalable set of icons handcrafted with <3 by GitHub.",
"homepage": "https://octicons.github.com",
Expand Down
2 changes: 1 addition & 1 deletion script/export
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Promise.resolve(fs.removeSync(outputDir))
dCount++
return svgo.optimize(svg, {})
.then(optimized => {
icon.path = /<svg.+>(.+)<\/svg>/g.exec(optimized.data).pop()
icon.path = optimized.data.slice(optimized.data.indexOf('>') + 1).slice(0, -6)

return fs.ensureDir(path.join(outputDir, "/svg"))
.then(() => fs.writeFileSync(path.resolve(outputDir, `svg/${icon.name}.svg`), optimized.data, "utf8"))
Expand Down
55 changes: 1 addition & 54 deletions script/utils.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
const got = require('got')

// Translates a path based on the xy array passed in
const translatePath = (p, xy) => {

let ds = p.match(/([A-Z]{1,2}[\s0-9\.\-e]+)/g)
let [x, y] = xy

let dd = ds.map((d) => {
var darr = d.split(" ").reverse()
for(let i = 0; i < darr.length; i += 2) {
if(darr[i+1]) {
darr[i] = parseFloat(darr[i]) + y
darr[i+1] = parseFloat(darr[i+1]) + x
}
}

return darr.reverse().join(" ")
}).join("") + "Z"

return dd
}

// Gets the sum of all the `translate(x y)` and reduces it
// <g transform="translate(-238 -286)"><g transform="translate(238 290)">
// becomes [0, 4]
const reduceTranslate = (t) => {
if(t == null) {
return [0, 0]
}
if(t.length == 1) {
return t[0].replace(/translate|[\(\)]/g,"").split(" ").map((v) => Math.round(parseFloat(v)))
}
return t.reduce((p,c) => {
p = p.replace(/translate|[\(\)]/g,"").split(" ")
c = c.replace(/translate|[\(\)]/g,"").split(" ")
for(let i = 0; i < c.length; i++) {
c[i] = Math.round(parseFloat(p[i])) + Math.round(parseFloat(c[i]))
}
return c
})
}

module.exports = {
progress: (current, total) => {
let percentage = Math.ceil((current * 10) / total)
Expand All @@ -60,19 +19,7 @@ module.exports = {
headers: { "Content-Type": "images/svg+xml" }
}).on('downloadProgress', downloadProgress)

let svg = response.body

let d = svg.match(/ d=["']([a-z\s0-9\.\-]+)["']/i).pop()
let translate = reduceTranslate(svg.match(/translate\([0-9\-\s\.e]+\)/g))
let d2 = translatePath(d, translate)

// Clean and replace svg elements
svg = svg.replace(`d="${d}"`, `d="${d2}"`)
.replace(/<\/?defs>/g,"")
.replace(/<use[^>]*>/g, "")

resolve(svg)
// .catch(err => reject(`There was trouble downloading ${url}\n${err}`))
resolve(response.body)
})
}
}

0 comments on commit abaeaa0

Please sign in to comment.