refinerycms 0.9.5.30 → 0.9.5.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.yardopts +15 -5
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/bin/refinery +9 -9
  5. data/bin/refinery-update-core +8 -5
  6. data/config/environment.rb +1 -1
  7. data/config/routes.rb +1 -0
  8. data/contributors.md +18 -0
  9. data/db/migrate/20100127004649_add_reset_code_to_users.rb +9 -0
  10. data/db/schema.rb +2 -1
  11. data/db/seeds.rb +11 -1
  12. data/{LICENSE → license.md} +3 -3
  13. data/public/javascripts/admin.js +5 -0
  14. data/public/javascripts/refinery/boot_wym.js +1 -1
  15. data/public/stylesheets/refinery/refinery.css +7 -0
  16. data/readme.md +161 -0
  17. data/themes/demolicious.zip +0 -0
  18. data/themes/hemingway.zip +0 -0
  19. data/vendor/plugins/authentication/app/controllers/admin/users_controller.rb +0 -27
  20. data/vendor/plugins/authentication/app/controllers/sessions_controller.rb +3 -0
  21. data/vendor/plugins/authentication/app/controllers/users_controller.rb +36 -21
  22. data/vendor/plugins/authentication/app/models/user.rb +40 -41
  23. data/vendor/plugins/authentication/app/models/user_mailer.rb +5 -12
  24. data/vendor/plugins/authentication/app/views/sessions/new.html.erb +3 -0
  25. data/vendor/plugins/authentication/app/views/user_mailer/reset_notification.html.erb +6 -0
  26. data/vendor/plugins/authentication/app/views/users/forgot.html.erb +13 -0
  27. data/vendor/plugins/authentication/app/views/users/reset.html.erb +18 -0
  28. data/vendor/plugins/authentication/authentication.md +7 -0
  29. data/vendor/plugins/authentication/config/routes.rb +6 -1
  30. data/vendor/plugins/dashboard/dashboard.md +22 -0
  31. data/vendor/plugins/images/images.md +46 -0
  32. data/vendor/plugins/inquiries/app/controllers/inquiries_controller.rb +0 -8
  33. data/vendor/plugins/inquiries/app/views/admin/inquiries/show.html.erb +3 -3
  34. data/vendor/plugins/inquiries/inquiries.md +31 -0
  35. data/vendor/plugins/news/app/controllers/news_items_controller.rb +9 -19
  36. data/vendor/plugins/news/app/views/news_items/index.html.erb +1 -1
  37. data/vendor/plugins/news/app/views/news_items/show.html.erb +13 -18
  38. data/vendor/plugins/news/news.md +20 -0
  39. data/vendor/plugins/pages/app/controllers/pages_controller.rb +2 -12
  40. data/vendor/plugins/pages/app/models/page.rb +5 -5
  41. data/vendor/plugins/pages/app/presenters/page_presenter.rb +3 -0
  42. data/vendor/plugins/pages/pages.md +141 -0
  43. data/vendor/plugins/pages/rails/init.rb +1 -1
  44. data/vendor/plugins/refinery/app/views/admin/_head.html.erb +1 -0
  45. data/vendor/plugins/refinery/app/views/layouts/application.html.erb +2 -15
  46. data/vendor/plugins/refinery/app/views/shared/_head.html.erb +13 -0
  47. data/vendor/plugins/refinery/app/views/shared/_header.html.erb +1 -1
  48. data/vendor/plugins/refinery/app/views/shared/_menu.html.erb +4 -15
  49. data/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb +20 -25
  50. data/vendor/plugins/refinery/app/views/shared/_submenu.html.erb +5 -4
  51. data/vendor/plugins/refinery/crud.md +197 -0
  52. data/vendor/plugins/refinery/lib/generators/refinery/templates/public_controller.rb +6 -1
  53. data/vendor/plugins/refinery/lib/refinery/application_controller.rb +18 -5
  54. data/vendor/plugins/refinery/lib/refinery/application_helper.rb +31 -28
  55. data/vendor/plugins/refinery/lib/refinery/base_presenter.rb +27 -0
  56. data/vendor/plugins/refinery/lib/refinery/initializer.rb +7 -3
  57. data/vendor/plugins/refinery/lib/tasks/doc.rake +4 -4
  58. data/vendor/plugins/refinery/plugins.md +194 -0
  59. data/vendor/plugins/refinery/rails/init.rb +5 -0
  60. data/vendor/plugins/refinery_settings/settings.md +5 -0
  61. data/vendor/plugins/resources/resources.md +9 -0
  62. data/vendor/plugins/themes/app/controllers/themes_controller.rb +12 -15
  63. data/vendor/plugins/themes/app/models/theme.rb +8 -14
  64. data/vendor/plugins/themes/config/routes.rb +3 -3
  65. data/vendor/plugins/themes/themes.md +133 -0
  66. metadata +29 -38
  67. data/CONTRIBUTORS +0 -11
  68. data/README.rdoc +0 -78
  69. data/themes/demolicious/LICENSE +0 -21
  70. data/themes/demolicious/README +0 -1
  71. data/themes/demolicious/images/footer_background.png +0 -0
  72. data/themes/demolicious/images/header_background.png +0 -0
  73. data/themes/demolicious/preview.png +0 -0
  74. data/themes/demolicious/stylesheets/application.css +0 -94
  75. data/themes/demolicious/stylesheets/formatting.css +0 -36
  76. data/themes/demolicious/stylesheets/home.css +0 -11
  77. data/themes/demolicious/stylesheets/ie6.css +0 -0
  78. data/themes/demolicious/stylesheets/ie7.css +0 -0
  79. data/themes/demolicious/views/layouts/application.html.erb +0 -33
  80. data/themes/demolicious/views/pages/home.html.erb +0 -1
  81. data/themes/demolicious/views/pages/show.html.erb +0 -1
  82. data/themes/hemingway/LICENSE +0 -7
  83. data/themes/hemingway/README +0 -3
  84. data/themes/hemingway/images/archives.gif +0 -0
  85. data/themes/hemingway/images/footer_black.gif +0 -0
  86. data/themes/hemingway/images/kyle-header.jpg +0 -0
  87. data/themes/hemingway/images/readon_black.gif +0 -0
  88. data/themes/hemingway/images/search.gif +0 -0
  89. data/themes/hemingway/images/spinner.gif +0 -0
  90. data/themes/hemingway/images/trackback_pingback.gif +0 -0
  91. data/themes/hemingway/preview.png +0 -0
  92. data/themes/hemingway/stylesheets/application.css +0 -713
  93. data/themes/hemingway/views/layouts/application.html.erb +0 -64
  94. data/themes/hemingway/views/shared/content_page.html.erb +0 -0
  95. data/vendor/plugins/authentication/app/models/user_observer.rb +0 -11
  96. data/vendor/plugins/authentication/app/views/user_mailer/activation.html.erb +0 -3
  97. data/vendor/plugins/authentication/app/views/user_mailer/signup_notification.html.erb +0 -8
  98. data/vendor/plugins/themes/themes.rdoc +0 -131
