refinerycms 0.9.6.6 → 0.9.6.7
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/VERSION +1 -1
- data/bin/refinery-override +1 -1
- data/db/schema.rb +1 -1
- data/public/javascripts/refinery/admin.js +17 -17
- data/vendor/plugins/authentication/app/views/admin/users/index.html.erb +1 -1
- data/vendor/plugins/dashboard/app/views/admin/dashboard/_recent_activity.html.erb +1 -1
- data/vendor/plugins/images/app/controllers/admin/images_controller.rb +6 -4
- data/vendor/plugins/images/app/models/image.rb +13 -1
- data/vendor/plugins/images/app/views/admin/images/_form.html.erb +1 -1
- data/vendor/plugins/images/app/views/admin/images/index.html.erb +2 -2
- data/vendor/plugins/images/app/views/admin/images/insert.html.erb +8 -8
- data/vendor/plugins/inquiries/app/views/admin/inquiries/index.html.erb +2 -2
- data/vendor/plugins/inquiries/app/views/admin/inquiry_settings/index.html.erb +1 -1
- data/vendor/plugins/news/app/views/admin/news_items/index.html.erb +1 -1
- data/vendor/plugins/news/app/views/news_items/index.html.erb +1 -1
- data/vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb +1 -1
- data/vendor/plugins/pages/app/views/admin/pages/_list.html.erb +1 -1
- data/vendor/plugins/pages/app/views/admin/pages/index.html.erb +2 -2
- data/vendor/plugins/refinery/app/views/shared/_content_page.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_submenu.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_submenu_branch.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +2 -2
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/index.html.erb +2 -2
- data/vendor/plugins/refinery_settings/app/views/admin/refinery_settings/index.html.erb +1 -1
- data/vendor/plugins/resources/app/controllers/admin/resources_controller.rb +7 -5
- data/vendor/plugins/resources/app/models/resource.rb +12 -1
- data/vendor/plugins/resources/app/views/admin/resources/index.html.erb +2 -2
- data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +18 -14
- data/vendor/plugins/themes/app/views/admin/themes/index.html.erb +3 -4
- metadata +1 -1
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.9.6. | 
| 1 | 
            +
            0.9.6.7
         | 
    
        data/bin/refinery-override
    CHANGED
    
    | @@ -30,7 +30,7 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0) | |
| 30 30 | 
             
                # copy the controller
         | 
| 31 31 | 
             
                unless controller_with_admin =~ /\*(\*)?/ and !action.nil?
         | 
| 32 32 | 
             
                  refinery_controllers = Dir[File.join(REFINERY_ROOT, %w(vendor plugins ** app controllers), "#{controller_with_admin}_controller.rb")]
         | 
| 33 | 
            -
                   | 
| 33 | 
            +
                  if refinery_controllers.compact.any? # the controllers may not exist.
         | 
| 34 34 | 
             
                    refinery_controllers.each do |refinery_controller|
         | 
| 35 35 | 
             
                      # make the directories
         | 
| 36 36 | 
             
                      FileUtils.mkdir_p(copy_to = File.join(RAILS_ROOT, %w(app controllers), admin))
         | 
    
        data/db/schema.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # This file is auto-generated from the current state of the database. Instead of editing this file,
         | 
| 1 | 
            +
            # This file is auto-generated from the current state of the database. Instead of editing this file, 
         | 
| 2 2 | 
             
            # please use the migrations feature of Active Record to incrementally modify your database, and
         | 
| 3 3 | 
             
            # then regenerate this schema definition.
         | 
| 4 4 | 
             
            #
         | 
| @@ -609,25 +609,25 @@ var image_picker = { | |
| 609 609 |  | 
| 610 610 | 
             
              , init: function(new_options){
         | 
| 611 611 | 
             
                this.options = $.extend(this.options, new_options);
         | 
| 612 | 
            -
                $(this.options.remove_image_button).click( | 
| 613 | 
            -
             | 
| 614 | 
            -
             | 
| 615 | 
            -
                                            .attr({'src': '', 'width': '', 'height': ''})
         | 
| 616 | 
            -
                                            .css({'width': 'auto', 'height': 'auto'})
         | 
| 617 | 
            -
                                            .hide();
         | 
| 618 | 
            -
                  $(this.options.field).val('');
         | 
| 619 | 
            -
                  $(this.options.no_image_message).show();
         | 
| 620 | 
            -
                  $(this).hide();
         | 
| 621 | 
            -
                });
         | 
| 612 | 
            +
                $(this.options.remove_image_button).click($.proxy(this.remove_image, this));
         | 
| 613 | 
            +
                $(this.options.image_toggler).click($.proxy(this.toggle_image, this));
         | 
| 614 | 
            +
              }
         | 
