refinerycms 0.9.6.5 → 0.9.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/application.rb +1 -1
  3. data/app/controllers/application_controller.rb +1 -1
  4. data/config/environment.rb +2 -2
  5. data/config/environments/development.rb +1 -1
  6. data/config/environments/production.rb +1 -1
  7. data/config/preinitializer.rb +1 -1
  8. data/db/migrate/20100114092849_add_themes_table.rb +12 -12
  9. data/db/migrate/20100202034802_remove_custom_title_image_id_and_image_id_from_pages.rb +6 -6
  10. data/db/schema.rb +1 -1
  11. data/db/seeds.rb +2 -2
  12. data/lib/refinery_initializer.rb +1 -1
  13. data/public/javascripts/refinery/admin.js +61 -61
  14. data/readme.md +3 -3
  15. data/test/files/The world!.gif +0 -0
  16. data/test/files/car-wallpapers19.jpg +0 -0
  17. data/test/fixtures/images.yml +14 -0
  18. data/test/test_helper.rb +1 -1
  19. data/test/unit/image_test.rb +19 -8
  20. data/test/unit/page_part_test.rb +11 -11
  21. data/test/unit/page_test.rb +125 -125
  22. data/vendor/plugins/authentication/app/controllers/users_controller.rb +20 -20
  23. data/vendor/plugins/authentication/app/models/user.rb +5 -5
  24. data/vendor/plugins/authentication/app/views/user_mailer/reset_notification.html.erb +2 -2
  25. data/vendor/plugins/authentication/app/views/users/forgot.html.erb +1 -1
  26. data/vendor/plugins/authentication/app/views/users/reset.html.erb +2 -2
  27. data/vendor/plugins/authentication/config/routes.rb +4 -4
  28. data/vendor/plugins/dashboard/app/helpers/admin/dashboard_helper.rb +1 -1
  29. data/vendor/plugins/dashboard/app/views/admin/dashboard/_recent_activity.html.erb +1 -1
  30. data/vendor/plugins/dashboard/rails/init.rb +1 -1
  31. data/vendor/plugins/images/app/models/image.rb +14 -14
  32. data/vendor/plugins/images/app/views/admin/images/_form.html.erb +1 -8
  33. data/vendor/plugins/images/app/views/admin/images/insert.html.erb +1 -1
  34. data/vendor/plugins/inquiries/app/views/admin/inquiries/_inquiry.html.erb +3 -3
  35. data/vendor/plugins/inquiries/app/views/inquiries/new.html.erb +1 -1
  36. data/vendor/plugins/inquiries/app/views/inquiries/thank_you.html.erb +1 -1
  37. data/vendor/plugins/news/app/controllers/admin/news_items_controller.rb +1 -1
  38. data/vendor/plugins/news/app/controllers/news_items_controller.rb +1 -1
  39. data/vendor/plugins/news/app/views/news_items/index.html.erb +1 -1
  40. data/vendor/plugins/news/app/views/news_items/show.html.erb +1 -1
  41. data/vendor/plugins/pages/app/controllers/admin/pages_controller.rb +1 -1
  42. data/vendor/plugins/pages/app/models/page.rb +42 -42
  43. data/vendor/plugins/pages/app/models/page_part.rb +1 -1
  44. data/vendor/plugins/pages/app/presenters/page_presenter.rb +1 -1
  45. data/vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb +1 -1
  46. data/vendor/plugins/pages/app/views/admin/pages/_form.html.erb +1 -1
  47. data/vendor/plugins/pages/app/views/admin/pages/_list.html.erb +1 -1
  48. data/vendor/plugins/pages/app/views/admin/pages/_page_part_field.html.erb +1 -1
  49. data/vendor/plugins/pages/app/views/pages/home.html.erb +1 -1
  50. data/vendor/plugins/pages/app/views/pages/show.html.erb +1 -1
  51. data/vendor/plugins/pages/rails/init.rb +5 -5
  52. data/vendor/plugins/rails_indexes/lib/indexer.rb +49 -47
  53. data/vendor/plugins/rails_indexes/tasks/indexer.rake +5 -3
  54. data/vendor/plugins/rails_indexes/test/fixtures/app/controllers/users_controller.rb +3 -3
  55. data/vendor/plugins/rails_indexes/test/fixtures/app/models/address.rb +2 -2
  56. data/vendor/plugins/rails_indexes/test/fixtures/app/models/company.rb +4 -4
  57. data/vendor/plugins/rails_indexes/test/fixtures/app/models/country.rb +1 -1
  58. data/vendor/plugins/rails_indexes/test/fixtures/app/models/freelancer.rb +1 -1
  59. data/vendor/plugins/rails_indexes/test/fixtures/app/models/gift.rb +4 -4
  60. data/vendor/plugins/rails_indexes/test/fixtures/app/models/god.rb +1 -1
  61. data/vendor/plugins/rails_indexes/test/fixtures/app/models/user.rb +7 -6
  62. data/vendor/plugins/rails_indexes/test/fixtures/app/sweepers/user_sweeper.rb +1 -1
  63. data/vendor/plugins/rails_indexes/test/fixtures/schema.rb +9 -9
  64. data/vendor/plugins/rails_indexes/test/rails_indexes_test.rb +18 -18
  65. data/vendor/plugins/refinery/app/views/admin/_head.html.erb +1 -1
  66. data/vendor/plugins/refinery/app/views/layouts/application.html.erb +1 -1
  67. data/vendor/plugins/refinery/app/views/shared/_content_page.html.erb +1 -1
  68. data/vendor/plugins/refinery/app/views/shared/_head.html.erb +1 -1
  69. data/vendor/plugins/refinery/app/views/shared/_header.html.erb +1 -1
  70. data/vendor/plugins/refinery/app/views/shared/_menu.html.erb +1 -1
  71. data/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb +5 -5
  72. data/vendor/plugins/refinery/app/views/shared/_submenu.html.erb +1 -1
  73. data/vendor/plugins/refinery/app/views/shared/admin/_continue_editing.html.erb +1 -1
  74. data/vendor/plugins/refinery/app/views/shared/admin/_error_messages_for.html.erb +1 -1
  75. data/vendor/plugins/refinery/app/views/shared/admin/_form_actions.html.erb +1 -1
  76. data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +27 -13
  77. data/vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb +1 -1
  78. data/vendor/plugins/refinery/app/views/shared/admin/_search.html.erb +1 -1
  79. data/vendor/plugins/refinery/app/views/shared/admin/_sortable_list.html.erb +1 -1
  80. data/vendor/plugins/refinery/lib/generators/refinery/templates/model.rb +1 -1
  81. data/vendor/plugins/refinery/lib/generators/refinery/templates/public_controller.rb +1 -1
  82. data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_sortable_list.html.erb +1 -1
  83. data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/index.html.erb +2 -2
  84. data/vendor/plugins/refinery/lib/generators/refinery/templates/views/index.html.erb +1 -1
  85. data/vendor/plugins/refinery/lib/generators/refinery/templates/views/show.html.erb +1 -1
  86. data/vendor/plugins/refinery/lib/refinery/activity.rb +1 -1
  87. data/vendor/plugins/refinery/lib/refinery/application_controller.rb +4 -4
  88. data/vendor/plugins/refinery/lib/refinery/application_helper.rb +1 -1
  89. data/vendor/plugins/refinery/lib/refinery/base_presenter.rb +1 -1
  90. data/vendor/plugins/refinery/lib/refinery/initializer.rb +1 -1
  91. data/vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb +1 -1
  92. data/vendor/plugins/resources/app/models/resource.rb +8 -8
  93. data/vendor/plugins/resources/app/views/admin/resources/_form.html.erb +1 -1
  94. data/vendor/plugins/resources/app/views/admin/resources/index.html.erb +1 -1
  95. data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +1 -1
  96. data/vendor/plugins/resources/config/routes.rb +2 -2
  97. data/vendor/plugins/resources/rails/init.rb +1 -1
  98. data/vendor/plugins/themes/app/controllers/admin/themes_controller.rb +17 -17
  99. data/vendor/plugins/themes/app/models/theme.rb +40 -40
  100. data/vendor/plugins/themes/app/views/admin/themes/_form.html.erb +1 -1
  101. data/vendor/plugins/themes/config/routes.rb +2 -2
  102. data/vendor/plugins/themes/lib/theme_server.rb +26 -0
  103. data/vendor/plugins/themes/rails/init.rb +3 -1
  104. metadata +6 -3
  105. data/vendor/plugins/themes/app/controllers/themes_controller.rb +0 -45
