refinerycms 0.9.6.2 → 0.9.6.3

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.
Files changed (30) hide show
  1. data/Rakefile +2 -2
  2. data/VERSION +1 -1
  3. data/config/preinitializer.rb +3 -3
  4. data/db/seeds.rb +1 -1
  5. data/lib/refinery_initializer.rb +1 -1
  6. data/public/javascripts/refinery/admin.js +62 -10
  7. data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +10 -10
  8. data/public/stylesheets/refinery/refinery.css +9 -0
  9. data/vendor/plugins/images/app/models/image.rb +14 -14
  10. data/vendor/plugins/inquiries/app/models/inquiry.rb +1 -1
  11. data/vendor/plugins/news/app/models/news_item.rb +2 -2
  12. data/vendor/plugins/pages/app/models/page.rb +23 -23
  13. data/vendor/plugins/pages/app/models/page_part.rb +1 -1
  14. data/vendor/plugins/refinery/app/views/admin/_head.html.erb +0 -1
  15. data/vendor/plugins/refinery/app/views/shared/_head.html.erb +3 -2
  16. data/vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb +25 -13
  17. data/vendor/plugins/refinery/lib/generators/refinery/templates/model.rb +1 -1
  18. data/vendor/plugins/refinery/lib/refinery/application_controller.rb +1 -1
  19. data/vendor/plugins/refinery/lib/refinery/application_helper.rb +52 -26
  20. data/vendor/plugins/refinery/lib/refinery/initializer.rb +2 -3
  21. data/vendor/plugins/refinery/lib/tasks/refinery.rake +4 -4
  22. data/vendor/plugins/refinery/plugins.md +1 -1
  23. data/vendor/plugins/refinery/rails/init.rb +1 -1
  24. data/vendor/plugins/resources/app/models/resource.rb +15 -16
  25. data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +2 -3
  26. data/vendor/plugins/themes/app/controllers/themes_controller.rb +9 -10
  27. data/vendor/plugins/themes/app/models/theme.rb +2 -2
  28. data/vendor/plugins/themes/config/routes.rb +3 -3
  29. data/vendor/plugins/themes/themes.md +2 -2
  30. metadata +2 -2
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ require 'tasks/rails'
17
17
 
18
18
  extra_rake_tasks = []
19
19
  # When running Refinery from a gem we lose the rake tasks, so add them back in:
20
- extra_rake_tasks << Dir[File.join(REFINERY_ROOT, %w(vendor plugins * ** tasks ** *.rake))].sort unless REFINERY_ROOT == RAILS_ROOT
20
+ extra_rake_tasks << Dir[File.join(REFINERY_ROOT, %w(vendor plugins * ** tasks ** *.rake))].sort unless REFINERY_ROOT.to_s == Rails.root.to_s
21
21
  # We also need to load in the rake tasks from gem plugins whether Refinery is a gem or not:
22
22
  extra_rake_tasks << $refinery_gem_plugin_lib_paths.collect {|path| Dir[File.join(%W(#{path} tasks ** *.rake))].sort} if defined?($refinery_gem_plugin_lib_paths) && !$refinery_gem_plugin_lib_paths.nil?
23
23
  extra_rake_tasks.flatten.compact.uniq.each {|rake| load rake }
@@ -45,7 +45,7 @@ begin
45
45
  namespace :bump do
46
46
  desc "Bump the gemspec by a build version."
47
47
  task :build => [:version_required, :version] do
48
- version = Jeweler::VersionHelper.new(RAILS_ROOT)
48
+ version = Jeweler::VersionHelper.new(Rails.root.to_s)
49
49
  version.update_to(version.major, version.minor, version.patch, ((version.build || 0).to_i + 1))
50
50
  version.write
51
51
  $stdout.puts "Updated version: #{version.to_s}"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.6.2
1
+ 0.9.6.3
@@ -1,6 +1,6 @@
1
1
  # pick the refinery root path
2
- if File.exist?("#{RAILS_ROOT}/lib/refinery_initializer.rb")
3
- require "#{RAILS_ROOT}/lib/refinery_initializer.rb"
2
+ if File.exist?(File.join(%W(#{RAILS_ROOT} lib refinery_initializer.rb)))
3
+ require File.join(%W(#{RAILS_ROOT} lib refinery_initializer.rb))
4
4
  else
5
5
  require 'rubygems'
6
6
  version = if defined? REFINERY_GEM_VERSION
@@ -21,7 +21,7 @@ else
21
21
  end
22
22
 
23
23
 
24
- REFINERY_ROOT = RAILS_ROOT unless defined? REFINERY_ROOT
24
+ REFINERY_ROOT = Rails.root.to_s unless defined? REFINERY_ROOT
25
25
 
26
26
  # Set to true in your environment specific file (e.g. production.rb) to use Amazon's Simple
27
27
  # Storage Service instead of the default file system for resources and images
@@ -118,7 +118,7 @@ Page.create(:title => "Down for maintenance",
118
118
  })
119
119
 
120
120
  # Install default themes.
121
- FileUtils::mkdir File.join(%W(#{RAILS_ROOT} themes)) unless File.directory? File.join(%W(#{RAILS_ROOT} themes))
121
+ FileUtils::mkdir Rails.root.join(themes) unless Rails.root.join("themes").directory?
122
122
  Dir[File.join(%W(#{REFINERY_ROOT} themes *.zip))].each do |theme|
123
123
  Theme.create(:uploaded_data => {
124
124
  "size" => File.size(theme),
@@ -6,4 +6,4 @@ unless REFINERY_ROOT == RAILS_ROOT # e.g. only if we're in a gem.
6
6
 
7
7
  require 'refinery'
8
8
  require 'refinery/initializer'
9
- end
9
+ end
@@ -35,15 +35,16 @@ init_modal_dialogs = function(){
35
35
  $('a[href*="dialog=true"]').each(function(i, anchor)
36
36
  {
37
37
  $(anchor).click(function(e){
38
- iframe = $("<iframe id='dialog_iframe' src='" + $(this).attr('href') + "'></iframe>");
39
- iframe.dialog({
38
+ $("<iframe id='dialog_iframe' src='" + $(this).attr('href') + "'></iframe>").dialog({
40
39
  title: $(anchor).attr('title') || $(anchor).attr('name') || $(anchor).html() || null,
41
40
  modal: true,
42
41
  resizable: false,
43
42
  autoOpen: true,
44
43
  width: (parseInt($(anchor.href.match("width=([0-9]*)")).last().get(0))||928),
45
- height: (parseInt($(anchor.href.match("height=([0-9]*)")).last().get(0))||473)
44
+ height: (parseInt($(anchor.href.match("height=([0-9]*)")).last().get(0))||473),
45
+ beforeclose: function(){$(document.body).removeClass('hide-overflow')}
46
46
  });
47
+ $(document.body).addClass('hide-overflow');
47
48
  e.preventDefault();
48
49
  });
49
50
  });
@@ -143,6 +144,7 @@ var link_dialog = {
143
144
  this.test_url = test_url;
144
145
  this.test_email = test_email;
145
146
  this.init_tabs();
147
+ this.init_resources_submit();
146
148
  this.init_close();
147
149
  this.page_tab();
148
150
  this.web_tab();
@@ -161,6 +163,41 @@ var link_dialog = {
161
163
  link_dialog.switch_area(selected);
162
164
  },
163
165
 
166
+ init_resources_submit: function(){
167
+ $('#dialog-form-actions #submit_button').click(function(e){
168
+ e.preventDefault();
169
+ if((resource_selected = $('#existing_resource_area_content ul li.linked a')).length > 0) {
170
+ resourceUrl = parseURL(resource_selected.attr('href'));
171
+ relevant_href = resourceUrl.pathname;
172
+ if (resourceUrl.protocol == "" && resourceUrl.hostname == "system") {
173
+ relevant_href = "/system" + relevant_href;
174
+ }
175
+
176
+ // Add any alternate resource stores that need a absolute URL in the regex below
177
+ if( resourceUrl.hostname.match(/s3.amazonaws.com/) ) {
178
+ relevant_href = resourceUrl.protocol + '//' + resourceUrl.host + relevant_href;
179
+ }
180
+
181
+ if (typeof(resource_picker.callback) == "function") {
182
+ resource_picker.callback({
183
+ id: resource_selected.attr('id').replace("resource_", "")
184
+ , href: relevant_href
185
+ , html: resource_selected.html()
186
+ });
187
+ }
188
+ }
189
+
190
+ if(parent && typeof(parent.tb_remove) == "function"){
191
+ parent.tb_remove();
192
+ }
193
+ });
194
+
195
+ $('#dialog-form-actions #cancel_button').click(function(e){
196
+ e.preventDefault();
197
+ parent.tb_remove();
198
+ });
199
+ },
200
+
164
201
  init_close: function(){
165
202
  $('#TB_title .close_dialog, #dialog_container .close_dialog').click(function(e) {
166
203
  e.preventDefault();
@@ -235,7 +272,7 @@ var link_dialog = {
235
272
 
236
273
  },
237
274
 
238
- email_tab: function(){
275
+ email_tab: function() {
239
276
  $('#email_address_text, #email_default_subject_text, #email_default_body_text').change(function(e){
240
277
  var default_subject = $('#email_default_subject_text').val(),
241
278
  default_body = $('#email_default_body_text').val(),
@@ -272,14 +309,21 @@ var link_dialog = {
272
309
  });
273
310
  },
274
311
 
275
- update_parent: function(url, title, target){
276
- parent.document.getElementById('wym_href').value = url;
277
- parent.document.getElementById('wym_title').value = title;
278
- parent.document.getElementById('wym_target').value = target || '';
312
+ update_parent: function(url, title, target) {
313
+ if (parent != null) {
314
+ if ((wym_href = parent.document.getElementById('wym_href')) != null) {
315
+ wym_href.value = url;
316
+ }
317
+ if ((wym_title = parent.document.getElementById('wym_title')) != null) {
318
+ wym_title.value = title;
319
+ }
320
+ if ((wym_target = parent.document.getElementById('wym_target')) != null) {
321
+ wym_target.value = target || "";
322
+ }
323
+ }
279
324
  }
280
325
  }
281
326
 
282
-
283
327
  var page_options = {
284
328
  init: function(enable_parts, new_part_url, del_part_url){
285
329
  this.enable_parts = enable_parts;
@@ -513,7 +557,7 @@ var list_reorder = {
513
557
  , 'items': 'li'
514
558
  , 'axis': 'y'
515
559
  });
516
-
560
+
517
561
  $('#reorder_action').hide();
518
562
  $('#reorder_action_done').show();
519
563
  }
@@ -596,6 +640,14 @@ var image_picker = {
596
640
  }
597
641
  }
598
642
 
643
+ var resource_picker = {
644
+ callback: null
645
+
646
+ , init: function(callback) {
647
+ this.callback = callback;
648
+ }
649
+ }
650
+
599
651
  //parse a URL to form an object of properties
600
652
  parseURL = function(url)
601
653
  {
@@ -1365,7 +1365,7 @@ WYMeditor.editor.prototype.paste = function(sData) {
1365
1365
  wym.format_block();
1366
1366
 
1367
1367
  var sTmp;
1368
- replaceable = jQuery(wym._doc.body).find('#replace_me_with_' + wym._current_unique_stamp);
1368
+ replaceable = $(wym._doc.body).find('#replace_me_with_' + wym._current_unique_stamp);
1369
1369
 
1370
1370
  // replaceable doesn't actually get replaced here, it's just used as a marker for where the cursor was.
1371
1371
  var container = replaceable.get(0) || this.selected();
@@ -1380,10 +1380,10 @@ WYMeditor.editor.prototype.paste = function(sData) {
1380
1380
  sTmp = aP[x];
1381
1381
  //simple newlines are replaced by a break
1382
1382
  sTmp = sTmp.replace(rExp, "<br />");
1383
- if (x == 0 && jQuery(container).html().replace(/<br\ ?\/?>/, "").length == 0) {
1384
- jQuery(container).html(sTmp);
1383
+ if (x == 0 && $(container).html().replace(/<br\ ?\/?>/, "").length == 0) {
1384
+ $(container).html(sTmp);
1385
1385
  } else {
1386
- jQuery(container).after("<p>" + sTmp + "</p>");
1386
+ $(container).after("<p>" + sTmp + "</p>");
1387
1387
  }
1388
1388
  }
1389
1389
  } else {
@@ -1391,10 +1391,10 @@ WYMeditor.editor.prototype.paste = function(sData) {
1391
1391
  sTmp = aP[x];
1392
1392
  //simple newlines are replaced by a break
1393
1393
  sTmp = sTmp.replace(rExp, "<br />");
1394
- if (x == 0 && jQuery(container).html().replace(/<br\ ?\/?>/, "").length == 0) {
1395
- jQuery(container).html(sTmp);
1394
+ if (x == 0 && $(container).html().replace(/<br\ ?\/?>/, "").length == 0) {
1395
+ $(container).html(sTmp);
1396
1396
  } else {
1397
- jQuery(wym._doc.body).append("<p>" + sTmp + "</p>");
1397
+ $(wym._doc.body).append("<p>" + sTmp + "</p>");
1398
1398
  }
1399
1399
  }
1400
1400
  }
@@ -4312,7 +4312,7 @@ WYMeditor.WymClassMozilla.prototype.initIframe = function(iframe) {
4312
4312
  $(this._doc).bind("keyup", this.keyup);
4313
4313
 
4314
4314
  //bind editor paste events
4315
- jQuery(this._doc).bind("paste", this.intercept_paste);
4315
+ $(this._doc).bind("paste", this.intercept_paste);
4316
4316
 
4317
4317
  //bind editor focus events (used to reset designmode - Gecko bug)
4318
4318
  $(this._doc).bind("focus", this.enableDesignMode);
@@ -4596,7 +4596,7 @@ WYMeditor.WymClassOpera.prototype.initIframe = function(iframe) {
4596
4596
  $(this._doc).bind("keyup", this.keyup);
4597
4597
 
4598
4598
  // bind paste events for when this is supported.
4599
- jQuery(this._doc).bind("paste", this.intercept_paste);
4599
+ $(this._doc).bind("paste", this.intercept_paste);
4600
4600
 
4601
4601
  //post-init functions
4602
4602
  if($.isFunction(this._options.postInit)) this._options.postInit(this);
@@ -4725,7 +4725,7 @@ WYMeditor.WymClassSafari.prototype.initIframe = function(iframe) {
4725
4725
  $(this._doc).bind("keyup", this.keyup);
4726
4726
 
4727
4727
  // bind paste events
4728
- jQuery(this._doc).bind("paste", this.intercept_paste);
4728
+ $(this._doc).bind("paste", this.intercept_paste);
4729
4729
 
4730
4730
  //post-init functions
4731
4731
  if($.isFunction(this._options.postInit)) this._options.postInit(this);
@@ -1217,4 +1217,13 @@ ul#plugins li {
1217
1217
  margin-top:1px;
1218
1218
  _margin-bottom:1px;
1219
1219
  width: 100% !important;
1220
+ }
1221
+
1222
+ .hide-overflow {
1223
+ overflow: hidden;
1224
+ }
1225
+ #remove_resource {
1226
+ margin-top:8px;
1227
+ display:inline-block;
1228
+ width:auto;
1220
1229
  }
@@ -1,5 +1,5 @@
1
1
  class Image < ActiveRecord::Base
2
-
2
+
3
3
  # Docs for attachment_fu http://github.com/technoweenie/attachment_fu
4
4
  has_attachment :content_type => :image,
5
5
  :storage => (USE_S3_BACKEND ? :s3 : :file_system),
@@ -7,31 +7,31 @@ class Image < ActiveRecord::Base
7
7
  :processor => 'Rmagick',
8
8
  :thumbnails => ((((thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})).is_a?(Hash) ? thumbnails : (RefinerySetting[:image_thumbnails] = {}))) rescue {}),
9
9
  :max_size => 50.megabytes
10
-
10
+
11
+ validates_as_attachment
12
+
11
13
  # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
12
14
  acts_as_indexed :fields => [:title],
13
- :index_file => [RAILS_ROOT,"tmp","index"]
15
+ :index_file => [Rails.root.to_s, "tmp", "index"]
14
16
 
15
17
  named_scope :thumbnails, :conditions => "parent_id NOT NULL"
16
18
  named_scope :originals, :conditions => {:parent_id => nil}
17
-
19
+
18
20
  # when a dialog pops up with images, how many images per page should there be
19
21
  PAGES_PER_DIALOG = 18
20
-
22
+
21
23
  # when listing images out in the admin area, how many images should show per page
22
24
  PAGES_PER_ADMIN_INDEX = 20
23
-
24
- validates_as_attachment
25
-
26
- # Returns a titleized version of the filename
27
- # my_file.jpg returns My File
28
- def title
29
- self.filename.gsub(/\.\w+$/, '').titleize
30
- end
31
-
25
+
32
26
  # How many images per page should be displayed?
33
27
  def self.per_page(dialog = false)
34
28
  dialog ? PAGES_PER_DIALOG : PAGES_PER_ADMIN_INDEX
35
29
  end
30
+
31
+ # Returns a titleized version of the filename
32
+ # my_file.jpg returns My File
33
+ def title
34
+ self.filename.gsub(/\.\w+$/, '').titleize
35
+ end
36
36
 
37
37
  end
@@ -6,7 +6,7 @@ class Inquiry < ActiveRecord::Base
6
6
  :message => 'must be valid'
7
7
 
8
8
  acts_as_indexed :fields => [:name, :email, :message, :phone],
9
- :index_file => [RAILS_ROOT,"tmp","index"]
9
+ :index_file => [Rails.root.to_s, "tmp", "index"]
10
10
 
11
11
  def self.closed
12
12
  find_all_by_open(false, :order => "created_at DESC")
@@ -3,10 +3,10 @@ class NewsItem < ActiveRecord::Base
3
3
  validates_presence_of :title, :content
4
4
  alias_attribute :content, :body
5
5
 
6
- has_friendly_id :title, :use_slug => true, :strip_diacritics => true
6
+ has_friendly_id :title, :use_slug => true
7
7
 
8
8
  acts_as_indexed :fields => [:title, :body],
9
- :index_file => [RAILS_ROOT,"tmp","index"]
9
+ :index_file => [Rails.root.to_s, "tmp", "index"]
10
10
 
11
11
  def self.latest(amount = 10)
12
12
  find(:all, :order => "publish_date DESC", :limit => amount,
@@ -3,25 +3,25 @@ class Page < ActiveRecord::Base
3
3
  validates_presence_of :title
4
4
 
5
5
  acts_as_tree :order => "position ASC", :include => [:children, :slugs]
6
-
6
+
7
7
  # Docs for friendly_id http://github.com/norman/friendly_id
8
- has_friendly_id :title, :use_slug => true, :strip_diacritics => true
8
+ has_friendly_id :title, :use_slug => true
9
9
 
10
10
  has_many :parts, :class_name => "PagePart", :order => "position ASC"
11
11
  accepts_nested_attributes_for :parts, :allow_destroy => true
12
-
12
+
13
13
  # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
14
14
  acts_as_indexed :fields => [:title, :meta_keywords, :meta_description, :custom_title, :browser_title, :all_page_part_content],
15
- :index_file => %W(#{RAILS_ROOT} tmp index)
15
+ :index_file => [Rails.root.to_s, "tmp", "index"]
16
16
 
17
17
  before_destroy :deletable?
18
18
 
19
19
  # when a dialog pops up to link to a page, how many pages per page should there be
20
20
  PAGES_PER_DIALOG = 14
21
-
21
+
22
22
  # when listing pages out in the admin area, how many pages should show per page
23
23
  PAGES_PER_ADMIN_INDEX = 20
24
-
24
+
25
25
  # when collecting the pages path how is each of the pages seperated?
26
26
  PATH_SEPERATOR = " - "
27
27
 
@@ -45,7 +45,7 @@ class Page < ActiveRecord::Base
45
45
  puts "unset .menu_match," if self.menu_match.present?
46
46
  puts "set .deletable to true" unless self.deletable
47
47
  end
48
-
48
+
49
49
  return false
50
50
  end
51
51
  end
@@ -75,11 +75,11 @@ class Page < ActiveRecord::Base
75
75
  self.title
76
76
  end
77
77
  end
78
-
78
+
79
79
  # When this page is rendered in the navigation, where should it link?
80
80
  # If a custom "link_url" is set, it uses that otherwise it defaults to a normal page URL.
81
81
  # The "link_url" is often used to link to a plugin rather than a page.
82
- #
82
+ #
83
83
  # For example if I had a "Contact Us" page I don't want it to just render a contact us page
84
84
  # I want it to show the Inquiries form so I can collect inquiries. So I would set the "link_url"
85
85
  # to "/inquiries/new"
@@ -90,29 +90,29 @@ class Page < ActiveRecord::Base
90
90
  "/pages/#{self.to_param}"
91
91
  end
92
92
  end
93
-
93
+
94
94
  # Returns true if this page is "published"
95
95
  def live?
96
96
  not self.draft?
97
97
  end
98
-
99
- # Return true if this page can be shown in the navigation. If it's a draft or is set to not show in the menu it will return false.
98
+
99
+ # Return true if this page can be shown in the navigation.
100
+ # If it's a draft or is set to not show in the menu it will return false.
101
+ # If any of the page's ancestors aren't to be shown in the menu then this page is not either.
100
102
  def in_menu?
101
- is_in_menu = self.live? && self.show_in_menu?
102
- self.ancestors.each {|a| is_in_menu = false unless a.in_menu? }
103
- is_in_menu
103
+ self.live? && self.show_in_menu? && !self.ancestors.any? { |a| !a.in_menu? }
104
104
  end
105
-
105
+
106
106
  # Returns true if this page is the home page or links to it.
107
107
  def home?
108
108
  self.link_url == "/"
109
109
  end
110
-
110
+
111
111
  # Returns all visible sibling pages that can be rendered for the menu
112
112
  def shown_siblings
113
113
  self.siblings.reject { |sibling| not sibling.in_menu? }
114
114
  end
115
-
115
+
116
116
  # Returns all the top level pages, usually to render the top level navigation.
117
117
  def self.top_level(include_children = false)
118
118
  include_associations = [:parts]
@@ -120,10 +120,10 @@ class Page < ActiveRecord::Base
120
120
  include_associations.push(:children) if include_children
121
121
  find_all_by_parent_id(nil,:conditions => {:show_in_menu => true, :draft => false}, :order => "position ASC", :include => include_associations)
122
122
  end
123
-
123
+
124
124
  # Accessor method to get a page part from a page.
125
125
  # Example:
126
- #
126
+ #
127
127
  # Page.first[:body]
128
128
  #
129
129
  # Will return the body page part of the first page.
@@ -139,13 +139,13 @@ class Page < ActiveRecord::Base
139
139
 
140
140
  super_value
141
141
  end
142
-
142
+
143
143
  # In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
144
144
  def title_with_meta
145
145
  title = self.title
146
146
  title << " <em>(hidden)</em>" unless self.show_in_menu?
147
147
  title << " <em>(draft)</em>" if self.draft?
148
-
148
+
149
149
  title.strip
150
150
  end
151
151
 
@@ -153,7 +153,7 @@ class Page < ActiveRecord::Base
153
153
  def all_page_part_content
154
154
  self.parts.collect {|p| p.body}.join(" ")
155
155
  end
156
-
156
+
157
157
  # Returns how many pages per page should there be when paginating pages
158
158
  def self.per_page(dialog = false)
159
159
  dialog ? PAGES_PER_DIALOG : PAGES_PER_ADMIN_INDEX
@@ -5,6 +5,6 @@ class PagePart < ActiveRecord::Base
5
5
  validates_presence_of :title
6
6
  alias_attribute :content, :body
7
7
 
8
- has_friendly_id :title, :use_slug => true, :strip_diacritics => true
8
+ has_friendly_id :title, :use_slug => true
9
9
 
10
10
  end
@@ -14,6 +14,5 @@
14
14
  <%= javascript_include_tag 'jquery', 'jquery-ui-1.8rc1.min.js', :cache => (use_caching ? "cache/libraries" : nil) if !using_google_libs or local_request? %>
15
15
  <%= javascript_include_tag 'admin', 'thickbox', 'wymeditor/jquery.refinery.wymeditor.js', 'refinery/boot_wym', 'refinery/admin', :cache => (use_caching ? "cache/admin" : false) %>
16
16
  <%= javascript_include_tag "http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js" if RefinerySetting.find_or_set(:show_firebug_lite, false) -%>
17
- <%= "<script type='text/javascript'>jQuery(document).ready(function(){ jQuery('#flash').fadeIn(550); });</script>" unless flash.empty? -%>
18
17
  <%= yield :head %>
19
18
  </head>
@@ -2,8 +2,9 @@
2
2
  <head>
3
3
  <title><%= browser_title(yield(:title)) %></title>
4
4
  <%= render :partial => 'shared/google_analytics' unless local_request? %>
5
- <%= stylesheet_link_tag "#{'theme/' if theme}application", "#{'theme/' if theme}formatting", "theme" %>
6
- <%= stylesheet_link_tag "#{'theme/' if theme}home" if home_page? %>
5
+ <%= stylesheet_link_tag "application", "formatting", :theme => theme %>
6
+ <%= stylesheet_link_tag "theme" %>
7
+ <%= stylesheet_link_tag "home", :theme => theme if home_page? %>
7
8
  <%= "<!--[if IE 7]>#{stylesheet_link_tag 'ie7'}<![endif]-->" if request.env['HTTP_USER_AGENT'] =~ /MSIE/ -%>
8
9
  <%= auto_discovery_link_tag(:rss, news_items_url(:format => 'rss')) %>
9
10
  <link rel="shortcut icon" href="/favicon.ico" />
@@ -1,40 +1,52 @@
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 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
- There is currently no <%= description ||= "resource" %> selected, click here to add one.
6
- </span>
7
- </a>
3
+ <%= link_to "<span id='no_resource_selected' #{"style='display: none;'" if resource.present?}>
4
+ There is currently no #{description ||= resource} selected, click here to add one.
5
+ </span>", insert_admin_resources_url(:dialog => true,
6
+ :thickbox => true,
7
+ :update_resource => 'current_resource',
8
+ :update_text => 'current_resource_text',
9
+ :callback => 'resource_changed',
10
+ :field => "#{f.object.class.name.underscore.downcase}_#{field}",
11
+ :current_link => "#{resource.public_filename if resource.present?}"),
12
+ :name => "Add #{(description ||= 'resource').titleize}",
13
+ :id => "current_resource_link"
14
+ %>
8
15
  <div id='current_resource_container' <%= "style='display:none'" unless resource.present? %>>
9
- Current <%= description ||= "resource" %>:
16
+ <span id='current_resource_tag'>Current <%= description ||= "resource" %>:</span>
10
17
  <span id='current_resource_text'>
11
18
  <%= "#{resource.title} (#{resource.public_filename})" if resource.present? %>
12
19
  </span>
13
20
  <br/>
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?}",
21
+ <%= link_to "#{refinery_icon_tag("page_white_put.png")} Download current #{description ||= "resource"} (<em>Opens in a new window</em>)", "#{resource.public_filename if resource.present?}",
15
22
  :id => "current_resource",
16
23
  :target => "_blank" %>
17
24
  </div>
18
25
  <br/>
19
26
  <%= link_to "Remove current #{description ||= "resource"}", "",
20
27
  :id => "remove_resource",
21
- :style => "margin-top:8px;display:inline-block;width:auto;#{"display:none;" if resource.nil?}" %>
28
+ :style => "#{"display:none;" unless resource.present?}" %>
22
29
  </div>
23
30
 
24
31
  <% content_for :head do %>
25
32
  <script type='text/javascript'>
26
- resource_changed = function() {
27
- $('#current_resource_link').attr('href', $('#current_resource_link').attr('href').replace(/current_link=([^&])*&/, "current_link=" + $('#current_resource').attr('href') + "&"));
33
+ resource_changed = function(callback_args) {
28
34
  $('#remove_resource').show();
29
35
  $('#current_resource_container').show();
30
36
  $('#no_resource_selected').hide();
37
+ $('iframe#dialog_iframe').dialog("close");
38
+ $('iframe#dialog_iframe').remove().parents(".ui-dialog").remove();
39
+ $('#<%= f.object.class.name.underscore.downcase %>_<%= field %>').val(callback_args.id);
40
+ $('#current_resource_link').attr('href', $('#current_resource_link').attr('href').replace(/current_link=([^&])*&/, "current_link=" + callback_args.href + "&"));
41
+ $("#current_resource").attr('href', callback_args.href);
42
+ $('#current_resource_text').html(callback_args.html);
31
43
  }
32
44
 
33
45
  $(document).ready(function(e) {
34
46
  $('#remove_resource').click(function(e) {
35
- $('#<%= f.object.class.name.underscore.downcase %>_<%= field %>').value = "";
47
+ $('#<%= f.object.class.name.underscore.downcase %>_<%= field %>').val("");
36
48
  $('#current_resource_container').hide();
37
- $('#current_resource_text').innerHTML = '';
49
+ $('#current_resource_text').html('');
38
50
  $('#no_resource_selected').show();
39
51
  $('#current_resource_link').attr('href', $('#current_resource_link').attr('href').replace(/current_link=([^&])*&/, "current_link=&"));
40
52
  $(this).hide();
@@ -42,4 +54,4 @@
42
54
  });
43
55
  });
44
56
  </script>
45
- <% end %>
57
+ <% end %>
@@ -1,7 +1,7 @@
1
1
  class <%= class_name %> < ActiveRecord::Base
2
2
 
3
3
  acts_as_indexed :fields => [:<%= attributes.collect{ |attribute| attribute.name if attribute.type.to_s =~ /string|text/ }.compact.uniq.join(", :") %>],
4
- :index_file => %W(#{RAILS_ROOT} tmp index)
4
+ :index_file => [Rails.root.to_s, "tmp", "index"]
5
5
 
6
6
  validates_presence_of :<%= attributes.first.name %>
7
7
  validates_uniqueness_of :<%= attributes.first.name %>
@@ -44,7 +44,7 @@ class Refinery::ApplicationController < ActionController::Base
44
44
  protected
45
45
 
46
46
  def setup_theme
47
- self.view_paths = ::ActionController::Base.view_paths.dup.unshift(File.join(%W(#{RAILS_ROOT} themes #{RefinerySetting[:theme]} views)))
47
+ self.view_paths = ::ActionController::Base.view_paths.dup.unshift(Rails.root.join("themes", RefinerySetting[:theme], "views").to_s)
48
48
  end
49
49
 
50
50
  def take_down_for_maintenance?
@@ -3,10 +3,6 @@ module Refinery::ApplicationHelper
3
3
 
4
4
  include Refinery::HtmlTruncationHelper
5
5
 
6
- def setup
7
- logger.warn("*** Refinery::ApplicationHelper::setup has now been deprecated from the Refinery API. ***")
8
- end
9
-
10
6
  def browser_title(yield_title=nil)
11
7
  [
12
8
  yield_title.present? ? yield_title : nil,
@@ -15,6 +11,47 @@ module Refinery::ApplicationHelper
15
11
  ].compact.join(" - ")
16
12
  end
17
13
 
14
+ # replace all system images with a thumbnail version of them (handy for all images inside a page part)
15
+ def content_fu(content, thumbnail)
16
+ content.scan(/\/system\/images([^\"\ ]*)/).flatten.each do |match|
17
+ parts = match.split(".")
18
+ extension = parts.pop
19
+ content.gsub!(match, "#{parts.join(".")}_#{thumbnail}.#{extension}")
20
+ end
21
+
22
+ return content
23
+ end
24
+
25
+ def descendant_page_selected?(page)
26
+ page.descendants.any? {|descendant| selected_page?(descendant) }
27
+ end
28
+
29
+ def image_fu(image, thumbnail = nil , options={})
30
+ if image.present?
31
+ image_thumbnail = image.thumbnails.detect {|t| t.thumbnail == thumbnail.to_s}
32
+ image_thumbnail = image unless image_thumbnail.present?
33
+ image_tag image_thumbnail.public_filename, {:alt => image.title, :width => image_thumbnail.width, :height => image_thumbnail.height}.merge!(options)
34
+ end
35
+ end
36
+
37
+ def image_tag(source, options={})
38
+ theme = (options.delete(:theme) == true)
39
+ tag = super
40
+ # inject /theme/ into the image tag src if this is themed.
41
+ tag.gsub!(/src=[\"|\']/) { |m| "#{m}/theme/" }.gsub!("//", "/") if theme
42
+
43
+ tag
44
+ end
45
+
46
+ def javascript_include_tag(*sources)
47
+ theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
48
+ tag = super
49
+ # inject /theme/ into the javascript include tag src if this is themed.
50
+ tag.gsub!(/\/javascripts\//, "/theme/javascripts/").gsub!(/theme=(.+?)\ /, '') if theme
51
+
52
+ tag
53
+ end
54
+
18
55
  # you can override the object used for the title by supplying options[:object]
19
56
  # this object must support custom_title_type if you want custom titles.
20
57
  def page_title(options = {})
@@ -64,36 +101,25 @@ module Refinery::ApplicationHelper
64
101
  end
65
102
  end
66
103
 
67
- def descendant_page_selected?(page)
68
- page.descendants.any? {|descendant| selected_page?(descendant) }
104
+ def refinery_icon_tag(filename, options = {})
105
+ image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge!(options)
69
106
  end
70
107
 
71
108
  def selected_page?(page)
72
109
  selected = current_page?(page) or (request.path =~ Regexp.new(page.menu_match) unless page.menu_match.blank?) or (request.path == page.link_url)
73
110
  end
74
111
 
75
- def image_fu(image, thumbnail = nil , options={})
76
- begin
77
- image_thumbnail = thumbnail.nil? ? image : image.thumbnails.collect {|t| t if t.thumbnail == thumbnail.to_s}.compact.first
78
- image_tag image_thumbnail.public_filename, {:alt => image.title, :width => image_thumbnail.width, :height => image_thumbnail.height}.merge!(options)
79
- rescue
80
- image_tag image.public_filename(thumbnail), {:alt => image.title}.merge!(options)
81
- end
82
- end
112
+ def stylesheet_link_tag(*sources)
113
+ theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
114
+ tag = super
115
+ # inject /theme/ into the stylesheet link tag href if this is themed.
116
+ tag.gsub!(/\/stylesheets\//, "/theme/stylesheets/").gsub!(/theme=(.+?)\ /, '') if theme
83
117
 
84
- def refinery_icon_tag(filename, options = {})
85
- image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge!(options)
118
+ tag
86
119
  end
87
120
 
88
- # replace all system images with a thumbnail version of them (handy for all images inside a page part)
89
- def content_fu(content, thumbnail)
90
- content.scan(/\/system\/images([^\"\ ]*)/).flatten.each do |match|
91
- parts = match.split(".")
92
- extension = parts.pop
93
- content.gsub!(match, "#{parts.join(".")}_#{thumbnail}.#{extension}")
94
- end
95
-
96
- return content
121
+ def setup
122
+ logger.warn("*** Refinery::ApplicationHelper::setup has now been deprecated from the Refinery API. ***")
97
123
  end
98
124
 
99
- end
125
+ end
@@ -1,6 +1,6 @@
1
1
  begin
2
2
  # Try to include the rails initializer. If this isn't in a gem, this will fail.
3
- require 'initializer' unless REFINERY_ROOT == RAILS_ROOT # A Refinery gem install's RAILS_ROOT is not the REFINERY_ROOT.
3
+ require 'initializer' unless REFINERY_ROOT == RAILS_ROOT # A Refinery gem install's Rails.root is not the REFINERY_ROOT.
4
4
  rescue LoadError => load_error
5
5
  end
6
6
 
@@ -21,7 +21,7 @@ module Refinery
21
21
  # add plugin lib paths to the $LOAD_PATH so that rake tasks etc. can be run when using a gem for refinery or gems for plugins.
22
22
  search_for = Regexp.new(File.join(%W(\( #{REFINERY_ROOT} vendor plugins \)? .+? lib)))
23
23
  paths = plugins.collect{ |plugin| plugin.load_paths }.flatten.reject{|path| path.scan(search_for).empty? or path.include?('/rails-') }
24
- paths = paths.reject{ |path| path.include?(REFINERY_ROOT) } if REFINERY_ROOT == RAILS_ROOT # superfluous when not in gem.
24
+ paths = paths.reject{ |path| path.include?(REFINERY_ROOT) } if REFINERY_ROOT == Rails.root.to_s # superfluous when not in gem.
25
25
  ($refinery_gem_plugin_lib_paths = paths).each do |path|
26
26
  $LOAD_PATH.unshift path
27
27
  end
@@ -34,7 +34,6 @@ module Refinery
34
34
  class Initializer < Rails::Initializer
35
35
  def self.run(command = :process, configuration = Configuration.new)
36
36
  Rails.configuration = configuration
37
- #configuration.reload_plugins = true if RAILS_ENV =~ /development/ and REFINERY_ROOT == RAILS_ROOT # seems to work, don't in gem.
38
37
  configuration.plugin_loader = Refinery::PluginLoader
39
38
  super
40
39
  end
@@ -4,8 +4,8 @@ namespace :refinery do
4
4
  task :override => :environment do
5
5
  dirs = ["app", "app/views", "app/views/layouts", "app/views/admin", "app/views/shared", "app/controllers", "app/models", "app/controllers/admin", "app/helpers", "app/helpers/admin"]
6
6
  dirs.each do |dir|
7
- dir = File.join([RAILS_ROOT] | dir.split('/'))
8
- Dir.mkdir dir unless File.directory? dir
7
+ dir = Rails.root.join(dir.split('/').join(File::SEPARATOR))
8
+ dir.mkdir unless dir.directory?
9
9
  end
10
10
  end
11
11
 
@@ -26,8 +26,8 @@ namespace :refinery do
26
26
  namespace :cache do
27
27
  desc "Eliminate existing cache files for javascript and stylesheet resources in default directories"
28
28
  task :clear => :environment do
29
- FileUtils.rm(Dir[File.join(RAILS_ROOT, %w(public javascripts cache [^.]*))])
30
- FileUtils.rm(Dir[File.join(RAILS_ROOT, %w(public stylesheets cache [^.]*))])
29
+ FileUtils.rm(Dir[Rails.root.join("public", "javascripts", "cache", "[^.]*")])
30
+ FileUtils.rm(Dir[Rails.root.join("public", "stylesheets", "cache", "[^.]*")])
31
31
  end
32
32
  end
33
33
 
@@ -169,7 +169,7 @@ In our example above we extended Refinery to manage a products area. The problem
169
169
 
170
170
  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:
171
171
 
172
- has_friendly_id :title, :use_slug => true, :strip_diacritics => true
172
+ has_friendly_id :title, :use_slug => true
173
173
 
174
174
  Note you want to change ``:title`` to the field which you want to show up in the URL.
175
175
 
@@ -9,6 +9,6 @@ end
9
9
  require_dependency 'refinery/form_helpers'
10
10
  require_dependency 'refinery/base_presenter'
11
11
 
12
- presenters_path = "#{RAILS_ROOT}/app/presenters/"
12
+ presenters_path = Rails.root.join("app", "presenters").to_s
13
13
  $LOAD_PATH << presenters_path
14
14
  ::ActiveSupport::Dependencies.load_paths << presenters_path
@@ -1,24 +1,25 @@
1
1
  class Resource < ActiveRecord::Base
2
2
 
3
+ # Docs for attachment_fu http://github.com/technoweenie/attachment_fu
3
4
  has_attachment :storage => (USE_S3_BACKEND ? :s3 : :file_system),
4
5
  :size => 0.kilobytes..50.megabytes,
5
6
  :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/resources')
6
7
 
8
+ validates_as_attachment
9
+
10
+ # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
7
11
  acts_as_indexed :fields => [:title, :type_of_content],
8
- :index_file => [RAILS_ROOT,"tmp","index"]
12
+ :index_file => [Rails.root.to_s, "tmp", "index"]
9
13
 
10
- def validate
11
- errors.add_to_base("You must choose a file to upload") unless self.filename
14
+ # when a dialog pops up with images, how many images per page should there be
15
+ PAGES_PER_DIALOG = 12
12
16
 
13
- unless self.filename.nil?
14
- [:size].each do |attr_name|
15
- enum = attachment_options[attr_name]
16
- unless enum.nil? || enum.include?(send(attr_name))
17
- errors.add_to_base("Files should be smaller than 50 MB in size")
18
- end
19
- end
20
- end
17
+ # when listing images out in the admin area, how many images should show per page
18
+ PAGES_PER_ADMIN_INDEX = 20
21
19
 
20
+ # How many images per page should be displayed?
21
+ def self.per_page(dialog = false)
22
+ dialog ? PAGES_PER_DIALOG : PAGES_PER_ADMIN_INDEX
22
23
  end
23
24
 
24
25
  # used for searching
@@ -26,12 +27,10 @@ class Resource < ActiveRecord::Base
26
27
  self.content_type.split("/").join(" ")
27
28
  end
28
29
 
30
+ # Returns a titleized version of the filename
31
+ # my_file.pdf returns My File
29
32
  def title
30
- (split_filename = self[:filename].split('.')).pop and return split_filename.join('.').titleize
31
- end
32
-
33
- def self.per_page(dialog = false)
34
- size = (dialog ? 12 : 20)
33
+ self.filename.gsub(/\.\w+$/, '').titleize
35
34
  end
36
35
 
37
36
  end
@@ -1,7 +1,7 @@
1
1
  <div class='clearfix'>
2
2
  <div id='dialog_menu_left'>
3
3
  <% unless @resources.empty? %>
4
- <span id='existing_resource_radio' class='radio'>
4
+ <span id='existing_resource_radio' class='radio<%= " selected_radio" if @resource.errors.empty? and @resources.size > 0 %>'>
5
5
  <input type='radio' name='resource_type' value='existing_resource' id='resource_type_existing' <%= "checked='true'" if @resource.errors.empty? %> />
6
6
  <label for='resource_type_existing' class='stripped'>Existing File</label>
7
7
  </span>
@@ -44,8 +44,6 @@
44
44
  <% if @thickbox %>
45
45
  <div id='dialog-form-actions' class='form-actions'>
46
46
  <%= submit_tag 'Insert', :id => "submit_button" %>
47
- or
48
- <%= link_to "Cancel", "", :id => "cancel_button", :class => "close_dialog" %>
49
47
 
50
48
  <%= will_paginate @resources,
51
49
  :previous_label => '&laquo; Previous',
@@ -59,6 +57,7 @@
59
57
  <script type='text/javascript'>
60
58
  $(document).ready(function(){
61
59
  link_dialog.init();
60
+ resource_picker.init(<%= @callback.present? ? "self.parent.#{@callback}" : "null" %>);
62
61
  });
63
62
  </script>
64
63
  <% end %>
@@ -1,28 +1,27 @@
1
1
  class ThemesController < ApplicationController
2
-
2
+
3
3
  def stylesheets
4
4
  render_theme_item(:stylesheets, params[:filepath])
5
- end
6
-
7
- def javascripts
5
+ end
6
+
7
+ def javascripts
8
8
  render_theme_item(:javascripts, params[:filepath])
9
9
  end
10
-
10
+
11
11
  def images
12
12
  render_theme_item(:images, params[:filepath])
13
13
  end
14
-
14
+
15
15
  protected
16
-
16
+
17
17
  def render_theme_item(type, relative_path)
18
- file_path = File.join(RAILS_ROOT, "themes", RefinerySetting[:theme], type.to_s, relative_path)
19
- if File.exists? file_path
18
+ if File.exist?(file_path = File.join(Rails.root, "themes", RefinerySetting[:theme], type.to_s, relative_path))
20
19
  send_file(file_path, :type => mime_for(relative_path), :disposition => 'inline', :stream => true)
21
20
  else
22
21
  return error_404
23
22
  end
24
23
  end
25
-
24
+
26
25
  def mime_for(filename)
27
26
  # could we use the built in Rails mime types to work this out?
28
27
  case filename.last.downcase
@@ -36,7 +36,7 @@ class Theme < ActiveRecord::Base
36
36
  end
37
37
 
38
38
  def theme_path
39
- File.join(RAILS_ROOT, "themes", folder_title)
39
+ Rails.root.join("themes", folder_title).to_s
40
40
  end
41
41
 
42
42
  def preview_image
@@ -50,7 +50,7 @@ class Theme < ActiveRecord::Base
50
50
  end
51
51
 
52
52
  def self.directory_is_writable?
53
- File.writable? File.join(RAILS_ROOT, "themes") # Heroku users (or users with read-only filesystem) will receive false here
53
+ Rails.root.join("themes").writable? # Heroku users (or users with read-only filesystem) will receive false here
54
54
  end
55
55
 
56
56
  end
@@ -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/*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'
8
+ map.connect 'theme/stylesheets/*filepath', :controller => 'themes', :action => 'stylesheets'
9
+ map.connect 'theme/javascripts/*filepath', :controller => 'themes', :action => 'javascripts'
10
+ map.connect 'theme/images/*filepath', :controller => 'themes', :action => 'images'
11
11
 
12
12
  end
@@ -119,7 +119,7 @@ You need to update the URL so it requests ``/images/themes`` instead of just ``/
119
119
  So the result is simply:
120
120
 
121
121
  #footer {
122
- background: url('/images/theme/footer_background.png') repeat-x;
122
+ background: url('/theme/images/footer_background.png') repeat-x;
123
123
  }
124
124
 
125
125
  This is the same with linking to Javascript and Stylesheets in your view. Say our ``application.html.erb`` layout had something like this:
@@ -128,7 +128,7 @@ This is the same with linking to Javascript and Stylesheets in your view. Say ou
128
128
 
129
129
  You just need to change that to:
130
130
 
131
- <%= stylesheet_link_tag 'theme/application' %>
131
+ <%= stylesheet_link_tag 'application', :theme => true %>
132
132
 
133
133
  ## I'm Stuck, is there an Example Theme?
134
134
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6.2
4
+ version: 0.9.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Resolve Digital
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-02-05 00:00:00 +13:00
14
+ date: 2010-02-08 00:00:00 +13:00
15
15
  default_executable:
16
16
  dependencies: []
17
17