| 622 615 |  | 
| 623 | 
            -
             | 
| 624 | 
            -
             | 
| 625 | 
            -
             | 
| 626 | 
            -
             | 
| 627 | 
            -
             | 
| 628 | 
            -
             | 
| 629 | 
            -
                 | 
| 616 | 
            +
              , remove_image: function(e) {
         | 
| 617 | 
            +
                e.preventDefault();
         | 
| 618 | 
            +
                $(this.options.image_display).removeClass('brown_border')
         | 
| 619 | 
            +
                                          .attr({'src': '', 'width': '', 'height': ''})
         | 
| 620 | 
            +
                                          .css({'width': 'auto', 'height': 'auto'})
         | 
| 621 | 
            +
                                          .hide();
         | 
| 622 | 
            +
                $(this.options.field).val('');
         | 
| 623 | 
            +
                $(this.options.no_image_message).show();
         | 
| 624 | 
            +
                $(this).hide();
         | 
| 625 | 
            +
              }
         | 
| 630 626 |  | 
| 627 | 
            +
              , toggle_image: function(e) {
         | 
| 628 | 
            +
                $(this.options.image_toggler).html(($(this.options.image_toggler).html() == 'Show' ? 'Hide' : 'Show'));
         | 
| 629 | 
            +
                $(this.options.image_container).toggle();
         | 
| 630 | 
            +
                e.preventDefault();
         | 
| 631 631 | 
             
              }
         | 
