tao_on_rails 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 228e7dfa827df0d446bedd259820d17065450fd2
4
- data.tar.gz: 67ea86aa0062a0592de2172fa20d420aaf7aad5f
3
+ metadata.gz: 723bdfc80962341e3edec02a1e904976a224c91b
4
+ data.tar.gz: 3721bd5ecea46051f3af0242d75543f6f14a7e22
5
5
  SHA512:
6
- metadata.gz: 749b87886e93f79e4dc52c6627875629d7e2435ad8b9956138bbfd432d003dabdd793001416c71086242a6f183380246e7084b29ca087097c9292c6bcfb841c3
7
- data.tar.gz: 4b9280e27eb2cd4f12bee6858a7a19fa80c0cdea7779a76fc265b80e52d2528c156fb5a56f8eaf8d99f2a2e334556748a185a0a444f4b280d11cd4e430757ae0
6
+ metadata.gz: e32ab3584038acca268311801e487c1f8478e02017aa752714afc146df51688c587deeb18f99caee457a7dda9ebb1731716de3a63ff26cf5f039eae7afc76749
7
+ data.tar.gz: 0058328d81ec7984f3f282faddd55a3725a5d0dff75989fa0da66ecbd656337fcb9aa92cd275149361f32eb306c021b9ed6e70ee9eb4c728545c53dbdbe0e3bb
data/README.md CHANGED
@@ -17,7 +17,6 @@ Several generators are available for you to quickly start your work:
17
17
  * tao:controller
18
18
  * tao:component
19
19
  * tao:locale
20
- * tao:icons
21
20
  * tao:channel
22
21
  * tao:scaffold
23
22
 
@@ -2,12 +2,22 @@
2
2
 
3
3
  class TaoApplication extends TaoModule
4
4
 
5
+ @_initializers: {}
6
+
7
+ @initializer: (name, callback) ->
8
+ @_initializers[name] = callback
9
+
10
+ @removeInitializer: (name) ->
11
+ @_initializers[name] = null
12
+
5
13
  _init: ->
6
14
  @_initGon()
7
15
  @_initI18n()
8
16
  @_initUjs()
9
17
  @_initTurbolinks()
10
18
 
19
+ callback?(@) for name, callback of @constructor._initializers
20
+
11
21
  _initGon: ->
12
22
  return unless window.gon
13
23
  $.extend @, window.gon
@@ -24,11 +34,6 @@ class TaoApplication extends TaoModule
24
34
  _initI18n: ->
25
35
  I18n.locale = @locale if window.I18n && @locale
26
36
 
27
- _initIcons: ($page) ->
28
- $icons = $page.siblings('#tao-icons')
29
- unless $icons.length > 0
30
- $page[0].insertAdjacentHTML('beforebegin', Tao.iconsHtml || '')
31
-
32
37
  _initPage: ($page) ->
33
38
  window.currentPage = @currentPage = $page[0]
34
39
 
@@ -72,7 +77,6 @@ class TaoApplication extends TaoModule
72
77
  $page = $ 'body > .tao-page'
73
78
  return unless $page.length > 0
74
79
  @_initGon()
75
- @_initIcons $page
76
80
  @_initPage $page
77
81
  @trigger 'page-load', [@currentPage]
78
82
 
@@ -3,8 +3,3 @@ Tao.helpers =
3
3
 
4
4
  reflow: (el) ->
5
5
  $(el)[0].offsetHeight
6
-
7
- icon: (name, attributes={}) ->
8
- $("<svg><use xlink:href=\"#icon-#{name}\"/></svg>")
9
- .attr attributes
10
- .addClass "icon icon-#{name}"
@@ -3,12 +3,10 @@
3
3
  #= require jquery3
4
4
  #= require jquery_ujs
5
5
  #= require lodash
6
- #= require i18n
7
6
 
8
7
  #= require_self
9
- #= require tao/application
10
- #= require tao/page
11
- #= require tao/helpers
12
- #= require tao/icons
8
+ #= require ./application
9
+ #= require ./page
10
+ #= require ./helpers
13
11
 
14
12
  window.Tao = {}
@@ -1,6 +1,3 @@
1
- //= require normalize
2
- //= require tao/icons
3
-
4
1
  .tao-page {
5
2
  display: block;
6
3
  }
@@ -3,6 +3,7 @@ module TaoOnRails
3
3
  module Helpers
4
4
 
5
5
  def page_id
6
+ return @page_id if @page_id.present?
6
7
  controller_names = controller_path.split('/')
7
8
  [controller_names, action_name].compact.flatten.join('_').dasherize
8
9
  end