@@ -17,13 +17,13 @@
17
17
  <div id='records'>
18
18
  <%% if searching? %>
19
19
  <h2>Search Results for "<%%= params[:search] %>"</h2>
20
- <%% if @<%= plural_name %>.size > 0 %>
20
+ <%% unless @<%= plural_name %>.empty? %>
21
21
  <%%= render :partial => "<%= singular_name %>", :collection => @<%= plural_name %> %>
22
22
  <%% else %>
23
23
  <p>Sorry, no results found.</p>
24
24
  <%% end %>
25
25
  <%% else %>
26
- <%% if @<%= plural_name %>.size > 0 %>
26
+ <%% unless @<%= plural_name %>.empty? %>
27
27
  <%%= will_paginate @<%= plural_name %>, :previous_label => '&laquo;', :next_label => '&raquo;' %>
28
28
  <ul id='sortable_list'>
29
29
  <%%= render :partial => "sortable_list" %>
@@ -8,4 +8,4 @@
8
8
  </ul>
9
9
  <%% end %>
10
10
 
11
- <%%= render :partial => "/shared/content_page" %>
11
+ <%%= render :partial => "/shared/content_page" %>
@@ -22,4 +22,4 @@
22
22
  </ul>
23
23
  <%% end %>
24
24
 
25
- <%%= render :partial => "/shared/content_page" %>
25
+ <%%= render :partial => "/shared/content_page" %>
@@ -34,4 +34,4 @@ module Refinery
34
34
  end
