smithycms 0.6.1 → 0.6.2
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.
- checksums.yaml +4 -4
 - data/app/assets/javascripts/smithy/asset_uploads.coffee +27 -25
 - data/app/assets/javascripts/smithy/editor.coffee +9 -4
 - data/app/models/smithy/assets_datatable.rb +9 -3
 - data/app/views/smithy/assets/_actions.html.erb +1 -1
 - data/app/views/smithy/assets/index.html.erb +3 -2
 - data/app/views/smithy/assets/selector_modal.html.erb +2 -1
 - data/lib/smithy/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 018b01cf5ecc5da13736a8510d7b6f46896cbfd1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 64e2790ec5c0df3f046c09a6a590acdf6f2a0456
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3fd38664b501d9fb6d06ef918d25fc479507df000393a21f624d8f760dd7c167a6d5c83b55563e71ea4e2ba29325217639739d225ca7c25b0ab71e16ec6499e7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4454069334657b4d12569529fd9a9e88884252786bf9a679d9434efcf70a4b7028130f52baab27600d48292d47ddea115d0a2dd5540a181b0cee65126add86f8
         
     | 
| 
         @@ -1,35 +1,37 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            $upload_button = $('#choose-files')
         
     | 
| 
       2 
2 
     | 
    
         
             
            $upload_form = $upload_button.closest('form')
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            file_input_selector = '#presigned_upload_field input[type="file"]'
         
     | 
| 
       4 
4 
     | 
    
         
             
            presigned_upload_field_url = $upload_button.attr('data-presigned-upload-field-url')
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
            $progress_bar = $($upload_form).append('<div class="progress" style="display:none;"><div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0;"></div></div>').find('.progress-bar')
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       6 
8 
     | 
    
         
             
            $upload_button.on 'click', (e) ->
         
     | 
| 
       7 
     | 
    
         
            -
              $ 
     | 
| 
      
 9 
     | 
    
         
            +
              $(file_input_selector).click();
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            total_uploaded = 0
         
     | 
| 
      
 12 
     | 
    
         
            +
            total_size = 0
         
     | 
| 
       8 
13 
     | 
    
         | 
| 
       9 
14 
     | 
    
         
             
            upload_files = (e) ->
         
     | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
      
 15 
     | 
    
         
            +
              total_uploaded = 0
         
     | 
| 
      
 16 
     | 
    
         
            +
              file_input = e.target
         
     | 
| 
      
 17 
     | 
    
         
            +
              $file_input = $(file_input)
         
     | 
| 
      
 18 
     | 
    
         
            +
              files = file_input.files
         
     | 
| 
       11 
19 
     | 
    
         
             
              if files.length
         
     | 
| 
       12 
     | 
    
         
            -
                $upload_form.submit()
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                # Reset the file input, so that it can be used again
         
     | 
| 
       15 
     | 
    
         
            -
                $.get presigned_upload_field_url, ->
         
     | 
| 
       16 
     | 
    
         
            -
                  $file_input = $('#presigned_upload_field').find('input[type="file"]')
         
     | 
| 
       17 
     | 
    
         
            -
                  bind_file_input()
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                $progress_bar = $($upload_form).append('<div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0;"></div></div>').find('.progress-bar')
         
     | 
| 
       20 
20 
     | 
    
         
             
                total_size = 0; (total_size += file.size for file in files)
         
     | 
| 
       21 
     | 
    
         
            -
                 
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                $(this).find("input[type=submit]").attr("disabled", true)
         
     | 
| 
       24 
     | 
    
         
            -
                $(document).on "upload:success", $upload_form, (e) ->
         
     | 
| 
       25 
     | 
    
         
            -
                  total_uploaded += e.originalEvent.detail.file.size
         
     | 
| 
       26 
     | 
    
         
            -
                  progress = parseInt(total_uploaded/total_size * 100, 10)
         
     | 
| 
       27 
     | 
    
         
            -
                  $progress_bar.css('width', "#{progress}%").attr('aria-valuenow', progress)
         
     | 
| 
       28 
     | 
    
         
            -
                  setTimeout((-> $progress_bar.parent().remove()), 2000) !$upload_form.find("input.uploading").length
         
     | 
| 
       29 
     | 
    
         
            -
                $(document).on "upload:failed", $upload_form, (e) ->
         
     | 
| 
       30 
     | 
    
         
            -
                  $(this).addClass("upload-failed").append("<p>Something went wrong, please check your connection and try again</p>")
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            bind_file_input = ->
         
     | 
| 
       33 
     | 
    
         
            -
              $file_input.on 'change', upload_files
         
     | 
| 
      
 21 
     | 
    
         
            +
                $progress_bar.parent().show()
         
     | 
| 
       34 
22 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
            $(document).on 'change', file_input_selector, upload_files
         
     | 
| 
      
 24 
     | 
    
         
            +
            $(document).on "upload:success", $upload_form, (e) ->
         
     | 
| 
      
 25 
     | 
    
         
            +
              total_uploaded += e.originalEvent.detail.file.size
         
     | 
| 
      
 26 
     | 
    
         
            +
              progress = parseInt(total_uploaded/total_size * 100, 10)
         
     | 
| 
      
 27 
     | 
    
         
            +
              $progress_bar.css('width', "#{progress}%").attr('aria-valuenow', progress)
         
     | 
| 
      
 28 
     | 
    
         
            +
              if !$upload_form.find("input.uploading").length
         
     | 
| 
      
 29 
     | 
    
         
            +
                $upload_form.submit()
         
     | 
| 
      
 30 
     | 
    
         
            +
                setTimeout((-> $progress_bar.css('width', "0%").parent().hide()), 1000)
         
     | 
| 
      
 31 
     | 
    
         
            +
            $(document).on "upload:failure", $upload_form, (e) ->
         
     | 
| 
      
 32 
     | 
    
         
            +
              $(this).addClass("upload-failed").append("<p>Something went wrong, please check your connection and try again</p>")
         
     | 
| 
      
 33 
     | 
    
         
            +
            $(document).on "upload:complete", $upload_form, (e) ->
         
     | 
| 
      
 34 
     | 
    
         
            +
              console.log("Complete")
         
     | 
| 
      
 35 
     | 
    
         
            +
              if !$upload_form.find("input.uploading").length
         
     | 
| 
      
 36 
     | 
    
         
            +
                # Reset the file input, so that it can be used again
         
     | 
| 
      
 37 
     | 
    
         
            +
                $.get presigned_upload_field_url
         
     | 
| 
         @@ -46,7 +46,7 @@ create_ace_toolbar = (editor, assets_modal_url, pages_modal_url) -> 
     | 
|
| 
       46 
46 
     | 
    
         
             
              ]
         
     | 
| 
       47 
47 
     | 
    
         
             
              actions = [
         
     | 
| 
       48 
48 
     | 
    
         
             
                $("<a href='javascript:void(0);' data-command='bold'><i class='fa fa-bold'></i></a>"),
         
     | 
| 
       49 
     | 
    
         
            -
                $("<a href='javascript:void(0);' data-command=' 
     | 
| 
      
 49 
     | 
    
         
            +
                $("<a href='javascript:void(0);' data-command='italic'><i class='fa fa-italic'></i></a>"),
         
     | 
| 
       50 
50 
     | 
    
         
             
                heading_dropdown,
         
     | 
| 
       51 
51 
     | 
    
         
             
                $("<a href='javascript:void(0);'><i class='fa fa-link'></i></a>").click(-> open_link_selector(pages_modal_url, editor))
         
     | 
| 
       52 
52 
     | 
    
         
             
                $("<a href='javascript:void(0);'>Image</a>").click(-> open_asset_selector(assets_modal_url, editor))
         
     | 
| 
         @@ -89,10 +89,16 @@ open_link_selector = (url, editor) -> 
     | 
|
| 
       89 
89 
     | 
    
         
             
                $form = $modal.find('form')
         
     | 
| 
       90 
90 
     | 
    
         
             
                $label_field = $form.find('input[name="label"]')
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
      
 92 
     | 
    
         
            +
                $label_field.on 'keypress', ->
         
     | 
| 
      
 93 
     | 
    
         
            +
                  $(this).data('custom-text', true)
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
       92 
95 
     | 
    
         
             
                $modal.on 'shown.bs.modal', ->
         
     | 
| 
       93 
     | 
    
         
            -
                  $label_field.val(editor.getSelectedText()) if !editor.selection.isEmpty()
         
     | 
| 
      
 96 
     | 
    
         
            +
                  $label_field.val(editor.getSelectedText()).trigger('keypress') if !editor.selection.isEmpty()
         
     | 
| 
       94 
97 
     | 
    
         
             
                .trigger('shown.bs.modal')
         
     | 
| 
       95 
98 
     | 
    
         | 
| 
      
 99 
     | 
    
         
            +
                $modal.on 'hidden.bs.modal', ->
         
     | 
| 
      
 100 
     | 
    
         
            +
                  $modal.find('form').trigger('reset')
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
       96 
102 
     | 
    
         
             
                $url_fields = $form.find('select[name="page"], input[name="url"]')
         
     | 
| 
       97 
103 
     | 
    
         
             
                $form.find('select[name="type"]').on 'change', (e) ->
         
     | 
| 
       98 
104 
     | 
    
         
             
                  $url_fields.closest('.form-group').addClass('hidden')
         
     | 
| 
         @@ -100,7 +106,7 @@ open_link_selector = (url, editor) -> 
     | 
|
| 
       100 
106 
     | 
    
         
             
                .change()
         
     | 
| 
       101 
107 
     | 
    
         | 
| 
       102 
108 
     | 
    
         
             
                $form.find('select[name="page"]').on 'change', (e) ->
         
     | 
| 
       103 
     | 
    
         
            -
                  $label_field.val($(this).find('option:selected').text().replace(/^[- ]+/, '')) if !$label_field. 
     | 
| 
      
 109 
     | 
    
         
            +
                  $label_field.val($(this).find('option:selected').text().replace(/^[- ]+/, '')) if !$label_field.data('custom-text')
         
     | 
| 
       104 
110 
     | 
    
         | 
| 
       105 
111 
     | 
    
         
             
                $modal.find('.btn.select').click ->
         
     | 
| 
       106 
112 
     | 
    
         
             
                  $form.submit()
         
     | 
| 
         @@ -113,7 +119,6 @@ open_link_selector = (url, editor) -> 
     | 
|
| 
       113 
119 
     | 
    
         
             
                  link_string = link_string + '{:target="_blank"}' if form.open_in_new_tab.checked
         
     | 
| 
       114 
120 
     | 
    
         
             
                  editor.insert(link_string)
         
     | 
| 
       115 
121 
     | 
    
         
             
                  $modal.modal('toggle')
         
     | 
| 
       116 
     | 
    
         
            -
                  $form.trigger('reset')
         
     | 
| 
       117 
122 
     | 
    
         
             
                  editor.focus()
         
     | 
| 
       118 
123 
     | 
    
         
             
                  return false
         
     | 
| 
       119 
124 
     | 
    
         | 
| 
         @@ -3,7 +3,7 @@ module Smithy 
     | 
|
| 
       3 
3 
     | 
    
         
             
                include AssetsHelper
         
     | 
| 
       4 
4 
     | 
    
         
             
                delegate :params, :link_to, :image_tag, :number_to_human_size, :attachment_url, :attachment_image_tag, :file_type_icon, :check_box_tag, :render, to: :@view
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                def initialize(view, view_type)
         
     | 
| 
      
 6 
     | 
    
         
            +
                def initialize(view, view_type='index_view')
         
     | 
| 
       7 
7 
     | 
    
         
             
                  @view = view
         
     | 
| 
       8 
8 
     | 
    
         
             
                  @view_type = view_type
         
     | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
         @@ -38,7 +38,8 @@ module Smithy 
     | 
|
| 
       38 
38 
     | 
    
         
             
                      asset_preview_link(asset),
         
     | 
| 
       39 
39 
     | 
    
         
             
                      asset.name,
         
     | 
| 
       40 
40 
     | 
    
         
             
                      number_to_human_size(asset.file_size),
         
     | 
| 
       41 
     | 
    
         
            -
                      asset.file_content_type
         
     | 
| 
      
 41 
     | 
    
         
            +
                      asset.file_content_type,
         
     | 
| 
      
 42 
     | 
    
         
            +
                      asset.updated_at.strftime('%b %e, %Y %H:%M:%S')
         
     | 
| 
       42 
43 
     | 
    
         
             
                    ]
         
     | 
| 
       43 
44 
     | 
    
         
             
                  else
         
     | 
| 
       44 
45 
     | 
    
         
             
                    [
         
     | 
| 
         @@ -47,6 +48,7 @@ module Smithy 
     | 
|
| 
       47 
48 
     | 
    
         
             
                      asset.name,
         
     | 
| 
       48 
49 
     | 
    
         
             
                      number_to_human_size(asset.file_size),
         
     | 
| 
       49 
50 
     | 
    
         
             
                      asset.file_content_type,
         
     | 
| 
      
 51 
     | 
    
         
            +
                      asset.updated_at.strftime('%b %e, %Y %H:%M:%S'),
         
     | 
| 
       50 
52 
     | 
    
         
             
                      render(partial: '/smithy/assets/actions', formats: :html, locals: { asset: asset })
         
     | 
| 
       51 
53 
     | 
    
         
             
                    ]
         
     | 
| 
       52 
54 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -75,7 +77,11 @@ module Smithy 
     | 
|
| 
       75 
77 
     | 
    
         
             
                end
         
     | 
| 
       76 
78 
     | 
    
         | 
| 
       77 
79 
     | 
    
         
             
                def sort_column
         
     | 
| 
       78 
     | 
    
         
            -
                   
     | 
| 
      
 80 
     | 
    
         
            +
                  if @view_type == 'selector_view'
         
     | 
| 
      
 81 
     | 
    
         
            +
                    columns = %w[url preview name file_size file_content_type updated_at]
         
     | 
| 
      
 82 
     | 
    
         
            +
                  else
         
     | 
| 
      
 83 
     | 
    
         
            +
                    columns = %w[delete preview name file_size file_content_type updated_at actions]
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
       79 
85 
     | 
    
         
             
                  columns[params[:order][:"0"][:column].to_i]
         
     | 
| 
       80 
86 
     | 
    
         
             
                end
         
     | 
| 
       81 
87 
     | 
    
         | 
| 
         @@ -1,3 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <%= link_to "Copy URL", asset 
     | 
| 
      
 1 
     | 
    
         
            +
            <%= link_to "Copy URL", asset_path(asset), class: "btn btn-primary btn-xs copy-to-clipboard", data: { 'clipboard-text' => asset_path(asset) } %>
         
     | 
| 
       2 
2 
     | 
    
         
             
            <%= link_to "Edit", [:edit, asset], class: "btn btn-primary btn-xs" %>
         
     | 
| 
       3 
3 
     | 
    
         
             
            <%= link_to "Delete", asset, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: "Are you sure?" } %>
         
     | 
| 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
                <%= f.inputs do %>
         
     | 
| 
       6 
6 
     | 
    
         
             
                  <a id="choose-files" data-presigned-upload-field-url="<%= presigned_upload_field_asset_source_path(@asset_source) %>" class="btn btn-default" href="javascript:void(0);"><%= icon('cloud-upload') %> Upload files</a>
         
     | 
| 
       7 
7 
     | 
    
         
             
                  <div id="presigned_upload_field" style="display:none;"><%= f.attachment_field :assets_files, multiple: true, direct: true, presigned: true %></div>
         
     | 
| 
       8 
     | 
    
         
            -
                  <%= f.action :submit,  
     | 
| 
      
 8 
     | 
    
         
            +
                  <%= f.action :submit, button_html: { style: 'display:none;' } %>
         
     | 
| 
       9 
9 
     | 
    
         
             
                <% end %>
         
     | 
| 
       10 
10 
     | 
    
         
             
              <% end %>
         
     | 
| 
       11 
11 
     | 
    
         
             
            </div>
         
     | 
| 
         @@ -14,7 +14,7 @@ 
     | 
|
| 
       14 
14 
     | 
    
         
             
            <%= semantic_form_for 'Asset', as: "assets", url: batch_destroy_assets_path, remote: true do |f| %>
         
     | 
