refinerycms 0.9.5.31 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/.gitignore +1 -0
  2. data/VERSION +1 -1
  3. data/bin/refinery +2 -1
  4. data/config/environment.rb +1 -1
  5. data/config/environments/development.rb +3 -0
  6. data/contributors.md +2 -0
  7. data/db/migrate/20100202034802_remove_custom_title_image_id_and_image_id_from_pages.rb +13 -0
  8. data/db/migrate/20100204011654_change_part_titles_to_titleized_version_for_new_format.rb +13 -0
  9. data/db/schema.rb +6 -10
  10. data/public/javascripts/admin.js +1 -1
  11. data/public/javascripts/jquery-ui-1.8rc1.min.js +375 -0
  12. data/public/javascripts/jquery.js +4231 -2529
  13. data/public/javascripts/refinery/admin.js +609 -38
  14. data/public/javascripts/refinery/boot_wym.js +3 -3
  15. data/public/javascripts/thickbox.js +116 -129
  16. data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +3674 -3732
  17. data/public/javascripts/wymeditor/skins/refinery/skin.js +8 -8
  18. data/public/stylesheets/refinery/refinery.css +142 -32
  19. data/public/stylesheets/wymeditor/skins/refinery/skin.css +8 -1
  20. data/readme.md +35 -21
  21. data/test/fixtures/page_parts.yml +9 -0
  22. data/test/fixtures/pages.yml +88 -0
  23. data/test/performance/browsing_test.rb +9 -0
  24. data/test/test_helper.rb +38 -0
  25. data/test/unit/image_test.rb +14 -0
  26. data/test/unit/page_part_test.rb +19 -0
  27. data/test/unit/page_test.rb +130 -0
  28. data/vendor/plugins/authentication/app/controllers/sessions_controller.rb +1 -1
  29. data/vendor/plugins/authentication/app/views/admin/users/index.html.erb +1 -2
  30. data/vendor/plugins/authentication/authentication.md +9 -1
  31. data/vendor/plugins/dashboard/dashboard.md +3 -3
  32. data/vendor/plugins/images/app/controllers/admin/images_controller.rb +17 -13
  33. data/vendor/plugins/images/app/helpers/admin/images_helper.rb +6 -0
  34. data/vendor/plugins/images/app/models/image.rb +24 -39
  35. data/vendor/plugins/images/app/views/admin/images/_form.html.erb +11 -4
  36. data/vendor/plugins/images/app/views/admin/images/_grid_view.html.erb +1 -2
  37. data/vendor/plugins/images/app/views/admin/images/_list_view_image.html.erb +1 -2
  38. data/vendor/plugins/images/app/views/admin/images/index.html.erb +1 -1
  39. data/vendor/plugins/images/app/views/admin/images/insert.html.erb +8 -71
  40. data/vendor/plugins/images/images.md +12 -7
  41. data/vendor/plugins/inquiries/app/views/admin/inquiries/_inquiry.html.erb +6 -13
  42. data/vendor/plugins/inquiries/app/views/admin/inquiry_settings/index.html.erb +1 -2
  43. data/vendor/plugins/inquiries/inquiries.md +8 -8
  44. data/vendor/plugins/news/app/views/admin/news_items/_news_item.html.erb +1 -2
  45. data/vendor/plugins/news/news.md +4 -4
  46. data/vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb +11 -10
  47. data/vendor/plugins/pages/app/controllers/admin/page_parts_controller.rb +5 -1
  48. data/vendor/plugins/pages/app/controllers/admin/pages_controller.rb +2 -2
  49. data/vendor/plugins/pages/app/models/page.rb +75 -29
  50. data/vendor/plugins/pages/app/models/page_part.rb +1 -1
  51. data/vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb +2 -2
  52. data/vendor/plugins/pages/app/views/admin/page_dialogs/link_to.html.erb +8 -112
  53. data/vendor/plugins/pages/app/views/admin/pages/_form.html.erb +50 -154
  54. data/vendor/plugins/pages/app/views/admin/pages/_list.html.erb +10 -10
  55. data/vendor/plugins/pages/app/views/admin/pages/_page_part_field.html.erb +4 -4
  56. data/vendor/plugins/pages/app/views/admin/pages/_sortable_list.html.erb +1 -1
  57. data/vendor/plugins/pages/pages.md +30 -25
  58. data/vendor/plugins/refinery/app/views/admin/_head.html.erb +5 -14
  59. data/vendor/plugins/refinery/app/views/admin/_menu.html.erb +2 -64
  60. data/vendor/plugins/refinery/app/views/shared/_message.html.erb +0 -6
  61. data/vendor/plugins/refinery/app/views/shared/admin/_error_messages_for.html.erb +1 -6
  62. data/vendor/plugins/refinery/app/views/shared/admin/_form_actions.html.erb +8 -10
  63. data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +22 -38
  64. data/vendor/plugins/refinery/app/views/shared/admin/_make_sortable.html.erb +6 -65
  65. data/vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb +16 -16
  66. data/vendor/plugins/refinery/app/views/shared/admin/_sortable_list.html.erb +3 -4
  67. data/vendor/plugins/refinery/lib/crud.rb +1 -1
  68. data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_singular_name.html.erb +1 -1
  69. data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_sortable_list.html.erb +1 -1
  70. data/vendor/plugins/refinery/plugins.md +19 -12
  71. data/vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb +6 -4
  72. data/vendor/plugins/refinery_dialogs/app/views/admin/dialogs/show.html.erb +3 -3
  73. data/vendor/plugins/refinery_dialogs/app/views/layouts/admin_dialog.html.erb +7 -14
  74. data/vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_refinery_setting.html.erb +1 -1
  75. data/vendor/plugins/refinery_settings/settings.md +51 -1
  76. data/vendor/plugins/resources/app/controllers/admin/resources_controller.rb +16 -11
  77. data/vendor/plugins/resources/app/views/admin/resources/_form.html.erb +9 -2
  78. data/vendor/plugins/resources/app/views/admin/resources/_resource.html.erb +1 -3
  79. data/vendor/plugins/resources/app/views/admin/resources/index.html.erb +2 -2
  80. data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +14 -60
  81. data/vendor/plugins/resources/resources.md +1 -1
  82. data/vendor/plugins/themes/app/controllers/admin/themes_controller.rb +6 -6
  83. data/vendor/plugins/themes/app/models/theme.rb +3 -3
  84. data/vendor/plugins/themes/app/views/admin/themes/_theme.html.erb +14 -20
  85. data/vendor/plugins/themes/themes.md +21 -19
  86. metadata +18 -19
  87. data/public/javascripts/builder.js +0 -136
  88. data/public/javascripts/controls.js +0 -963
  89. data/public/javascripts/dragdrop.js +0 -973
  90. data/public/javascripts/effects.js +0 -1128
  91. data/public/javascripts/fastinit.js +0 -84
  92. data/public/javascripts/livepipe.js +0 -180
  93. data/public/javascripts/prototype.js +0 -4874
  94. data/public/javascripts/refinery/dialog.js +0 -52
  95. data/public/javascripts/refinery/parse_url.js +0 -38
  96. data/public/javascripts/refinery/prototype.enhancements.js +0 -24
  97. data/public/javascripts/refinery/tooltips.js +0 -173
  98. data/public/javascripts/scriptaculous.js +0 -47
  99. data/public/javascripts/slider.js +0 -275
  100. data/public/javascripts/tabs.js +0 -149
  101. data/vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_make_sortable.html.erb +0 -7