@@ -1,4 +1,3 @@
1
- require 'tao_on_rails/components/icon_component'
2
1
  require 'tao_on_rails/components/page_component'
3
2
 
4
3
  module TaoOnRails
@@ -1,3 +1,3 @@
1
1
  module TaoOnRails
2
- VERSION = "0.7.3"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siyuan Liu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-31 00:00:00.000000000 Z
12
+ date: 2017-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turbolinks
@@ -142,17 +142,14 @@ files:
142
142
  - LICENSE
143
143
  - README.md
144
144
  - Rakefile
145
- - lib/assets/javascripts/i18n.js
146
- - lib/assets/javascripts/tao.coffee
147
145
  - lib/assets/javascripts/tao/application.coffee
148
146
  - lib/assets/javascripts/tao/attribute_parser.coffee
149
147
  - lib/assets/javascripts/tao/component.coffee
150
148
  - lib/assets/javascripts/tao/helpers.coffee
151
- - lib/assets/javascripts/tao/icons.coffee
149
+ - lib/assets/javascripts/tao/index.coffee
152
150
  - lib/assets/javascripts/tao/module.coffee
153
151
  - lib/assets/javascripts/tao/page.coffee
154
152
  - lib/assets/stylesheets/tao.scss
155
- - lib/assets/stylesheets/tao/icons.scss
156
153
  - lib/generators/tao/assets/USAGE
157
154
  - lib/generators/tao/assets/assets_generator.rb
158
155
  - lib/generators/tao/channel/USAGE
@@ -170,9 +167,6 @@ files:
170
167
  - lib/generators/tao/controller/USAGE
171
168
  - lib/generators/tao/controller/controller_generator.rb
172
169
  - lib/generators/tao/controller/templates/controller.rb.erb
173
- - lib/generators/tao/icons/USAGE
174
- - lib/generators/tao/icons/icons_generator.rb
175
- - lib/generators/tao/icons/templates/icons.coffee.erb
176
170
  - lib/generators/tao/locale/USAGE
177
171
  - lib/generators/tao/locale/locale_generator.rb
178
172
  - lib/generators/tao/locale/templates/model.yml.erb
@@ -194,14 +188,12 @@ files:
194
188
  - lib/tao_on_rails/action_view/helpers.rb
195
189
  - lib/tao_on_rails/components.rb
196
190
  - lib/tao_on_rails/components/base.rb
197
- - lib/tao_on_rails/components/icon_component.rb
198
191
  - lib/tao_on_rails/components/page_component.rb
199
192
  - lib/tao_on_rails/engine.rb
200
193
  - lib/tao_on_rails/version.rb
201
194
  - vendor/assets/javascripts/polyfills/custom-elements.js
202
195
  - vendor/assets/javascripts/polyfills/native-shim.coffee
203
196
  - vendor/assets/javascripts/polyfills/polyfills.coffee
204
- - vendor/assets/stylesheets/normalize.css
205
197
  homepage: https://github.com/mycolorway/tao_on_rails
206
198
  licenses:
207
199
  - MIT