35
35
 
36
36
  end
37
- end
37
+ end
@@ -43,9 +43,9 @@ class Refinery::ApplicationController < ActionController::Base
43
43
 
44
44
  protected
45
45
 
46
- def setup_theme
47
- self.view_paths = ::ActionController::Base.view_paths.dup.unshift(Rails.root.join("themes", RefinerySetting[:theme], "views").to_s)
48
- end
46
+ def setup_theme
47
+ self.view_paths = ::ActionController::Base.view_paths.dup.unshift(Rails.root.join("themes", RefinerySetting[:theme], "views").to_s)
48
+ end
49
49
 
50
50
  def take_down_for_maintenance?
51
51
  if RefinerySetting.find_or_set(:down_for_maintenance, false)
@@ -78,4 +78,4 @@ protected
78
78
  super
79
79
  end
80
80
 
81
- end
81
+ end
@@ -122,4 +122,4 @@ module Refinery::ApplicationHelper
122
122
  logger.warn("*** Refinery::ApplicationHelper::setup has now been deprecated from the Refinery API. ***")
123
123
  end
124
124
 
125
- end
125
+ end
@@ -24,4 +24,4 @@ class Refinery::BasePresenter
24
24
  end
25
25
  end
26
26
 
27
- end
27
+ end
@@ -45,4 +45,4 @@ module Refinery
45
45
  end
46
46
  end
47
47
 
48
- end
48
+ end
@@ -4,7 +4,7 @@ class Admin::DialogsController < Admin::BaseController
4
4
 
5
5
  def show
6
6
  @dialog_type = params[:id].try(:downcase)
7
-
7
+
8
8
  if @dialog_type
9
9
  @submit_button_text = "Insert"
10
10
 
@@ -1,6 +1,6 @@
1
1
  class Resource < ActiveRecord::Base
2
2
 
3
- # Docs for attachment_fu http://github.com/technoweenie/attachment_fu
3
+ # Docs for attachment_fu http://github.com/technoweenie/attachment_fu
4
4
  has_attachment :storage => (USE_S3_BACKEND ? :s3 : :file_system),
5
5
  :size => 0.kilobytes..50.megabytes,
6
6
  :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/resources')