@@ -0,0 +1,194 @@
1
+ # Extending Refinery with Plugins
2
+
3
+ ## Introduction
4
+
5
+ Refinery is designed to be easily extended so you can quickly customise your Refinery site to manage new areas you want to add to your site. If you see something you want to customise, the chances are you can customise it.
6
+
7
+ The main way of extending Refinery is through adding new plugins to your app. By default you can edit pages in Refinery's backend, but how do you add a new section to manage like products?
8
+
9
+ ## The Refinery Generator
10
+
11
+ The Refinery generator is a standard Rails generator that functions just like the scaffold generator. It allows you to quickly add new "tabs" to the Refinery backend and the front end views.
12
+
13
+ To see how to use the generator run
14
+
15
+ ruby script/generate refinery
16
+
17
+ ## Example of Using the Generator
18
+
19
+ Let's say you have a client who has a range of products they want to show on their website.
20
+
21
+ First decide what fields they need to manage. In our case the client is going to want to edit the title and description of each product. They would also like a little "facts panel" to show on the right of the page.
22
+
23
+ So go to the root of your project and run
24
+
25
+ ruby script/generate refinery
26
+
27
+ This will output the help on how to use the generator. To generate the new section we want to manage products we run:
28
+
29
+ ruby script/generate refinery product title:string description:text facts:text
30
+
31
+ The generator will output a list of files it generated. You'll notice there is a new plugin that has been added in ``vendor/plugins/products``. This is where both the backend and front end files are held for this new products area.
32
+
33
+ A new database migration has been added to add the products table in so run:
34
+
35
+ rake db:migrate
36
+
37
+ Start up your app by running ``ruby script/server`` go to [http://localhost:3000](http://localhost:3000) and you'll see instantly a new menu item called "products". Click on that and you'll see there are no products yet.
38
+
39
+ Now go to the backend of your site by visiting [http://localhost:3000/admin](http://localhost:3000/admin) and logging in. You'll see a new tab called "Products", click on that and then click "Add a new product", fill the form and to add an example product. Now go back to the front end and you'll see your product is showing up in the products part of your site.
40
+
41
+ Now you have a fully managed products section in Refinery, nice.
42
+
43
+ If you want to modify your generated plugin you need to understand the basic structure of how they work.
44
+
45
+ ## The Structure of a Plugin
46
+
47
+ Think of a plugin in Refinery as a small Rails app or an "engine". Plugins have a structure that is extremely similar to a Rails app. Here's an example of Refinery's pages plugin (located in Refinery's ``vendor/plugins/pages/`` folder)
48
+
49
+ pages
50
+ |- app
51
+ | |- controllers
52
+ | | |- admin
53
+ | | | |- pages_dialogs_controller.rb
54
+ | | | |- page_parts_controller.rb
55
+ | | | |- pages_controller.rb
56
+ | | |- pages_controller.rb
57
+ | |- helpers
58
+ | | |- pages_helper.rb
59
+ | |- models
60
+ | | |- page.rb
61
+ | |- views
62
+ | |- pages
63
+ | | |- home.html.erb
64
+ | | |- show.html.erb
65
+ | |- admin
66
+ | |- pages
67
+ | |- _form.html.erb
68
+ | |- edit.html.erb
69
+ | |- index.html.erb
70
+ | |- new.html.erb
71
+ |- config
72
+ | |- routes.rb
73
+ |- rails
74
+ |- init.rb
75
+
76
+
77
+ ### app/controllers
78
+
79
+ In this example you see one "public" controller ``app/controllers/pages_controller`` that is responsible for managing the front end when I view a page.
80
+
81
+ ### app/controllers/admin
82
+
83
+ This bit is important. It's where all the controllers are held to manage pages in the Refinery back end in this example. You can ignore the ``pages_dialogs_controller.rb`` and ``page_parts_controller.rb`` for now and let's just focus on the ``admin/pages_controller.rb`` file. Here's what that looks like inside at a basic level:
84
+
85
+ class Admin::PagesController < Admin::BaseController
86
+
87
+ crudify :page, :conditions => "parent_id IS NULL",
88
+ :order => "position ASC", :paging => false
89
+
90
+ end
91
+
92
+ This single controller allows us to create, read, update and delete pages in the backend. With a little bit of Refinery magic we utilise the crudify mixin which gives us all of these regular features out of the box.
93
+
94
+ To read more about how crudify works, checkout the crudify.md file.
95
+
96
+ ### app/views and app/helpers
97
+
98
+ Works exactly the same as ``app/views`` and ``app/helpers`` in a normal Rails app. You just put the views and helpers related to this plugin in here instead of in your actual main app directory.
99
+
100
+ ### config/routes.rb
101
+
102
+ Works exactly the same as ``config/routes.rb`` in your app except this routes file only loads the routes for this plugin.
103
+
104
+ ### rails/init.rb
105
+
106
+ This file runs when your site is started up. All is does is registers this plugin with Refinery so it knows that it exists, how to handle it in the Refinery admin menu and how to render recent activity on the Dashboard (see "Getting your plugin to report activity in the dashboard")
107
+
108
+ Refinery::Plugin.register do |plugin|
109
+ plugin.title = "Pages"
110
+ plugin.description = "Manage content pages"
111
+ plugin.version = 1.0
112
+ plugin.menu_match = /admin\/((pages)|(page_dialogs)|(page_parts))$/
113
+ plugin.activity = {:class => Page,
114
+ :url_prefix => "edit_",
115
+ :title => "title",
116
+ :created_image => "page_add.png",
117
+ :updated_image => "page_edit.png"}
118
+ end
119
+
120
+ ## Getting your plugin to report activity in the dashboard
121
+
122
+ Recent activity reporting is built right in, so all you need to do is follow the convention below and your plugin will start showing up in the recent activity list of the Dashboard.
123
+
124
+ In our example above we showed the use of ``plugin.activity`` for the pages plugin.
125
+
126
+ Refinery::Plugin.register do |plugin|
127
+ plugin.title = "Pages"
128
+ plugin.description = "Manage content pages"
129
+ plugin.version = 1.0
130
+ plugin.menu_match = /admin\/((pages)|(page_dialogs)|(page_parts))$/
131
+ plugin.activity = {:class => Page,
132
+ :url_prefix => "edit_",
133
+ :title => "title",
134
+ :created_image => "page_add.png",
135
+ :updated_image => "page_edit.png"}
136
+ end
137
+
138
+ Here's what the different activity options mean:
139
+
140
+ ### Required
141
+
142
+ :class
143
+ # the name of the class we're watching.
144
+
145
+ :url_prefix
146
+ # when it says "'About Us' page was updated about 4 hours ago", the page title "About Us"
147
+ # is linked to that page in a way we specify. So by setting "_edit" as a :url_preview what
148
+ # we're doing is making it link to the page that allows us to edit this page.
149
+
150
+ :title
151
+ # which attribute on the :class should be in the activty message. In our case it's "title"
152
+ # because we want it to run something like this "#{page.title} was updated about ...."
153
+
154
+ ### Optional
155
+
156
+ :created_image and :updated_image
157
+ # the activity monitor knows if something is created or updated and shows a different icon
158
+ # depending on how you want that to look. You can specify the filename to any image you
159
+ # want in the public/images/refinery/icons/ directory.
160
+
161
+ ## Improving the URLs
162
+
163
+ In our example above we extended Refinery to manage a products area. The problem is when I look at a product on the front end I get a URL like [http://localhost:3000/products/1](http://localhost:3000/products/1) but I would really like it to be something like [http://localhost:3000/products/my-product](http://localhost:3000/products/my-product)
164
+
165
+ To achieve this all you need to do is open up the product model (found in ``/vendor/plugins/products/app/models/product.rb``) and add the following line inside your class:
166
+
167
+ has_friendly_id :title, :use_slug => true, :strip_diacritics => true
168
+
169
+ Note you want to change ``:title`` to the field which you want to show up in the URL.
170
+
171
+ This will work just fine for new products added from this point, but you'll want to migrate any existing products you have to use this new URL format. All you have to do is save each product you have in the database to make it create a nice URL for you.
172
+
173
+ ruby script/console
174
+ >> Product.all.each {|p| p.save };nil
175
+
176
+ Now all the products in your database will have nice URLs.
177
+
178
+ ## How to get a WYSIWYG editor to show on your form fields
179
+
180
+ Refinery uses a standards compliant visual editor called [WYMeditor](http://www.wymeditor.org/)
181
+
182
+ The WYSIWYG editor can only be applied to a ``textarea``. All you need to do is add a class of "wymeditor" to a ``textarea`` in your form and a WYSIWYG WYMEditor will load right in place.
183
+
184
+ ### Example
185
+
186
+ Again going back to our product plugin example if you had this in your ``vendor/plugins/products/app/views/admin/products/_form.html.erb`` file:
187
+
188
+ <%= f.text_area :description %>
189
+
190
+ Just change that to:
191
+
192
+ <%= f.text_area :description, :class => "wymeditor" %>
193
+
194
+ Refresh and you're done.
@@ -7,3 +7,8 @@ Refinery::Plugin.register do |plugin|
7
7
  plugin.menu_match = /admin\/(refinery_core|base)$/
8
8
  end
9
9
  require_dependency 'refinery/form_helpers'
10
+ require_dependency 'refinery/base_presenter'
11
+
12
+ presenters_path = "#{RAILS_ROOT}/app/presenters/"
13
+ $LOAD_PATH << presenters_path
14
+ ::ActiveSupport::Dependencies.load_paths << presenters_path
@@ -0,0 +1,5 @@
1
+ # Settings
2
+
3
+ ![Refinery Settings](http://refinerycms.com/system/images/0000/0666/settings.png)
4
+
5
+ need to add info in here about how to use a setting in your plugin.
@@ -0,0 +1,9 @@
1
+ # Resources
2
+
3
+ ## About
4
+
5
+ The Resources plugin allows you to upload files such as PDFs and other files you want your users to download.
6
+
7
+ ## How it works
8
+
9
+ The resources plugins is made up of attachment_fu and the Crudfiy mixin (see the crud.md file for details)
@@ -1,26 +1,23 @@
1
1
  class ThemesController < ApplicationController
2
2
 
3
3
  def stylesheets
4
- render_theme_item(:stylesheets, params[:filename], 'text/css; charset=utf-8')
5
- end
6
-
7
- def javascripts
8
- render_theme_item(:javascript, params[:filename], 'text/javascript; charset=utf-8')
4
+ render_theme_item(:stylesheets, params[:filepath])
5
+ end
6
+
7
+ def javascripts
8
+ render_theme_item(:javascripts, params[:filepath])
9
9
  end
10
10
 
11
11
  def images
12
- render_theme_item(:images, params[:filename])
12
+ render_theme_item(:images, params[:filepath])
13
13
  end
14
14
 
15
15
  protected
16
16
 
17
- def render_theme_item(type, file, mime = nil)
18
- mime ||= mime_for(file)
19
-
20
- file_path = File.join(RAILS_ROOT, "themes", RefinerySetting[:theme], "#{type}/#{file}#{params[:extension]}")
21
-
17
+ def render_theme_item(type, relative_path)
18
+ file_path = File.join(RAILS_ROOT, "themes", RefinerySetting[:theme], type.to_s, relative_path)
22
19
  if File.exists? file_path
23
- send_file(file_path, :type => mime, :disposition => 'inline', :stream => true)
20
+ send_file(file_path, :type => mime_for(relative_path), :disposition => 'inline', :stream => true)
24
21
  else
25
22
  return error_404
26
23
  end
@@ -28,11 +25,11 @@ protected
28
25
 
29
26
  def mime_for(filename)
30
27
  # could we use the built in Rails mime types to work this out?
31
- case filename.downcase
28
+ case filename.last.downcase
32
29
  when /\.js$/
33
- 'text/javascript'
30
+ 'text/javascript; charset=utf-8'
34
31
  when /\.css$/
35
- 'text/css'
32
+ 'text/css; charset=utf-8'
36
33
  when /\.gif$/
37
34
  'image/gif'
38
35
  when /(\.jpg|\.jpeg)$/
@@ -8,10 +8,10 @@ end
8
8
 
9
9
  class Theme < ActiveRecord::Base
10
10
 
11
- before_save :read_theme
11
+ before_save :read_theme
12
12
 
13
13
  has_attachment :storage => (USE_S3_BACKEND ? :s3 : :file_system),
14
- :size => 0.kilobytes..15.megabytes,
14
+ :size => 0.kilobytes..25.megabytes,
15
15
  :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/themes'),
16
16
  :content_type => 'application/zip'
17
17
 
@@ -19,10 +19,10 @@ class Theme < ActiveRecord::Base
19
19
  def after_attachment_saved
20
20
  if Theme::directory_is_writable?
21
21
  # make the folder for the them
22
- FileUtils.mkdir(self.theme_path) unless File.exists? self.theme_path
22
+ FileUtils.mkdir(self.theme_path) unless File.directory? self.theme_path
23
23
 
24
24
  # extracts the contents of the zip file into the theme directory
25
- Zip::ZipFile.foreach(self.filename) do |entry|
25
+ Zip::ZipFile.foreach(self.full_filename) do |entry|
26
26
  FileUtils.mkdir_p(File.dirname("#{theme_path}/#{entry}"))
27
27
  entry.extract("#{theme_path}/#{entry}") { true }
28
28
  end
@@ -32,7 +32,7 @@ class Theme < ActiveRecord::Base
32
32
  end
33
33
 
34
34
  def theme_folder_title
35
- File.basename(self.filename).split(".").first
35
+ File.basename(self.full_filename).split(".").first
36
36
  end
37
37
 
38
38
  def theme_path
@@ -44,15 +44,9 @@ class Theme < ActiveRecord::Base
44
44
  end
45
45
 
46
46
  def read_theme
47
- self.title = File.basename(self.filename).split(".").first.titleize
48
-
49
- if File.exists? File.join(theme_path, "LICENSE")
50
- self.license = File.open(File.join(theme_path, "LICENSE")).read
51
- end
52
-
53
- if File.exists? File.join(theme_path, "README")
54
- self.description = File.open(File.join(theme_path, "README")).read
55
- end
47
+ self.title = File.basename(self.full_filename).split(".").first.titleize
48
+ self.license = File.open(File.join(theme_path, "LICENSE")).read if File.exists? File.join(theme_path, "LICENSE")
49
+ self.description = File.open(File.join(theme_path, "README")).read if File.exists? File.join(theme_path, "README")
56
50
  end
57
51
 
58
52
  def self.directory_is_writable?
@@ -5,8 +5,8 @@ ActionController::Routing::Routes.draw do |map|
5
5
  end
6
6
 
7
7
  # allows theme files that are not in the Rails public directory to be served back to the client
8
- map.connect 'stylesheets/theme/:filename*extension', :controller => 'themes', :action => 'stylesheets'
9
- map.connect 'javascripts/theme/:filename*extension', :controller => 'themes', :action => 'javascripts'
10
- map.connect 'images/theme/:filename*extension', :controller => 'themes', :action => 'images'
8
+ map.connect 'stylesheets/theme/*filepath', :controller => 'themes', :action => 'stylesheets'
9
+ map.connect 'javascripts/theme/*filepath', :controller => 'themes', :action => 'javascripts'
10
+ map.connect 'images/theme/*filepath', :controller => 'themes', :action => 'images'
11
11
 
12
12
  end
@@ -0,0 +1,133 @@
1
+ # Themes
2
+
3
+ ![Refinery Dashboard](http://refinerycms.com/system/images/0000/0576/dashboard.png)
4
+
5
+ ## Introduction
6
+
7
+ __Themes allow you to wrap up the design of your Refinery site into a single folder that is portable.__
8
+
9
+ Refinery doesn't force you to learn a special templating language, but rather just uses the regular
10
+ ERB views you're used to in Rails. This means creating a theme from your existing site is extremely easy.
11
+
12
+ Think of a theme as your ``app/views`` directory with a few extra things like images, css and javascript.
13
+
14
+ 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 designs.
15
+
16
+ ## The structure of a theme
17
+
18
+ Themes sit in your Rails app like this
19
+
20
+ app/
21
+ config/
22
+ db/
23
+ lib/
24
+ public/
25
+ themes/
26
+ |- mytheme/
27
+ |- othertheme/
28
+ plugins/
29
+ tests/
30
+
31
+ So let's take the ``mytheme`` example theme shown above. This is how the theme is structured:
32
+
33
+ mytheme/
34
+ |- images
35
+ | |- whatever.png
36
+ | |- foo.jpg
37
+ |- javascripts
38
+ | |- whatever.js
39
+ |- LICENSE
40
+ |- preview.png
41
+ |- README
42
+ |- stylesheets/
43
+ | |- application.css
44
+ | |- whatever.css
45
+ |- views
46
+ |- pages
47
+ | |- show.html.erb
48
+ | |- index.html.erb
49
+ |- layouts
50
+ |- application.html.erb
51
+
52
+ ### Images
53
+
54
+ Usually this would be just what you have in ``public/images`` except we move that to the theme instead.
55
+
56
+ ### Javascripts
57
+
58
+ Same with javascripts, just what you normally have in ``public/javascripts`` just in this theme directory instead.
59
+
60
+ ### Readme
61
+
62
+ The ``README`` file is just a description of your theme.
63
+
64
+ ### Views
65
+
66
+ 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/``
67
+
68
+ ### Preview Image
69
+
70
+ The ``preview.png`` image is used when selecting the theme in the backend. It must be a png and ideally is 135x135 pixels.
71
+
72
+ ## How do I make my own theme?
73
+
74
+ Create a folder with the name if your theme inside ``/themes`` e.g. ``/themes/mytheme`` and follow the directory structure outlined in 'The structure of a theme'.
75
+
76
+ ## How do I select which theme Refinery should use?
77
+
78
+ In the admin area of Refinery go to the "Settings" area, locate the setting called "theme" and edit it.
79
+
80
+ Set the value of that setting to the name of your themes folder. For example if your theme is sitting in:
81
+
82
+ themes/my_theme
83
+
84
+ set it to ``my_theme`` and hit save.
85
+
86
+ ## How do I zip my theme to use it on other sites
87
+
88
+ If you want to share a theme and install it on another site you have to zip it first.
89
+
90
+ It's important to note you don't zip the theme's directory itself just the contents.
91
+
92
+ If I had a theme sitting in:
93
+
94
+ themes/mytheme/[theme files here]
95
+
96
+ The zip file would look like this
97
+
98
+ mytheme.zip
99
+ |- [theme files here]
100
+
101
+ Read 'How do I install someone else's theme?' to take that zip file and install the theme.
102
+
103
+ ## How do I install someone else's theme?
104
+
105
+ If you have the themes plugin added to your admin user, you should see in the admin area of Refinery a "Themes" tab in the main navigation. Click on that, then click "Upload new theme". Upload the theme zip file and then click on the "star" below the preview image for the theme to activate that theme as the one to use right now.
106
+
107
+ ## How can I convert my current views into a theme?
108
+
109
+ This should be fairly straightforward just following the directory structure outlined in 'The structure of a theme'.
110
+
111
+ But there is one important difference that need to be addressed to convert your current site into a theme.
112
+
113
+ If you have some CSS which refers to an image or URL:
114
+
115
+ #footer {
116
+ background: url('/images/footer_background.png') repeat-x;
117
+ }
118
+
119
+ You need to update the URL so it requests /images/themes instead of /images. This tells Refinery we need to actually load this image from the theme and not just the public directory.
120
+
121
+ So the result is simply:
122
+
123
+ #footer {
124
+ background: url('/images/theme/footer_background.png') repeat-x;
125
+ }
126
+
127
+ This is the same with linking to Javascript and Stylesheets in your view. Say our ``application.html.erb`` layout had something like this:
128
+
129
+ <%= stylesheet_link_tag 'application' %>
130
+
131
+ You just need to change that to:
132
+
133
+ <%= stylesheet_link_tag 'theme/application' %>