css_sprite 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +47 -24
- data/VERSION +1 -1
- data/css_sprite.gemspec +55 -0
- data/lib/css_sprite/sprite.rb +7 -7
- metadata +4 -3
data/README.textile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
h1. css_sprite
|
2
2
|
|
3
|
-
A rails plugin/gem to generate css sprite automatically.
|
3
|
+
A rails plugin/gem to generate css sprite images automatically.
|
4
4
|
|
5
5
|
**************************************************************************
|
6
6
|
|
@@ -11,7 +11,18 @@ install rmagick gem first:
|
|
11
11
|
sudo gem install rmagick
|
12
12
|
</code></pre>
|
13
13
|
|
14
|
+
if you have any problems with the rmagick gem, install imagemagick via macports first:
|
15
|
+
|
16
|
+
<pre><code>
|
17
|
+
sudo port install libxml2
|
18
|
+
sudo port install ImageMagick
|
19
|
+
</code></pre>
|
20
|
+
|
21
|
+
or via installer: <a href="http://github.com/maddox/magick-installer/tree/master">http://github.com/maddox/magick-installer/tree/master</a>
|
22
|
+
|
23
|
+
|
14
24
|
install it as a gem:
|
25
|
+
|
15
26
|
<pre><code>
|
16
27
|
sudo gem sources -a http://gemcutter.org
|
17
28
|
sudo gem install css_sprite
|
@@ -19,7 +30,7 @@ sudo gem install css_sprite
|
|
19
30
|
|
20
31
|
or install it as a plugin:
|
21
32
|
<pre><code>
|
22
|
-
script/plugin install git
|
33
|
+
script/plugin install git://github.com/flyerhzm/css_sprite.git
|
23
34
|
</code></pre>
|
24
35
|
|
25
36
|
**************************************************************************
|
@@ -28,14 +39,14 @@ h2. Configuration
|
|
28
39
|
|
29
40
|
add <code>config/css_sprite.yml</code>, define about compositing what images.
|
30
41
|
<pre><code>
|
31
|
-
forum_icon_vertical.gif:
|
32
|
-
sources:
|
42
|
+
forum_icon_vertical.gif: # destination image file
|
43
|
+
sources: # source image file list
|
33
44
|
- good_topic.gif
|
34
45
|
- mid_topic.gif
|
35
46
|
- unread_topic.gif
|
36
47
|
- sticky_topic.gif
|
37
|
-
orient: vertical
|
38
|
-
span:
|
48
|
+
orient: vertical # composite gravity, vertical or horizontal
|
49
|
+
span: 5 # span of space between two images
|
39
50
|
</code></pre>
|
40
51
|
|
41
52
|
first line defines the destination image filename.
|
@@ -43,6 +54,8 @@ first line defines the destination image filename.
|
|
43
54
|
<code>orient</code> defines the composite gravity type, horizontal or vertical. Default is 'vertical'.
|
44
55
|
<code>span</code> defines the span between two images. Default is 0.
|
45
56
|
|
57
|
+
you can define any number of destination image files.
|
58
|
+
|
46
59
|
**************************************************************************
|
47
60
|
|
48
61
|
h2. Usage
|
@@ -55,30 +68,40 @@ if you use it as a plugin, ignore the step above.
|
|
55
68
|
|
56
69
|
then just run rake task:
|
57
70
|
<pre><code>
|
58
|
-
rake
|
71
|
+
rake css_sprite:build
|
59
72
|
</code></pre>
|
60
73
|
|
61
|
-
the result css is generated at <code>
|
74
|
+
the result css is generated at <code>public/stylesheets/css_sprite.css</code>
|
62
75
|
<pre><code>
|
63
|
-
.good_topic
|
64
|
-
|
65
|
-
width: 20px
|
66
|
-
height: 19px
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
.good_topic {
|
77
|
+
background: url('/images/forum_icon_vertical.gif') no-repeat 0px 0px;
|
78
|
+
width: 20px;
|
79
|
+
height: 19px;
|
80
|
+
}
|
81
|
+
.mid_topic {
|
82
|
+
background: url('/images/forum_icon_vertical.gif') no-repeat 0px 24px
|
83
|
+
width: 20px;
|
84
|
+
height: 19px;
|
85
|
+
}
|
86
|
+
.unread_topic {
|
87
|
+
background: url('/images/forum_icon_vertical.gif') no-repeat 0px 48px;
|
88
|
+
width: 19px;
|
89
|
+
height: 18px;
|
90
|
+
}
|
91
|
+
.sticky_topic {
|
92
|
+
background: url('/images/forum_icon_vertical.gif') no-repeat 0px 71px;
|
93
|
+
width: 19px;
|
94
|
+
height: 18px;
|
95
|
+
}
|
79
96
|
</code></pre>
|
80
97
|
|
81
98
|
**************************************************************************
|
82
99
|
|
100
|
+
h2. Contributor
|
101
|
+
|
102
|
+
josedelcorral - fix the style of generated css
|
103
|
+
|
104
|
+
**************************************************************************
|
105
|
+
|
83
106
|
|
84
107
|
Copyright (c) 2009 [Richard Huang (flyerhzm@gmail.com)], released under the MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/css_sprite.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
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 = %q{css_sprite}
|
8
|
+
s.version = "1.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Richard Huang"]
|
12
|
+
s.date = %q{2009-10-16}
|
13
|
+
s.description = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
|
14
|
+
s.email = %q{flyerhzm@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.textile"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.textile",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"css_sprite.gemspec",
|
24
|
+
"init.rb",
|
25
|
+
"install.rb",
|
26
|
+
"lib/css_sprite.rb",
|
27
|
+
"lib/css_sprite/sprite.rb",
|
28
|
+
"spec/css_sprite_spec.rb",
|
29
|
+
"spec/resources/good_topic.gif",
|
30
|
+
"spec/resources/mid_topic.gif",
|
31
|
+
"spec/spec.opts",
|
32
|
+
"spec/spec_helper.rb",
|
33
|
+
"tasks/css_sprite_tasks.rake",
|
34
|
+
"uninstall.rb"
|
35
|
+
]
|
36
|
+
s.homepage = %q{}
|
37
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.5}
|
40
|
+
s.summary = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
|
41
|
+
s.test_files = [
|
42
|
+
"spec/css_sprite_spec.rb",
|
43
|
+
"spec/spec_helper.rb"
|
44
|
+
]
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
|
+
else
|
52
|
+
end
|
53
|
+
else
|
54
|
+
end
|
55
|
+
end
|
data/lib/css_sprite/sprite.rb
CHANGED
@@ -3,7 +3,7 @@ require 'RMagick'
|
|
3
3
|
class Sprite
|
4
4
|
CONFIG_PATH = RAILS_ROOT + '/config/'
|
5
5
|
IMAGE_PATH = RAILS_ROOT + '/public/images/'
|
6
|
-
|
6
|
+
PUBLIC_PATH = RAILS_ROOT + '/public/stylesheets/'
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@output = {}
|
@@ -43,14 +43,14 @@ class Sprite
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def output_css
|
46
|
-
File.open(
|
46
|
+
File.open(PUBLIC_PATH + 'css_sprite.css', 'w') do |f|
|
47
47
|
@output.each do |dest, results|
|
48
48
|
results.each do |result|
|
49
|
-
f.puts ".#{result[:name]}"
|
50
|
-
f.puts "\
|
51
|
-
f.puts "\twidth: #{result[:width]}px"
|
52
|
-
f.puts "\theight: #{result[:height]}px"
|
53
|
-
f.puts ""
|
49
|
+
f.puts ".#{result[:name]} \{ "
|
50
|
+
f.puts "\tbackground: url('/images/#{dest}') no-repeat #{result[:x]}px #{result[:y]}px;"
|
51
|
+
f.puts "\twidth: #{result[:width]}px;"
|
52
|
+
f.puts "\theight: #{result[:height]}px;"
|
53
|
+
f.puts "\}"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css_sprite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-16 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- README.textile
|
27
27
|
- Rakefile
|
28
28
|
- VERSION
|
29
|
+
- css_sprite.gemspec
|
29
30
|
- init.rb
|
30
31
|
- install.rb
|
31
32
|
- lib/css_sprite.rb
|
@@ -66,5 +67,5 @@ signing_key:
|
|
66
67
|
specification_version: 3
|
67
68
|
summary: css_sprite is a rails plugin/gem to generate css sprite image automatically.
|
68
69
|
test_files:
|
69
|
-
- spec/spec_helper.rb
|
70
70
|
- spec/css_sprite_spec.rb
|
71
|
+
- spec/spec_helper.rb
|