rest-assured 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +17 -0
  3. data/LICENSE +22 -0
  4. data/README.markdown +78 -0
  5. data/Rakefile +4 -0
  6. data/bin/console +12 -0
  7. data/bin/rest-assured +28 -0
  8. data/cucumber.yml +3 -0
  9. data/db/migrate/20110620161740_add_fixtures.rb +12 -0
  10. data/db/migrate/20110625155332_add_redirects_table.rb +12 -0
  11. data/db/migrate/20110709150645_add_description_to_fixtures.rb +9 -0
  12. data/db/migrate/20110807222522_add_active_bit_to_fixtures.rb +9 -0
  13. data/db/migrate/20110818155555_add_position_to_redirects.rb +9 -0
  14. data/db/migrate/20110823132023_add_method_to_fixtures.rb +9 -0
  15. data/db/migrate/20110912162948_rename_url_to_fullpath.rb +9 -0
  16. data/db/migrate/20110912163705_rename_fixtures_to_doubles.rb +9 -0
  17. data/features/doubles_via_api.feature +50 -0
  18. data/features/doubles_via_ui.feature +66 -0
  19. data/features/persistence.feature +24 -0
  20. data/features/redirect_rules_via_api.feature +29 -0
  21. data/features/redirect_rules_via_ui.feature +68 -0
  22. data/features/step_definitions/doubles_steps.rb +143 -0
  23. data/features/step_definitions/persistence_steps.rb +13 -0
  24. data/features/step_definitions/redirect_rules_steps.rb +64 -0
  25. data/features/step_definitions/support/numeric_transforms.rb +3 -0
  26. data/features/support/env.rb +71 -0
  27. data/lib/rest-assured.rb +66 -0
  28. data/lib/rest-assured/config.rb +11 -0
  29. data/lib/rest-assured/init.rb +12 -0
  30. data/lib/rest-assured/models/double.rb +30 -0
  31. data/lib/rest-assured/models/redirect.rb +37 -0
  32. data/lib/rest-assured/routes/double.rb +77 -0
  33. data/lib/rest-assured/routes/redirect.rb +71 -0
  34. data/lib/rest-assured/version.rb +3 -0
  35. data/lib/sinatra/partials.rb +18 -0
  36. data/public/css/grid.inuit.css +76 -0
  37. data/public/css/inuit.css +904 -0
  38. data/public/css/jquery.jgrowl.css +132 -0
  39. data/public/css/style.css +88 -0
  40. data/public/img/css/12-grid-720.png +0 -0
  41. data/public/img/css/12-grid.png +0 -0
  42. data/public/img/css/baseline.gif +0 -0
  43. data/public/img/css/grid-720.png +0 -0
  44. data/public/img/css/grid.png +0 -0
  45. data/public/img/css/icons/error.png +0 -0
  46. data/public/img/css/icons/info.png +0 -0
  47. data/public/img/css/icons/success.png +0 -0
  48. data/public/img/css/icons/warning.png +0 -0
  49. data/public/javascript/application.js +12 -0
  50. data/public/javascript/jquery.jgrowl_minimized.js +11 -0
  51. data/rest-assured.gemspec +36 -0
  52. data/spec/functional/double_routes_spec.rb +117 -0
  53. data/spec/functional/redirect_routes_spec.rb +108 -0
  54. data/spec/models/double_spec.rb +73 -0
  55. data/spec/models/redirect_spec.rb +38 -0
  56. data/spec/spec_helper.rb +47 -0
  57. data/views/base.scss +11 -0
  58. data/views/doubles/_form.haml +16 -0
  59. data/views/doubles/edit.haml +4 -0
  60. data/views/doubles/index.haml +41 -0
  61. data/views/doubles/new.haml +3 -0
  62. data/views/layout.haml +25 -0
  63. data/views/redirects/_form.haml +11 -0
  64. data/views/redirects/edit.haml +4 -0
  65. data/views/redirects/index.haml +33 -0
  66. data/views/redirects/new.haml +3 -0
  67. metadata +250 -0
