rails-themes 1.0.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.
- data/lib/rails-themes.rb +44 -0
- metadata +64 -0
data/lib/rails-themes.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
ActionController::Base.class_eval do
|
2
|
+
|
3
|
+
attr_accessor :current_theme
|
4
|
+
|
5
|
+
##
|
6
|
+
# Use it like the Rails <tt>layout</tt> macro.
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# theme "theme"
|
11
|
+
#
|
12
|
+
# -or-
|
13
|
+
#
|
14
|
+
# theme :set_theme
|
15
|
+
#
|
16
|
+
# def set_theme
|
17
|
+
# request.domain
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
def self.theme(site_theme)
|
21
|
+
write_inheritable_attribute "theme", site_theme
|
22
|
+
before_filter :add_theme_path
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def add_theme_path
|
28
|
+
current_theme
|
29
|
+
new_path = "#{Rails.public_path}/themes/#{@active_theme}/views"
|
30
|
+
self.prepend_view_path(new_path)
|
31
|
+
return true
|
32
|
+
end
|
33
|
+
|
34
|
+
def current_theme
|
35
|
+
theme = self.class.read_inheritable_attribute("theme")
|
36
|
+
|
37
|
+
@active_theme = case theme
|
38
|
+
when Proc then theme.call(self)
|
39
|
+
when String then theme
|
40
|
+
when Symbol then send(theme)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-themes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Francesc Esplugas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-09 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.0.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description:
|
27
|
+
email: contact@francescesplugas.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- lib/rails-themes.rb
|
36
|
+
homepage:
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.5
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Macros to have themes on Rails applications
|
63
|
+
test_files: []
|
64
|
+
|