themeable 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/themeable/acts_as_themeable.rb +1 -1
- data/lib/themeable/command.rb +6 -1
- data/lib/themeable/railtie.rb +2 -2
- data/lib/themeable/theme.rb +53 -9
- data/lib/themeable/version.rb +1 -1
- data/templates/theme_main.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 226dd22ad75dcbfb96aa75860a0c8cb733cedfec
|
4
|
+
data.tar.gz: 9dc9079e67e956c5486543615891f0ab19cc6ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33dffd44dd810e344ed29ec70625221a950588f341da2054950aea59e9ec1094e966011bffe221e2c49be4db32b3524141a74d3d417ee110811e946c8fe73b2d
|
7
|
+
data.tar.gz: d2ffc2a5423dacc228742ba9f8bea34548242aeba590bcc7efb93277a4ae6f71d1a1db5c4235cbc6e0b5592bf8715df387dfc5fb8120979d5a69af9f3d90e83c
|
@@ -18,7 +18,7 @@ module Themeable
|
|
18
18
|
return if theme_name == :none
|
19
19
|
view_paths = lookup_context.view_paths.to_a.map(&:to_path)
|
20
20
|
theme = Themeable.theme(__themeable_theme_name)
|
21
|
-
theme_view_path = File.join(theme.
|
21
|
+
theme_view_path = File.join(theme.root_path, theme.theme_path, 'views')
|
22
22
|
lookup_context.view_paths = view_paths.insert(1, theme_view_path)
|
23
23
|
end
|
24
24
|
RUBY
|
data/lib/themeable/command.rb
CHANGED
@@ -31,15 +31,20 @@ module Themeable
|
|
31
31
|
"\n s.add_dependency 'themeable'"
|
32
32
|
end
|
33
33
|
|
34
|
+
# generators
|
34
35
|
template 'theme_views_generator.rb', "lib/generators/themeable/#{theme_name}/views_generator.rb"
|
35
36
|
template 'theme_assets_generator.rb', "lib/generators/themeable/#{theme_name}/assets_generator.rb"
|
36
37
|
|
37
|
-
|
38
|
+
# assets and views
|
38
39
|
create_file "theme/assets/#{theme_name}/application.css"
|
39
40
|
create_file "theme/assets/#{theme_name}/application.js"
|
40
41
|
create_file "theme/views/layouts/.gitkeep"
|
41
42
|
template "view_application.html.erb", "theme/views/layouts/application.html.erb"
|
42
43
|
|
44
|
+
# vender files
|
45
|
+
create_file "vendor/#{theme_name}/.gitkeep"
|
46
|
+
|
47
|
+
# libs
|
43
48
|
remove_file "lib/#{app_name}.rb"
|
44
49
|
template 'theme_main.rb', "lib/#{app_name}.rb"
|
45
50
|
|
data/lib/themeable/railtie.rb
CHANGED
@@ -5,9 +5,9 @@ module Themeable
|
|
5
5
|
ActionController::Base.send :include, Themeable::ActsAsThemeable
|
6
6
|
end
|
7
7
|
initializer :themeable do
|
8
|
-
# puts "== Themeable =="
|
9
8
|
Themeable.themes.each do |theme|
|
10
|
-
config.assets.paths << File.join(theme.
|
9
|
+
config.assets.paths << File.join(theme.root_path, theme.theme_path, 'assets')
|
10
|
+
config.assets.paths << File.join(theme.root_path, 'vendor')
|
11
11
|
config.assets.precompile << /\A#{Regexp.escape(theme.name)}\/[^\/]+\.(js|css)\z/
|
12
12
|
config.assets.precompile << /\A#{Regexp.escape(theme.name)}\/.+\.(gif|jpg|png|svg)\z/
|
13
13
|
end
|
data/lib/themeable/theme.rb
CHANGED
@@ -1,27 +1,71 @@
|
|
1
1
|
module Themeable
|
2
|
+
|
3
|
+
# Theme's basic module, automatically define methods
|
4
|
+
# - name
|
5
|
+
# - root_path
|
6
|
+
# - theme_path
|
2
7
|
module Theme
|
3
8
|
def self.included(subclass)
|
9
|
+
|
4
10
|
Themeable.add_theme(subclass)
|
5
|
-
|
6
|
-
|
7
|
-
|
11
|
+
|
12
|
+
# set default values
|
13
|
+
caller_file = caller.first
|
14
|
+
if caller_file =~ %r{/theme_(.+?)/lib/theme_\1\.rb}
|
15
|
+
default_name = $1.to_sym
|
16
|
+
default_root = File.expand_path(File.join(caller_file, '../../'))
|
17
|
+
end
|
18
|
+
|
19
|
+
subclass.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
20
|
+
@name = #{default_name.inspect}
|
21
|
+
|
22
|
+
# Theme name
|
23
|
+
#
|
24
|
+
# @return [Symbol]
|
8
25
|
def name
|
9
26
|
@name || raise("Theme name is no defined")
|
10
27
|
end
|
11
28
|
|
12
|
-
@
|
13
|
-
|
14
|
-
|
29
|
+
@root_path = #{default_root.inspect}
|
30
|
+
|
31
|
+
# Theme project's root path
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
def root_path
|
35
|
+
@root_path || raise("Theme project's root path is no defined")
|
36
|
+
end
|
37
|
+
|
38
|
+
# Theme's relative path, 'theme' by default
|
39
|
+
#
|
40
|
+
# @return [String] default is 'theme'
|
41
|
+
def theme_path
|
42
|
+
@theme_path || 'theme'
|
15
43
|
end
|
16
44
|
|
17
|
-
|
45
|
+
protected
|
18
46
|
|
47
|
+
# Set theme name
|
48
|
+
#
|
49
|
+
# @param [String] name
|
50
|
+
# @return [Symbol] symbolized name
|
19
51
|
def set_name(name)
|
20
52
|
@name = name.to_sym
|
21
53
|
end
|
22
54
|
|
23
|
-
|
24
|
-
|
55
|
+
# Set root path of theme project
|
56
|
+
#
|
57
|
+
# @param [String] path
|
58
|
+
# @return [String]
|
59
|
+
def set_root_path(path)
|
60
|
+
@root_path = path
|
61
|
+
end
|
62
|
+
|
63
|
+
# Set theme's relative path, which path includes assets and views
|
64
|
+
#
|
65
|
+
# @param [String] path is a relative path where assets and views locate.
|
66
|
+
# @return [String]
|
67
|
+
def set_theme_path(path)
|
68
|
+
@theme_path = theme_path
|
25
69
|
end
|
26
70
|
|
27
71
|
RUBY
|
data/lib/themeable/version.rb
CHANGED
data/templates/theme_main.rb
CHANGED
@@ -3,6 +3,7 @@ require 'theme_<%= theme_name %>/version'
|
|
3
3
|
|
4
4
|
module <%= app_name.camelize %>
|
5
5
|
include Themeable::Theme
|
6
|
-
set_name '<%= theme_name %>'
|
7
|
-
|
6
|
+
# set_name '<%= theme_name %>' # by default, resovle name by file path automatically
|
7
|
+
# set_root_path File.expand_path('../..', __FILE__)
|
8
|
+
# set_theme_path 'theme'
|
8
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: themeable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiaohui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|