@@ -1,14 +1,14 @@
1
1
  <%= f.hidden_field field %>
2
2
  <div>
3
- <a id='current_resource_link' href="<%= insert_admin_resources_url %>?thickbox=true&amp;modal=true&amp;titlebar=true&amp;field=<%= "#{f.object.class.name.underscore.downcase}_#{field}" %><%= "&amp;current_link=#{resource.public_filename unless resource.nil?}" %>&amp;update_resource=current_resource&amp;update_text=current_resource_text&amp;callback=resource_changed&amp;KeepThis=true&amp;TB_iframe=true&amp;width=<%= width ||= 950 %>&amp;height=<%= height ||= 510 %>" style='border: 0px' title='Add <%= (description ||= "resource").titleize %>' name='Add <%= (description ||= "resource").titleize %>' class='thickbox'>
4
- <span id='no_resource_selected' <%= "style='display: none;'" unless resource.nil? %>>
3
+ <a id='current_resource_link' href="<%= insert_admin_resources_url %>?thickbox=true&amp;modal=true&amp;titlebar=true&amp;field=<%= "#{f.object.class.name.underscore.downcase}_#{field}" %><%= "&amp;current_link=#{resource.public_filename if resource.present?}" %>&amp;update_resource=current_resource&amp;update_text=current_resource_text&amp;callback=resource_changed&amp;KeepThis=true&amp;TB_iframe=true&amp;width=<%= width ||= 950 %>&amp;height=<%= height ||= 510 %>" style='border: 0px' title='Add <%= (description ||= "resource").titleize %>' name='Add <%= (description ||= "resource").titleize %>' class='thickbox'>
4
+ <span id='no_resource_selected' <%= "style='display: none;'" if resource.present? %>>
5
5
  There is currently no <%= description ||= "resource" %> selected, click here to add one.