@@ -1 +0,0 @@
1
- // to be generated by i18n-js gem in project
@@ -1,2 +0,0 @@
1
- # generate this file by generator:
2
- # rails g tao:icons
@@ -1,17 +0,0 @@
1
-
2
- @keyframes spin {
3
- from { transform:rotate(0deg); }
4
- to { transform:rotate(360deg); }
5
- }
6
-
7
- .icon {
8
- display: inline-block;
9
- width: 24px;
10
- height: 24px;
11
- vertical-align: middle;
12
- fill: #9b9b9b;
13
-
14
- &.spin {
15
- animation: spin 1s infinite linear;
16
- }
17
- }
@@ -1,8 +0,0 @@
1
- Description:
2
- Generate coffee file containing all svg icons.
3
-
4
- Example:
5
- `rails generate tao:icons`
6
-
7
- Create coffee file:
8
- lib/assets/javascripts/tao/icons.coffee
@@ -1,45 +0,0 @@
1
- module Tao
2
- module Generators
3
- class IconsGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- class_option :svg_path, type: :string, default: 'app/assets/icons', desc: "Directory path containing svg source files."
7
-
8
- attr_reader :icons_html
9
-
10
- def create_icons_file
11
- @icons_html = svg_files.map {|file| " #{symbol(file)}\n"}.join
12
- template 'icons.coffee.erb', 'lib/assets/javascripts/tao/icons.coffee'
13
- end
14
-
15
- private
16
-
17
- def svg_files
18
- Dir.glob(File.expand_path(File.join(options[:svg_path], '*.svg'), destination_root)).uniq
19
- end
20
-
21
- def symbol(path)
22
- name = File.basename(path, ".*").underscore().dasherize()
23
- document = Nokogiri::XML(File.read(path))
24
- document.css('[id="Main"], [id="Main"] [fill], [fill="none"]').each {|n| n.delete 'fill' }
25
- content = document.to_s
26
- content.gsub(/<?.+\?>/,'')
27
- .gsub(/<!.+?>/,'')
28
- .gsub(/<title>.*<\/title>/, '')
29
- .gsub(/<desc>.*<\/desc>/, '')
30
- .gsub(/id=/,'class=')
31
- .gsub(/<svg.+?>/, %Q{<svg id="icon-#{name}" #{dimensions(content)}>})
32
- .gsub(/svg/,'symbol')
33
- .gsub(/\n/, '') # Remove endlines
34
- .gsub(/\s{2,}/, ' ') # Remove whitespace
35
- .gsub(/>\s+</, '><') # Remove whitespace between tags
36
- end
37
-
38
- def dimensions(content)
39
- dimension = content.scan(/<svg.+(viewBox=["'](.+?)["'])/).flatten
40
- %Q{#{dimension.first} width="100%" height="100%"}
41
- end
42
-
43
- end
44
- end
45
- end
@@ -1,5 +0,0 @@
1
- Tao.iconsHtml = '''
2
- <svg id="tao-icons" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none">
3
- <%= icons_html %>
4
- </svg>
5
- '''
@@ -1,31 +0,0 @@
1
- require 'tao_on_rails/components/base'
2
-
3
- module TaoOnRails
4
- module Components
5
- class IconComponent < Base
6
-
7
- attr_reader :name
8
-
9
- def initialize view, name, options = {}
10
- super view, options
11
-
12
- @name = name
13
-
14
- if @options[:class].present?
15
- @options[:class] += " icon icon-#{name}"
16
- else
17
- @options[:class] = "icon icon-#{name}"
18
- end
19
- end
20
-
21
- def render
22
- view.content_tag(:svg, %Q(<use xlink:href="#icon-#{name}"/>).html_safe, options)
23
- end
24
-
25
- def self.component_name
26
- :icon
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,461 +0,0 @@
1
- /*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
2
-
3
- /* Document
4
- ========================================================================== */
5
-
6
- /**
7
- * 1. Change the default font family in all browsers (opinionated).
8
- * 2. Correct the line height in all browsers.
9
- * 3. Prevent adjustments of font size after orientation changes in
10
- * IE on Windows Phone and in iOS.
11
- */
12
-
13
- html {
14
- font-family: sans-serif; /* 1 */
15
- line-height: 1.15; /* 2 */
16
- -ms-text-size-adjust: 100%; /* 3 */
17
- -webkit-text-size-adjust: 100%; /* 3 */
18
- }
19
-
20
- /* Sections
21
- ========================================================================== */
22
-
23
- /**
24
- * Remove the margin in all browsers (opinionated).
25
- */
26
-
27
- body {
28
- margin: 0;
29
- }
30
-
31
- /**
32
- * Add the correct display in IE 9-.
33
- */
34
-
35
- article,
36
- aside,
37
- footer,
38
- header,
39
- nav,
40
- section {
41
- display: block;
42
- }
43
-
44
- /**
45
- * Correct the font size and margin on `h1` elements within `section` and
46
- * `article` contexts in Chrome, Firefox, and Safari.
47
- */
48
-
49
- h1 {
50
- font-size: 2em;
51
- margin: 0.67em 0;
52
- }
53
-
54
- /* Grouping content
55
- ========================================================================== */
56
-
57
- /**
58
- * Add the correct display in IE 9-.
59
- * 1. Add the correct display in IE.
60
- */
61
-
62
- figcaption,
63
- figure,
64
- main { /* 1 */
65
- display: block;
66
- }
67
-
68
- /**
69
- * Add the correct margin in IE 8.
70
- */
71
-
72
- figure {
73
- margin: 1em 40px;
74
- }
75
-
76
- /**
77
- * 1. Add the correct box sizing in Firefox.
78
- * 2. Show the overflow in Edge and IE.
79
- */
80
-
81
- hr {
82
- box-sizing: content-box; /* 1 */
83
- height: 0; /* 1 */
84
- overflow: visible; /* 2 */
85
- }
86
-
87
- /**
88
- * 1. Correct the inheritance and scaling of font size in all browsers.
89
- * 2. Correct the odd `em` font sizing in all browsers.
90
- */
91
-
92
- pre {
93
- font-family: monospace, monospace; /* 1 */
94
- font-size: 1em; /* 2 */
95
- }
96
-
97
- /* Text-level semantics
98
- ========================================================================== */
99
-
100
- /**
101
- * 1. Remove the gray background on active links in IE 10.
102
- * 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
103
- */
104
-
105
- a {
106
- background-color: transparent; /* 1 */
107
- -webkit-text-decoration-skip: objects; /* 2 */
108
- }
109
-
110
- /**
111
- * Remove the outline on focused links when they are also active or hovered
112
- * in all browsers (opinionated).
113
- */
114
-
115
- a:active,
116
- a:hover {
117
- outline-width: 0;
118
- }
119
-
120
- /**
121
- * 1. Remove the bottom border in Firefox 39-.
122
- * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
123
- */
124
-
125
- abbr[title] {
126
- border-bottom: none; /* 1 */
127
- text-decoration: underline; /* 2 */
128
- text-decoration: underline dotted; /* 2 */
129
- }
130
-
131
- /**
132
- * Prevent the duplicate application of `bolder` by the next rule in Safari 6.
133
- */
134
-
135
- b,
136
- strong {
137
- font-weight: inherit;
138
- }
139
-
140
- /**
141
- * Add the correct font weight in Chrome, Edge, and Safari.
142
- */
143
-
144
- b,
145
- strong {
146
- font-weight: bolder;
147
- }
148
-
149
- /**
150
- * 1. Correct the inheritance and scaling of font size in all browsers.
151
- * 2. Correct the odd `em` font sizing in all browsers.
152
- */
153
-
154
- code,
155
- kbd,
156
- samp {
157
- font-family: monospace, monospace; /* 1 */
158
- font-size: 1em; /* 2 */
159
- }
160
-
161
- /**
162
- * Add the correct font style in Android 4.3-.
163
- */
164
-
165
- dfn {
166
- font-style: italic;
167
- }
168
-
169
- /**
170
- * Add the correct background and color in IE 9-.
171
- */
172
-
173
- mark {
174
- background-color: #ff0;
175
- color: #000;
176
- }
177
-
178
- /**
179
- * Add the correct font size in all browsers.
180
- */
181
-
182
- small {
183
- font-size: 80%;
184
- }
185
-
186
- /**
187
- * Prevent `sub` and `sup` elements from affecting the line height in
188
- * all browsers.
189
- */
190
-
191
- sub,
192
- sup {
193
- font-size: 75%;
194
- line-height: 0;
195
- position: relative;
196
- vertical-align: baseline;
197
- }
198
-
199
- sub {
200
- bottom: -0.25em;
201
- }
202
-
203
- sup {
204
- top: -0.5em;
205
- }
206
-
207
- /* Embedded content
208
- ========================================================================== */
209
-
210
- /**
211
- * Add the correct display in IE 9-.
212
- */
213
-
214
- audio,
215
- video {
216
- display: inline-block;
217
- }
218
-
219
- /**
220
- * Add the correct display in iOS 4-7.
221
- */
222
-
223
- audio:not([controls]) {
224
- display: none;
225
- height: 0;
226
- }
227
-
228
- /**
229
- * Remove the border on images inside links in IE 10-.
230
- */
231
-
232
- img {
233
- border-style: none;
234
- }
235
-
236
- /**
237
- * Hide the overflow in IE.
238
- */
239
-
240
- svg:not(:root) {
241
- overflow: hidden;
242
- }
243
-
244
- /* Forms
245
- ========================================================================== */
246
-
247
- /**
248
- * 1. Change the font styles in all browsers (opinionated).
249
- * 2. Remove the margin in Firefox and Safari.
250
- */
251
-
252
- button,
253
- input,
254
- optgroup,
255
- select,
256
- textarea {
257
- font-family: sans-serif; /* 1 */
258
- font-size: 100%; /* 1 */
259
- line-height: 1.15; /* 1 */
260
- margin: 0; /* 2 */
261
- }
262
-
263
- /**
264
- * Show the overflow in IE.
265
- * 1. Show the overflow in Edge.
266
- */
267
-
268
- button,
269
- input { /* 1 */
270
- overflow: visible;
271
- }
272
-
273
- /**
274
- * Remove the inheritance of text transform in Edge, Firefox, and IE.
275
- * 1. Remove the inheritance of text transform in Firefox.
276
- */
277
-
278
- button,
279
- select { /* 1 */
280
- text-transform: none;
281
- }
282
-
283
- /**
284
- * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
285
- * controls in Android 4.
286
- * 2. Correct the inability to style clickable types in iOS and Safari.
287
- */
288
-
289
- button,
290
- html [type="button"], /* 1 */
291
- [type="reset"],
292
- [type="submit"] {
293
- -webkit-appearance: button; /* 2 */
294
- }
295
-
296
- /**
297
- * Remove the inner border and padding in Firefox.
298
- */
299
-
300
- button::-moz-focus-inner,
301
- [type="button"]::-moz-focus-inner,
302
- [type="reset"]::-moz-focus-inner,
303
- [type="submit"]::-moz-focus-inner {
304
- border-style: none;
305
- padding: 0;
306
- }
307
-
308
- /**
309
- * Restore the focus styles unset by the previous rule.
310
- */
311
-
312
- button:-moz-focusring,
313
- [type="button"]:-moz-focusring,
314
- [type="reset"]:-moz-focusring,
315
- [type="submit"]:-moz-focusring {
316
- outline: 1px dotted ButtonText;
317
- }
318
-
319
- /**
320
- * Change the border, margin, and padding in all browsers (opinionated).
321
- */
322
-
323
- fieldset {
324
- border: 1px solid #c0c0c0;
325
- margin: 0 2px;
326
- padding: 0.35em 0.625em 0.75em;
327
- }
328
-
329
- /**
330
- * 1. Correct the text wrapping in Edge and IE.
331
- * 2. Correct the color inheritance from `fieldset` elements in IE.
332
- * 3. Remove the padding so developers are not caught out when they zero out
333
- * `fieldset` elements in all browsers.
334
- */
335
-
336
- legend {
337
- box-sizing: border-box; /* 1 */
338
- color: inherit; /* 2 */
339
- display: table; /* 1 */
340
- max-width: 100%; /* 1 */
341
- padding: 0; /* 3 */
342
- white-space: normal; /* 1 */
343
- }
344
-
345
- /**
346
- * 1. Add the correct display in IE 9-.
347
- * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
348
- */
349
-
350
- progress {
351
- display: inline-block; /* 1 */
352
- vertical-align: baseline; /* 2 */
353
- }
354
-
355
- /**
356
- * Remove the default vertical scrollbar in IE.
357
- */
358
-
359
- textarea {
360
- overflow: auto;
361
- }
362
-
363
- /**
364
- * 1. Add the correct box sizing in IE 10-.
365
- * 2. Remove the padding in IE 10-.
366
- */
367
-
368
- [type="checkbox"],
369
- [type="radio"] {
370
- box-sizing: border-box; /* 1 */
371
- padding: 0; /* 2 */
372
- }
373
-
374
- /**
375
- * Correct the cursor style of increment and decrement buttons in Chrome.
376
- */
377
-
378
- [type="number"]::-webkit-inner-spin-button,
379
- [type="number"]::-webkit-outer-spin-button {
380
- height: auto;
381
- }
382
-
383
- /**
384
- * 1. Correct the odd appearance in Chrome and Safari.
385
- * 2. Correct the outline style in Safari.
386
- */
387
-
388
- [type="search"] {
389
- -webkit-appearance: textfield; /* 1 */
390
- outline-offset: -2px; /* 2 */
391
- }
392
-
393
- /**
394
- * Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
395
- */
396
-
397
- [type="search"]::-webkit-search-cancel-button,
398
- [type="search"]::-webkit-search-decoration {
399
- -webkit-appearance: none;
400
- }
401
-
402
- /**
403
- * 1. Correct the inability to style clickable types in iOS and Safari.
404
- * 2. Change font properties to `inherit` in Safari.
405
- */
406
-
407
- ::-webkit-file-upload-button {
408
- -webkit-appearance: button; /* 1 */
409
- font: inherit; /* 2 */
410
- }
411
-
412
- /* Interactive
413
- ========================================================================== */
414
-
415
- /*
416
- * Add the correct display in IE 9-.
417
- * 1. Add the correct display in Edge, IE, and Firefox.
418
- */
419
-
420
- details, /* 1 */
421
- menu {
422
- display: block;
423
- }
424
-
425
- /*
426
- * Add the correct display in all browsers.
427
- */
428
-
429
- summary {
430
- display: list-item;
431
- }
432
-
433
- /* Scripting
434
- ========================================================================== */
435
-
436
- /**
437
- * Add the correct display in IE 9-.
438
- */
439
-
440
- canvas {
441
- display: inline-block;
442
- }
443
-
444
- /**
445
- * Add the correct display in IE.
446
- */
447
-
448
- template {
449
- display: none;
450
- }
451
-
452
- /* Hidden
453
- ========================================================================== */
454
-
455
- /**
456
- * Add the correct display in IE 10-.
457
- */
458
-
459
- [hidden] {
460
- display: none;
461
- }