refinerycms-images 1.0.11 → 2.0.0
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.
- data/app/controllers/refinery/admin/images_controller.rb +110 -0
- data/app/helpers/refinery/admin/images_helper.rb +24 -0
- data/app/models/refinery/image.rb +96 -0
- data/app/views/refinery/admin/images/_actions.html.erb +15 -0
- data/app/views/{admin → refinery/admin}/images/_existing_image.html.erb +13 -26
- data/app/views/{admin → refinery/admin}/images/_form.html.erb +11 -15
- data/app/views/{admin → refinery/admin}/images/_grid_view.html.erb +7 -5
- data/app/views/refinery/admin/images/_images.html.erb +2 -0
- data/app/views/{admin → refinery/admin}/images/_list_view.html.erb +0 -0
- data/app/views/{admin → refinery/admin}/images/_list_view_image.html.erb +7 -5
- data/app/views/refinery/admin/images/_records.html.erb +18 -0
- data/app/views/refinery/admin/images/edit.html.erb +1 -0
- data/app/views/refinery/admin/images/index.html.erb +6 -0
- data/app/views/{admin → refinery/admin}/images/insert.html.erb +10 -13
- data/app/views/refinery/admin/images/new.html.erb +1 -0
- data/config/locales/bg.yml +37 -36
- data/config/locales/cs.yml +37 -36
- data/config/locales/da.yml +37 -36
- data/config/locales/de.yml +37 -36
- data/config/locales/el.yml +37 -36
- data/config/locales/en.yml +37 -36
- data/config/locales/es.yml +38 -37
- data/config/locales/fi.yml +37 -36
- data/config/locales/fr.yml +37 -36
- data/config/locales/it.yml +47 -45
- data/config/locales/ja.yml +44 -0
- data/config/locales/ko.yml +44 -0
- data/config/locales/lt.yml +37 -36
- data/config/locales/lv.yml +37 -36
- data/config/locales/nb.yml +37 -37
- data/config/locales/nl.yml +36 -35
- data/config/locales/pl.yml +38 -37
- data/config/locales/pt-BR.yml +38 -37
- data/config/locales/rs.yml +37 -37
- data/config/locales/ru.yml +37 -36
- data/config/locales/sk.yml +37 -36
- data/config/locales/sl.yml +36 -35
- data/config/locales/sv.yml +37 -36
- data/config/locales/vi.yml +37 -36
- data/config/locales/zh-CN.yml +37 -36
- data/config/locales/zh-TW.yml +37 -36
- data/config/routes.rb +4 -7
- data/db/migrate/20100913234707_create_refinerycms_images_schema.rb +10 -18
- data/lib/generators/refinery/images/images_generator.rb +10 -0
- data/lib/generators/refinery/images/templates/config/initializers/refinery/images.rb.erb +41 -0
- data/lib/refinery/images.rb +25 -0
- data/lib/refinery/images/configuration.rb +54 -0
- data/lib/refinery/images/dragonfly.rb +54 -0
- data/lib/refinery/images/engine.rb +38 -0
- data/lib/refinery/images/validators.rb +7 -0
- data/lib/refinery/images/validators/image_size_validator.rb +19 -0
- data/lib/refinerycms-images.rb +1 -76
- data/refinerycms-images.gemspec +14 -91
- data/spec/factories/image.rb +5 -0
- data/{features/uploads → spec/fixtures}/beach.jpeg +0 -0
- data/spec/fixtures/fathead.png +0 -0
- data/spec/fixtures/image-with-dashes.jpg +0 -0
- data/spec/lib/generators/refinery/images/images_generator_spec.rb +29 -0
- data/spec/models/refinery/image_spec.rb +158 -0
- data/spec/requests/refinery/admin/images_spec.rb +103 -0
- metadata +116 -106
- data/app/controllers/admin/images_controller.rb +0 -106
- data/app/helpers/admin/images_helper.rb +0 -27
- data/app/models/image.rb +0 -116
- data/app/views/admin/images/_actions.html.erb +0 -16
- data/app/views/admin/images/_images.html.erb +0 -2
- data/app/views/admin/images/_records.html.erb +0 -18
- data/app/views/admin/images/edit.html.erb +0 -1
- data/app/views/admin/images/index.html.erb +0 -6
- data/app/views/admin/images/new.html.erb +0 -1
- data/config/locales/jp.yml +0 -43
- data/config/locales/lolcat.yml +0 -43
- data/features/manage_images.feature +0 -49
- data/features/step_definitions/image_steps.rb +0 -40
- data/features/support/factories.rb +0 -7
- data/features/support/paths.rb +0 -17
- data/features/uploads/id-rather-be-here.jpg +0 -0
- data/features/uploads/refinery_is_awesome.txt +0 -1
- data/lib/gemspec.rb +0 -38
- data/lib/generators/refinerycms_images_generator.rb +0 -8
- data/spec/models/image_spec.rb +0 -115
- data/spec/uploads/beach.jpeg +0 -0
| @@ -0,0 +1,110 @@ | |
| 1 | 
            +
            module ::Refinery
         | 
| 2 | 
            +
              module Admin
         | 
| 3 | 
            +
                class ImagesController < ::Refinery::AdminController
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  crudify :'refinery/image',
         | 
| 6 | 
            +
                          :order => "created_at DESC",
         | 
| 7 | 
            +
                          :sortable => false,
         | 
| 8 | 
            +
                          :xhr_paging => true
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  before_filter :change_list_mode_if_specified, :init_dialog
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def new
         | 
| 13 | 
            +
                    @image = ::Refinery::Image.new if @image.nil?
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    @url_override = refinery.admin_images_path(:dialog => from_dialog?)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  # This renders the image insert dialog
         | 
| 19 | 
            +
                  def insert
         | 
| 20 | 
            +
                    self.new if @image.nil?
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    @url_override = refinery.admin_images_path(request.query_parameters.merge(:insert => true))
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    if params[:conditions].present?
         | 
| 25 | 
            +
                      extra_condition = params[:conditions].split(',')
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                      extra_condition[1] = true if extra_condition[1] == "true"
         | 
| 28 | 
            +
                      extra_condition[1] = false if extra_condition[1] == "false"
         | 
| 29 | 
            +
                      extra_condition[1] = nil if extra_condition[1] == "nil"
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    find_all_images(({extra_condition[0].to_sym => extra_condition[1]} if extra_condition.present?))
         | 
| 33 | 
            +
                    search_all_images if searching?
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    paginate_images
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    render :action => "insert"
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  def create
         | 
| 41 | 
            +
                    @images = []
         | 
| 42 | 
            +
                    begin
         | 
| 43 | 
            +
                      unless params[:image].present? and params[:image][:image].is_a?(Array)
         | 
| 44 | 
            +
                        @images << (@image = ::Refinery::Image.create(params[:image]))
         | 
| 45 | 
            +
                      else
         | 
| 46 | 
            +
                        params[:image][:image].each do |image|
         | 
| 47 | 
            +
                          @images << (@image = ::Refinery::Image.create(:image => image))
         | 
| 48 | 
            +
                        end
         | 
| 49 | 
            +
                      end
         | 
| 50 | 
            +
                    rescue Dragonfly::FunctionManager::UnableToHandle
         | 
| 51 | 
            +
                      logger.warn($!.message)
         | 
| 52 | 
            +
                      @image = ::Refinery::Image.new
         | 
| 53 | 
            +
                    end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    unless params[:insert]
         | 
| 56 | 
            +
                      if @images.all?(&:valid?)
         | 
| 57 | 
            +
                        flash.notice = t('created', :scope => 'refinery.crudify', :what => "'#{@images.map(&:title).join("', '")}'")
         | 
| 58 | 
            +
                        if from_dialog?
         | 
| 59 | 
            +
                          @dialog_successful = true
         | 
| 60 | 
            +
                          render :nothing => true, :layout => true
         | 
| 61 | 
            +
                        else
         | 
| 62 | 
            +
                          redirect_to refinery.admin_images_path
         | 