@@ -11,13 +11,13 @@ class Resource < ActiveRecord::Base
11
11
  acts_as_indexed :fields => [:title, :type_of_content],
12
12
  :index_file => [Rails.root.to_s, "tmp", "index"]
13
13
 
14
- # when a dialog pops up with images, how many images per page should there be
15
- PAGES_PER_DIALOG = 12
14
+ # when a dialog pops up with images, how many images per page should there be
15
+ PAGES_PER_DIALOG = 12
16
16
 
17
- # when listing images out in the admin area, how many images should show per page
18
- PAGES_PER_ADMIN_INDEX = 20
17
+ # when listing images out in the admin area, how many images should show per page
18
+ PAGES_PER_ADMIN_INDEX = 20
19
19
 
20
- # How many images per page should be displayed?
20
+ # How many images per page should be displayed?
21
21
  def self.per_page(dialog = false)
22
22
  dialog ? PAGES_PER_DIALOG : PAGES_PER_ADMIN_INDEX
23
23
  end
@@ -28,9 +28,9 @@ class Resource < ActiveRecord::Base
28
28
  end
29
29
 
30
30
  # Returns a titleized version of the filename
31
- # my_file.pdf returns My File
31
+ # my_file.pdf returns My File
32
32
  def title
33
- self.filename.gsub(/\.\w+$/, '').titleize
33
+ CGI::unescape(self.filename).gsub(/\.\w+$/, '').titleize
34
34
  end
35
35
 
36
36
  end
@@ -30,4 +30,4 @@
30
30
  link_dialog.init();
31
31
  });
32
32
  </script>
33
- <% end if from_dialog? %>
33
+ <% end if from_dialog? %>
@@ -38,4 +38,4 @@
38
38
  </p>
39
39
  <% end -%>
40
40
  <% end %>
41
- </div>
41
+ </div>
@@ -60,4 +60,4 @@
60
60
  resource_picker.init(<%= @callback.present? ? "self.parent.#{@callback}" : "null" %>);
61
61
  });
62
62
  </script>
63
- <% end %>
63
+ <% end %>
@@ -1,9 +1,9 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
-
2
+
3
3
  map.resources :resources
4
4
 
5
5
  map.namespace(:admin) do |admin|
6
6
  admin.resources :resources, :collection => {:insert => :get}
7
7
  end
8
8
 
9
- end
9
+ end
@@ -9,4 +9,4 @@ Refinery::Plugin.register do |plugin|
9
9
  :created_image => "page_white_put.png",
10
10
  :updated_image => "page_white_edit.png"
11
11
  }
12
- end
12
+ end
@@ -2,24 +2,24 @@ class Admin::ThemesController < Admin::BaseController
2
2
 
3
3
  crudify :theme, :order => "updated_at DESC"
4
4
 
5
- before_filter :find_theme, :only => [:update, :destroy, :edit, :preview_image, :activate]
5
+ before_filter :find_theme, :only => [:update, :destroy, :edit, :preview_image, :activate]
6
6
 
7
- # accessor method for theme preview image
8
- def preview_image
9
- if File.exists? @theme.preview_image
10
- send_file(@theme.preview_image, :type => 'image/png',
11
- :disposition => 'inline',
12
- :stream => true)
13
- else
14
- return error_404
15
- end
16
- end
7
+ # accessor method for theme preview image
8
+ def preview_image
9
+ if File.exists? @theme.preview_image
10
+ send_file(@theme.preview_image, :type => 'image/png',
11
+ :disposition => 'inline',
12
+ :stream => true)
13
+ else
14
+ return error_404
15
+ end
16
+ end
17
17
 
18
- def activate
19
- RefinerySetting[:theme] = @theme.folder_title
18
+ def activate
19
+ RefinerySetting[:theme] = @theme.folder_title
20
20
 
21
- flash[:notice] = "'#{@theme.title}' applied to live site."
22
- redirect_to admin_themes_url
23
- end
21
+ flash[:notice] = "'#{@theme.title}' applied to live site."
22
+ redirect_to admin_themes_url
23
+ end
24
24
 