| 632 632 |  | 
| 633 633 | 
             
              , changed: function(image) {
         | 
| @@ -28,7 +28,7 @@ class Admin::ImagesController < Admin::BaseController | |
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 30 | 
             
              def new
         | 
| 31 | 
            -
                @image = Image.new  | 
| 31 | 
            +
                @image = Image.new if @image.nil?
         | 
| 32 32 |  | 
| 33 33 | 
             
                @url_override = admin_images_url(:dialog => from_dialog?)
         | 
| 34 34 | 
             
              end
         | 
| @@ -38,7 +38,7 @@ class Admin::ImagesController < Admin::BaseController | |
| 38 38 |  | 
| 39 39 | 
             
                @url_override = admin_images_url(:dialog => from_dialog?, :insert => true)
         | 
| 40 40 |  | 
| 41 | 
            -
                 | 
| 41 | 
            +
                if params[:conditions].present?
         | 
| 42 42 | 
             
                  extra_condition = params[:conditions].split(',')
         | 
| 43 43 |  | 
| 44 44 | 
             
                  extra_condition[1] = true if extra_condition[1] == "true"
         | 
| @@ -68,8 +68,10 @@ class Admin::ImagesController < Admin::BaseController | |
| 68 68 | 
             
                    render :action => 'new'
         | 
| 69 69 | 
             
                  end
         | 
| 70 70 | 
             
                else
         | 
| 71 | 
            -
                   | 
| 72 | 
            -
             | 
| 71 | 
            +
                  if @image.valid?
         | 
| 72 | 
            +
                    @image_id = @image.id
         | 
| 73 | 
            +
                    @image = nil
         | 
| 74 | 
            +
                  end
         | 
| 73 75 | 
             
                  self.insert
         | 
| 74 76 | 
             
                end
         | 
| 75 77 | 
             
              end
         | 
| @@ -8,7 +8,19 @@ class Image < ActiveRecord::Base | |
| 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 | 
            -
             | 
| 11 | 
            +
               def validate
         | 
| 12 | 
            +
                 if self.filename.nil?
         | 
| 13 | 
            +
                   errors.add_to_base("You must choose an image to upload")
         | 
| 14 | 
            +
                 else
         | 
| 15 | 
            +
                   [:size, :content_type].each do |attr_name|
         | 
| 16 | 
            +
                     enum = attachment_options[attr_name]
         | 
| 17 | 
            +
                     unless enum.nil? || enum.include?(send(attr_name))
         | 
| 18 | 
            +
                       errors.add_to_base("Images should be smaller than 50 MB in size") if attr_name == :size
         | 
| 19 | 
            +
                       errors.add_to_base("Your image must be either a JPG, PNG or GIF") if attr_name == :content_type
         | 
| 20 | 
            +
                     end
         | 
| 21 | 
            +
                   end
         | 
| 22 | 
            +
                 end
         | 
| 23 | 
            +
               end
         | 
| 12 24 |  | 
| 13 25 | 
             
              # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
         | 
| 14 26 | 
             
              acts_as_indexed :fields => [:title],
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            <%= error_messages_for | 
| 1 | 
            +
            <%= error_messages_for :image %>
         | 
| 2 2 |  | 
| 3 3 | 
             
            <% form_for [:admin, @image], :url => @url_override || @url,
         | 
| 4 4 | 
             
                                          :html => {:multipart => true, :style => 'float: left; width: 70%'} do |f| %>
         | 
| @@ -20,13 +20,13 @@ | |
| 20 20 | 
             
            <div id='records'>
         | 
| 21 21 | 
             
              <% if searching? %>
         | 
| 22 22 | 
             
                <h2>Search Results for "<%= params[:search] %>"</h2>
         | 
| 23 | 
            -
                <% if @images. | 
| 23 | 
            +
                <% if @images.any? %>
         | 
| 24 24 | 
             
                  <%= render :partial => "#{current_image_view}_view" %>
         | 
| 25 25 | 
             
                <% else %>
         | 
| 26 26 | 
             
                  <p>Sorry, no results found.</p>
         | 
| 27 27 | 
             
                <% end %>
         | 
| 28 28 | 
             
              <% else %>
         | 
| 29 | 
            -
                <% if @images. | 
| 29 | 
            +
                <% if @images.any? %>
         | 
| 30 30 | 
             
                  <%= will_paginate @images, :previous_label => '«', :next_label => '»' %>
         | 
| 31 31 | 
             
                  <%= render :partial => "#{current_image_view}_view" %>
         | 
| 32 32 | 
             
                  <%= will_paginate @images, :previous_label => '«', :next_label => '»' %>
         | 
| @@ -1,20 +1,20 @@ | |
| 1 1 | 
             
            <div class='clearfix'>
         | 
| 2 2 | 
             
              <div id='dialog_menu_left'>
         | 
| 3 | 
            -
                <%  | 
| 4 | 
            -
                  <span id="existing_image_radio" class="radio<%= " selected_radio" if @image.errors.empty?  | 
| 3 | 
            +
                <% if @images.any? %>
         | 
| 4 | 
            +
                  <span id="existing_image_radio" class="radio<%= " selected_radio" if @image.errors.empty? %>">
         | 
| 5 5 | 
             
                    <input type='radio' name='image_type' value='existing_image' id='image_type_existing' <%= "checked='true'" if @image.errors.empty? %> />
         | 
| 6 6 | 
             
                    <label for='image_type_existing' class='stripped'>Existing Image</label>
         | 
| 7 7 | 
             
                  </span>
         | 
| 8 8 | 
             
                <% end %>
         | 
| 9 | 
            -
                <span id="upload_image_radio" class="radio<%= " selected_radio" if @image.errors. | 
| 10 | 
            -
                  <input type='radio' name='image_type' value='upload_image' id='image_type_upload' <%= "checked='true'" if @images.empty? ||  | 
| 9 | 
            +
                <span id="upload_image_radio" class="radio<%= " selected_radio" if @image.errors.any? or @images.empty? %>">
         | 
| 10 | 
            +
                  <input type='radio' name='image_type' value='upload_image' id='image_type_upload' <%= "checked='true'" if @images.empty? || @image.errors.any? %> />
         | 
| 11 11 | 
             
                  <label for='image_type_upload' class='stripped'>New Image</label>
         | 
| 12 12 | 
             
                </span>
         | 
| 13 13 | 
             
              </div>
         | 
| 14 14 |  | 
| 15 15 | 
             
              <div id='dialog_main'>
         | 
| 16 | 
            -
                <%  | 
| 17 | 
            -
                  <div id='existing_image_area' class='dialog_area' <%= "style='display:none;'"  | 
| 16 | 
            +
                <% if @images.any? %>
         | 
| 17 | 
            +
                  <div id='existing_image_area' class='dialog_area' <%= "style='display:none;'" if @image.errors.any? %>>
         | 
| 18 18 | 
             
                    <input type='hidden' name='selected_image' id='selected_image' />
         | 
| 19 19 | 
             
                    <div id='existing_image_area_content' class='clearfix'>
         | 
| 20 20 | 
             
                      <ul>
         | 
| @@ -28,7 +28,7 @@ | |
| 28 28 | 
             
                    <%= images_paginator @images, from_dialog? %>
         | 
| 29 29 | 
             
                  </div>
         | 
| 30 30 | 
             
                <% end %>
         | 
| 31 | 
            -
                <div id='upload_image_area' class='dialog_area' <%= "style='display:none;'"  | 
| 31 | 
            +
                <div id='upload_image_area' class='dialog_area' <%= "style='display:none;'" if @images.any? and @image.errors.empty? %>>
         | 
| 32 32 | 
             
                  <%= render :partial => "form", :locals => {:insert => true} %>
         | 
| 33 33 | 
             
                </div>
         | 
| 34 34 | 
             
              </div>
         | 
| @@ -47,4 +47,4 @@ | |
| 47 47 | 
             
                  image_dialog.init(<%= @callback.present? ? "self.parent.#{@callback}" : "null" %>);
         | 
| 48 48 | 
             
                });
         | 