| 63 | 
            +
                        end
         | 
| 64 | 
            +
                      else
         | 
| 65 | 
            +
                        self.new # important for dialogs
         | 
| 66 | 
            +
                        render :action => 'new'
         | 
| 67 | 
            +
                      end
         | 
| 68 | 
            +
                    else
         | 
| 69 | 
            +
                      # if all uploaded images are ok redirect page back to dialog, else show current page with error
         | 
| 70 | 
            +
                      if @images.all?(&:valid?)
         | 
| 71 | 
            +
                        @image_id = @image.id if @image.persisted?
         | 
| 72 | 
            +
                        @image = nil
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                        self.insert
         | 
| 75 | 
            +
                      end
         | 
| 76 | 
            +
                    end
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                protected
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  def init_dialog
         | 
| 82 | 
            +
                    @app_dialog = params[:app_dialog].present?
         | 
| 83 | 
            +
                    @field = params[:field]
         | 
| 84 | 
            +
                    @update_image = params[:update_image]
         | 
| 85 | 
            +
                    @thumbnail = params[:thumbnail]
         | 
| 86 | 
            +
                    @callback = params[:callback]
         | 
| 87 | 
            +
                    @conditions = params[:conditions]
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  def change_list_mode_if_specified
         | 
| 91 | 
            +
                    if action_name == 'index' && params[:view].present? && Refinery::Images.image_views.include?(params[:view].to_sym)
         | 
| 92 | 
            +
                       Refinery::Images.preferred_image_view = params[:view]
         | 
| 93 | 
            +
                    end
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  def paginate_images
         | 
| 97 | 
            +
                    @images = @images.paginate(:page => params[:page], :per_page => Image.per_page(from_dialog?, !@app_dialog))
         | 
| 98 | 
            +
                  end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  def restrict_controller
         | 
| 101 | 
            +
                    super unless action_name == 'insert'
         | 
| 102 | 
            +
                  end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                  def store_current_location!
         | 
| 105 | 
            +
                    super unless action_name == 'insert' or from_dialog?
         | 
| 106 | 
            +
                  end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
              end
         | 
| 110 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            module Refinery
         | 
| 2 | 
            +
              module Admin
         | 
| 3 | 
            +
                module ImagesHelper
         | 
| 4 | 
            +
                  def other_image_views
         | 
| 5 | 
            +
                    Refinery::Images.image_views.reject { |image_view|
         | 
| 6 | 
            +
                      image_view.to_s == Refinery::Images.preferred_image_view.to_s
         | 
| 7 | 
            +
                    }
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def thumbnail_urls(image)
         | 
| 11 | 
            +
                    thumbnail_urls = {
         | 
| 12 | 
            +
                      :"data-original" => asset_paths.compute_public_path(image.url, ''),
         | 
| 13 | 
            +
                      :"data-grid" => asset_paths.compute_public_path(image.thumbnail('135x135#c').url, '')
         | 
| 14 | 
            +
                    }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    Refinery::Images.user_image_sizes.sort_by{|key,geometry| geometry}.each do |size, pixels|
         | 
| 17 | 
            +
                      thumbnail_urls[:"data-#{size.to_s.parameterize}"] = asset_paths.compute_public_path(image.thumbnail(pixels).url, '')
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    thumbnail_urls
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| @@ -0,0 +1,96 @@ | |
| 1 | 
            +
            module Refinery
         | 
| 2 | 
            +
              class Image < Refinery::Core::BaseModel
         | 
| 3 | 
            +
                include Images::Validators
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                image_accessor :image
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                validates :image, :presence  => true
         | 
| 8 | 
            +
                validates_with ImageSizeValidator
         | 
| 9 | 
            +
                validates_property :mime_type, :of => :image, :in => %w(image/jpeg image/png image/gif image/tiff),
         | 
| 10 | 
            +
                                   :message => :incorrect_format
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
         | 
| 13 | 
            +
                acts_as_indexed :fields => [:title]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                # allows Mass-Assignment
         | 
| 16 | 
            +
                attr_accessible :id, :image, :image_size
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                delegate :size, :mime_type, :url, :width, :height, :to => :image
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                class << self
         | 
| 21 | 
            +
                  # How many images per page should be displayed?
         | 
| 22 | 
            +
                  def per_page(dialog = false, has_size_options = false)
         | 
| 23 | 
            +
                    if dialog
         | 
| 24 | 
            +
                      unless has_size_options
         | 
| 25 | 
            +
                        Images.pages_per_dialog
         | 
| 26 | 
            +
                      else
         | 
| 27 | 
            +
                        Images.pages_per_dialog_that_have_size_options
         | 
| 28 | 
            +
                      end
         | 
| 29 | 
            +
                    else
         | 
| 30 | 
            +
                      Images.pages_per_admin_index
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                # Get a thumbnail job object given a geometry.
         | 
| 36 | 
            +
                def thumbnail(geometry = nil)
         | 
| 37 | 
            +
                  if geometry.is_a?(Symbol) and Refinery::Images.user_image_sizes.keys.include?(geometry)
         | 
| 38 | 
            +
                    geometry = Refinery::Images.user_image_sizes[geometry]
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  if geometry.present? && !geometry.is_a?(Symbol)
         | 
| 42 | 
            +
                    image.thumb(geometry)
         | 
| 43 | 
            +
                  else
         | 
| 44 | 
            +
                    image
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                # Intelligently works out dimensions for a thumbnail of this image based on the Dragonfly geometry string.
         | 
| 49 | 
            +
                def thumbnail_dimensions(geometry)
         | 
| 50 | 
            +
                  geometry = geometry.to_s
         | 
| 51 | 
            +
                  width = original_width = self.image_width.to_f
         | 
| 52 | 
            +
                  height = original_height = self.image_height.to_f
         | 
| 53 | 
            +
                  geometry_width, geometry_height = geometry.to_s.split(%r{\#{1,2}|\+|>|!|x}im)[0..1].map(&:to_f)
         | 
| 54 | 
            +
                  if (original_width * original_height > 0) && geometry =~ ::Dragonfly::ImageMagick::Processor::THUMB_GEOMETRY
         | 
| 55 | 
            +
                    if geometry =~ ::Dragonfly::ImageMagick::Processor::RESIZE_GEOMETRY
         | 
| 56 | 
            +
                      if geometry !~ %r{\d+x\d+>} || (geometry =~ %r{\d+x\d+>} && (width > geometry_width.to_f || height > geometry_height.to_f))
         | 
| 57 | 
            +
                        # Try scaling with width factor first. (wf = width factor)
         | 
| 58 | 
            +
                        wf_width = (original_width * (geometry_width / width)).ceil
         | 
| 59 | 
            +
                        wf_height = (original_height * (geometry_width / width)).ceil
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                        # Scale with height factor (hf = height factor)
         | 
| 62 | 
            +
                        hf_width = (original_width * (geometry_height / height)).ceil
         | 
| 63 | 
            +
                        hf_height = (original_height * (geometry_height / height)).ceil
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                        # Take the highest value that doesn't exceed either axis limit.
         | 
| 66 | 
            +
                        use_wf = wf_width <= geometry_width && wf_height <= geometry_height
         | 
| 67 | 
            +
                        if use_wf && hf_width <= geometry_width && hf_height <= geometry_height
         | 
| 68 | 
            +
                          use_wf = wf_width * wf_height > hf_width * hf_height
         | 
| 69 | 
            +
                        end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                        if use_wf
         | 
| 72 | 
            +
                          width = wf_width
         | 
| 73 | 
            +
                          height = wf_height
         | 
| 74 | 
            +
                        else
         | 
| 75 | 
            +
                          width = hf_width
         | 
| 76 | 
            +
                          height = hf_height
         | 
| 77 | 
            +
                        end
         | 
| 78 | 
            +
                      end
         | 
| 79 | 
            +
                    else
         | 
| 80 | 
            +
                      # cropping
         | 
| 81 | 
            +
                      width = geometry_width
         | 
| 82 | 
            +
                      height = geometry_height
         | 
| 83 | 
            +
                    end
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  { :width => width.to_i, :height => height.to_i }
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                # Returns a titleized version of the filename
         | 
| 90 | 
            +
                # my_file.jpg returns My File
         | 
| 91 | 
            +
                def title
         | 
| 92 | 
            +
                  CGI::unescape(image_name.to_s).gsub(/\.\w+$/, '').titleize
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            <ul>
         | 
| 2 | 
            +
              <li>
         | 
| 3 | 
            +
                <%= render '/refinery/admin/search', :url => refinery.admin_images_path %>
         | 
| 4 | 
            +
              </li>
         | 
| 5 | 
            +
              <li>
         | 
| 6 | 
            +
                <%= link_to t('.create_new_image'), refinery.new_admin_image_path(:dialog => true), :class => "add_icon" %>
         | 
| 7 | 
            +
              </li>
         | 
| 8 | 
            +
              <% other_image_views.each do |image_view| %>
         | 
| 9 | 
            +
                <li>
         | 
| 10 | 
            +
                  <%= link_to t('switch_to', :scope => 'refinery.admin.images.index.view', :view_name => t("#{image_view}", :scope => 'refinery.admin.images.index.view')),
         | 
| 11 | 
            +
                              refinery.admin_images_path(:view => image_view, :page => params[:page]),
         | 
| 12 | 
            +
                              :class => "reorder_icon"  %>
         | 
| 13 | 
            +
                </li>
         | 
| 14 | 
            +
              <% end %>
         | 
| 15 | 
            +
            </ul>
         | 
| @@ -1,36 +1,26 @@ | |
| 1 1 | 
             
            <div id='existing_image_area' class='dialog_area' <%= "style='display:none;'" if @image.errors.any? %>>
         | 
| 2 | 
            -
              <%= render  | 
| 3 | 
            -
                         :locals => {:url => insert_admin_images_path(params.dup.delete(:image))} %>
         | 
| 2 | 
            +
              <%= render '/refinery/admin/search', :url => refinery.insert_admin_images_path(params.dup.except('image')) %>
         | 
| 4 3 | 
             
              <input type='hidden' name='selected_image' id='selected_image' />
         | 
| 5 4 | 
             
              <div id='existing_image_area_content' class='clearfix'>
         | 
| 6 5 | 
             
            <% if @images.any? %>
         | 
| 7 6 | 
             
                <ul>
         | 
| 8 | 
            -
            <%
         | 
| 9 | 
            -
                  @images.each do |image|
         | 
| 10 | 
            -
                    thumbnail_urls = {
         | 
| 11 | 
            -
                      :"data-original" => compute_public_path(image.url, ''),
         | 
| 12 | 
            -
                      :"data-grid" => compute_public_path(image.thumbnail('135x135#c').url, '')
         | 
| 13 | 
            -
                    }
         | 
| 14 | 
            -
                    ::Image.user_image_sizes.sort_by{|key,geometry| geometry}.each do |size, pixels|
         | 
| 15 | 
            -
                      thumbnail_urls[:"data-#{size.to_s.parameterize}"] = compute_public_path(image.thumbnail(pixels).url, '')
         | 
| 16 | 
            -
                    end
         | 
| 17 | 
            -
            -%>
         | 
| 7 | 
            +
                  <% @images.each do |image| -%>
         | 
| 18 8 | 
             
                    <li<%= " class='selected'" if @image_id == image.id %>>
         | 
| 19 9 | 
             
                      <%= image_fu(image, '106x106#c', {
         | 
| 20 10 | 
             
                                     :alt => image.title,
         | 
| 21 11 | 
             
                                     :title => image.title,
         | 
| 22 12 | 
             
                                     :id => "image_#{image.id}",
         | 
| 23 13 | 
             
                                     :'data-id' => image.id
         | 
| 24 | 
            -
                                   }.merge(thumbnail_urls)) -%>
         | 
| 14 | 
            +
                                   }.merge(thumbnail_urls(image))) -%>
         | 
| 25 15 | 
             
                    </li>
         | 
| 26 16 | 
             
                  <% end -%>
         | 
| 27 17 | 
             
                </ul>
         | 
| 28 18 | 
             
            <% elsif searching? %>
         | 
| 29 | 
            -
                <%= t('no_results', :scope => ' | 
| 19 | 
            +
                <%= t('no_results', :scope => 'refinery.admin.search') %>
         | 
| 30 20 | 
             
            <% end %>
         | 
| 31 21 | 
             
              </div>
         | 
| 32 22 |  | 
| 33 | 
            -
              <%=  | 
| 23 | 
            +
              <%= will_paginate @images, :params => params.dup %>
         | 
| 34 24 |  | 
| 35 25 | 
             
              <% unless @app_dialog or @images.empty? %>
         | 
| 36 26 | 
             
                <div id='existing_image_size_area' class='clearfix'>
         | 
| @@ -43,7 +33,7 @@ | |
| 43 33 | 
             
                  </p>
         | 
| 44 34 | 
             
                  <ul>
         | 
| 45 35 | 
             
                    <%
         | 
| 46 | 
            -
                      :: | 
| 36 | 
            +
                      Refinery::Images.user_image_sizes.sort_by { |key, geometry| geometry }.each_with_index do |(size, pixels), index|
         | 
| 47 37 | 
             
                        safe_pixels = pixels.to_s.gsub(/[<>=]/, '')
         | 
| 48 38 | 
             
                        # (parndt): ' selected' if size.to_s == 'medium' is not very generic, but I
         | 
| 49 39 | 
             
                        # can't think of a decent way of making it so for even sets (e.g. 2,4,6,8,etc image sizes).
         | 
| @@ -60,14 +50,11 @@ | |
| 60 50 | 
             
                </div>
         | 
| 61 51 | 
             
              <% end %>
         | 
| 62 52 |  | 
| 63 | 
            -
              <%= render  | 
| 64 | 
            -
                         : | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                           :hide_delete => true,
         | 
| 71 | 
            -
                           :cancel_title => nil
         | 
| 72 | 
            -
                         } if @app_dialog or @images.any? or searching? %>
         | 
| 53 | 
            +
              <%= render '/refinery/admin/form_actions', :f => nil,
         | 
| 54 | 
            +
                         :cancel_url => '',
         | 
| 55 | 
            +
                         :submit_button_text => t('.button_text'),
         | 
| 56 | 
            +
                         :hide_submit => @images.empty?,
         | 
| 57 | 
            +
                         :hide_cancel => false,
         | 
| 58 | 
            +
                         :hide_delete => true,
         | 
| 59 | 
            +
                         :cancel_title => nil if @app_dialog or @images.any? or searching? %>
         | 
| 73 60 | 
             
            </div>
         | 
| @@ -1,10 +1,9 @@ | |
| 1 | 
            -
            <%= form_for  | 
| 1 | 
            +
            <%= form_for @image, :url => (@url_override or @image.persisted? ? refinery.admin_image_path(@image) : refinery.admin_images_path),
         | 
| 2 | 
            +
                         :html => { :multipart => true } do |f| %>
         | 
| 2 3 |  | 
| 3 | 
            -
              <%= render  | 
| 4 | 
            -
                         : | 
| 5 | 
            -
             | 
| 6 | 
            -
                           :include_object_name => false
         | 
| 7 | 
            -
                         } %>
         | 
| 4 | 
            +
              <%= render '/refinery/admin/error_messages',
         | 
| 5 | 
            +
                         :object => @image,
         | 
| 6 | 
            +
                         :include_object_name => false %>
         | 
| 8 7 |  | 
| 9 8 | 
             
              <div class='field'>
         | 
| 10 9 | 
             
                <% if action_name =~ /(edit)|(update)/ %>
         | 
| @@ -22,19 +21,16 @@ | |
| 22 21 | 
             
              </div>
         | 
| 23 22 |  | 
| 24 23 | 
             
              <div class='field'>
         | 
