pictos-icons 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ group :development do
4
+ gem "rspec", ">= 2.8.0"
5
+ gem "rdoc", ">= 3.12"
6
+ gem "bundler", ">= 1.1.0"
7
+ gem "jeweler", ">= 1.8.4"
8
+ end
@@ -0,0 +1,31 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.8.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.7.4)
12
+ rake (0.9.2.2)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+ rspec (2.11.0)
16
+ rspec-core (~> 2.11.0)
17
+ rspec-expectations (~> 2.11.0)
18
+ rspec-mocks (~> 2.11.0)
19
+ rspec-core (2.11.1)
20
+ rspec-expectations (2.11.2)
21
+ diff-lcs (~> 1.1.3)
22
+ rspec-mocks (2.11.1)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (>= 1.1.0)
29
+ jeweler (>= 1.8.4)
30
+ rdoc (>= 3.12)
31
+ rspec (>= 2.8.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Kristian Mandrup
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ # Pictos icons
2
+
3
+ Pictos icons for the Rails asset pipeline. Extracted from Sencha Touch GNU license framework. The sprite icons come in the following sizes:
4
+
5
+ * 15 px
6
+ * 30 px
7
+ * 60 px
8
+
9
+ ## Install via Rails asset pipeline
10
+
11
+ Simply require the css (or scss) stylesheet in your stylesheet manifest, fx `app/assets/stylesheets/application.css`
12
+
13
+ ```css
14
+ /*
15
+ *= require pictos
16
+ *= require pictos-15
17
+ *= require pictos-30
18
+ *= require pictos-60
19
+ */
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Use like this:
25
+
26
+ ```html
27
+ <ul class='p30.pictos'>
28
+ <li class='pic action'></li>
29
+ </ul>
30
+
31
+ <ul class='p15.pictos'>
32
+ <li class='pic search'></li>
33
+ </ul>
34
+
35
+ ```
36
+
37
+ Or in HAML
38
+
39
+ ```haml
40
+ %ul.p60.pictos
41
+ %li.pic.action
42
+ %li.pic.search
43
+ ```
44
+
45
+ You don't have to use an unordered list with list items, but it gives a nice result. You simply have to ensure that you are using block elements that can take a background image ;).
46
+
47
+ See the *world-flags* gem for more info, tips etc.
48
+
49
+ ## Auto Resize
50
+
51
+ This gem also includes a sprite utility: `lib/tools/resize_css.rb` for generating sprite sets of different sizes :)
52
+
53
+ Usage example
54
+
55
+ ```text
56
+ $ cd lib/pictos-icons/tools/
57
+ $ edit resize_css.rb # change the run arguments at the bottom!
58
+ $ ruby resize_css.rb
59
+ ```
60
+
61
+ TODO: Make resize tool into a rake task or similar which can take arguments!
62
+
63
+ ## Contributing to pictos-icons
64
+
65
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
66
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
67
+ * Fork the project.
68
+ * Start a feature/bugfix branch.
69
+ * Commit and push until you are happy with your contribution.
70
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
71
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
72
+
73
+ ## Copyright
74
+
75
+ Copyright (c) 2012 Kristian Mandrup. See LICENSE.txt for
76
+ further details. (Icons extracted from Sencha Touch 2 GNU version)
77
+
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "pictos-icons"
18
+ gem.homepage = "http://github.com/kristianmandrup/pictos-icons"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Pictos icon sprite set ready for use with Rails asset pipeline}
21
+ gem.description = %Q{This icon set should cover most use cases :)}
22
+ gem.email = "kmandrup@gmail.com"
23
+ gem.authors = ["Kristian Mandrup"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ # require 'rspec/core'
29
+ # require 'rspec/core/rake_task'
30
+ # RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ # spec.pattern = FileList['spec/**/*_spec.rb']
32
+ # end
33
+
34
+ # task :default => :spec
35
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1
@@ -0,0 +1,7 @@
1
+ module PictosIcons
2
+ module Rails
3
+ # adds vendor/assets to Rails asset pipeline!
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,185 @@
1
+ # use ImageMagick to Resize, using 32px version as base
2
+ # convert flags32.png -resize 75% flags24.png
3
+ # convert flags32_semi.png -resize 75% flags24_semi.png
4
+
5
+ require 'open3'
6
+
7
+ class ResizeCss
8
+
9
+ attr_reader :base_size, :new_size, :stylesheet_folder, :stylesheet_name, :sprite_name
10
+ attr_reader :template_lang, :size_prefix, :options
11
+
12
+ def initialize base_size, new_size, options = {}
13
+ @base_size = base_size
14
+ @new_size = new_size
15
+ @options = options
16
+
17
+ @stylesheet_folder = options[:stylesheet_folder] if options[:stylesheet_folder]
18
+ @stylesheet_name = options[:stylesheet_name] if options[:stylesheet_name]
19
+ @sprite_name = options[:sprite_name] if options[:sprite_name]
20
+
21
+ resize = "convert #{sprite_name}-#{base_size}.png -resize #{factor * 100}%"
22
+ new_file_name = "#{sprite_name}-#{new_size}"
23
+
24
+ command_resize = "#{resize} #{new_file_name}.png"
25
+ command_resize_light = "#{resize} #{lighten} #{new_file_name}_light.png"
26
+ command_resize_dark = "#{resize} #{darken} #{new_file_name}_dark.png"
27
+ command_resize_gray = "#{resize} #{grayscale} #{new_file_name}_gray.png"
28
+
29
+ if auto_exec?
30
+ Open3.popen3("pwd") do |stdin, stdout, e, t|
31
+ base_dir = stdout
32
+ Open3.popen3 "cd #{images_dir}"
33
+
34
+ Open3.popen3 command_resize
35
+ Open3.popen3 command_resize_light if lighten?
36
+ Open3.popen3 command_resize_dark if darken?
37
+ Open3.popen3 command_resize_gray if gray?
38
+
39
+ Open3.popen3 "cd #{base_dir}"
40
+ end
41
+ else
42
+ puts "Use ImageMagick to resize #{sprite_name} sprites:"
43
+ puts command_resize
44
+ puts command_resize_light if lighten?
45
+ puts command_resize_dark if darken?
46
+ puts command_resize_gray if gray?
47
+ end
48
+ end
49
+
50
+ def lighten?
51
+ options[:light]
52
+ end
53
+
54
+ def darken?
55
+ options[:dark]
56
+ end
57
+
58
+ def gray?
59
+ options[:gray]
60
+ end
61
+
62
+ def lighten
63
+ "-level 0%,100%,2.0"
64
+ end
65
+
66
+ def darken
67
+ "-level 0%,100%,0.5"
68
+ end
69
+
70
+ def grayscale
71
+ "-colorspace Gray"
72
+ end
73
+
74
+ def auto_exec?
75
+ options[:auto_exec]
76
+ end
77
+
78
+ def size_prefix
79
+ @size_prefix ||= 'p'
80
+ end
81
+
82
+ def stylesheet_path
83
+ "../../../vendor/assets/stylesheets"
84
+ end
85
+
86
+ def stylesheet_folder
87
+ @stylesheet_folder ||= ''
88
+ end
89
+
90
+ def stylesheet_full_path
91
+ @stylesheet_full_path ||= File.join(stylesheet_path, stylesheet_folder)
92
+ end
93
+
94
+ def stylesheet_name
95
+ @stylesheet_name ||= 'pictos-'
96
+ end
97
+
98
+ def sprite_name
99
+ @sprite_name ||= 'pictos'
100
+ end
101
+
102
+ def template_lang
103
+ @template_lang ||= '' #'erb'
104
+ end
105
+
106
+ def template_ext
107
+ !blank?(template_lang) ? ".#{template_lang}" : ''
108
+ end
109
+
110
+ def blank? txt
111
+ !txt || txt.empty?
112
+ end
113
+
114
+ def execute options = {:ext => 'css', :semi => false}
115
+ semi = options[:semi] ? '-semi': ''
116
+ ext = options[:ext] ? options[:ext] : 'css'
117
+ src_file_path = File.expand_path "#{stylesheet_full_path}/#{stylesheet_name}#{base_size}#{semi}.#{ext}#{template_ext}", File.dirname(__FILE__)
118
+ target_file_path = File.expand_path "#{stylesheet_full_path}/#{stylesheet_name}#{new_size}#{semi}.#{ext}#{template_ext}", File.dirname(__FILE__)
119
+
120
+ puts "src: #{src_file_path} -> #{target_file_path}"
121
+
122
+ lines = File.open(src_file_path).readlines
123
+
124
+ img_exp = "#{sprite_name}-#{base_size}"
125
+ replace_img = "#{sprite_name}-#{new_size}"
126
+
127
+ # puts "img_exp: #{img_exp}"
128
+ # puts "replace_img: #{replace_img}"
129
+
130
+ repositioned_css = lines.map do |line|
131
+ pos_match = line.match /.+position:\s-?(\d+)(px)?\s-?(\d+)(px)?/
132
+ # puts "pos_match: #{line} - #{pos_match.inspect}"
133
+ img_match = line.match /#{img_exp}/
134
+ new_line = line.sub(/#{img_exp}/, replace_img) if img_match
135
+ new_line = replace_pos pos_match, line if pos_match
136
+ # puts "line: #{line} -> #{new_line}"
137
+ new_line ||= line
138
+ new_line
139
+ end.join("")
140
+
141
+ puts "Write new CSS:"
142
+ puts repositioned_css
143
+
144
+ File.open(target_file_path, 'w') do |f|
145
+ f.puts repositioned_css.gsub ".#{size_prefix}#{base_size}", ".#{size_prefix}#{new_size}"
146
+ end
147
+ end
148
+
149
+ def factor
150
+ @factor ||= new_size / base_size.to_f
151
+ end
152
+
153
+ def replace_pos pos_match, line
154
+ pos_x = pos_match[1].to_i
155
+ new_pos_x = (pos_x * factor).to_i.to_s
156
+
157
+ pos_y = pos_match[3].to_i
158
+ new_pos_y = (pos_y * factor).to_i.to_s
159
+ # puts "new pos: #{new_pos_x}, #{new_pos_y}"
160
+
161
+ rest = line[6..-1]
162
+ rest = rest.sub /#{pos_x}/, new_pos_x.to_s
163
+ rest = rest.sub /#{pos_y}/, new_pos_y.to_s
164
+
165
+ rest = rest.gsub /#{base_size}px;/, "#{new_size}px;"
166
+
167
+ # first = line[0..10].sub(".f#{base_size}", ".f#{newsize}")
168
+ line[0..5] + rest
169
+ end
170
+ end
171
+
172
+ # options
173
+ # - :stylesheet_folder, :stylesheet_name, :sprite_name, :template_lang, :size_prefix
174
+ # - :dark, :light, :gray
175
+ # - :auto-exec
176
+
177
+ # change last argument to fit sprite size of flags
178
+ # first arg is the flag size (css files) that is used as base
179
+ resizer = ResizeCss.new 30, 15
180
+
181
+ resizer.execute
182
+ resizer.execute :ext => 'css.scss'
183
+
184
+ # resizer.execute :semi => true
185
+ # resizer.execute :ext => 'css.scss', :semi => true
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "pictos-icons"
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kristian Mandrup"]
12
+ s.date = "2012-08-09"
13
+ s.description = "This icon set should cover most use cases :)"
14
+ s.email = "kmandrup@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/pictos-icons.rb",
29
+ "lib/pictos-icons/tools/resize_css.rb",
30
+ "pictos-icons.gemspec",
31
+ "spec/spec_helper.rb",
32
+ "vendor/assets/images/pictos-15.png",
33
+ "vendor/assets/images/pictos-30.png",
34
+ "vendor/assets/images/pictos-60.png",
35
+ "vendor/assets/stylesheets/pictos-15.css",
36
+ "vendor/assets/stylesheets/pictos-15.css.scss",
37
+ "vendor/assets/stylesheets/pictos-30.css",
38
+ "vendor/assets/stylesheets/pictos-30.css.scss",
39
+ "vendor/assets/stylesheets/pictos-60.css",
40
+ "vendor/assets/stylesheets/pictos-60.css.scss",
41
+ "vendor/assets/stylesheets/pictos.css",
42
+ "vendor/assets/stylesheets/pictos.css.scss"
43
+ ]
44
+ s.homepage = "http://github.com/kristianmandrup/pictos-icons"
45
+ s.licenses = ["MIT"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = "1.8.24"
48
+ s.summary = "Pictos icon sprite set ready for use with Rails asset pipeline"
49
+
50
+ if s.respond_to? :specification_version then
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
55
+ s.add_development_dependency(%q<rdoc>, [">= 3.12"])
56
+ s.add_development_dependency(%q<bundler>, [">= 1.1.0"])
57
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
58
+ else
59
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
60
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
61
+ s.add_dependency(%q<bundler>, [">= 1.1.0"])
62
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
66
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
67
+ s.add_dependency(%q<bundler>, [">= 1.1.0"])
68
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
69
+ end
70
+ end
71
+