-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME
274 lines (224 loc) · 6.17 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
Saucy
=====
Dynamic Text Rendering Plugin for Rails. Like sIFR but without the hassle/flash/javascript.
* Automatic caching
* SEO friendly
* render any TTF font
Examples
--------
<%= saucy_tag("Hi there") %>
<%= saucy_tag("I am red", :style => {:font => {:color => 'red' }}) %>
<%= saucy_tag("I am a red/blue sprite",
:style => {:font => {:color => 'red'}},
:highlight => {:font => {:color => 'blue'}}
) %>
Use
---
In a view:
<%= saucy_tag(text, options) %>
* text: your own text. Note it can contain newlines which will be interpreted as multiline text.
* options: html attributes to be inserted
Available options
-----------------
# Style needs to be a hash - see the 'Styles' heading below
{:style => {}}
# Highlight option is for sprites, the styles passed in override
# the styles that were passed in for :style. This can be used for hover or focus effects
{:highlight => {}}
# The html style needs to be a hash
# The html class needs to be a array of classNames
{:html => {:style => {}, :class => []}}
# Tag needs to be symbol (default is :a)
{:tag => :p}
# Transparent needs to be a boolean -
# this defaults to true
{:transparent => false}
Styles
------
The style has has several options and the default style is:
{
:background => "transparent",
:font => {
:size => 18,
:color => "#000",
:font => "arial",
:stretch => "normal"
},
:stroke => {
:width => 0,
:color => "#000",
:inner => true
},
:spacing => {
:letter => 0,
:word => 0
},
:rotate => 0,
:shadow => {
:color => "#000",
:opacity => 0.6,
:top => 2,
:left => 2,
:blur => 5.0,
:render => false
}
}
The style that's passed in will be merged over the top of this.
Internet Explorer
-----
Saucy will apply an AlphaFilter if you the background color is "transparent" (or absent since this is the default)
Fonts
-----
Fonts are loaded from the /plugins/saucy/fonts directory.
Sprites
-------
If you set an highlight style Saucy will render a sprite consisting of 2 images, the normal and the highlight.
To set a sprite to be at the highlight style, simply set the top margin to 0. E.g. the following is for a hover effect:
<style type="text/css" media="screen">
.saucySprite:hover {
margin-top: 0 !important;
}
</style>
You need to pass in a :highlight option which is in the same format as the :style option.
The :highlight option overrides the :style option (you don't need to pass in all the styles again).
Try out
-------
* In your controller
def saucy
@spacing = {
:font => {
:size => 70,
:color => "#cfc"
},
:spacing => {
:letter => -6
}
}
@thick_stroked = {
:stroke => {
:color => "red",
:width => 5
},
:font => {
:size => 50,
:color => "#fff"
}
}
@bauhaus = {
:font => {
:size => 50,
:font => "bauhausl.ttf",
:color => "white"
}
}
@outline = {
:font => {
:size => 60,
:font => "basket.ttf",
:color => "transparent"
},
:stroke => {
:width => 2
},
:shadow => {
:render => true,
:top => 5,
:left => 5,
:opacity => 0.2
}
}
@shadow = {
:font => {
:size => 60,
:font => "basket.ttf",
:color => "#fff"
},
:shadow => {
:render => true,
:top => 5,
:left => 5,
:opacity => 0.2
}
}
@rotate = {
:rotate => -15,
:font => {
:size => 70,
:font => "bauhausl.ttf",
:color => "#fec",
:stretch => "condensed"
}
}
@saucy = {
:font => {
:size => 80,
:font => "basket.ttf",
:color => "#f6c"
},
:stroke => {
:color => "white",
:width => 15,
:inner => 1
},
:shadow => {
:render => true,
:top => 5,
:left => 5,
:opacity => 0.2
}
}
@thick_stroked = {
:stroke => {
:color => "red",
:width => 20,
:inner => 1
},
:font => {
:size => 50,
:color => "#fff"
},
:rotate => 10,
:shadow => {
:render => true,
:top => 5,
:left => 5
}
}
end
* In saucy.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Saucy</title>
<style type="text/css">
body {background: url(http://www.mr-tut.com/images/uploads/803.gif); }
p {margin-right: 3em; margin-top: 3em; float: left}
#container {width: 1000px}
.saucySprite:hover { margin-top: 0px !important; }
</style>
</head>
<body>
<%= saucy_tag "Saucy - Examples", :style=> @saucy, :tag=> "h2" %>
<div id=container>
<%= saucy_tag "text\non\nmultiple\nlines",:style => @bauhaus %>
<%= saucy_tag "letter spacing...", :style => @spacing, :html => {:class=>["myclass"]} %>
<%= saucy_tag "stroked!!", :style => @thick_stroked, :html =>{:class=>["myclass"]} %>
<%= saucy_tag "30 degrees", :style => @rotate %>
<%= saucy_tag "shadow", :style => @shadow %>
<%= saucy_tag("I am a red/blue sprite",
:style => {:font => {:color => 'red'}},
:highlight => {:font => {:color => 'blue'}}
) %>
<%= saucy_tag("hover effects sprite!!",
:style => @thick_stroked,
:highlight => {:stroke => {:color => "#5fe"}},
:html => {:class => ["myclass2"]}
) %>
<%= saucy_tag( "outline...",
:style=> @outline,
:highlight => {:stroke => {:color => "blue" }}
) %>
</div>
</body>
</html>