| 25 | 
            -
                <label><%= t('.maximum_image_size', : | 
| 24 | 
            +
                <label><%= t('.maximum_image_size', :bytes => number_to_human_size(Refinery::Images.max_image_size)) %></label>
         | 
| 26 25 | 
             
              </div>
         | 
| 27 26 |  | 
| 28 27 | 
             
              <input type='hidden' name='wymeditor' value='<%= params[:wymeditor] %>'>
         | 
| 29 28 |  | 
| 30 | 
            -
              <%= render  | 
| 31 | 
            -
                         : | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
                           :delete_title => t('delete', :scope => 'admin.images'),
         | 
| 36 | 
            -
                           :delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @image.image_name)
         | 
| 37 | 
            -
                         } -%>
         | 
| 29 | 
            +
              <%= render '/refinery/admin/form_actions', :f => f,
         | 
| 30 | 
            +
                         :continue_editing => false,
         | 
| 31 | 
            +
                         :hide_cancel => (@app_dialog or action_name == "insert" or from_dialog?),
         | 
| 32 | 
            +
                         :delete_title => t('delete', :scope => 'refinery.admin.images'),
         | 
| 33 | 
            +
                         :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @image.image_name) -%>
         | 
| 38 34 |  | 
| 39 35 | 
             
              <% if @app_dialog %>
         | 
| 40 36 | 
             
                <input type='hidden' name='app_dialog' value='<%= @app_dialog %>' />
         | 
| @@ -6,12 +6,14 @@ | |
| 6 6 | 
             
                    <%= link_to refinery_icon_tag('eye.png'), image.url,
         | 
| 7 7 | 
             
                                :target => "_blank",
         | 
| 8 8 | 
             
                                :title => t('.view_live_html') %>
         | 
| 9 | 
            -
                    <%= link_to refinery_icon_tag('application_edit.png'), | 
| 10 | 
            -
                                 | 
| 11 | 
            -
             | 
| 9 | 
            +
                    <%= link_to refinery_icon_tag('application_edit.png'),
         | 
| 10 | 
            +
                                refinery.edit_admin_image_path(image),
         | 
| 11 | 
            +
                                :title => t('edit', :scope => 'refinery.admin.images') %>
         | 
| 12 | 
            +
                    <%= link_to refinery_icon_tag('delete.png'),
         | 
| 13 | 
            +
                                refinery.admin_image_path(image),
         | 
| 12 14 | 
             
                                :class => "cancel confirm-delete",
         | 
| 13 | 
            -
                                :title => t('delete', :scope => 'admin.images'),
         | 