@@ -0,0 +1,12 @@
1
+ require 'sinatra/activerecord'
2
+ require 'meta_where'
3
+ require 'rest-assured/config'
4
+
5
+ ActiveRecord::Base.establish_connection(
6
+ :adapter => "sqlite3",
7
+ :database => AppConfig[:database]
8
+ )
9
+
10
+ ActiveRecord::Migrator.migrate(
11
+ File.expand_path('../../../db/migrate', __FILE__)
12
+ )
@@ -0,0 +1,30 @@
1
+ class Double < ActiveRecord::Base
2
+ attr_accessible :fullpath, :content, :description, :method
3
+
4
+ METHODS = %w{GET POST PUT DELETE}
5
+
6
+ validates_presence_of :fullpath, :content
7
+ validates_inclusion_of :method, :in => METHODS
8
+
9
+ before_save :toggle_active
10
+ before_validation :set_method
11
+ after_destroy :set_active
12
+
13
+ private
14
+ def toggle_active
15
+ if active && Double.where(:fullpath => fullpath, :active => true, :id.ne => id).exists?
16
+ Double.where(:fullpath => fullpath, :id.ne => id).update_all :active => false
17
+ end
18
+ end
19
+
20
+ def set_method
21
+ self.method = 'GET' unless method.present?
22
+ end
23
+
24
+ def set_active
25
+ if active && f = Double.where(:fullpath => fullpath).last
26
+ f.active = true
27
+ f.save
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ class Redirect < ActiveRecord::Base
2
+ attr_accessible :pattern, :to
3
+
4
+ validates_presence_of :pattern, :to
5
+ validates_uniqueness_of :position, :allow_blank => true
6
+
7
+ scope :ordered, order('position')
8
+
9
+ before_create :assign_position
10
+
11
+ def self.update_order(ordered_redirect_ids)
12
+ success = true
13
+
14
+ transaction do
15
+ begin
16
+ update_all :position => nil
17
+
18
+ ordered_redirect_ids.each_with_index do |r_id, idx|
19
+ r = find(r_id)
20
+ r.position = idx
21
+ r.save!
22
+ end
23
+ rescue
24
+ # TODO log exception
25
+ success = false
26
+ raise ActiveRecord::Rollback
27
+ end
28
+ end
29
+ success
30
+ end
31
+
32
+ private
33
+
34
+ def assign_position
35
+ self.position = ( self.class.maximum(:position) || -1 ) + 1
36
+ end
37
+ end
@@ -0,0 +1,77 @@
1
+ module RestAssured
2
+ module DoubleRoutes
3
+ def self.included(router)
4
+ router.get '/' do
5
+ redirect to('/doubles')
6
+ end
7
+
8
+ router.get '/doubles' do
9
+ @doubles = Double.all
10
+ haml :'doubles/index'
11
+ end
12
+
13
+ router.get '/doubles/new' do
14
+ @double = Double.new
15
+ haml :'doubles/new'
16
+ end
17
+
18
+ router.post '/doubles' do
19
+ f = { :fullpath => params['fullpath'], :content => params['content'], :description => params['description'], :method => params['method'] }
20
+ @double = Double.create(params['double'] || f)
21
+
22
+ if browser?
23
+ if @double.errors.blank?
24
+ flash[:notice] = "Double created"
25
+ redirect '/doubles'
26
+ else
27
+ flash[:error] = "Crumps! " + @double.errors.full_messages.join("; ")
28
+ haml :'doubles/new'
29
+ end
30
+ else
31
+ if @double.errors.present?
32
+ status 400
33
+ body @double.errors.full_messages.join("\n")
34
+ end
35
+ end
36
+ end
37
+
38
+ router.get %r{/doubles/(\d+)/edit} do |id|
39
+ @double = Double.find(id)
40
+ haml :'doubles/edit'
41
+ end
42
+
43
+ router.put %r{/doubles/(\d+)} do |id|
44
+ @double = Double.find(id)
45
+
46
+ if request.xhr?
47
+ if params['active']
48
+ @double.active = params['active']
49
+ @double.save
50
+ 'Changed'
51
+ end
52
+ elsif params['double']
53
+ @double.update_attributes(params['double'])
54
+
55
+ if @double.save
56
+ flash[:notice] = 'Double updated'
57
+ redirect '/doubles'
58
+ else
59
+ flash[:error] = 'Crumps! ' + @double.errors.full_messages.join("\n")
60
+ haml :'doubles/edit'
61
+ end
62
+ end
63
+ end
64
+
65
+ router.delete %r{/doubles/(\d+)} do |id|
66
+ if Double.destroy(id)
67
+ flash[:notice] = 'Double deleted'
68
+ redirect '/doubles'
69
+ end
70
+ end
71
+
72
+ router.delete '/doubles/all' do
73
+ Double.delete_all
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,71 @@
1
+ module RestAssured
2
+ module RedirectRoutes
3
+ def self.included(router)
4
+ router.get '/redirects' do
5
+ @redirects = Redirect.ordered
6
+ haml :'redirects/index'
7
+ end
8
+
9
+ router.get '/redirects/new' do
10
+ @redirect = Redirect.new
11
+ haml :'redirects/new'
12
+ end
13
+
14
+ router.post '/redirects' do
15
+ @redirect = Redirect.create(params['redirect'] || { :pattern => params['pattern'], :to => params['to'] })
16
+
17
+ if browser?
18
+ if @redirect.errors.blank?
19
+ flash[:notice] = "Redirect created"
20
+ redirect '/redirects'
21
+ else
22
+ flash[:error] = "Crumps! " + @redirect.errors.full_messages.join("; ")
23
+ haml :'redirects/new'
24
+ end
25
+ else
26
+ if @redirect.errors.present?
27
+ status 400
28
+ body @redirect.errors.full_messages.join("\n")
29
+ end
30
+ end
31
+ end
32
+
33
+ router.get %r{/redirects/(\d+)/edit} do |id|
34
+ @redirect = Redirect.find(id)
35
+ haml :'redirects/edit'
36
+ end
37
+
38
+ router.put %r{/redirects/(\d+)} do |id|
39
+ @redirect = Redirect.find(id)
40
+
41
+ @redirect.update_attributes(params['redirect'])
42
+
43
+ if @redirect.save
44
+ flash[:notice] = 'Redirect updated'
45
+ redirect '/redirects'
46
+ else
47
+ flash[:error] = 'Crumps! ' + @redirect.errors.full_messages.join("\n")
48
+ haml :'redirects/edit'
49
+ end
50
+ end
51
+
52
+ router.put '/redirects/reorder' do
53
+ if params['redirect']
54
+ if Redirect.update_order(params['redirect'])
55
+ 'Changed'
56
+ else
57
+ 'Crumps! It broke'
58
+ end
59
+ end
60
+ end
61
+
62
+ router.delete %r{/redirects/(\d+)} do |id|
63
+ if Redirect.destroy(id)
64
+ flash[:notice] = 'Redirect deleted'
65
+ redirect '/redirects'
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module RestAssured
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,18 @@
1
+ module Sinatra::Partials
2
+ def partial(template, *args)
3
+ template_array = template.to_s.split('/')
4
+ template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
5
+ options = args.last.is_a?(Hash) ? args.pop : {}
6
+ options.merge!(:layout => false)
7
+ if collection = options.delete(:collection) then
8
+ collection.inject([]) do |buffer, member|
9
+ buffer << haml(:"#{template}", options.merge(
10
+ :layout => false,
11
+ :locals => {template_array[-1].to_sym => member}
12
+ ))
13
+ end.join("\n")
14
+ else
15
+ haml(:"#{template}", options)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,76 @@
1
+ /*------------------------------------*\
2
+ GRID.INUIT.CSS
3
+ \*------------------------------------*/
4
+
5
+
6
+
7
+
8
+
9
+ /*
10
+ grid.inuit.css is an inuit.css igloo
11
+ igloos are CSS plugins which extend the inuit.css framework
12
+ They are released under the Apache License, Version 2.0 -- http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ @inuitcss
15
+ inuitcss.com
16
+ */
17
+
18
+
19
+
20
+
21
+
22
+ /*------------------------------------*\
23
+ GRIDS
24
+ \*------------------------------------*/
25
+ /*
26
+ Page wrapper. Apply to the body where possible, as per: http://csswizardry.com/2011/01/using-the-body-element-as-a-wrapper/
27
+ */
28
+ .wrapper{
29
+ width:940px;
30
+ margin:0 auto;
31
+ padding:0 10px;
32
+ }
33
+
34
+ /*
35
+ Most frameworks rely on class="end" or similar to remove the margin from the last column in a row of grids. We don't want to do that so we use a combination of margin- and negative margin-left. It's clever...
36
+ We also allow you to use grid items as stand alone columns or in a series of columns. To use a series just wrap them all in <div class="grids">...</div>
37
+ */
38
+ .grids{
39
+ clear:both;
40
+ max-width:960px;
41
+ margin:0 0 0 -20px;
42
+ list-style:none; /* So we can make grids out of lists */
43
+ }
44
+
45
+ /*
46
+ Here we are using an attribute selector to detect the string 'grid-' in an element's class.
47
+ This works by assuming that anything we call grid-<n> we also want to be a grid item. It means less code and less for you to remember!
48
+
49
+ Ensure any grid item's FIRST class is a grid-<n> class. e.g.
50
+ VALID: class="grid-4 text-centre"
51
+ INVALID: class="left grid-4"
52
+ */
53
+ [class^="grid-"]{
54
+ float:left;
55
+ margin:0 20px 0 0;
56
+ }
57
+ .grids [class^="grid-"]{
58
+ margin:0 0 0 20px;
59
+ }
60
+
61
+ .grid-1{ width:40px }
62
+ .grid-2{ width:100px }
63
+ .grid-3{ width:160px }
64
+ .grid-4{ width:220px }
65
+ .grid-5{ width:280px }
66
+ .grid-6{ width:340px }
67
+ .grid-7{ width:400px }
68
+ .grid-8{ width:460px }
69
+ .grid-9{ width:520px }
70
+ .grid-10{ width:580px }
71
+ .grid-11{ width:640px }
72
+ .grid-12{ width:700px }
73
+ .grid-13{ width:760px }
74
+ .grid-14{ width:820px }
75
+ .grid-15{ width:880px }
76
+ .grid-16{ width:940px; margin:0 }
@@ -0,0 +1,904 @@
1
+ @charset "UTF-8";
2
+ /*------------------------------------*\
3
+ INUIT.CSS
4
+ \*------------------------------------*/
5
+ /*
6
+ Author: Harry Roberts
7
+ Twitter: @inuitcss
8
+ Author URL: csswizardry.com
9
+ Project URL: inuitcss.com
10
+ Version: 3.0.a
11
+ Date: 30 June 2011
12
+
13
+ Copyright 2011 Harry Roberts
14
+
15
+ Licensed under the Apache License, Version 2.0 (the "License");
16
+ you may not use this file except in compliance with the License.
17
+ You may obtain a copy of the License at
18
+
19
+ http://www.apache.org/licenses/LICENSE-2.0
20
+
21
+ Unless required by applicable law or agreed to in writing, software
22
+ distributed under the License is distributed on an "AS IS" BASIS,
23
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ See the License for the specific language governing permissions and
25
+ limitations under the License.
26
+
27
+ */
28
+
29
+
30
+
31
+
32
+
33
+ /*------------------------------------*\
34
+ RESET
35
+ \*------------------------------------*/
36
+ html,body,div,span,applet,object,iframe,
37
+ h1,h2,h3,h4,h5,h6,p,blockquote,pre,
38
+ a,abbr,acronym,address,big,cite,code,
39
+ del,dfn,em,img,ins,kbd,q,s,samp,
40
+ small,strike,strong,sub,sup,tt,var,
41
+ b,u,i,center,
42
+ dl,dt,dd,ol,ul,li,
43
+ fieldset,form,label,legend,
44
+ table,caption,tbody,tfoot,thead,tr,th,td,
45
+ article,aside,canvas,details,figcaption,figure,
46
+ footer,header,hgroup,menu,nav,section,summary,
47
+ time,mark,audio,video{
48
+ margin:0;
49
+ padding:0;
50
+ }
51
+ article,aside,details,figcaption,figure,footer,
52
+ header,hgroup,menu,nav,section{
53
+ display: block;
54
+ }
55
+
56
+ table{
57
+ border-collapse:collapse;
58
+ border-spacing:0;
59
+ }
60
+ fieldset,img{
61
+ border:0;
62
+ }
63
+ address,caption,cite,dfn,th,var{
64
+ font-style:normal;
65
+ font-weight:normal;
66
+ }
67
+ caption,th{
68
+ text-align:left;
69
+ }
70
+ h1,h2,h3,h4,h5,h6{
71
+ font-size:100%;
72
+ font-weight:normal;
73
+ }
74
+ q:before,q:after{
75
+ content:'';
76
+ }
77
+ abbr,acronym{
78
+ border:0;
79
+ }
80
+
81
+
82
+
83
+
84
+
85
+ /*------------------------------------*\
86
+ MAIN
87
+ \*------------------------------------*/
88
+ html{
89
+ overflow-y:scroll; /* Force scrollbars 100% of the time */
90
+ font-size:100%; /* Use 16px as per http://www.informationarchitects.jp/en/100e2r/ and http://www.wilsonminer.com/posts/2008/oct/20/relative-readability/ */
91
+ font-family:Calibri, "Helvetica Neue", Arial, sans-serif; /* Swap these two lines around to switch between serif and sans */
92
+ font-family:Cambria, Georgia, "Times New Roman", serif; /* Swap these two lines around to switch between serif and sans */
93
+ line-height:1.5;
94
+ /*background:url(../img/css/baseline.gif) 0 18px #fff;*/
95
+ color:#333;
96
+ }
97
+ body{
98
+ min-height:100%;
99
+ }
100
+
101
+
102
+
103
+
104
+
105
+ /*------------------------------------*\
106
+ GRIDS
107
+ \*------------------------------------*/
108
+ /*
109
+ Build a custom grid-system igloo at inuitcss.com
110
+ */
111
+
112
+
113
+
114
+
115
+
116
+ /*------------------------------------*\
117
+ CLEARFIX
118
+ \*------------------------------------*/
119
+ /*
120
+ Fix clearing issues as per: http://nicolasgallagher.com/micro-clearfix-hack/
121
+ */
122
+ .cf,
123
+ .grids{
124
+ zoom:1;
125
+ }
126
+ .cf:before,
127
+ .grids:before,
128
+ .cf:after,
129
+ .grids:after{
130
+ content:"";
131
+ display:table;
132
+ }
133
+ .cf:after,
134
+ .grids:after{
135
+ clear:both;
136
+ }
137
+
138
+
139
+
140
+
141
+
142
+ /*------------------------------------*\
143
+ LOGO
144
+ \*------------------------------------*/
145
+ /*
146
+ Your logo is an image, not a h1: http://csswizardry.com/2010/10/your-logo-is-an-image-not-a-h1/
147
+ */
148
+ #logo,
149
+ #logo img{
150
+ display:block;
151
+ width:auto; /* Width of your logo in pixels (ideally a round grid-number) */
152
+ height:auto; /* Height of your logo in pixels */
153
+ }
154
+ /* Based on the fact that we need to use an <img /> in our markup, let’s hide the actual image and use a background on the <a>--this gives us semantically sound markup and the ability to use sprites for hover effects! */
155
+ #logo{
156
+ background:url(/path/to/logo);
157
+ }
158
+ #logo:hover{
159
+ /* Hover states */
160
+ background-position:0 -00px;
161
+ }
162
+ #logo img{
163
+ position:absolute;
164
+ left:-99999px;
165
+ }
166
+
167
+
168
+
169
+
170
+
171
+ /*------------------------------------*\
172
+ NAV
173
+ \*------------------------------------*/
174
+ .nav{
175
+ list-style:none;
176
+ margin:0 0 1.5em 0;
177
+ }
178
+ .nav li{
179
+ display:inline;
180
+ }
181
+ .nav a{
182
+ display:inline-block;
183
+ }
184
+
185
+
186
+
187
+
188
+
189
+ /*------------------------------------*\
190
+ TYPE
191
+ \*------------------------------------*/
192
+ /*--- HEADINGS ---*/
193
+ h1{
194
+ font-size:2em; /* 32px */
195
+ margin-bottom:0.75em; /* 24px */
196
+ line-height:1.5; /* 48px */
197
+ }
198
+ h2{
199
+ font-size:1.5em; /* 24px */
200
+ margin-bottom:1em; /* 24px */
201
+ line-height:1; /* 24px */
202
+ }
203
+ h3{
204
+ font-size:1.25em; /* 20px */
205
+ margin-bottom:1.2em; /* 24px */
206
+ line-height:1.2; /* 24px */
207
+ }
208
+ h4{
209
+ font-size:1.125em; /* 18px */
210
+ margin-bottom:1.333em; /* 24px */
211
+ line-height:1.333; /* 24px */
212
+ }
213
+ h5{
214
+ font-weight:bold;
215
+ }
216
+ h5,
217
+ h6{
218
+ font-size:1em; /* 16px */
219
+ margin-bottom:1.5em; /* 24px */
220
+ line-height:1.5; /* 24px */
221
+ }
222
+
223
+ /*--- PARAGRAPHS ---*/
224
+ p,
225
+ address{
226
+ margin-bottom:1.5em;
227
+ }
228
+ /*
229
+ Mo’ robust paragraph indenting: http://csswizardry.com/2010/12/mo-robust-paragraph-indenting/
230
+ Uncomment to activate
231
+ p+p{
232
+ text-indent:2em;
233
+ margin-top:-1.5em;
234
+ }
235
+ */
236
+
237
+ /*--- FIGURES ---*/
238
+ figure{
239
+ margin-bottom:1.5em;
240
+ }
241
+ figure img{
242
+ display:block;
243
+ margin-bottom:0;
244
+ }
245
+ figcaption{
246
+ font-size:0.75em;
247
+ }
248
+
249
+ /*--- LINKS ---*/
250
+ /*
251
+ Say no to negative hovers: http://csswizardry.com/2011/05/on-negative-hovers/
252
+ A negative hover is one whose appearance is subtracted from on hover rather than added to.
253
+ */
254
+ a{
255
+ text-decoration:none;
256
+ }
257
+ a:visited{
258
+ opacity:0.8; /* A bit basic, but it’s a bare minumum... */
259
+ }
260
+ a:hover{
261
+ text-decoration:underline;
262
+ }
263
+ a:active,
264
+ a:focus{
265
+ /* Give clicked links a depressed effect. */
266
+ position:relative;
267
+ top:1px;
268
+ }
269
+
270
+ /*--- LISTS ---*/
271
+ ul,
272
+ ol{
273
+ margin:0 0 1.5em 60px;
274
+ }
275
+ ul ul,
276
+ ol ol,
277
+ ul ol,
278
+ ol ul{
279
+ /* Let’s take care of lists in lists */
280
+ margin:0 0 0 60px;
281
+ }
282
+
283
+ /*
284
+ A numbered list is NOT the same as an ordered one.
285
+ Use this class when you want a list to be numbered but it has no order.
286
+ See http://jsfiddle.net/csswizardry/sdrth/
287
+ */
288
+ ul.numbered{
289
+ list-style:decimal outside;
290
+ }
291
+ dl{
292
+ margin-bottom:1.5em;
293
+ }
294
+ dt{
295
+ font-weight:bold;
296
+ }
297
+ dt:after{
298
+ content:":";
299
+ }
300
+ dt::after{
301
+ content:":";
302
+ }
303
+ dd{
304
+ margin-left:60px;
305
+ }
306
+
307
+ /*--- QUOTES ---*/
308
+ blockquote{
309
+ text-indent:-0.4em; /* Hang that punctuation */
310
+ }
311
+ blockquote b,
312
+ blockquote .source{
313
+ /* Mark the source up with either a <b> or another element of your choice with a class of source. */
314
+ display:block;
315
+ text-indent:0;
316
+ }
317
+
318
+ /*--- GENERAL ---*/
319
+ q,
320
+ i,
321
+ em,
322
+ cite{
323
+ font-style:italic;
324
+ font-weight:inherit;
325
+ }
326
+ b,
327
+ strong{
328
+ font-weight:bold;
329
+ font-style:inherit;
330
+ }
331
+ mark{
332
+ background:#ffc;
333
+ }
334
+ s,
335
+ del{
336
+ text-decoration:line-through;
337
+ }
338
+ small{
339
+ font-size:0.75em;
340
+ line-height:1;
341
+ }
342
+
343
+ /*--- CODE ---*/
344
+ pre,
345
+ code{
346
+ font-family:monospace;
347
+ font-size:1em;
348
+ }
349
+ pre{
350
+ overflow:auto;
351
+ margin-bottom:1.5em;
352
+ line-height:24px; /* Having to define explicit pixel values :( */
353
+ }
354
+ code{
355
+ line-height:1;
356
+ }
357
+
358
+
359
+
360
+
361
+
362
+ /*------------------------------------*\
363
+ IMAGES
364
+ \*------------------------------------*/
365
+ img{
366
+ max-width:100%;
367
+ height:auto;
368
+ /* Give it some text styles to offset alt text */
369
+ font-style:italic;
370
+ color:#c00;
371
+ }
372
+ img.left { margin:0 20px 0 0; }
373
+ img.right { margin:0 0 0 20px; }
374
+
375
+ /*--- FLASH/VIDEO ---*/
376
+ object,
377
+ embed,
378
+ video{
379
+ max-width:100%;
380
+ height:auto;
381
+ }
382
+
383
+
384
+
385
+
386
+
387
+ /*------------------------------------*\
388
+ FORMS
389
+ \*------------------------------------*/
390
+ /*
391
+ Unfortunately, and somewhat obviously, forms don’t fit the baseline all too well. Perhaps in a later version...
392
+ */
393
+ fieldset{
394
+ padding:10px;
395
+ border:1px solid #ccc;
396
+ margin-bottom:1.5em;
397
+ }
398
+ label{
399
+ display:block;
400
+ cursor:pointer;
401
+ }
402
+ label:after{
403
+ content:":";
404
+ }
405
+ label::after{
406
+ content:":";
407
+ }
408
+ input,
409
+ textarea{
410
+ font-family:inherit;
411
+ font-size:1em;
412
+ line-height:1.5;
413
+ }
414
+
415
+ /*
416
+ Nice UI touch for placeholders. To get placeholders working cross-browser see @dan_bentley’s jQuery plugin: https://github.com/danbentley/placeholder
417
+ */
418
+ [placeholder]{
419
+ cursor:pointer;
420
+ }
421
+ [placeholder]:active,
422
+ [placeholder]:focus{
423
+ cursor:text;
424
+ }
425
+ .check-list{
426
+ width:100%;
427
+ overflow:hidden;
428
+ list-style:none;
429
+ margin:0 0 1.5em 0;
430
+ }
431
+ .check-list li{
432
+ width:25%;
433
+ float:left;
434
+ }
435
+ .check-label{
436
+ display:inline;
437
+ }
438
+ .check-label:after{
439
+ content:normal;
440
+ }
441
+ .check-label::after{
442
+ content:normal;
443
+ }
444
+ .button{
445
+ cursor:pointer;
446
+ }
447
+ fieldset > :last-child{
448
+ /* Remove the margin from the last element in the fieldset--this makes our padding more consistent. */
449
+ margin:0;
450
+ }
451
+
452
+
453
+
454
+
455
+
456
+ /*------------------------------------*\
457
+ TABLES
458
+ \*------------------------------------*/
459
+ /*
460
+ Unfortunately, and somewhat obviously, tables don’t fit the baseline all too well. Perhaps in a later version...
461
+ */
462
+ table{
463
+ margin-bottom:1.5em;
464
+ width:100%;
465
+ max-width:100%;
466
+ }
467
+ thead tr:last-of-type th{
468
+ /* Thicker border on the table-headers of the last row in the table head */
469
+ border-bottom-width:2px;
470
+ }
471
+ tbody th{
472
+ /* Thicker right border on table-headers in the table body */
473
+ border-right-width:2px;
474
+ }
475
+ th:empty{
476
+ /* Hide the borders on any empty table-headers */
477
+ border:none;
478
+ }
479
+ th,td{
480
+ vertical-align:top;
481
+ padding:0.75em;
482
+ border:1px solid #ccc;
483
+ }
484
+ th{
485
+ font-weight:bold;
486
+ text-align:center
487
+ }
488
+ table [colspan]{
489
+ /* This looks lovely, trust me... */
490
+ text-align:center;
491
+ }
492
+ table [rowspan]{
493
+ /* ...as does this. */
494
+ vertical-align:middle;
495
+ }
496
+ /*
497
+ Assuming IE has an 'implied' colspan of one on cells without an explicit colspan attribute, fix/undo it.
498
+ See http://jsfiddle.net/csswizardry/UJJay/
499
+ */
500
+ [colspan="1"]{
501
+ text-align:left;
502
+ }
503
+ [rowspan="1"]{
504
+ vertical-align:top;
505
+ }
506
+ tbody tr:nth-of-type(odd){
507
+ background:rgba(0,0,0,0.05);
508
+ }
509
+ tfoot{
510
+ text-align:center;
511
+ }
512
+ tfoot td{
513
+ border-top-width:2px;
514
+ }
515
+
516
+
517
+
518
+
519
+
520
+ /*------------------------------------*\
521
+ MESSAGES
522
+ \*------------------------------------*/
523
+ /*
524
+ Unfortunately feedback messages don’t fit the baseline all too well. Perhaps in a later version...
525
+ */
526
+ .message{
527
+ font-weight:normal;
528
+ display:block;
529
+ padding:10px 10px 10px 36px;
530
+ border:1px solid #ccc;
531
+ margin:0 0 1.5em 0;
532
+
533
+ -moz-border-radius:2px;
534
+ -webkit-border-radius:2px;
535
+ border-radius:2px;
536
+ -moz-box-shadow:0 1px 0 rgba(255,255,255,0.5) inset;
537
+ -webkit-box-shadow:0 1px 0 rgba(255,255,255,0.5) inset;
538
+ box-shadow:0 1px 0 rgba(255,255,255,0.5) inset;
539
+ }
540
+ /* With multiple errors it’s nice to group them. */
541
+ ul.message{
542
+ list-style:decimal outside; /* It’s also handy to number them. However, they might not necessarily be in a particular order, so we spoof it by putting numbers on an unordered list */
543
+ padding:10px 10px 10px 56px;
544
+ }
545
+ .error{
546
+ border-color:#fb5766;
547
+ background:url(../img/css/icons/error.png) 10px center no-repeat #fab;
548
+ }
549
+ .success{
550
+ border-color:#83ba77;
551
+ background:url(../img/css/icons/success.png) 10px center no-repeat #d1feba;
552
+ }
553
+ .info{
554
+ border-color:#85a5be;
555
+ background:url(../img/css/icons/info.png) 10px center no-repeat #c4dbec;
556
+ }
557
+ .warning{
558
+ border-color:#d8d566;
559
+ background:url(../img/css/icons/warning.png) 10px center no-repeat #fef8c4;
560
+ }
561
+
562
+
563
+
564
+
565
+
566
+ /*------------------------------------*\
567
+ MISC
568
+ \*------------------------------------*/
569
+ hr{
570
+ margin:0 0 1.5em 0;
571
+ }
572
+ .accessibility{
573
+ /* Hide content off-screen without hiding from screen-readers. N.B. This is not suited to RTL languages */
574
+ position:absolute;
575
+ left:-99999px;
576
+ }
577
+ .more-link:after{
578
+ /* Too many people use &raquo; in their markup to signify progression/movement, that ain’t cool. Let’s insert that using content:""; */
579
+ content:" »";
580
+ }
581
+ .more-link::after{
582
+ content:" »";
583
+ }
584
+
585
+
586
+
587
+
588
+
589
+ /*------------------------------------*\
590
+ CLASSES
591
+ \*------------------------------------*/
592
+ /*
593
+ Some not-too-pretty and insemantic classes to do odd jobs.
594
+ */
595
+ .left { float:left!important; }
596
+ .right { float:right!important; }
597
+ .clear { clear:both; float:none; }
598
+
599
+ .text-left { text-align:left; }
600
+ .text-right { text-align:right; }
601
+ .text-center,
602
+ .text-centre { text-align:center; }
603
+
604
+
605
+
606
+
607
+
608
+ /*------------------------------------*\
609
+ DIAGNOSTICS
610
+ \*------------------------------------*/
611
+ /*
612
+ APPLY A CLASS OF .debug TO THE HTML ELEMENT ONLY WHEN YOUR SITE IS ON DEV
613
+
614
+ Turn the grids back on. Idea given by @VictorPimentel
615
+ */
616
+
617
+ .debug { background:url(../img/css/baseline.gif) 0 18px #fff!important; }
618
+
619
+ /*
620
+ Red border == something is wrong
621
+ Yellow border == something may be wrong, you should double check.
622
+ Green border == perfect, nice one!
623
+ */
624
+
625
+ /* Styles */
626
+ .debug [style]{
627
+ /* Inline styles aren’t great, can this be avoided? */
628
+ outline:5px solid yellow;
629
+ }
630
+
631
+ /* Images */
632
+ .debug img{
633
+ /* Images without alt attributes are bad! */
634
+ outline:5px solid red;
635
+ }
636
+ .debug img[alt]{
637
+ /* Images with alt attributes are good! */
638
+ outline-color:green;
639
+ }
640
+ .debug img[alt=""]{
641
+ /* Images with empty alt attributes are okay in the right circumstances. */
642
+ outline-color:yellow;
643
+ }
644
+
645
+ /* Links */
646
+ .debug a{
647
+ /* Links without titles are yellow, does your link need one? */
648
+ outline:5px solid yellow;
649
+ }
650
+ .debug a[title]{
651
+ /* Links with titles are green, title attributes can be very useful! */
652
+ outline-color:green;
653
+ }
654
+ .debug a[href="#"]{
655
+ /* Were you meant to leave that hash in there? */
656
+ outline-color:yellow;
657
+ }
658
+ .debug a[target]/*,
659
+ .debug a[onclick],
660
+ .debug a[href*=javascript]*/{
661
+ /* What were you thinking?! */
662
+ outline-color:red;
663
+ }
664
+
665
+ /* Classes/IDs */
666
+ .debug [class=""],
667
+ .debug [id=""]{
668
+ /* Is this element meant to have an empty class/ID? */
669
+ outline:5px solid yellow;
670
+ }
671
+
672
+
673
+
674
+
675
+
676
+ /*------------------------------------*\
677
+ NARROW
678
+ \*------------------------------------*/
679
+ /*
680
+ CSS for tablets and narrower devices
681
+ */
682
+
683
+
684
+
685
+
686
+
687
+ @media (min-width: 721px) and (max-width: 960px){
688
+ }
689
+ /*--- END NARROW ---*/
690
+
691
+
692
+
693
+
694
+
695
+ /*------------------------------------*\
696
+ MOBILE
697
+ \*------------------------------------*/
698
+ /*
699
+ CSS for mobile devices.
700
+ Linearise it!
701
+ */
702
+
703
+
704
+
705
+
706
+
707
+ @media (max-width: 720px){
708
+ /*------------------------------------*\
709
+ MAIN
710
+ \*------------------------------------*/
711
+ .debug,
712
+ .debug body{
713
+ background:none!important;
714
+ }
715
+ html{
716
+ font-size:1.125em;
717
+ }
718
+ body{
719
+ -webkit-text-size-adjust:none;
720
+ }
721
+ .wrapper{
722
+ width:auto!important;
723
+ padding:10px!important;
724
+ width:auto!important;
725
+ }
726
+ .grids{
727
+ margin:0!important;
728
+ width:auto!important;
729
+ }
730
+ [class^="grid-"],
731
+ .grids [class^="grid-"]{
732
+ width:auto!important;
733
+ float:none!important;
734
+ margin:0!important;
735
+ }
736
+
737
+
738
+
739
+
740
+
741
+ /*------------------------------------*\
742
+ LOGO
743
+ \*------------------------------------*/
744
+ #logo{
745
+ margin:0 auto 1.5em;
746
+ }
747
+
748
+
749
+
750
+
751
+
752
+ /*------------------------------------*\
753
+ TYPE
754
+ \*------------------------------------*/
755
+ /*--- LISTS ---*/
756
+ ul,
757
+ ol{
758
+ margin:0 0 1.5em 25px;
759
+ }
760
+ ul ul,
761
+ ol ol,
762
+ ul ol,
763
+ ol ul{
764
+ /* Let’s take care of lists in lists */
765
+ margin:0 0 0 25px;
766
+ }
767
+ dd{
768
+ margin-left:25px;
769
+ }
770
+
771
+
772
+
773
+
774
+ /*------------------------------------*\
775
+ IMAGES
776
+ \*------------------------------------*/
777
+ img.left,
778
+ img.right { max-width:50%; height:auto; }
779
+ }
780
+ /*--- END MOBILE ---*/
781
+
782
+
783
+
784
+
785
+
786
+ /*------------------------------------*\
787
+ PRINT
788
+ \*------------------------------------*/
789
+ /*
790
+ Good ol’ fashioned paper...
791
+ */
792
+
793
+
794
+
795
+
796
+
797
+ @media print{
798
+ /*------------------------------------*\
799
+ MAIN
800
+ \*------------------------------------*/
801
+ /*
802
+ Give everything some decent contrast.
803
+ */
804
+ *{
805
+ background:#fff;
806
+ color:#000;
807
+ text-shadow:none!important;
808
+ }
809
+ /*
810
+ Set a nice measure and take the font down to print-acceptable sizes.
811
+ */
812
+ body{
813
+ font-size:0.75em; /* 12px (if base font-size was 16px) */
814
+ }
815
+ .wrapper{
816
+ width:75%;
817
+ margin:0 auto;
818
+ }
819
+ /*
820
+ A list of things you don’t want printing. Add to/subtract from as necessary.
821
+ */
822
+ .nav,
823
+ #footer{
824
+ display:none;
825
+ }
826
+ #logo img{
827
+ position:static;
828
+ }
829
+ /*
830
+ Linearise
831
+ */
832
+ .grids{
833
+ width:auto;
834
+ }
835
+ [class^="grid-"]{
836
+ width:auto;
837
+ float:none;
838
+ clear:both;
839
+ }
840
+ /*
841
+ Don’t let images break anything.
842
+ */
843
+ img{
844
+ max-width:100%;
845
+ height:auto;
846
+ }
847
+ /*
848
+ Messages look odd with just borders.
849
+ */
850
+ .message{
851
+ border:none;
852
+ font-weight:bold;
853
+ }
854
+ /*
855
+ Try to avoid tables spanning multiple pages. Not failsafe, but a good start.
856
+ */
857
+ table{
858
+ page-break-before:always;
859
+ }
860
+ /*
861
+ Show the accessibility class.
862
+ */
863
+ .accessibility{
864
+ position:static;
865
+ }
866
+ /*
867
+ Display the href of any links.
868
+ */
869
+ a:link:after,a:visited:after{
870
+ content:" (" attr(href) ")";
871
+ font-size:smaller;
872
+ }
873
+ a:link::after,a:visited::after{
874
+ content:" (" attr(href) ")";
875
+ font-size:smaller;
876
+ }
877
+ /*
878
+ Any links that are root relative to your site need prepending with your URL.
879
+ */
880
+ a[href^="/"]:after{
881
+ content:" (http://yoururlhere.com" attr(href) ")";
882
+ font-size:smaller;
883
+ }
884
+ a[href^="/"]::after{
885
+ content:" (http://yoururlhere.com" attr(href) ")";
886
+ font-size:smaller;
887
+ }
888
+ /*
889
+ Any Flash/video content can’t be printed so leave a message.
890
+ */
891
+ object:after{
892
+ content:"Flash/video content. Head to http://yoururlhere.com/ to view this content.";
893
+ display:block;
894
+ font-weight:bold;
895
+ margin-bottom:1.5em;
896
+ }
897
+ object::after{
898
+ content:"Flash/video content. Head to http://yoururlhere.com/ to view this content.";
899
+ display:block;
900
+ font-weight:bold;
901
+ margin-bottom:1.5em;
902
+ }
903
+ }
904
+ /*--- END PRINT ---*/