refinerycms-theming 0.9.8.1 → 0.9.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/app/models/theme.rb CHANGED
@@ -1,7 +1,18 @@
1
1
  class Theme
2
2
 
3
- def self.current_theme(env)
4
- RefinerySetting[:theme]
3
+ def self.current_theme(env = nil)
4
+ ::RefinerySetting[:theme]
5
5
  end
6
6
 
7
+ def self.root
8
+ Pathname.new( File.expand_path('../../../', __FILE__) )
9
+ end
10
+
11
+ def self.current_theme_dir
12
+ theme = self.current_theme
13
+ theme_dir = Rails.root.join("themes",theme)
14
+ theme_dir = self.root.join('themes', theme) unless theme_dir.directory?
15
+ theme_dir
16
+ end
17
+
7
18
  end
data/lib/gemspec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- version = '0.9.8.1'
2
+ version = '0.9.8.2'
3
3
  raise "Could not get version so gemspec can not be built" if version.nil?
4
4
  files = Dir[%q{**/*}].flatten.reject{|f| f =~ /\.gem$/}
5
5
 
@@ -16,7 +16,7 @@ module Refinery
16
16
  # add back theme paths if there is a theme present.
17
17
  if (theme = ::Theme.current_theme(request.env)).present?
18
18
  # Set up view path again for the current theme.
19
- view_paths.unshift Rails.root.join("themes", theme, "views").to_s
19
+ view_paths.unshift ::Theme.current_theme_dir.join("views").to_s
20
20
 
21
21
  # Ensure that routes within the application are top priority.
22
22
  # Here we grab all the routes that are under the application's view folder
data/lib/theme_server.rb CHANGED
@@ -12,7 +12,7 @@ module Refinery
12
12
  def call(env)
13
13
  if env["PATH_INFO"] =~ /^\/theme\/(stylesheets|javascripts|images)/ and (theme = Theme.current_theme(env)).present?
14
14
  env["PATH_INFO"].gsub!(/^\/theme\//, '')
15
- if (file_path = (dir = Rails.root.join("themes", theme)).join(env["PATH_INFO"])).exist?
15
+ if (file_path = (dir = Theme.current_theme_dir).join(env["PATH_INFO"])).exist?
16
16
  etag = Digest::MD5.hexdigest("#{file_path.to_s}#{file_path.mtime}")
17
17
  unless (etag == env["HTTP_IF_NONE_MATCH"])
18
18
  status, headers, body = Rack::File.new(dir).call(env)
@@ -29,4 +29,4 @@ module Refinery
29
29
  end
30
30
 
31
31
  end
32
- end
32
+ end
data/readme.md CHANGED
@@ -11,6 +11,17 @@ Think of a theme as your ``app/views`` directory with a few extra things like im
11
11
 
12
12
  It's worth noting you don't need to use a theme if you don't want to. Placing files in the ``app/views`` directory like any other Rails app will work just fine. It's only if you want to wrap your design up into a single location that you would use a theme or allow your client to easily change between designs.
13
13
 
14
+ ## How do I make my own Theme?
15
+
16
+ __Uncomment the gem 'refinerycms-theming' in your project's Gemfile & run ``bundle install``__
17
+
18
+ Then, simply use the Theme generator to make the basic structure of a new theme.
19
+
20
+ rails generate refinery_theme name_of_theme
21
+
22
+ Don't forget to "activate" this new theme by setting the theme setting to the name of this new theme. The __first__ time you create a theme, this setting will be created and set for you. If you already have a theme from an earlier project but no setting, you can create it manually in the __refinery admin / settings__ section. __The setting name is ``theme``__.
23
+
24
+
14
25
  ## The Structure of a Theme
15
26
 
16
27
  Themes sit in your Rails app like this
@@ -46,7 +57,7 @@ Let's take the ``mytheme`` example theme shown above. This is how the theme is s
46
57
  |- layouts
47
58
  |- application.html.erb
48
59
 
49
-
60
+
50
61
  ### Images
51
62
 
52
63
  Usually this would be just what you have in ``public/images`` except we move that to the theme instead.
@@ -59,17 +70,43 @@ Same with javascripts, just what you normally have in ``public/javascripts`` but
59
70
 
60
71
  The ``README`` file is just a description of your theme.
61
72
 
62
- ### Views
73
+ ### Partials && /shared Content
63
74
 
64
- This is exactly the same as how you lay your views out in ``app/views/`` just instead of putting them in ``app/views/`` you put them into ``themes/mytheme/views/``
75
+ In the default views, you will notice lines such as:
65
76
 
66
- ## How do I make my own Theme?
77
+ <%= render :partial => '/shared/header' %>
67
78
 
68
- Simply use the Theme generator to make the basic structure of a new theme.
79
+ These are built-in partials for RefineryCMS. To __override__ these partials, run the command:
69
80
 
70
- rails generate refinery_theme name_of_theme
81
+ rake refinery:override view=shared/* theme=theme-name
71
82
 
72
- Don't forget to "activate" this new theme by setting the theme setting to the name of this new theme.
83
+ __theme=theme-name is optional__ but is convenient for keeping things together.
84
+
85
+
86
+ ### content_for :body\_content\_title, :body\_content\_left, etc.
87
+
88
+ These are the default sections built up in __/shared/\_content\_page.html.erb__
89
+ You can add your own sections or rename these as you'd like. Say you wanted to add a left side bar, you could modify the __/shared/\_content\_page partial__ like so:
90
+
91
+ sections = [
92
+ {:yield => :body_content_title, :fallback => page_title, :id => 'body_content_page_title', :title => true},
93
+ {:yield => :body_content_sidebar, :fallback => nil},
94
+ {:yield => :body_content_left, :fallback => (@page.present? ? @page[Page.default_parts.first.to_sym] : nil)},
95
+ {:yield => :body_content_right, :fallback => (@page.present? ? @page[Page.default_parts.second.to_sym] : nil)}.reject {|section| hide_sections.include?(section[:yield]) }
96
+
97
+ Where you'll see I added "body_content_sidebar". And of course you could set the fallback to whatever you like.
98
+
99
+ Including the partial /shared/content_page is what causes all your content_for blocks to work. So you would use
100
+
101
+ <% content_for :body_content_sidebar do -%>
102
+ blah
103
+ <% end -%>
104
+
105
+ in this instance.
106
+
107
+ ### Views
108
+
109
+ This is exactly the same as how you lay your views out in ``app/views/`` just instead of putting them in ``app/views/`` you put them into ``themes/mytheme/views/``
73
110
 
74
111
  ## How do I select which Theme Refinery should use?
75
112
 
@@ -87,7 +124,7 @@ Just copy their theme directory into your themes folder and Refinery will see it
87
124
 
88
125
  ## How can I Convert my Current Views into a Theme?
89
126
 
90
- This should be fairly straightforward, just follow the directory structure outlined in 'The structure of a Theme'.
127
+ This should be fairly straightforward, just follow the directory structure outlined in 'The structure of a Theme'.
91
128
 
92
129
  But there is one important difference that need to be addressed to convert your current site into a theme.
93
130
 
@@ -112,7 +149,7 @@ This is the same with linking to Javascript and Stylesheets in your view. Say ou
112
149
  You just need to change that to:
113
150
 
114
151
  <%= stylesheet_link_tag 'application', :theme => true %>
115
-
152
+
116
153
  ## I'm Stuck, is there an Example Theme?
117
154
 
118
155
  Yep, there is an example theme called "demolicious" that comes with Refinery located in ``/themes/demolicious``. If you find yourself getting stuck, just check out that theme and get a feel for how it works.
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{refinerycms-theming}
3
- s.version = %q{0.9.8.1}
3
+ s.version = %q{0.9.8.2}
4
4
  s.description = %q{Theming functionality for the Refinery CMS project, extracted from Refinery CMS core.}
5
- s.date = %q{2010-09-28}
5
+ s.date = %q{2010-10-27}
6
6
  s.summary = %q{Theming functionality for the Refinery CMS project.}
7
7
  s.email = %q{info@refinerycms.com}
8
8
  s.homepage = %q{http://refinerycms.com}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-theming
3
3
  version: !ruby/object:Gem::Version
4
- hash: 37
4
+ hash: 35
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 8
10
- - 1
11
- version: 0.9.8.1
10
+ - 2
11
+ version: 0.9.8.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Resolve Digital
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-28 00:00:00 +13:00
19
+ date: 2010-10-27 00:00:00 +13:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency