diff --git a/app/helpers/box_organizer_helper.rb b/app/helpers/box_organizer_helper.rb index 0756343..777a1cc 100644 --- a/app/helpers/box_organizer_helper.rb +++ b/app/helpers/box_organizer_helper.rb @@ -23,11 +23,40 @@ module BoxOrganizerHelper end def display_previews(block) -# def self.previews_path -# previews = Dir.glob(File.join(images_filesystem_path, 'previews/*')).map do |path| -# File.join(images_base_url_path, 'previews', File.basename(path)) + images_path = nil + plugin = @plugins.fetch_first_plugin(:has_block?, block) + + theme = Theme.new(environment.theme) # remove this + +# images_path = Dir.glob(File.join(theme.public_path, 'images', block.previews_path, '*')) + + + images_path = Dir.glob(File.join(theme.filesystem_path, 'images', block.preview_path, '*')) + images_path = images_path.map{|path| path.gsub(theme.filesystem_path, theme.public_path) } unless images_path.empty? + + images_path = Dir.glob(File.join(Rails.root, 'public', plugin.public_path, 'images', block.preview_path, '*')) if plugin && images_path.empty? + images_path = images_path.map{|path| path.gsub(File.join(Rails.root, 'public'), '') } unless images_path.empty? + + images_path = Dir.glob(File.join(Rails.root, 'public', 'images', block.preview_path, '*')) if images_path.empty? + images_path = images_path.map{|path| path.gsub(File.join(Rails.root, 'public', 'images'), '') } unless images_path.empty? + + images_path = 1.upto(3).map{block.default_preview_path} if images_path.empty? + +# if File.exists?(File.join(theme.filesystem_path, 'images', block.previews_path)) +# images_path = Dir.glob(File.join(theme.public_path, 'images', block.previews_path, '*')) +# elsif plugin && File.exists?(File.join(Rails.root, 'public', plugin.public_path, 'images', block.previews_path)) +# images_path = Dir.glob(File.join('/', plugin.public_path, 'images', block.previews_path, '*')) +# elsif File.exists?(File.join(Rails.root, 'public', 'images', block.previews_path)) +# images_path = block.previews_path +# else +# images_path = block.default_previews_path # end - '' + + content_tag(:ul, + images_path.map do |preview| + content_tag(:li, image_tag(preview, height: '240', width: '384', alt: '')) + end.join("\n") + ) end def icon_selector(icon = 'no-ico') diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 64d0541..fcedc07 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -27,6 +27,7 @@ module LayoutHelper 'thickbox', 'lightbox', 'colorbox', + 'block_store', pngfix_stylesheet_path, ] + tokeninput_stylesheets plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } diff --git a/app/models/block.rb b/app/models/block.rb index 82f1134..1b18776 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -247,9 +247,9 @@ class Block < ActiveRecord::Base duplicated_block end - def self.previews_path + def self.preview_path base_name = self.name.split('::').last.underscore - Dir.glob(File.join('blocks', base_name,'previews/*')) + File.join('blocks', base_name,'previews') end def self.icon_path @@ -265,5 +265,4 @@ class Block < ActiveRecord::Base "block_preview.png" end - end diff --git a/app/views/box_organizer/show_block_type_info.html.erb b/app/views/box_organizer/show_block_type_info.html.erb index 4674e10..ef194a3 100644 --- a/app/views/box_organizer/show_block_type_info.html.erb +++ b/app/views/box_organizer/show_block_type_info.html.erb @@ -1,6 +1,6 @@
<%= @block.short_description %>
@@ -8,15 +8,7 @@