tao_on_rails 0.6.13 → 0.7.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.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/assets/javascripts/tao/component.coffee +7 -3
- data/lib/generators/tao/component/USAGE +10 -0
- data/lib/generators/tao/component/component_generator.rb +20 -0
- data/lib/generators/tao/component/templates/component.coffee.erb +5 -0
- data/lib/generators/tao/component/templates/component.rb.erb +3 -0
- data/lib/generators/tao/component/templates/component.scss.erb +3 -0
- data/lib/generators/tao/icons/icons_generator.rb +3 -2
- data/lib/generators/tao/sass/templates/sass.erb +2 -2
- data/lib/tao_on_rails/action_view/helpers.rb +14 -24
- data/lib/tao_on_rails/components/base.rb +41 -0
- data/lib/tao_on_rails/components/icon_component.rb +31 -0
- data/lib/tao_on_rails/components/page_component.rb +29 -0
- data/lib/tao_on_rails/components.rb +7 -0
- data/lib/tao_on_rails/engine.rb +3 -1
- data/lib/tao_on_rails/version.rb +1 -1
- metadata +25 -21
- data/lib/templates/app/app_template.rb +0 -60
- data/lib/templates/app/templates/app/assets/javascripts/application.coffee +0 -12
- data/lib/templates/app/templates/app/assets/javascripts/home/index_page.coffee +0 -14
- data/lib/templates/app/templates/app/assets/stylesheets/application.scss +0 -10
- data/lib/templates/app/templates/app/assets/stylesheets/home/index_page.scss +0 -3
- data/lib/templates/app/templates/app/controllers/home_controller.rb +0 -2
- data/lib/templates/app/templates/app/helpers/application_helper.rb +0 -8
- data/lib/templates/app/templates/app/views/home/index.html.erb +0 -1
- data/lib/templates/app/templates/app/views/layouts/application.html.erb +0 -22
- data/lib/templates/plugin/plugin_template.rb +0 -67
- data/lib/templates/plugin/templates/Rakefile +0 -10
- data/lib/templates/plugin/templates/index.html +0 -29
- data/lib/templates/plugin/templates/lib/assets/javascripts/plugin_name.coffee +0 -14
- data/lib/templates/plugin/templates/lib/assets/stylesheets/plugin_name.scss +0 -4
- data/lib/templates/plugin/templates/lib/plugin_name/engine.rb +0 -7
- data/lib/templates/plugin/templates/plugin_name.gemspec +0 -23
- data/lib/templates/plugin/templates/test/javascripts/plugin_name_test.coffee +0 -21
- data/lib/templates/plugin/templates/test/plugin_name_test.rb +0 -13
- data/lib/templates/plugin/templates/test/test_helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 130e2b4ff4f8a942bd21ed9f730890b5cceae063
|
4
|
+
data.tar.gz: 56bcfaaf1f2ea39abede5493a79c14f6aa9e4e87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdb3fead11748e863da712cde44a0de990479e2aef83bec1a241a3f48d24c337df4ea5bdb50dd369993715a692b0ebd882c008c217b92b3a0f2f96b58d76c1bb
|
7
|
+
data.tar.gz: 31435d53c65786d178ca7670acf13e5738eb9cfa52214434a2c58c4ac766f7fd1ebb5b9e69e4f8de5614ee6d2acc81bfc5f28dd5651e1d48ce666a42ef0a98b6
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
Create new Tao on Rails application with following commands:
|
8
8
|
|
9
9
|
```bash
|
10
|
-
rails new app_name -m https://git.io/
|
10
|
+
rails new app_name -m https://git.io/vSvyw
|
11
11
|
```
|
12
12
|
|
13
13
|
Several generators are available for you to quickly start your work:
|
@@ -15,19 +15,20 @@ Several generators are available for you to quickly start your work:
|
|
15
15
|
* tao:assets
|
16
16
|
* tao:view
|
17
17
|
* tao:controller
|
18
|
+
* tao:component
|
18
19
|
* tao:locale
|
19
20
|
* tao:icons
|
20
21
|
* tao:channel
|
21
22
|
* tao:scaffold
|
22
23
|
|
23
|
-
|
24
|
+
See `rails g tao:xxx --help` for more information.
|
24
25
|
|
25
26
|
## Plugin
|
26
27
|
|
27
28
|
Start writing plugin for Tao on Rails with following commands:
|
28
29
|
|
29
30
|
```bash
|
30
|
-
rails plugin new plugin_name -m https://git.io/
|
31
|
+
rails plugin new plugin_name -m https://git.io/vSvyy
|
31
32
|
```
|
32
33
|
|
33
34
|
## Contributing
|
@@ -79,11 +79,15 @@ TaoComponentBasedOn = (superClassName = 'HTMLElement') ->
|
|
79
79
|
|
80
80
|
@observedAttributes.push(attrName) if options.observe
|
81
81
|
|
82
|
-
@
|
82
|
+
@_tag: 'tao-component'
|
83
|
+
|
84
|
+
@tag: (tag) ->
|
85
|
+
@_tag = tag unless _.isUndefined tag
|
86
|
+
@_tag
|
83
87
|
|
84
88
|
@register: (componentClass) ->
|
85
|
-
return unless componentClass.tag && window.customElements
|
86
|
-
customElements.define componentClass.tag, componentClass
|
89
|
+
return unless componentClass.tag() && window.customElements
|
90
|
+
customElements.define componentClass.tag(), componentClass
|
87
91
|
|
88
92
|
@observedAttributes: []
|
89
93
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
Generate controller files
|
3
|
+
|
4
|
+
Example:
|
5
|
+
`rails generate tao:component posts/autosave`
|
6
|
+
|
7
|
+
Create file:
|
8
|
+
app/components/posts/autosave_component.rb
|
9
|
+
app/assets/javascripts/posts/components/autosave.coffee
|
10
|
+
app/assets/stylesheets/posts/components/autosave.scss
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tao
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class ComponentGenerator < Rails::Generators::NamedBase
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
check_class_collision suffix: "Component"
|
8
|
+
|
9
|
+
attr_reader :component_name
|
10
|
+
|
11
|
+
def create_component_file
|
12
|
+
@component_name = class_name.underscore.split('/').map(&:singularize).join('_')
|
13
|
+
template "component.rb.erb", File.join('app/components', class_path, "#{file_name}_component.rb")
|
14
|
+
template "component.coffee.erb", File.join('app/assets/javascripts/', class_path, "components/#{file_name}.coffee")
|
15
|
+
template "component.scss.erb", File.join('app/assets/stylesheets/', class_path, "components/#{file_name}.scss")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -20,7 +20,9 @@ module Tao
|
|
20
20
|
|
21
21
|
def symbol(path)
|
22
22
|
name = File.basename(path, ".*").underscore().dasherize()
|
23
|
-
|
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
|
24
26
|
content.gsub(/<?.+\?>/,'')
|
25
27
|
.gsub(/<!.+?>/,'')
|
26
28
|
.gsub(/<title>.*<\/title>/, '')
|
@@ -28,7 +30,6 @@ module Tao
|
|
28
30
|
.gsub(/id=/,'class=')
|
29
31
|
.gsub(/<svg.+?>/, %Q{<svg id="icon-#{name}" #{dimensions(content)}>})
|
30
32
|
.gsub(/svg/,'symbol')
|
31
|
-
.gsub(/\sfill=".+?"/,'')
|
32
33
|
.gsub(/\n/, '') # Remove endlines
|
33
34
|
.gsub(/\s{2,}/, ' ') # Remove whitespace
|
34
35
|
.gsub(/>\s+</, '><') # Remove whitespace between tags
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.<%= page_id.dasherize %>-page {
|
2
|
+
|
3
3
|
}
|
@@ -2,38 +2,28 @@ module TaoOnRails
|
|
2
2
|
module ActionView
|
3
3
|
module Helpers
|
4
4
|
|
5
|
-
include ::ActionView::Helpers
|
6
|
-
include ::ActionView::Context
|
7
|
-
|
8
5
|
def page_id
|
9
6
|
controller_names = controller_path.split('/')
|
10
7
|
[controller_names, action_name].compact.flatten.join('-')
|
11
8
|
end
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
content_tag(:svg, use_tag, attributes).html_safe
|
22
|
-
end
|
23
|
-
|
24
|
-
def tao_page(tag, attributes = nil, &block)
|
25
|
-
if tag.is_a? Hash
|
26
|
-
attributes = tag
|
27
|
-
tag = "#{page_id.dasherize}-page"
|
10
|
+
# Define the dynamic view helpers for components
|
11
|
+
# This method should be called in action_view context
|
12
|
+
def self.define_component_helpers
|
13
|
+
Dir.glob([
|
14
|
+
Rails.root.join('lib/components/**/*.rb'),
|
15
|
+
Rails.root.join('app/components/**/*.rb')
|
16
|
+
]).each do |component|
|
17
|
+
require component
|
28
18
|
end
|
29
19
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
20
|
+
TaoOnRails::Components::Base.descendants.each do |klass|
|
21
|
+
module_eval %Q{
|
22
|
+
def #{klass.tag_name.underscore} *args, &block
|
23
|
+
#{klass.name}.new(self, *args).render(&block)
|
24
|
+
end
|
25
|
+
}
|
34
26
|
end
|
35
|
-
|
36
|
-
content_tag(tag, capture(&block), attributes)
|
37
27
|
end
|
38
28
|
|
39
29
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module TaoOnRails
|
2
|
+
module Components
|
3
|
+
class Base
|
4
|
+
|
5
|
+
attr_reader :options, :template_path, :view
|
6
|
+
|
7
|
+
def initialize view, options = {}
|
8
|
+
@view = view
|
9
|
+
@options = options
|
10
|
+
@template_path = @options.delete(:template_path) || self.class.template_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def render &block
|
14
|
+
if view.lookup_context.exists?(template_path, [], true)
|
15
|
+
view.render layout: template_path, locals: {component: self}, &block
|
16
|
+
else
|
17
|
+
view.content_tag self.class.tag_name, options, &block
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.tag_name
|
22
|
+
@tag_name ||= "#{self.tag_prefix}-#{self.component_name.to_s.dasherize}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.component_name
|
26
|
+
@component_name ||= self.name.underscore.split('/').map(&:singularize).join('_')
|
27
|
+
.gsub(/(.+)_component$/, '\1')
|
28
|
+
.gsub(/^#{Regexp.quote(self.tag_prefix.to_s.underscore)}_(.+)/, '\1')
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.tag_prefix
|
32
|
+
:tao
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.template_path
|
36
|
+
@template_path ||= "components/#{self.name.underscore}"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'tao_on_rails/components/base'
|
2
|
+
|
3
|
+
module TaoOnRails
|
4
|
+
module Components
|
5
|
+
class PageComponent < Base
|
6
|
+
|
7
|
+
def initialize view, options = {}
|
8
|
+
super
|
9
|
+
|
10
|
+
@page_id = view.page_id
|
11
|
+
|
12
|
+
if @options[:class].present?
|
13
|
+
@options[:class] += " tao-page #{@page_id}-page"
|
14
|
+
else
|
15
|
+
@options[:class] = "tao-page #{@page_id}-page"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def render &block
|
20
|
+
view.content_tag "#{view.page_id}-page", options, &block
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.component_name
|
24
|
+
:page
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/tao_on_rails/engine.rb
CHANGED
@@ -2,12 +2,14 @@ require 'turbolinks'
|
|
2
2
|
require 'jquery-rails'
|
3
3
|
require 'lodash-rails'
|
4
4
|
require 'tao_on_rails/action_view/helpers'
|
5
|
+
require 'tao_on_rails/components'
|
5
6
|
|
6
7
|
module TaoOnRails
|
7
8
|
class Engine < Rails::Engine
|
8
9
|
|
9
10
|
initializer "tao_on_rails.view_helpers" do |app|
|
10
|
-
ActiveSupport.on_load :action_view do
|
11
|
+
::ActiveSupport.on_load :action_view do
|
12
|
+
TaoOnRails::ActionView::Helpers.define_component_helpers
|
11
13
|
include TaoOnRails::ActionView::Helpers
|
12
14
|
end
|
13
15
|
end
|
data/lib/tao_on_rails/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.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-
|
12
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: turbolinks
|
@@ -115,6 +115,20 @@ dependencies:
|
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 0.6.2
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
name: nokogiri
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.7'
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.7'
|
118
132
|
description: Ruby on Rails lacks a recommended way to structure your frontend code
|
119
133
|
for many years. Tao on Rails is the framework to fill the gap which will modularize
|
120
134
|
your page with the new Custom Elements v1 API.
|
@@ -148,6 +162,11 @@ files:
|
|
148
162
|
- lib/generators/tao/coffee/USAGE
|
149
163
|
- lib/generators/tao/coffee/coffee_generator.rb
|
150
164
|
- lib/generators/tao/coffee/templates/coffee.erb
|
165
|
+
- lib/generators/tao/component/USAGE
|
166
|
+
- lib/generators/tao/component/component_generator.rb
|
167
|
+
- lib/generators/tao/component/templates/component.coffee.erb
|
168
|
+
- lib/generators/tao/component/templates/component.rb.erb
|
169
|
+
- lib/generators/tao/component/templates/component.scss.erb
|
151
170
|
- lib/generators/tao/controller/USAGE
|
152
171
|
- lib/generators/tao/controller/controller_generator.rb
|
153
172
|
- lib/generators/tao/controller/templates/controller.rb.erb
|
@@ -173,27 +192,12 @@ files:
|
|
173
192
|
- lib/generators/tao/view/view_generator.rb
|
174
193
|
- lib/tao_on_rails.rb
|
175
194
|
- lib/tao_on_rails/action_view/helpers.rb
|
195
|
+
- lib/tao_on_rails/components.rb
|
196
|
+
- lib/tao_on_rails/components/base.rb
|
197
|
+
- lib/tao_on_rails/components/icon_component.rb
|
198
|
+
- lib/tao_on_rails/components/page_component.rb
|
176
199
|
- lib/tao_on_rails/engine.rb
|
177
200
|
- lib/tao_on_rails/version.rb
|
178
|
-
- lib/templates/app/app_template.rb
|
179
|
-
- lib/templates/app/templates/app/assets/javascripts/application.coffee
|
180
|
-
- lib/templates/app/templates/app/assets/javascripts/home/index_page.coffee
|
181
|
-
- lib/templates/app/templates/app/assets/stylesheets/application.scss
|
182
|
-
- lib/templates/app/templates/app/assets/stylesheets/home/index_page.scss
|
183
|
-
- lib/templates/app/templates/app/controllers/home_controller.rb
|
184
|
-
- lib/templates/app/templates/app/helpers/application_helper.rb
|
185
|
-
- lib/templates/app/templates/app/views/home/index.html.erb
|
186
|
-
- lib/templates/app/templates/app/views/layouts/application.html.erb
|
187
|
-
- lib/templates/plugin/plugin_template.rb
|
188
|
-
- lib/templates/plugin/templates/Rakefile
|
189
|
-
- lib/templates/plugin/templates/index.html
|
190
|
-
- lib/templates/plugin/templates/lib/assets/javascripts/plugin_name.coffee
|
191
|
-
- lib/templates/plugin/templates/lib/assets/stylesheets/plugin_name.scss
|
192
|
-
- lib/templates/plugin/templates/lib/plugin_name/engine.rb
|
193
|
-
- lib/templates/plugin/templates/plugin_name.gemspec
|
194
|
-
- lib/templates/plugin/templates/test/javascripts/plugin_name_test.coffee
|
195
|
-
- lib/templates/plugin/templates/test/plugin_name_test.rb
|
196
|
-
- lib/templates/plugin/templates/test/test_helper.rb
|
197
201
|
- vendor/assets/javascripts/polyfills/custom-elements.js
|
198
202
|
- vendor/assets/javascripts/polyfills/native-shim.coffee
|
199
203
|
- vendor/assets/javascripts/polyfills/polyfills.coffee
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require "shellwords"
|
2
|
-
|
3
|
-
def apply_template!
|
4
|
-
assert_rails_version
|
5
|
-
assert_options
|
6
|
-
add_template_dir_to_source_paths
|
7
|
-
|
8
|
-
gem 'tao_on_rails', github: 'mycolorway/tao_on_rails', branch: 'refactor-structure'
|
9
|
-
|
10
|
-
remove_file 'app/assets/javascripts/cable.js'
|
11
|
-
remove_file 'app/assets/javascripts/application.js'
|
12
|
-
remove_file 'app/assets/stylesheets/application.css'
|
13
|
-
|
14
|
-
template 'app/assets/javascripts/application.coffee'
|
15
|
-
template 'app/assets/stylesheets/application.scss'
|
16
|
-
template 'app/assets/javascripts/home/index_page.coffee'
|
17
|
-
template 'app/assets/stylesheets/home/index_page.scss'
|
18
|
-
|
19
|
-
template 'app/views/layouts/application.html.erb', force: true
|
20
|
-
template 'app/helpers/application_helper.rb', force: true
|
21
|
-
template 'app/views/home/index.html.erb'
|
22
|
-
|
23
|
-
template 'app/controllers/home_controller.rb'
|
24
|
-
route "root to: 'home#index'"
|
25
|
-
end
|
26
|
-
|
27
|
-
def assert_rails_version
|
28
|
-
requirement = Gem::Requirement.new('~> 5.0.0')
|
29
|
-
rails_version = Gem::Version.new(Rails::VERSION::STRING)
|
30
|
-
return if requirement.satisfied_by?(rails_version)
|
31
|
-
fail Rails::Generators::Error, 'Rails #{RAILS_REQUIREMENT} is required'
|
32
|
-
end
|
33
|
-
|
34
|
-
def assert_options
|
35
|
-
valid_options = {
|
36
|
-
:skip_gemfile => false,
|
37
|
-
:skip_bundle => false
|
38
|
-
}
|
39
|
-
valid_options.each do |key, expected|
|
40
|
-
next unless options.key?(key)
|
41
|
-
actual = options[key]
|
42
|
-
if actual != expected
|
43
|
-
fail Rails::Generators::Error, "Unsupported option: #{key}=#{actual}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_template_dir_to_source_paths
|
49
|
-
if __FILE__ =~ %r{\Ahttps?://}
|
50
|
-
tmp_dir = Dir.mktmpdir('_tao_template')
|
51
|
-
at_exit { remove_dir tmp_dir }
|
52
|
-
repo_url = 'https://github.com/mycolorway/tao_on_rails.git'
|
53
|
-
git :clone => "--quiet --depth 1 #{repo_url} #{tmp_dir}".shellescape
|
54
|
-
source_paths.unshift File.expand_path('lib/templates/app/templates', tmp_dir)
|
55
|
-
else
|
56
|
-
source_paths.unshift(File.expand_path('../templates', __FILE__))
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
apply_template!
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class HomeIndexPage extends TaoPage
|
2
|
-
|
3
|
-
@tag: 'home-index-page'
|
4
|
-
|
5
|
-
_init: ->
|
6
|
-
# called when the page connected to dom for the first time
|
7
|
-
|
8
|
-
_connected: ->
|
9
|
-
# called every time the page connected to dom
|
10
|
-
|
11
|
-
_disconnected: ->
|
12
|
-
# called every time the page disconnected from dom
|
13
|
-
|
14
|
-
TaoPage.register HomeIndexPage
|
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Tao on Rails</h1>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="renderer" content="webkit">
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
7
|
-
<title><%%= content_for(:title) || 'Using Tao on Rails' %></title>
|
8
|
-
<%%= csrf_meta_tags %>
|
9
|
-
|
10
|
-
<%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
11
|
-
<%%= content_for(:stylesheet) %>
|
12
|
-
|
13
|
-
<%%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
14
|
-
<%%= content_for(:javascript) %>
|
15
|
-
</head>
|
16
|
-
|
17
|
-
<body>
|
18
|
-
<<%%= page_id %>-page>
|
19
|
-
<%%= yield %>
|
20
|
-
</<%%= page_id %>-page>
|
21
|
-
</body>
|
22
|
-
</html>
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require "shellwords"
|
3
|
-
|
4
|
-
def apply_template!
|
5
|
-
assert_rails_version
|
6
|
-
assert_options
|
7
|
-
add_template_dir_to_source_paths
|
8
|
-
|
9
|
-
plugin_name = name.underscore
|
10
|
-
|
11
|
-
remove_dir 'bin'
|
12
|
-
remove_dir 'lib/tasks'
|
13
|
-
template 'lib/plugin_name/engine.rb', "lib/#{plugin_name}/engine.rb"
|
14
|
-
|
15
|
-
template 'lib/assets/javascripts/plugin_name.coffee', "lib/assets/javascripts/#{plugin_name}.coffee"
|
16
|
-
template 'lib/assets/stylesheets/plugin_name.scss', "lib/assets/stylesheets/#{plugin_name}.scss"
|
17
|
-
|
18
|
-
template 'test/plugin_name_test.rb', "test/#{plugin_name}_test.rb", force: true
|
19
|
-
template 'test/test_helper.rb', force: true
|
20
|
-
template 'test/javascripts/plugin_name_test.coffee', "test/javascripts/#{plugin_name}_test.coffee"
|
21
|
-
|
22
|
-
template '.blade.yml'
|
23
|
-
template '.gitignore', force: true
|
24
|
-
template '.travis.yml'
|
25
|
-
template 'index.html'
|
26
|
-
template 'Rakefile', force: true
|
27
|
-
template 'plugin_name.gemspec', "#{plugin_name}.gemspec", force: true
|
28
|
-
|
29
|
-
inside do
|
30
|
-
FileUtils.mv 'MIT-LICENSE', 'LICENSE'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def assert_rails_version
|
35
|
-
requirement = Gem::Requirement.new('~> 5.0.0')
|
36
|
-
rails_version = Gem::Version.new(Rails::VERSION::STRING)
|
37
|
-
return if requirement.satisfied_by?(rails_version)
|
38
|
-
fail Rails::Generators::Error, 'Rails #{RAILS_REQUIREMENT} is required'
|
39
|
-
end
|
40
|
-
|
41
|
-
def assert_options
|
42
|
-
valid_options = {
|
43
|
-
:skip_gemfile => false,
|
44
|
-
:skip_bundle => false
|
45
|
-
}
|
46
|
-
valid_options.each do |key, expected|
|
47
|
-
next unless options.key?(key)
|
48
|
-
actual = options[key]
|
49
|
-
if actual != expected
|
50
|
-
fail Rails::Generators::Error, "Unsupported option: #{key}=#{actual}"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def add_template_dir_to_source_paths
|
56
|
-
if __FILE__ =~ %r{\Ahttps?://}
|
57
|
-
tmp_dir = Dir.mktmpdir('_tao_template')
|
58
|
-
at_exit { remove_dir tmp_dir }
|
59
|
-
repo_url = 'https://github.com/mycolorway/tao_on_rails.git'
|
60
|
-
git :clone => "--quiet --depth 1 #{repo_url} #{tmp_dir}".shellescape
|
61
|
-
source_paths.unshift File.expand_path('lib/templates/app/templates', tmp_dir)
|
62
|
-
else
|
63
|
-
source_paths.unshift(File.expand_path('../templates', __FILE__))
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
apply_template!
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title><%= name.camelize %></title>
|
5
|
-
<meta charset="utf-8">
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
-
|
8
|
-
<link media="all" rel="stylesheet" type="text/css" href="dist/tao.css">
|
9
|
-
<link media="all" rel="stylesheet" type="text/css" href="dist/<%= name.underscore %>.css">
|
10
|
-
<style>
|
11
|
-
.wrapper {
|
12
|
-
width: 800px;
|
13
|
-
height: 600px;
|
14
|
-
border: 1px solid #cccccc;
|
15
|
-
position: relative;
|
16
|
-
margin: 80px auto;
|
17
|
-
}
|
18
|
-
</style>
|
19
|
-
|
20
|
-
<script type="text/javascript" src="dist/tao.js"></script>
|
21
|
-
<script type="text/javascript" src="dist/<%= name.underscore %>.js"></script>
|
22
|
-
|
23
|
-
</head>
|
24
|
-
<body>
|
25
|
-
<div class="wrapper">
|
26
|
-
<<%= name.dasherize %>></<%= name.dasherize %>>
|
27
|
-
</div>
|
28
|
-
</body>
|
29
|
-
</html>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class <%= name.camelize %> extends TaoComponent
|
2
|
-
|
3
|
-
@tag: '<%= name.dasherize %>'
|
4
|
-
|
5
|
-
_init: ->
|
6
|
-
# called when the page connected to dom for the first time
|
7
|
-
|
8
|
-
_connected: ->
|
9
|
-
# called every time the page connected to dom
|
10
|
-
|
11
|
-
_disconnected: ->
|
12
|
-
# called every time the page disconnected from dom
|
13
|
-
|
14
|
-
TaoComponent.register <%= name.camelize %>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
$:.push File.expand_path('../lib', __FILE__)
|
3
|
-
|
4
|
-
require '<%= name.underscore %>/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = '<%= name.underscore %>'
|
8
|
-
spec.version = TaoOnRails::VERSION
|
9
|
-
spec.authors = ['your name']
|
10
|
-
spec.email = ['your email']
|
11
|
-
|
12
|
-
spec.homepage = ''
|
13
|
-
spec.summary = ''
|
14
|
-
spec.description = ''
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = Dir["{lib,vendor}/**/*", "LICENSE", "Rakefile", "README.md"]
|
18
|
-
|
19
|
-
spec.add_dependency "tao_on_rails", "~> 0.6.0"
|
20
|
-
|
21
|
-
spec.add_development_dependency "blade", "~> 0.7.0"
|
22
|
-
spec.add_development_dependency "blade-sauce_labs_plugin", "~> 0.6.2"
|
23
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
{module, test} = QUnit
|
2
|
-
|
3
|
-
module '<%= name.camelize %>',
|
4
|
-
|
5
|
-
beforeEach: (assert) ->
|
6
|
-
done = assert.async()
|
7
|
-
|
8
|
-
@<%= name.camelize(:lower) %> = $('''
|
9
|
-
<<%= name.dasherize %>/>
|
10
|
-
''').appendTo('body').get(0)
|
11
|
-
|
12
|
-
setTimeout -> done()
|
13
|
-
|
14
|
-
afterEach: ->
|
15
|
-
@<%= name.camelize(:lower) %>.jq.remove()
|
16
|
-
@<%= name.camelize(:lower) %> = null
|
17
|
-
|
18
|
-
, ->
|
19
|
-
|
20
|
-
test 'inherits from TaoComponent', (assert) ->
|
21
|
-
assert.ok @<%= name.camelize(:lower) %> instanceof TaoComponent
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class <%= name.camelize %>Test < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'version number' do
|
6
|
-
assert <%= name.camelize %>::VERSION.is_a? String
|
7
|
-
end
|
8
|
-
|
9
|
-
test '<%= name.camelize %>::Engine inherits from Rails::Engine' do
|
10
|
-
assert <%= name.camelize %>::Engine < Rails::Engine
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
-
require "rails/test_help"
|
6
|
-
|
7
|
-
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
8
|
-
# to be shown.
|
9
|
-
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|