25
- end
25
+ end
@@ -11,46 +11,46 @@ class Theme < ActiveRecord::Base
11
11
  before_save :read_theme
12
12
 
13
13
  has_attachment :storage => (USE_S3_BACKEND ? :s3 : :file_system),
14
- :size => 0.kilobytes..25.megabytes,
15
- :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/themes'),
16
- :content_type => 'application/zip'
17
-
18
- # Once a zip is uploaded it unzips it into the themes directory if writable
19
- def after_attachment_saved
20
- if Theme::directory_is_writable?
21
- # make the folder for the them
22
- FileUtils.mkdir(self.theme_path) unless File.directory? self.theme_path
23
-
24
- # extracts the contents of the zip file into the theme directory
25
- Zip::ZipFile.foreach(self.full_filename) do |entry|
26
- FileUtils.mkdir_p(File.dirname("#{theme_path}/#{entry}"))
27
- entry.extract("#{theme_path}/#{entry}") { true }
28
- end
29
- else
30
- raise "Theme directory not writable"
31
- end
32
- end
33
-
34
- def folder_title
35
- File.basename(self.full_filename).split(".").first
36
- end
37
-
38
- def theme_path
39
- Rails.root.join("themes", folder_title).to_s
40
- end
41
-
42
- def preview_image
43
- File.join(theme_path, "preview.png")
44
- end
45
-
46
- def read_theme
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")
14
+ :size => 0.kilobytes..25.megabytes,
15
+ :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/themes'),
16
+ :content_type => 'application/zip'
17
+
18
+ # Once a zip is uploaded it unzips it into the themes directory if writable
19
+ def after_attachment_saved
20
+ if Theme::directory_is_writable?
21
+ # make the folder for the them
22
+ FileUtils.mkdir(self.theme_path) unless File.directory? self.theme_path
23
+
24
+ # extracts the contents of the zip file into the theme directory
25
+ Zip::ZipFile.foreach(self.full_filename) do |entry|
26
+ FileUtils.mkdir_p(File.dirname("#{theme_path}/#{entry}"))
27
+ entry.extract("#{theme_path}/#{entry}") { true }
28
+ end
29
+ else
30
+ raise "Theme directory not writable"
31
+ end
32
+ end
33
+
34
+ def folder_title
35
+ File.basename(self.full_filename).split(".").first
36
+ end
37
+
38
+ def theme_path
39
+ Rails.root.join("themes", folder_title).to_s
40
+ end
41
+
42
+ def preview_image
43
+ File.join(theme_path, "preview.png")
44
+ end
45
+
46
+ def read_theme
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
49
  self.description = File.open(File.join(theme_path, "README")).read if File.exists? File.join(theme_path, "README")
50
- end
50
+ end
51
51
 
52
- def self.directory_is_writable?
53
- Rails.root.join("themes").writable? # Heroku users (or users with read-only filesystem) will receive false here
54
- end
52
+ def self.directory_is_writable?
53
+ Rails.root.join("themes").writable? # Heroku users (or users with read-only filesystem) will receive false here
54
+ end
55
55
 
56
- end
56
+ end
@@ -8,4 +8,4 @@
8
8
  </div>
9
9
 
10
10
  <%= render :partial => "/shared/admin/form_actions", :locals => {:f => f, :continue_editing => false} %>
11
- <% end -%>
11
+ <% end -%>
@@ -4,9 +4,9 @@ ActionController::Routing::Routes.draw do |map|
4
4
  admin.resources :themes, :member => {:preview_image => :get, :activate => :get}
5
5
  end
6
6
 
7
- # allows theme files that are not in the Rails public directory to be served back to the client
7
+ # allows theme files that are not in the Rails public directory to be served back to the client
8
8
  map.connect 'theme/stylesheets/*filepath', :controller => 'themes', :action => 'stylesheets'
9
9
  map.connect 'theme/javascripts/*filepath', :controller => 'themes', :action => 'javascripts'
10
10
  map.connect 'theme/images/*filepath', :controller => 'themes', :action => 'images'
11
11
 