6
6
  </span>
7
7
  </a>
8
- <div id='current_resource_container' <%= "style='display:none'" if resource.nil? %>>
8
+ <div id='current_resource_container' <%= "style='display:none'" unless resource.present? %>>
9
9
  Current <%= description ||= "resource" %>:
10
10
  <span id='current_resource_text'>
11
- <%= "#{resource.title} (#{resource.public_filename})" unless resource.nil? %>
11
+ <%= "#{resource.title} (#{resource.public_filename})" if resource.present? %>
12
12
  </span>
13
13
  <br/>
14
14
  <%= link_to "#{refinery_icon_tag("page_white_put.png")} Download current #{description ||= "resource"} (<em>Opens in a new window</em>)", "#{resource.public_filename unless resource.nil?}",
@@ -24,20 +24,20 @@
24
24
  <% content_for :head do %>
25
25
  <script type='text/javascript'>
26
26
  resource_changed = function() {
27
- $('current_resource_link').href = $('current_resource_link').href.gsub(/current_link=([^&])*&/, "current_link=" + $('current_resource').href + "&");
28
- $('remove_resource').show();
29
- $('current_resource_container').show();
30
- $('no_resource_selected').hide();
27
+ $('#current_resource_link').attr('href', $('#current_resource_link').attr('href').replace(/current_link=([^&])*&/, "current_link=" + $('#current_resource').attr('href') + "&");
28
+ $('#remove_resource').show();
29
+ $('#current_resource_container').show();
30
+ $('#no_resource_selected').hide();
31
31
  }
32
32
 
33
- FastInit.addOnLoad(function() {
34
- $('remove_resource').observe('click', function(e) {
35
- $('<%= f.object.class.name.underscore.downcase %>_<%= field %>').value = "";
36
- $('current_resource_container').hide();
37
- $('current_resource_text').innerHTML = '';
38
- $('no_resource_selected').show();
39
- $('current_resource_link').href = $('current_resource_link').href.gsub(/current_link=([^&])*&/, "current_link=&");
40
- this.hide();
33
+ $(document).ready(function(e) {
34
+ $('#remove_resource').click(function(e) {
35
+ $('#<%= f.object.class.name.underscore.downcase %>_<%= field %>').value = "";
36
+ $('#current_resource_container').hide();
37
+ $('#current_resource_text').innerHTML = '';
38
+ $('#no_resource_selected').show();
39
+ $('#current_resource_link').attr('href', $('#current_resource_link').attr('href').replace(/current_link=([^&])*&/, "current_link=&");
40
+ $(this).hide();
41
41
  e.preventDefault();
42
42
  });
43
43
  });
@@ -1,10 +1,9 @@
1
1
  <input type='hidden' id='reorder_authenticity_token' name='reorder_authenticity_token' value='<%= form_authenticity_token %>'/>
2
2
  <% unless params[(list_id ||= "sortable_list").to_sym].blank? %>
3
3
  <script type='text/javascript'>
4
- FastInit.addOnLoad(function()
5
- {
6
- enable_reordering();
4
+ $(document).ready(function(){
5
+ <%= "list_reorder.enable_reordering();" if (defined?(continue_reordering) ? continue_reordering : true) -%>
7
6
  init_tooltips();
8
7
  });
9
8
  </script>
10
- <% end %>
9
+ <% end %>
@@ -199,7 +199,7 @@ module Crud
199
199
  end
200
200
 
201
201
  find_all_#{plural_name}
202
- render :partial => 'sortable_list', :layout => false
202
+ render :partial => 'sortable_list', :layout => false, :locals => {:continue_reordering => params[:continue_reordering]}
203
203
  end
204
204
 
205
205
  # takes in a single branch and saves the nodes inside it
@@ -8,7 +8,7 @@
8
8
  :title => 'Edit this <%= $title_name.downcase %>' %>
9
9
  <%%= link_to refinery_icon_tag("delete.png"), admin_<%= singular_name %>_path(<%= singular_name %>),
10
10
  :confirm => 'Are you sure you want to remove this <%= $title_name.downcase %> forever?',
11
- :class => "cancel", :method => :delete,
11
+ :class => "cancel confirm-delete",
12
12
  :title => 'Remove this <%= $title_name.downcase %> forever' %>
13
13
  </span>
14
14
  <%%=h <%= singular_name %>.<%= attributes.first.name %> %> <span class="preview">&nbsp;</span>
@@ -1,2 +1,2 @@
1
1
  <%%= render :partial => '<%= singular_name %>', :collection => @<%= plural_name %> %>
2
- <%%= render :partial => "/shared/admin/sortable_list" %>
2
+ <%%= render :partial => "/shared/admin/sortable_list", :locals => {:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)} %>
@@ -2,23 +2,25 @@
2
2
 
3
3
  ## Introduction
4
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.
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
6
 
7
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
8
 
9
9
  ## The Refinery Generator
10
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.
11
+ The Refinery generator is a standard Rails generator that functions just like the scaffold generator. It allows you to quickly add new managed sections to the Refinery backend and get the front end views for free.
12
12
 
13
13
  To see how to use the generator run
14
14
 
15
15
  ruby script/generate refinery
16
+
17
+ Usage instructions should appear.
16
18
 
17
19
  ## Example of Using the Generator
18
20
 
19
- Let's say you have a client who has a range of products they want to show on their website.
21
+ Let's say you have a client who has a range of products they want to show on their website. You've considered using a few pages to manage the products but you've decided it would be much nicer if there was a separate place that had forms dedicated to managing products.
20
22
 
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.
23
+ 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
24
 
23
25
  So go to the root of your project and run
24
26
 
@@ -36,7 +38,7 @@ A new database migration has been added to add the products table in so run:
36
38
 
37
39
  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
40
 
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.
41
+ 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 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
42
 
41
43
  Now you have a fully managed products section in Refinery, nice.
42
44
 
@@ -89,9 +91,9 @@ This bit is important. It's where all the controllers are held to manage pages i
89
91
 
90
92
  end
91
93
 
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.
94
+ 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](http://github.com/resolve/refinerycms/blob/master/vendor/plugins/refinery/crud.md) which gives us all of these regular features out of the box.
93
95
 
94
- To read more about how crudify works, checkout the crudify.md file.
96
+ How crudify works is an entire topic of it's own. Checkout the [crudify documentation](http://github.com/resolve/refinerycms/blob/master/vendor/plugins/refinery/crud.md) to get an insight into how that works.
95
97
 
96
98
  ### app/views and app/helpers
97
99
 
@@ -103,7 +105,7 @@ Works exactly the same as ``config/routes.rb`` in your app except this routes fi
103
105
 
104
106
  ### rails/init.rb
105
107
 
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")
108
+ 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
109
 
108
110
  Refinery::Plugin.register do |plugin|
109
111
  plugin.title = "Pages"
@@ -117,7 +119,7 @@ This file runs when your site is started up. All is does is registers this plugi
117
119
  :updated_image => "page_edit.png"}
118
120
  end
119
121
 
120
- ## Getting your plugin to report activity in the dashboard
122
+ ## Getting your Plugin to Report Activity in the Dashboard
121
123
 
122
124
  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
125
 
@@ -143,9 +145,12 @@ Here's what the different activity options mean:
143
145
  # the name of the class we're watching.
144
146
 
145
147
  :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
+ # Just use "_edit" if you're not sure how this works.
149
+ #
150
+ # When it says "'About Us' page was updated about 4 hours ago", the page title "About Us"
151
+ # is linked to that page in a way we specify. So by setting "_edit" as a :url_prefix what
148
152
  # we're doing is making it link to the page that allows us to edit this page.
153
+ # So the next result is edit_admin_page_url(page)
149
154
 
150
155
  :title
151
156
  # which attribute on the :class should be in the activty message. In our case it's "title"
@@ -158,7 +163,7 @@ Here's what the different activity options mean:
158
163
  # depending on how you want that to look. You can specify the filename to any image you
159
164
  # want in the public/images/refinery/icons/ directory.
160
165
 
161
- ## Improving the URLs
166
+ ## Search Engine Optimisation: Improving the default URLs
162
167
 
163
168
  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
169
 
@@ -179,6 +184,8 @@ Now all the products in your database will have nice URLs.
179
184
 
180
185
  Refinery uses a standards compliant visual editor called [WYMeditor](http://www.wymeditor.org/)
181
186
 
187
+ _Note: When using the Refinery generator, if you apply a field type of "text" to any of your fields, they automatically load as a WYMEditor._
188
+
182
189
  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
190
 
184
191
  ### Example
@@ -3,18 +3,20 @@ class Admin::DialogsController < Admin::BaseController
3
3
  layout 'admin_dialog'
4
4
 
5
5
  def show
6
- unless (@dialog_type = params[:id]).blank?
6
+ @dialog_type = params[:id].try(:downcase)
7
+
8
+ if @dialog_type
7
9
  @submit_button_text = "Insert"
8
10
 
9
11
  url_params = params.reject {|key, value| key =~ /(action)|(controller)/}
10
12
 
11
- if @dialog_type.downcase.split("&")[0] == "image"
13
+ if @dialog_type == 'image'
12
14
  @iframe_src = insert_admin_images_url(:dialog => true)
13
- elsif @dialog_type.downcase.split("&")[0] == "link"
15
+ elsif @dialog_type == 'link'
14
16
  @iframe_src = link_to_admin_pages_dialogs_url(url_params)
15
17
  end
16
18
 
17
- render :layout => false#"admin_dialog"
19
+ render :layout => false #"admin_dialog"
18
20
 
19
21
  else
20
22
  render :nothing => true
@@ -1,12 +1,12 @@
1
- <form class='wym_dialog wym_dialog_<%= @dialog_type.downcase.split("&")[0] %>'>
1
+ <form class='wym_dialog wym_dialog_<%= @dialog_type %>'>
2
2
  <input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='<%= @dialog_type %>' />
3
3
  <iframe src='<%= @iframe_src %>' id='dialog_frame' frameborder='0'></iframe>
4
4
  <div class='wym_hideables'>
5
- <% if @dialog_type.downcase.split("&")[0] == "image" %>
5
+ <% if @dialog_type == "image" %>
6
6
  <input type='text' id='wym_src' class='wym_src' value='' size='40' />
7
7
  <input type='text' id='wym_alt' class='wym_alt' value='' size='40' />
8
8
  <input type='text' id='wym_title' class='wym_title' value='' size='40' />
9
- <% elsif @dialog_type.downcase.split("&")[0] == "link" %>
9
+ <% elsif @dialog_type == "link" %>
10
10
  <input type='text' id='wym_href' class='wym_href' value='' size='40' />
11
11
  <input type='text' id='wym_title' class='wym_title' value='' size='40' />
12
12
  <input type='text' id='wym_target' class='wym_target' value='' size='40' />
@@ -1,26 +1,19 @@
1
+ <% use_caching = RefinerySetting.find_or_set(:use_resource_caching, false) -%>
1
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
3
  <html xmlns="http://www.w3.org/1999/xhtml">
3
4
  <head>
4
5
  <%= stylesheet_link_tag 'refinery/refinery' %>
5
- <% unless local_request? %>
6
+ <% if (using_google_libs = RefinerySetting.find_or_set(:use_google_ajax_libraries, true)) and !local_request? -%>
6
7
  <script type='text/javascript' src="http://www.google.com/jsapi"></script>
7
8
  <script type='text/javascript'>
8
- google.load("prototype", "1.6");
9
- google.load("scriptaculous", "1.8.2");
9
+ google.load("jquery", "1.4");
10
+ google.load("jqueryui", "1.8");
10
11
  </script>
11
- <% else %>
12
- <%= javascript_include_tag "prototype", "scriptaculous" %>
13
12
  <% end %>
14
- <%= javascript_include_tag "fastinit", "refinery/tooltips", "refinery/dialog" %>
13
+ <%= javascript_include_tag('jquery.js', 'jquery-ui-1.8rc1.min.js', :cache => (use_caching ? "cache/libraries" : false)) if !using_google_libs or local_request? %>
14
+ <%= javascript_include_tag 'refinery/admin', :cache => (use_caching ? "cache/admin_dialog" : false) %>
15
15
  <%= yield :head %>
16
- <%= "<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>" if RefinerySetting.find_or_set(:show_firebug_lite, false) == true %>
17
- <% if @flash %>
18
- <script type='text/javascript'>
19
- document.observe('dom:loaded', function() {
20
- $('flash').appear();
21
- });
22
- </script>
23
- <% end %>
16
+ <%= javascript_include_tag "http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js" if RefinerySetting.find_or_set(:show_firebug_lite, false) -%>
24
17
  </head>
25
18
  <body id='dialog_container' class='dialog'>
26
19
  <div id="flash_container">
@@ -5,7 +5,7 @@
5
5
  :title => 'Edit this setting' %>
6
6
  <%= link_to refinery_icon_tag("delete.png"), admin_refinery_setting_path(refinery_setting),
7
7
  :confirm => 'Are you sure you want to remove this setting forever?',
8
- :class => "cancel", :method => :delete,
8
+ :class => "cancel confirm-delete",
9
9
  :title => 'Remove this setting forever' if refinery_setting.destroyable %>
10
10
  </span>
11
11
  <%=h refinery_setting.name.titleize %> <span class="preview">- <%=h truncate(refinery_setting.value.to_s, :length => 40) %></span>
@@ -2,4 +2,54 @@
2
2
 
3
3
  ![Refinery Settings](http://refinerycms.com/system/images/0000/0666/settings.png)
4
4
 
5
- need to add info in here about how to use a setting in your plugin.
5
+ ## About
6
+
7
+ Refinery comes out of the box with a full settings area that is populated with smart defaults to avoid configuration.
8
+
9
+ ## Settings of Interest
10
+
11
+ Here's an overview of what comes out of the box
12
+
13
+ ### Google Analytics
14
+
15
+ Just edit the setting called "Analytics Page Code" and enter just your account number. It will look something like this
16
+
17
+ UA-XXXXXX-X
18
+
19
+ Save this and Refinery will automatically note you have set the page code up and start rendering it on the front end so tracking can begin.
20
+
21
+ ### Firebug Lite Support
22
+
23
+ [Firebug lite](http://getfirebug.com/lite) is fantastic for debugging your site in Internet Explorer.
24
+
25
+ Set the 'Show Firebug Lite' setting to ``true`` and you'll be able to debug your views in Internet Explorer in no time.
26
+
27
+ _Note: you'll want to turn this off once your site is live_
28
+
29
+ ### Use Google Ajax Libraries
30
+
31
+ This setting will automatically change your AJAX libraries to use the ones delivered by Google's CDN (Content Delivery Network) which means your Javascript will be cached and delivery as quickly as possible.
32
+
33
+ ## How do I Make my Own Settings?
34
+
35
+ Settings can be really useful, especially when you have custom display logic or new plugins that need to behave in different ways.
36
+
37
+ To best explain how settings work let's use an example. Say you have a client who has a display in a local trade show every year and 2 months before the trade show they want to display a little banner in the header of all pages.
38
+
39
+ But once the trade show is finsihed, the client needs to be able to hide it again until next year. This is what my ``application.html.erb`` file might look like:
40
+
41
+ ...
42
+ <div id='header'>
43
+ <h1>My Company</h1>
44
+
45
+ <% if RefinerySetting.find_or_set(:show_trade_show_banner, false) %>
46
+ <%= image_tag ('trade-show-banner.jpg') %>
47
+ <% end %>
48
+ </div>
49
+ ...
50
+
51
+ The following will automatically create a new Refinery setting called "show_trade_show_banner" and default it to ``false``. If that setting already exists, it just reads in what the current value is.
52
+
53
+ So as you can see this is quite clever because you can quickly define new settings and their defaults right from the view as you need them.
54
+
55
+ This setting would then show up in the backend in the 'Settings' area where the client could change the value as their trade show approaches. Easy as pie!
@@ -1,9 +1,10 @@
1
1
  class Admin::ResourcesController < Admin::BaseController
2
2
 
3
3
  crudify :resource, :order => "updated_at DESC"
4
+ before_filter :init_dialog
4
5
 
5
6
  def new
6
- @resource = Resource.new
7
+ @resource = Resource.new unless @resource.present?
7
8
 
8
9
  @url_override = admin_resources_url(:dialog => from_dialog?)
9
10
  end
@@ -20,6 +21,7 @@ class Admin::ResourcesController < Admin::BaseController
20
21
  render :text => "<script type='text/javascript'>parent.window.location = '#{admin_resources_url}';</script>"
21
22
  end
22
23
  else
24
+ self.new # important for dialogs
23
25
  render :action => 'new'
24
26
  end
25
27
  else
@@ -51,16 +53,8 @@ class Admin::ResourcesController < Admin::BaseController
51
53
 
52
54
  def insert
53
55
  self.new if @resource.nil?
54
- @dialog = from_dialog?
55
- @thickbox = !params[:thickbox].blank?
56
- @field = params[:field]
57
- @update_resource = params[:update_resource]
58
- @update_text = params[:update_text]
59
- @thumbnail = params[:thumbnail]
60
- @callback = params[:callback]
61
- @conditions = params[:conditions]
62
- @current_link = params[:current_link]
63
- @url_override = admin_resources_url(:dialog => @dialog, :insert => true)
56
+
57
+ @url_override = admin_resources_url(:dialog => from_dialog?, :insert => true)
64
58
 
65
59
  unless params[:conditions].blank?
66
60
  extra_condition = params[:conditions].split(',')
@@ -77,6 +71,17 @@ class Admin::ResourcesController < Admin::BaseController
77
71
 
78
72
  protected
79
73
 
74
+ def init_dialog
75
+ @thickbox = params[:thickbox].present?
76
+ @field = params[:field]
77
+ @update_resource = params[:update_resource]
78
+ @update_text = params[:update_text]
79
+ @thumbnail = params[:thumbnail]
80
+ @callback = params[:callback]
81
+ @conditions = params[:conditions]
82
+ @current_link = params[:current_link]
83
+ end
84
+
80
85
  def paginate_resources(conditions={})
81
86
  @resources = Resource.paginate :page => (@paginate_page_number ||= params[:page]),
82
87
  :conditions => conditions,
@@ -13,7 +13,7 @@
13
13
 
14
14
  <%= render :partial => "/shared/admin/form_actions", :locals => {:f => f, :continue_editing => false} %>
15
15
 
16
- <% if @thickbox %>
16
+ <% if @thickbox -%>
17
17
  <input type='hidden' name='thickbox' value='<%= @thickbox %>' />
18
18
  <input type='hidden' name='field' value='<%= @field %>' />
19
19
  <input type='hidden' name='update_resource' value='<%= @update_resource %>' />
@@ -22,5 +22,12 @@
22
22
  <input type='hidden' name='callback' value='<%= @callback %>' />
23
23
  <input type='hidden' name='conditions' value='<%= @conditions %>' />
24
24
  <input type='hidden' name='current_link' value='<%= @current_link %>' />
25
- <% end %>
25
+ <% end -%>
26
26
  <% end -%>
27
+ <% content_for :head do %>
28
+ <script type='text/javascript'>
29
+ $(document).ready(function(){
30
+ link_dialog.init();
31
+ });
32
+ </script>
33
+ <% end if from_dialog? %>
@@ -5,9 +5,7 @@
5
5
  :title => "Download this file (#{number_to_human_size(resource.size)})" %>
6
6
  <%= link_to refinery_icon_tag('application_edit.png'), edit_admin_resource_url(resource),
7
7
  :title => "Edit this file" %>
8
- <%= link_to refinery_icon_tag('delete.png'), admin_resource_path(resource),
9
- :confirm => "Are you sure you want to delete '#{resource.title}'?",
10
- :class => "cancel", :method => :delete,
8
+ <%= link_to refinery_icon_tag('delete.png'), admin_resource_path(resource), :class => "cancel confirm-delete",
11
9
  :title => "Remove this file forever" %>
12
10
  </span>
13
11
  <%=h resource.title %>
@@ -4,7 +4,7 @@
4
4
  <%= render :partial => "/shared/admin/search", :locals => {:url => admin_resources_url} %>
5
5
  </li>
6
6
  <li>
7
- <%= link_to "Upload New File", new_admin_resource_url, :class => "add_icon" %>
7
+ <%= link_to "Upload New File", new_admin_resource_url(:dialog => true, :width => 600, :height => 300), :class => "add_icon" %>
8
8
  </li>
9
9
  </ul>
10
10
  </div>
@@ -38,4 +38,4 @@
38
38
  </p>
39
39
  <% end -%>
40
40
  <% end %>
41
- </div>
41
+ </div>
@@ -29,7 +29,11 @@
29
29
  </ul>
30
30
  </div>
31
31
  </div>
32
- <%= will_paginate @resources, :previous_label => '&laquo; Previous', :next_label => 'Next &raquo;', :renderer => Refinery::LinkRenderer, :url => {:controller => "admin/resources", :action => "insert", :dialog => @dialog} unless @thickbox %>
32
+ <%= will_paginate @resources,
33
+ :previous_label => '&laquo; Previous',
34
+ :next_label => 'Next &raquo;',
35
+ :renderer => Refinery::LinkRenderer,
36
+ :url => {:controller => "admin/resources", :action => "insert", :dialog => from_dialog?} unless @thickbox %>
33
37
  </div>
34
38
  <% end %>
35
39
  <div id='upload_resource_area' class='dialog_area' <%= "style='display:none;'" if @resources.empty? %>>
@@ -43,68 +47,18 @@
43
47
  or
44
48
  <%= link_to "Cancel", "", :id => "cancel_button", :class => "close_dialog" %>
45
49
 
46
- <%= will_paginate @resources, :previous_label => '&laquo; Previous', :next_label => 'Next &raquo;', :renderer => Refinery::LinkRenderer, :url => {:controller => "admin/resources", :action => "insert", :dialog => @dialog } %>
50
+ <%= will_paginate @resources,
51
+ :previous_label => '&laquo; Previous',
52
+ :next_label => 'Next &raquo;',
53
+ :renderer => Refinery::LinkRenderer,
54
+ :url => {:controller => "admin/resources", :action => "insert", :dialog => from_dialog? } %>
47
55
  </div>
48
56
  <% end %>
57
+
49
58
  <% content_for :head do %>
50
- <%= javascript_include_tag 'refinery/parse_url' %>
51
59
  <script type='text/javascript'>
52
- set_resource = function(anchor)
53
- {
54
- if (anchor != null) {
55
- $$('#existing_resource_area_content ul li.linked').each(function(linked)
56
- {
57
- $(linked).removeClassName('linked');
58
- });
59
- $(anchor.parentNode).addClassName('linked');
60
- }
61
- }
62
-
63
- FastInit.addOnLoad(function()
64
- {
65
- <% unless @resource_id.nil? %>
66
- set_resource($('resource_<%= @resource_id %>'));
67
- <% end %>
68
- $$('#existing_resource_area_content ul li a').each(function(anchor)
69
- {
70
- anchor.observe('click', function(e){set_resource(this);e.preventDefault()});
71
- });
72
-
73
- <% if @thickbox %>
74
- $('dialog-form-actions').down('#submit_button').observe('click', function(e)
75
- {
76
- linked = null;
77
- $$('#existing_resource_area_content ul li.linked a').each(function(linked_anchor)
78
- {
79
- linked = linked_anchor;
80
- });
81
- if (linked != null)
82
- {
83
- <% unless @field.blank? %>
84
- if ((field = parent.document.getElementById('<%= @field %>')) != null)
85
- {
86
- field.value = linked.id.replace("resource_", "");
87
- }
88
- if ((resource = parent.document.getElementById('<%= @update_resource %>')) != null)
89
- {
90
- resourceUrl = parseURL(linked.href);
91
- relevant_href = resourceUrl.pathname;
92
- // Add any alternate resource stores that need a absolute URL in the regex below
93
- if( resourceUrl.hostname.match(/s3.amazonaws.com/) ) {
94
- relevant_href = resourceUrl.protocol + '//' + resourceUrl.host + relevant_href;
95
- }
96
- resource.href = relevant_href;
97
- }
98
- if ((text = parent.document.getElementById('<%= @update_text %>')) != null) {
99
- text.innerHTML = linked.innerHTML;
100
- }
101
- <% end %>
102
- <%= "self.parent.#{@callback}();" unless @callback.blank? %>
103
- self.parent.tb_remove();
104
- }
105
- e.stop();
106
- });
107
- <% end %>
60
+ $(document).ready(function(){
61
+ link_dialog.init();
108
62
  });
109
63
  </script>
110
- <% end %>
64
+ <% end %>