| 
       15 
15 
     | 
    
         
             
              <%= f.action :submit, label: 'Delete Selected', button_html: { id: "delete_selected_assets", class: 'btn btn-danger', style: "display:none;" } %>
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              <%= content_tag :table, id: "assets", class: "table table-striped responsive no-wrap display", data: { source: "#{ assets_url(format: "json") }" } do %>
         
     | 
| 
      
 17 
     | 
    
         
            +
              <%= content_tag :table, id: "assets", class: "table table-striped responsive no-wrap display", data: { source: "#{ assets_url(format: "json") }", order: '[[ 5, "desc" ]]' } do %>
         
     | 
| 
       18 
18 
     | 
    
         
             
                <thead>
         
     | 
| 
       19 
19 
     | 
    
         
             
                  <tr>
         
     | 
| 
       20 
20 
     | 
    
         
             
                    <%= content_tag :th, check_box_tag("assets_table_select_all"), class: 'column_delete', style: 'width:20px;', data: { orderable: false, searchable: false } %>
         
     | 
| 
         @@ -22,6 +22,7 @@ 
     | 
|
| 
       22 
22 
     | 
    
         
             
                    <th>Name</th>
         
     | 
| 
       23 
23 
     | 
    
         
             
                    <th>Size</th>
         
     | 
| 
       24 
24 
     | 
    
         
             
                    <th>Type</th>
         
     | 
| 
      
 25 
     | 
    
         
            +
                    <th>Last Updated</th>
         
     | 
| 
       25 
26 
     | 
    
         
             
                    <%= content_tag :th, "Actions", data: { orderable: false, searchable: false } %>
         
     | 
| 
       26 
27 
     | 
    
         
             
                  </tr>
         
     | 
| 
       27 
28 
     | 
    
         
             
                </thead>
         
     | 
| 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
              Insert Image(s)
         
     | 
| 
       3 
3 
     | 
    
         
             
            <% end %>
         
     | 
| 
       4 
4 
     | 
    
         
             
            <div>
         
     | 
| 
       5 
     | 
    
         
            -
              <%= content_tag :table, id: "assets", class: "table table-striped no-wrap display", data: { source: "#{ assets_url(format: "json", type: :selector_view) }" } do %>
         
     | 
| 
      
 5 
     | 
    
         
            +
              <%= content_tag :table, id: "assets", class: "table table-striped no-wrap display", data: { source: "#{ assets_url(format: "json", type: :selector_view) }", order: '[[ 5, "desc" ]]' } do %>
         
     | 
| 
       6 
6 
     | 
    
         
             
                <thead>
         
     | 
| 
       7 
7 
     | 
    
         
             
                  <tr>
         
     | 
| 
       8 
8 
     | 
    
         
             
                    <%= content_tag :th, "", data: { orderable: false, searchable: false, visible: false } %>
         
     | 
| 
         @@ -10,6 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
                    <th>Name</th>
         
     | 
| 
       11 
11 
     | 
    
         
             
                    <th>Size</th>
         
     | 
| 
       12 
12 
     | 
    
         
             
                    <th>Type</th>
         
     | 
| 
      
 13 
     | 
    
         
            +
                    <th>Last Updated</th>
         
     | 
| 
       13 
14 
     | 
    
         
             
                  </tr>
         
     | 
| 
       14 
15 
     | 
    
         
             
                </thead>
         
     | 
| 
       15 
16 
     | 
    
         
             
              <% end %>
         
     | 
    
        data/lib/smithy/version.rb
    CHANGED