12
- end
12
+ end
@@ -0,0 +1,26 @@
1
+ # Allow the metal piece to run in isolation
2
+ require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
3
+
4
+ # Servers theme files from the them directory without touching Rails too much
5
+ class ThemeServer
6
+
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ if env["PATH_INFO"] =~ /^\/theme/
13
+ relative_path = env["PATH_INFO"].gsub(/^\/theme\//, '')
14
+
15
+ if (file_path = Rails.root.join "themes", RefinerySetting[:theme], relative_path).exist?
16
+ [200, {"Content-Type" => Rack::Mime.mime_type(File.extname file_path)}, file_path.open]
17
+ else
18
+ [404, {"Content-Type" => "text/html"}, ["404 file not found."]]
19
+ end
20
+ else
21
+ status, headers, response = @app.call(env)
22
+ [status, headers, response]
23
+ end
24
+ end
25
+
26
+ end
@@ -9,4 +9,6 @@ Refinery::Plugin.register do |plugin|
9
9
  :created_image => "layout_add.png",
10
10
  :updated_image => "layout_edit.png"
11
11
  }
12
- end
12
+ end
13
+
14
+ config.middleware.use "ThemeServer"
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.5
4
+ version: 0.9.6.6
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-09 00:00:00 +13:00
14
+ date: 2010-02-11 00:00:00 +13:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
@@ -212,6 +212,9 @@ files:
212
212
  - script/process/spawner
213
213
  - script/runner
214
214
  - script/server
215
+ - test/files/The world!.gif
216
+ - test/files/car-wallpapers19.jpg
217
+ - test/fixtures/images.yml
215
218
  - test/fixtures/page_parts.yml
216
219
  - test/fixtures/pages.yml
217
220
  - test/performance/browsing_test.rb
@@ -516,7 +519,6 @@ files:
516
519
  - vendor/plugins/resources/rails/init.rb
517
520
  - vendor/plugins/resources/resources.md
518
521
  - vendor/plugins/themes/app/controllers/admin/themes_controller.rb
519
- - vendor/plugins/themes/app/controllers/themes_controller.rb
520
522
  - vendor/plugins/themes/app/models/theme.rb
521
523
  - vendor/plugins/themes/app/views/admin/themes/_form.html.erb
522
524
  - vendor/plugins/themes/app/views/admin/themes/_theme.html.erb
@@ -524,6 +526,7 @@ files:
524
526
  - vendor/plugins/themes/app/views/admin/themes/index.html.erb
525
527
  - vendor/plugins/themes/app/views/admin/themes/new.html.erb
526
528
  - vendor/plugins/themes/config/routes.rb
529
+ - vendor/plugins/themes/lib/theme_server.rb
527
530
  - vendor/plugins/themes/rails/init.rb
528
531
  - vendor/plugins/themes/themes.md
529
532
  has_rdoc: true
@@ -1,45 +0,0 @@
1
- class ThemesController < ApplicationController
2
-
3
- def stylesheets
4
- render_theme_item(:stylesheets, params[:filepath])
5
- end
6
-
7
- def javascripts
8
- render_theme_item(:javascripts, params[:filepath])
9
- end
10
-
11
- def images
12
- render_theme_item(:images, params[:filepath])
13
- end
14
-
15
- protected
16
-
17
- def render_theme_item(type, relative_path)
18
- if File.exist?(file_path = File.join(Rails.root, "themes", RefinerySetting[:theme], type.to_s, relative_path))
19
- send_file(file_path, :type => mime_for(relative_path), :disposition => 'inline', :stream => true)
20
- else
21
- return error_404
22
- end
23
- end
24
-
25
- def mime_for(filename)
26
- # could we use the built in Rails mime types to work this out?
27
- case filename.last.downcase
28
- when /\.js$/
29
- 'text/javascript; charset=utf-8'
30
- when /\.css$/
31
- 'text/css; charset=utf-8'
32
- when /\.gif$/
33
- 'image/gif'
34
- when /(\.jpg|\.jpeg)$/
35
- 'image/jpeg'
36
- when /\.png$/
37
- 'image/png'
38
- when /\.swf$/
39
- 'application/x-shockwave-flash'
40
- else
41
- 'application/binary'
42
- end
43
- end
44
-
45
- end