| 14 | 
            -
                                :confirm => t('message', :scope => ' | 
| 15 | 
            +
                                :title => t('delete', :scope => 'refinery.admin.images'),
         | 
| 16 | 
            +
                                :confirm => t('message', :scope => 'refinery.admin.delete', :title => image.title),
         | 
| 15 17 | 
             
                                :method => :delete %>
         | 
| 16 18 | 
             
                  </span>
         | 
| 17 19 | 
             
                </li>
         | 
| 
            File without changes
         | 
| @@ -6,12 +6,14 @@ | |
| 6 6 | 
             
                <%= link_to refinery_icon_tag('eye.png'), list_view_image.url,
         | 
| 7 7 | 
             
                            :target => "_blank",
         | 
| 8 8 | 
             
                            :title => "#{image_fu list_view_image, '96x96#c', :size => '96x96'}" %>
         | 
| 9 | 
            -
                <%= link_to refinery_icon_tag('application_edit.png'), | 
| 10 | 
            -
                             | 
| 11 | 
            -
             | 
| 9 | 
            +
                <%= link_to refinery_icon_tag('application_edit.png'),
         | 
| 10 | 
            +
                            refinery.edit_admin_image_path(list_view_image),
         | 
| 11 | 
            +
                            :title => t('edit', :scope => 'refinery.admin.images') %>
         | 
| 12 | 
            +
                <%= link_to refinery_icon_tag('delete.png'),
         | 
| 13 | 
            +
                            refinery.admin_image_path(list_view_image),
         | 
| 12 14 | 
             
                            :class => "cancel confirm-delete",
         | 
| 13 | 
            -
                            :title => t('delete', :scope => 'admin.images'),
         | 
| 14 | 
            -
                            :confirm => t('message', :scope => ' | 
| 15 | 
            +
                            :title => t('delete', :scope => 'refinery.admin.images'),
         | 
| 16 | 
            +
                            :confirm => t('message', :scope => 'refinery.admin.delete', :title => list_view_image.title),
         | 
| 15 17 | 
             
                            :method => :delete %>
         | 
| 16 18 | 
             
              </span>
         | 
| 17 19 | 
             
            </li>
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            <% if searching? %>
         | 
| 2 | 
            +
              <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
         | 
| 3 | 
            +
            <% end %>
         | 
| 4 | 
            +
            <div class='pagination_container'>
         | 
| 5 | 
            +
              <% if @images.any? %>
         | 
| 6 | 
            +
                <%= render 'images' %>
         | 
| 7 | 
            +
              <% else %>
         | 
| 8 | 
            +
                <p>
         | 
| 9 | 
            +
                  <% unless searching? %>
         | 
| 10 | 
            +
                    <strong>
         | 
| 11 | 
            +
                      <%= t('.no_images_yet') %>
         | 
| 12 | 
            +
                    </strong>
         | 
| 13 | 
            +
                  <% else %>
         | 
| 14 | 
            +
                    <%= t('no_results', :scope => 'refinery.admin.search') %>
         | 
| 15 | 
            +
                  <% end %>
         | 
| 16 | 
            +
                </p>
         | 
| 17 | 
            +
              <% end %>
         | 
| 18 | 
            +
            </div>
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            <%= render 'form' %>
         | 
| @@ -16,25 +16,22 @@ | |
| 16 16 |  | 
| 17 17 | 
             
            <div id='dialog_main'>
         | 
| 18 18 | 
             
              <% if any_images or user_can_modify_images %>
         | 
| 19 | 
            -
                <%= render  | 
| 19 | 
            +
                <%= render 'existing_image' if any_images or searching? %>
         | 
| 20 20 |  | 
| 21 21 | 
             
                <% if user_can_modify_images %>
         | 
| 22 22 | 
             
                  <div id='upload_image_area' class='dialog_area'<%= " style='display:none;'" if any_images and (no_errors or searching?) %>>
         | 
| 23 | 
            -
                    <%= render  | 
| 23 | 
            +
                    <%= render 'form', :insert => true %>
         | 
| 24 24 | 
             
                  </div>
         | 
| 25 25 | 
             
                <% end %>
         | 
| 26 26 | 
             
              <% else %>
         | 
| 27 | 
            -
                <% flash.now[:error] = t('no_images_yet', :scope => 'admin.images.records').split('.').first.html_safe + "." %>
         | 
| 28 | 
            -
                <%= render  | 
| 29 | 
            -
                           : | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
                             :cancel_button_text => t('close', :scope => 'shared.admin.form_actions'),
         | 
| 36 | 
            -
                             :cancel_title => nil
         | 
| 37 | 
            -
                           } %>
         | 
| 27 | 
            +
                <% flash.now[:error] = t('no_images_yet', :scope => 'refinery.admin.images.records').split('.').first.html_safe + "." %>
         | 
| 28 | 
            +
                <%= render '/refinery/admin/form_actions', :f => nil,
         | 
| 29 | 
            +
                           :cancel_url => '',
         | 
| 30 | 
            +
                           :hide_cancel => false,
         | 
| 31 | 
            +
                           :hide_delete => true,
         | 
| 32 | 
            +
                           :hide_submit => true,
         | 
| 33 | 
            +
                           :cancel_button_text => t('close', :scope => 'refinery.admin.form_actions'),
         | 
| 34 | 
            +
                           :cancel_title => nil %>
         | 
| 38 35 | 
             
              <% end %>
         | 
| 39 36 | 
             
            </div>
         | 
| 40 37 |  |