| 49 49 | 
             
              </script>
         | 
| 50 | 
            -
            <% end %>
         | 
| 50 | 
            +
            <% end %>
         | 
| @@ -19,7 +19,7 @@ | |
| 19 19 | 
             
                <%= render :partial => "inquiry", :collection => @inquiries %>
         | 
| 20 20 | 
             
              <% else %>
         | 
| 21 21 | 
             
                <h2>Open Inquiries</h2>
         | 
| 22 | 
            -
                <% if @open_inquiries. | 
| 22 | 
            +
                <% if @open_inquiries.any? -%>
         | 
| 23 23 | 
             
                  <ul>
         | 
| 24 24 | 
             
                    <%= render :partial => "inquiry", :collection => @open_inquiries %>
         | 
| 25 25 | 
             
                  </ul>
         | 
| @@ -30,7 +30,7 @@ | |
| 30 30 | 
             
                  </p>
         | 
| 31 31 | 
             
                <% end -%>
         | 
| 32 32 | 
             
                <h2>Closed Inquiries</h2>
         | 
| 33 | 
            -
                <% if @closed_inquiries. | 
| 33 | 
            +
                <% if @closed_inquiries.any? -%>
         | 
| 34 34 | 
             
                  <ul>
         | 
| 35 35 | 
             
                    <%= render :partial => "inquiry", :collection => @closed_inquiries %>
         | 
| 36 36 | 
             
                  </ul>
         | 
| @@ -10,7 +10,7 @@ | |
| 10 10 | 
             
            </div>
         | 
| 11 11 | 
             
            <div id='records'>
         | 
| 12 12 | 
             
              <%= "<h2>Search Results for \"#{params[:search]}\"</h2>" if searching? %>
         | 
| 13 | 
            -
              <%  | 
| 13 | 
            +
              <% if @news_items.any? %>
         | 
| 14 14 | 
             
                <%= will_paginate @news_items, :previous_label => '«', :next_label => '»' %>
         | 
| 15 15 | 
             
                <ul>
         | 
| 16 16 | 
             
                  <%= render :partial => "news_item", :collection => @news_items %>
         | 
| @@ -2,4 +2,4 @@ | |
| 2 2 | 
             
            <li class='clearfix<%= " child#{child}" if child %><%= " linked" if linked%>' id="<%= dom_id(page_link) -%>">
         | 
| 3 3 | 
             
              <%= link_to page_link.title_with_meta, page_link.url, :title => 'Link to this Page', :rel => page_link.title, :class => 'page_link' %>
         | 
| 4 4 | 
             
            </li>
         | 
| 5 | 
            -
            <%= render :partial => 'page_link', :collection => page_link.children, :locals => {:child => child ? (child+1) : 1}  | 
| 5 | 
            +
            <%= render :partial => 'page_link', :collection => page_link.children, :locals => {:child => child ? (child+1) : 1} if page_link.children.any? %>
         | 
| @@ -19,7 +19,7 @@ | |
| 19 19 | 
             
                <%= h page.title %> <%= "<em>(hidden)</em>" unless page.show_in_menu? %>
         | 
| 20 20 | 
             
                <%= "<em>(draft)</em>" if page.draft? %>
         | 
| 21 21 | 
             
              </div>
         | 
| 22 | 
            -
              <%  | 
| 22 | 
            +
              <% if (children = page.children).any? %>
         | 
| 23 23 | 
             
                <ul<%= " class='nested'" %>>
         | 
| 24 24 | 
             
                  <% children.each do |child| %>
         | 
| 25 25 | 
             
                    <%= render :partial => 'list', :locals => {:page => child} %>
         | 
| @@ -16,7 +16,7 @@ | |
| 16 16 | 
             
            </div>
         | 
| 17 17 | 
             
            <div id='records' class='tree'>
         | 
| 18 18 | 
             
              <% if searching? %>
         | 
| 19 | 
            -
                <%  | 
| 19 | 
            +
                <% if @pages.any? %>
         | 
| 20 20 | 
             
                  <h2>Search Results for "<%= params[:search] %>"</h2>
         | 
| 21 21 | 
             
                  <ul id='sortable_list'>
         | 
| 22 22 | 
             
                    <%= render :partial => "sortable_list" %>
         | 
| @@ -27,7 +27,7 @@ | |
| 27 27 | 
             
                  </p>
         | 
| 28 28 | 
             
                <% end %>
         | 
| 29 29 | 
             
              <% else %>
         | 
| 30 | 
            -
                <%  | 
| 30 | 
            +
                <% if @pages.any? %>
         | 
| 31 31 | 
             
                  <ul id='sortable_list'>
         | 
| 32 32 | 
             
                    <%= render :partial => "sortable_list" %>
         | 
| 33 33 | 
             
                  </ul>
         | 
| @@ -8,7 +8,7 @@ | |
| 8 8 | 
             
              extra_body_content_classes << "no_right" if body_content_right.blank?
         | 
| 9 9 | 
             
            -%>
         | 
| 10 10 | 
             
            <%= render :partial => "/shared/submenu" if !admin? and (show_submenu ||= true) and RefinerySetting.find_or_set(:show_submenu_on_content_pages, true) %>
         | 
| 11 | 
            -
            <div id='body_content' class='clearfix<%= " #{extra_body_content_classes.join(" ")}"  | 
| 11 | 
            +
            <div id='body_content' class='clearfix<%= " #{extra_body_content_classes.join(" ")}" if extra_body_content_classes.any? %>'>
         | 
| 12 12 | 
             
            <% unless body_content_title.blank? and !(show_empty_sections ||= false) -%>
         | 
| 13 13 | 
             
              <h1 id='body_content_page_title'>
         | 
| 14 14 | 
             
                <%= body_content_title %>
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            <% if submenu_branch.in_menu? %>
         | 
| 2 2 | 
             
            <li<%= " class='selected'" if selected_page?(submenu_branch) or descendant_page_selected?(submenu_branch) %>>
         | 
| 3 3 | 
             
              <%= link_to submenu_branch.title, submenu_branch.url -%>
         | 
| 4 | 
            -
              <%  | 
| 4 | 
            +
              <% if (children = submenu_branch.children).any? %>
         | 
| 5 5 | 
             
              <ul>
         | 
| 6 6 | 
             
                <%= render :partial => "/shared/submenu_branch", :collection => children %>
         | 
| 7 7 | 
             
              </ul>
         | 
| @@ -10,7 +10,7 @@ | |
| 10 10 | 
             
            <div id='current_image_container_<%= randomiser %>'<%= " style='display: none'" if toggle_image_display %> style="margin-top: 10px;">
         | 
| 11 11 | 
             
              <a id='current_image_link_<%= randomiser %>' href="<%= insert_admin_images_url %>?thickbox=true&modal=true&titlebar=true&callback=image_picker_<%= randomiser %>_changed&KeepThis=true&TB_iframe=true&width=958&height=510" style='border: 0px' title='Change <%= description.titleize %>' name='Change <%= description.titleize %>' class='thickbox'>
         | 
| 12 12 | 
             
                <% unless image.nil? -%>
         | 
| 13 | 
            -
                  <%= image_fu image, nil, {:class => "brown_border", :id => " | 
| 13 | 
            +
                  <%= image_fu image, nil, {:class => "brown_border", :id => "current_picked_image_#{randomiser}"} %>
         | 
| 14 14 | 
             
                <% else -%>
         | 
| 15 15 | 
             
                  <img id="current_picked_image_<%= randomiser %>" class="" src="" alt="" style='display: none' />
         | 
| 16 16 | 
             
                <% end -%>
         | 
| @@ -27,7 +27,7 @@ | |
| 27 27 | 
             
                // We're so un-object-oriented here. We need to rewrite the jQuery admin.js file to use OO.
         | 
| 28 28 | 
             
                var image_picker_<%= randomiser %>_options = {
         | 
| 29 29 | 
             
                  thumbnail: '<%= thumbnail %>'
         | 
| 30 | 
            -
                  ,  | 
| 30 | 
            +
                  , image_toggler: '<%= toggle_image_display ? "#current_image_toggler_#{randomiser}" : "null" %>'
         | 
| 31 31 | 
             
                  , description: '<%= description %>'
         | 
| 32 32 | 
             
                  , field: '#current_image_id_<%= randomiser %>'
         | 
| 33 33 | 
             
                  , image_display: '#current_picked_image_<%= randomiser %>'
         | 
| @@ -17,13 +17,13 @@ | |
| 17 17 | 
             
            <div id='records'>
         | 
| 18 18 | 
             
              <%% if searching? %>
         | 
| 19 19 | 
             
                <h2>Search Results for "<%%= params[:search] %>"</h2>
         | 
| 20 | 
            -
                <%%  | 
| 20 | 
            +
                <%% if @<%= plural_name %>.any? %>
         | 
| 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 | 
            -
                <%%  | 
| 26 | 
            +
                <%% if @<%= plural_name %>.any? %>
         | 
| 27 27 | 
             
                  <%%= will_paginate @<%= plural_name %>, :previous_label => '«', :next_label => '»' %>
         | 
| 28 28 | 
             
                   <ul id='sortable_list'>
         | 
| 29 29 | 
             
                    <%%= render :partial => "sortable_list" %>
         | 
| @@ -6,7 +6,7 @@ | |
| 6 6 | 
             
              </ul>
         | 
| 7 7 | 
             
            </div>
         | 
| 8 8 | 
             
            <div id='records'>
         | 
| 9 | 
            -
              <%  | 
| 9 | 
            +
              <% if @refinery_settings.any? %>
         | 
| 10 10 | 
             
                <%= will_paginate @refinery_settings, :previous_label => '«', :next_label => '»' unless searching? %>
         | 
| 11 11 | 
             
                <ul>
         | 
| 12 12 | 
             
                  <%= render :partial => 'refinery_setting', :collection => @refinery_settings %>
         | 
| @@ -4,13 +4,13 @@ class Admin::ResourcesController < Admin::BaseController | |
| 4 4 | 
             
              before_filter :init_dialog
         | 
| 5 5 |  | 
| 6 6 | 
             
              def new
         | 
| 7 | 
            -
                @resource = Resource.new  | 
| 7 | 
            +
                @resource = Resource.new if @resource.nil?
         | 
| 8 8 |  | 
| 9 9 | 
             
                @url_override = admin_resources_url(:dialog => from_dialog?)
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 12 | 
             
              def create
         | 
| 13 | 
            -
                @resource = Resource.create | 
| 13 | 
            +
                @resource = Resource.create(params[:resource])
         | 
| 14 14 |  | 
| 15 15 | 
             
                unless params[:insert]
         | 
| 16 16 | 
             
                  if @resource.valid?
         | 
| @@ -25,8 +25,10 @@ class Admin::ResourcesController < Admin::BaseController | |
| 25 25 | 
             
                    render :action => 'new'
         | 
| 26 26 | 
             
                  end
         | 
| 27 27 | 
             
                else
         | 
| 28 | 
            -
                   | 
| 29 | 
            -
             | 
| 28 | 
            +
                  if @resource.valid?
         | 
| 29 | 
            +
                    @resource_id = @resource.id
         | 
| 30 | 
            +
                    @resource = nil
         | 
| 31 | 
            +
                  end
         | 
| 30 32 | 
             
                  self.insert
         | 
| 31 33 | 
             
                end
         | 
| 32 34 | 
             
              end
         | 
| @@ -56,7 +58,7 @@ class Admin::ResourcesController < Admin::BaseController | |
| 56 58 |  | 
| 57 59 | 
             
                @url_override = admin_resources_url(:dialog => from_dialog?, :insert => true)
         | 
| 58 60 |  | 
| 59 | 
            -
                 | 
| 61 | 
            +
                if params[:conditions].present?
         | 
| 60 62 | 
             
                  extra_condition = params[:conditions].split(',')
         | 
| 61 63 |  | 
| 62 64 | 
             
                  extra_condition[1] = true if extra_condition[1] == "true"
         | 
| @@ -5,7 +5,18 @@ class Resource < ActiveRecord::Base | |
| 5 5 | 
             
                             :size => 0.kilobytes..50.megabytes,
         | 
| 6 6 | 
             
                             :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/resources')
         | 
| 7 7 |  | 
| 8 | 
            -
               | 
| 8 | 
            +
              def validate
         | 
| 9 | 
            +
                if self.filename.nil?
         | 
| 10 | 
            +
                  errors.add_to_base("You must choose a file to upload")
         | 
| 11 | 
            +
                else
         | 
| 12 | 
            +
                  [:size].each do |attr_name|
         | 
| 13 | 
            +
                    enum = attachment_options[attr_name]
         | 
| 14 | 
            +
                    unless enum.nil? || enum.include?(send(attr_name))
         | 
| 15 | 
            +
                      errors.add_to_base("Files should be smaller than 50 MB in size") if attr_name == :size
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 9 20 |  | 
| 10 21 | 
             
              # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
         | 
| 11 22 | 
             
              acts_as_indexed :fields => [:title, :type_of_content],
         | 
| @@ -11,13 +11,13 @@ | |
| 11 11 | 
             
            <div id='records'>
         | 
| 12 12 | 
             
              <% if searching? %>
         | 
| 13 13 | 
             
                <h2>Search Results for "<%= params[:search] %>"</h2>
         | 
| 14 | 
            -
                <% if @resources. | 
| 14 | 
            +
                <% if @resources.any? %>
         | 
| 15 15 | 
             
                    <%= render :partial => "resource", :collection => @resources %>
         | 
| 16 16 | 
             
                <% else %>
         | 
| 17 17 | 
             
                  <p>Sorry, no results found.</p>
         | 
| 18 18 | 
             
                <% end %>
         | 
| 19 19 | 
             
              <% else %>
         | 
| 20 | 
            -
                <% if @resources. | 
| 20 | 
            +
                <% if @resources.any? -%>
         | 
| 21 21 | 
             
                  <%= will_paginate @resources, :previous_label => '«', :next_label => '»' %>
         | 
| 22 22 | 
             
                  <% if RefinerySetting.find_or_set(:group_resources_by_date_uploaded, true) %>
         | 
| 23 23 | 
             
                    <% @grouped_resources.each do |container| %>
         | 
| @@ -1,29 +1,33 @@ | |
| 1 1 | 
             
            <div class='clearfix'>
         | 
| 2 2 | 
             
              <div id='dialog_menu_left'>
         | 
| 3 | 
            -
                <%  | 
| 4 | 
            -
                  <span id='existing_resource_radio' class='radio<%= " selected_radio" if @resource.errors.empty?  | 
| 3 | 
            +
                <% if @resources.any? %>
         | 
| 4 | 
            +
                  <span id='existing_resource_radio' class='radio<%= " selected_radio" if @resource.errors.empty? %>'>
         | 
| 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>
         | 
| 8 8 | 
             
                <% end %>
         | 
| 9 | 
            -
                <span id='upload_resource_radio' class='radio<%= " selected_radio" if @resource.errors. | 
| 10 | 
            -
                  <input type='radio' name='resource_type' value='upload_resource' id='resource_type_upload' <%= "checked='true'" if @resources.empty? or  | 
| 9 | 
            +
                <span id='upload_resource_radio' class='radio<%= " selected_radio" if @resource.errors.any? or @resources.empty? %>'>
         | 
| 10 | 
            +
                  <input type='radio' name='resource_type' value='upload_resource' id='resource_type_upload' <%= "checked='true'" if @resources.empty? or @resource.errors.any? %> />
         | 
| 11 11 | 
             
                  <label for='resource_type_upload' class='stripped'>New File</label>
         | 
| 12 12 | 
             
                </span>
         | 
| 13 13 | 
             
              </div>
         | 
| 14 14 |  | 
| 15 15 | 
             
              <div id='dialog_main'>
         | 
| 16 | 
            -
                <%  | 
| 17 | 
            -
                  <div id='existing_resource_area' class='dialog_area' <%= "style='display:none;'"  | 
| 16 | 
            +
                <% if @resources.any? %>
         | 
| 17 | 
            +
                  <div id='existing_resource_area' class='dialog_area' <%= "style='display:none;'" if @resource.errors.any? %>>
         | 
| 18 18 | 
             
                    <input type='hidden' name='linked_resource' id='linked_resource' />
         | 
| 19 19 | 
             
                    <div id='existing_resource_area_content' class='clearfix'>
         | 
| 20 20 | 
             
                      <div id='pages_list'>
         | 
| 21 21 | 
             
                        <ul class='link_list'>
         | 
| 22 22 | 
             
                          <% @resources.each do |resource| -%>
         | 
| 23 | 
            -
                            <% resource_linked = (resource.public_filename == params[:current_link])  | 
| 23 | 
            +
                            <% resource_linked = (resource.public_filename == params[:current_link]) if params[:current_link].present? %>
         | 
| 24 24 | 
             
                            <li<%= " class='linked'" if resource_linked %>>
         | 
| 25 | 
            -
                              <%= link_to "#{resource.title} (#{resource.public_filename})", | 
| 26 | 
            -
                                           | 
| 25 | 
            +
                              <%= link_to "#{resource.title} (#{resource.public_filename})",
         | 
| 26 | 
            +
                                          resource.public_filename,
         | 
| 27 | 
            +
                                          :title => 'Link to this Resource',
         | 
| 28 | 
            +
                                          :rel => resource.title,
         | 
| 29 | 
            +
                                          :class => 'page_link',
         | 
| 30 | 
            +
                                          :id => "resource_#{resource.id}" %>
         | 
| 27 31 | 
             
                            </li>
         | 
| 28 32 | 
             
                          <% end %>
         | 
| 29 33 | 
             
                        </ul>
         | 
| @@ -36,7 +40,7 @@ | |
| 36 40 | 
             
                                      :url => {:controller => "admin/resources", :action => "insert", :dialog => from_dialog?} unless @thickbox %>
         | 
| 37 41 | 
             
                  </div>
         | 
| 38 42 | 
             
                <% end %>
         | 
| 39 | 
            -
                <div id='upload_resource_area' class='dialog_area' <%= "style='display:none;'"  | 
| 43 | 
            +
                <div id='upload_resource_area' class='dialog_area' <%= "style='display:none;'" if @resources.any? and @resource.errors.empty? %>>
         | 
| 40 44 | 
             
                  <%= render :partial => "form", :locals => {:insert => true} %>
         | 
| 41 45 | 
             
                </div>
         | 
| 42 46 | 
             
              </div>
         | 
| @@ -46,10 +50,10 @@ | |
| 46 50 | 
             
                <%= submit_tag 'Insert', :id => "submit_button" %>
         | 
| 47 51 |  | 
| 48 52 | 
             
                <%= will_paginate @resources,
         | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            +
                                  :previous_label => '« Previous',
         | 
| 54 | 
            +
                                  :next_label => 'Next »',
         | 
| 55 | 
            +
                                  :renderer => Refinery::LinkRenderer,
         | 
| 56 | 
            +
                                  :url => {:controller => "admin/resources", :action => "insert", :dialog => from_dialog? } %>
         | 
| 53 57 | 
             
              </div>
         | 
| 54 58 | 
             
            <% end %>
         | 
| 55 59 |  | 
| @@ -13,18 +13,17 @@ | |
| 13 13 | 
             
            <div id='records'>
         | 
| 14 14 | 
             
              <% if searching? %>
         | 
| 15 15 | 
             
                <h2>Search Results for "<%= params[:search] %>"</h2>
         | 
| 16 | 
            -
                <% if @themes. | 
| 16 | 
            +
                <% if @themes.any? %>
         | 
| 17 17 | 
             
                    <%= render :partial => "theme", :collection => @themes %>
         | 
| 18 18 | 
             
                <% else %>
         | 
| 19 19 | 
             
                  <p>Sorry, no results found.</p>
         | 
| 20 20 | 
             
                <% end %>
         | 
| 21 21 | 
             
              <% else %>
         | 
| 22 | 
            -
                <% if @themes. | 
| 22 | 
            +
                <% if @themes.any? -%>
         | 
| 23 23 | 
             
                  <%= will_paginate @themes, :previous_label => '«', :next_label => '»' %>
         | 
| 24 24 | 
             
                  <ul id='image_grid'>
         | 
| 25 25 | 
             
                    <%= render :partial => "theme", :collection => @themes %>
         | 
| 26 26 | 
             
                  </ul>
         | 
| 27 | 
            -
             | 
| 28 27 | 
             
                  <%= will_paginate @themes, :previous_label => '«', :next_label => '»' %>
         | 
| 29 28 | 
             
                <% else -%>
         | 
| 30 29 | 
             
                  <p>
         | 
| @@ -32,4 +31,4 @@ | |
| 32 31 | 
             
                  </p>
         | 
| 33 32 | 
             
                <% end -%>
         | 
| 34 33 | 
             
              <% end %>
         | 
| 35 | 
            -
            </div>
         | 
| 34 | 
            +
            </div>
         |