bootstrap_refile 0.0.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 +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/bootstrap_refile.js +60 -0
- data/app/assets/stylesheets/bootstrap_refile.scss +106 -0
- data/bootstrap_refile.gemspec +26 -0
- data/lib/bootstrap_refile/rails/attachment_helper.rb +107 -0
- data/lib/bootstrap_refile/version.rb +3 -0
- data/lib/bootstrap_refile.rb +13 -0
- metadata +111 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 6ba7c473753c6e2aa933e40c6aacfa6d90f71614
         | 
| 4 | 
            +
              data.tar.gz: 1af4eef11284c53d217ea53a1d8b11691179f32d
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 73f24c6950ad409362b7bf4ee1088c812ff2a6bcf1f66ab433ae6e81b27479212fededadc8e9e300988d6c793380297875457e6ec8ee9908fe46c808b33e228a
         | 
| 7 | 
            +
              data.tar.gz: 5236baff08ef97e33961ae45ee29bc71a80ce8c8366158d04c7c47d290b72481a323a60b720d0fdf20f69c76fd2fccee93d1f14ea2d278a7946c1fe5ec9c1bf2
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 Joshua Novak
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            # Bootstrap Refile
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            A bootstrap styled single file uploader for refile with progress bar and image preview.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```ruby
         | 
| 10 | 
            +
            gem 'bootstrap_refile'
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            `bundle install` and restart your server to make the files available through the pipeline.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Add this line to your javascript file ( after `//= require refile` ):
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            ```js
         | 
| 18 | 
            +
            //= require bootstrap_refile
         | 
| 19 | 
            +
            ```
         | 
| 20 | 
            +
             | 
| 21 | 
            +
             | 
| 22 | 
            +
            Add this line to your stylesheet:
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            ```scss
         | 
| 25 | 
            +
            @import "bootstrap_refile";
         | 
| 26 | 
            +
            ```
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             | 
| 29 | 
            +
            ## Usage
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ``` erb
         | 
| 32 | 
            +
            <%= form_for @user do |form| %>
         | 
| 33 | 
            +
              <%= form.bootstrap_attachment_field :profile_image %>
         | 
| 34 | 
            +
            <% end %>
         | 
| 35 | 
            +
            ```
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            If you want to change the style of the progress bar you can pass it in:
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ``` erb
         | 
| 40 | 
            +
            <%= form_for @user do |form| %>
         | 
| 41 | 
            +
              <%= form.attachment_field :profile_image, progress_class: 'progress-bar-danger' %>
         | 
| 42 | 
            +
            <% end %>
         | 
| 43 | 
            +
            ```
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            Options:
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            - progress_class
         | 
| 48 | 
            +
            - remove_class
         | 
| 49 | 
            +
            - select_class
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            $(document).on("upload:start", "input[type=file]", function(e) {
         | 
| 2 | 
            +
              var refileUploadContainer = $(this).closest(".refile-upload");
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              $(this).closest("form").find("input[type=submit]").attr("disabled", true);
         | 
| 5 | 
            +
              //refileUploadContainer.find('.progress').css('opacity', 1);
         | 
| 6 | 
            +
            });
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            $(document).on("upload:progress", "input[type=file]", function(e) {
         | 
| 9 | 
            +
              var refileUploadContainer = $(this).closest(".refile-upload");
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              var detail = e.originalEvent.detail;
         | 
| 12 | 
            +
              var progress = Math.round(detail.loaded / detail.total * 100);
         | 
| 13 | 
            +
              var progressBar = refileUploadContainer.find('.progress-bar');
         | 
| 14 | 
            +
              progressBar.css('width', progress + '%');
         | 
| 15 | 
            +
              progressBar.attr('aria-valuenow', progress);
         | 
| 16 | 
            +
              progressBar.find('.sr-only').text(progress + '% Complete');
         | 
| 17 | 
            +
            });
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            $(document).on("upload:complete", "input[type=file]", function(e) {
         | 
| 20 | 
            +
              var refileUploadContainer = $(this).closest(".refile-upload");
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              if(!refileUploadContainer.find("input.uploading").length) {
         | 
| 23 | 
            +
                $(this).closest("form").find("input[type=submit]").removeAttr("disabled");
         | 
| 24 | 
            +
                var progressBar = refileUploadContainer.find('.progress-bar');
         | 
| 25 | 
            +
                progressBar.css('width', '0%');
         | 
| 26 | 
            +
                progressBar.attr('aria-valuenow', 0);
         | 
| 27 | 
            +
                progressBar.find('.sr-only').text('0% Complete');
         | 
| 28 | 
            +
                //refileUploadContainer.find('.progress').css('opacity', 0);
         | 
| 29 | 
            +
              }
         | 
| 30 | 
            +
            });
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            $(document).on("change", "input[type=file]", function() {
         | 
| 33 | 
            +
              fileIcons = {
         | 
| 34 | 
            +
                'default': 'fa-file-o',
         | 
| 35 | 
            +
                'pdf': 'fa-file-pdf-o',
         | 
| 36 | 
            +
                'xls': 'fa-file-excel-o',
         | 
| 37 | 
            +
                'xlsx': 'fa-file-excel-o',
         | 
| 38 | 
            +
                'csv': 'fa-file-excel-o',
         | 
| 39 | 
            +
                'doc': 'fa-file-word-o',
         | 
| 40 | 
            +
                'docx': 'fa-file-word-o',
         | 
| 41 | 
            +
                'jpg': 'fa-file-image-o',
         | 
| 42 | 
            +
                'jpeg': 'fa-file-image-o',
         | 
| 43 | 
            +
                'png': 'fa-file-image-o',
         | 
| 44 | 
            +
                'gif': 'fa-file-image-o'
         | 
| 45 | 
            +
              }
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              if (this.files.length == 0) return;
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              var refileUploadContainer = $(this).closest(".refile-upload");
         | 
| 50 | 
            +
              var fileName = this.files[0].name;
         | 
| 51 | 
            +
              var fileExt = fileName.split('.').pop().toLowerCase();
         | 
| 52 | 
            +
              var attachmentIcon = (fileIcons[fileExt])? fileIcons[fileExt] : fileIcons['default']
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              refileUploadContainer.addClass('filled').addClass((fileExt != '')? 'filled-type-' + fileExt : '');
         | 
| 55 | 
            +
              refileUploadContainer.find('.file-info').html('<i class="fa ' + attachmentIcon + '"></i> ' + fileName);
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              var reader = new FileReader();
         | 
| 58 | 
            +
              reader.onload = function (e) { refileUploadContainer.find("img.preview").attr("src", e.target.result); };
         | 
| 59 | 
            +
              reader.readAsDataURL(this.files[0]);
         | 
| 60 | 
            +
            });
         | 
| @@ -0,0 +1,106 @@ | |
| 1 | 
            +
            .refile-upload {
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              .progress {
         | 
| 4 | 
            +
                height: 10px;
         | 
| 5 | 
            +
                // opacity: 0;
         | 
| 6 | 
            +
                margin-bottom: 10px;
         | 
| 7 | 
            +
              }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              .file-info {
         | 
| 10 | 
            +
                font-size: 12px;
         | 
| 11 | 
            +
                opacity: .5;
         | 
| 12 | 
            +
                margin-bottom: 10px;
         | 
| 13 | 
            +
                white-space: nowrap;
         | 
| 14 | 
            +
                overflow: hidden;
         | 
| 15 | 
            +
                text-overflow: ellipsis;
         | 
| 16 | 
            +
              }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              .file-preview {
         | 
| 19 | 
            +
                border: none;
         | 
| 20 | 
            +
                border-radius: 0;
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                .file-preview-frame {
         | 
| 23 | 
            +
                  box-shadow: none;
         | 
| 24 | 
            +
                  border: none;
         | 
| 25 | 
            +
                  height: auto !important;
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  &:hover,
         | 
| 28 | 
            +
                  &:active,
         | 
| 29 | 
            +
                  &:focus {
         | 
| 30 | 
            +
                    box-shadow: none;
         | 
| 31 | 
            +
                    border: none;
         | 
| 32 | 
            +
                  }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  // img {
         | 
| 35 | 
            +
                  //   width: 100%;
         | 
| 36 | 
            +
                  //   max-width: 150px;
         | 
| 37 | 
            +
                  //   height: auto !important;
         | 
| 38 | 
            +
                  // }
         | 
| 39 | 
            +
                }
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                .fileinput-remove {
         | 
| 42 | 
            +
                  display: none;
         | 
| 43 | 
            +
                }
         | 
| 44 | 
            +
              }
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              // img.preview {
         | 
| 47 | 
            +
              //   width: 100%;
         | 
| 48 | 
            +
              //   max-width: 150px;
         | 
| 49 | 
            +
              //   height: auto;
         | 
| 50 | 
            +
              // }
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              // .drop {
         | 
| 53 | 
            +
              //   padding: 15px;
         | 
| 54 | 
            +
              //   border: 2px #f1f1f1 dashed;
         | 
| 55 | 
            +
              //   border-radius: 5px;
         | 
| 56 | 
            +
              //   line-height: 34px;
         | 
| 57 | 
            +
              // }
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              .btn-file {
         | 
| 60 | 
            +
                  position: relative;
         | 
| 61 | 
            +
                  overflow: hidden;
         | 
| 62 | 
            +
              }
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              .btn-file input[type=file] {
         | 
| 65 | 
            +
                  position: absolute;
         | 
| 66 | 
            +
                  top: 0;
         | 
| 67 | 
            +
                  right: 0;
         | 
| 68 | 
            +
                  min-width: 100%;
         | 
| 69 | 
            +
                  min-height: 100%;
         | 
| 70 | 
            +
                  font-size: 100px;
         | 
| 71 | 
            +
                  text-align: right;
         | 
| 72 | 
            +
                  filter: alpha(opacity=0);
         | 
| 73 | 
            +
                  opacity: 0;
         | 
| 74 | 
            +
                  outline: none;
         | 
| 75 | 
            +
                  background: white;
         | 
| 76 | 
            +
                  cursor: inherit;
         | 
| 77 | 
            +
                  display: block;
         | 
| 78 | 
            +
              }
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              .btn-remove {
         | 
| 81 | 
            +
                display: none;
         | 
| 82 | 
            +
              }
         | 
| 83 | 
            +
             | 
| 84 | 
            +
              &.filled {
         | 
| 85 | 
            +
                .btn-remove {
         | 
| 86 | 
            +
                  display: inline-block;
         | 
| 87 | 
            +
                }
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                .btn-file {
         | 
| 90 | 
            +
                  display: none;
         | 
| 91 | 
            +
                }
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                .thumbnail {
         | 
| 94 | 
            +
                  display: none;
         | 
| 95 | 
            +
                }
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                &.filled-type-jpg,
         | 
| 98 | 
            +
                &.filled-type-jpeg,
         | 
| 99 | 
            +
                &.filled-type-png,
         | 
| 100 | 
            +
                &.filled-type-gif {
         | 
| 101 | 
            +
                  .thumbnail {
         | 
| 102 | 
            +
                    display: block;
         | 
| 103 | 
            +
                  }
         | 
| 104 | 
            +
                }
         | 
| 105 | 
            +
              }
         | 
| 106 | 
            +
            }
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'bootstrap_refile/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "bootstrap_refile"
         | 
| 8 | 
            +
              spec.version       = BootstrapRefile::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Joshua Novak"]
         | 
| 10 | 
            +
              spec.email         = ["JoshuaNovak919@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = "A bootstrap styled single uploader for refile."
         | 
| 12 | 
            +
              spec.description   = "A bootstrap styled single uploader for refile."
         | 
| 13 | 
            +
              spec.homepage      = "https://github.com/JoshuaNovak919/bootstrap_refile"
         | 
| 14 | 
            +
              spec.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_dependency "railties", ">= 3.1"
         | 
| 22 | 
            +
              spec.add_dependency "refile"
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              spec.add_development_dependency "bundler", "~> 1.7"
         | 
| 25 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,107 @@ | |
| 1 | 
            +
            module BootstrapRefile
         | 
| 2 | 
            +
              # Rails view helpers which aid in using Refile from views.
         | 
| 3 | 
            +
              module AttachmentHelper
         | 
| 4 | 
            +
                # Form builder extension
         | 
| 5 | 
            +
                module FormBuilder
         | 
| 6 | 
            +
                  # @see BootstrapAttachmentHelper#attachment_field
         | 
| 7 | 
            +
                  def bootstrap_attachment_field(method, options = {})
         | 
| 8 | 
            +
                    self.multipart = true
         | 
| 9 | 
            +
                    @template.bootstrap_attachment_field(@object_name, method, objectify_options(options))
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                # Generates a form field which can be used with records which have
         | 
| 14 | 
            +
                # attachments. This will generate both a file field as well as a hidden
         | 
| 15 | 
            +
                # field which tracks the id of the file in the cache before it is
         | 
| 16 | 
            +
                # permanently stored.
         | 
| 17 | 
            +
                #
         | 
| 18 | 
            +
                # @param object_name                    The name of the object to generate a field for
         | 
| 19 | 
            +
                # @param method                         The name of the field
         | 
| 20 | 
            +
                # @param [Hash] options
         | 
| 21 | 
            +
                # @option options [Object] object       Set by the form builder, currently required for direct/presigned uploads to work.
         | 
| 22 | 
            +
                # @option options [Boolean] direct      If set to true, adds the appropriate data attributes for direct uploads with refile.js.
         | 
| 23 | 
            +
                # @option options [Boolean] presign     If set to true, adds the appropriate data attributes for presigned uploads with refile.js.
         | 
| 24 | 
            +
                # @return [ActiveSupport::SafeBuffer]   The generated form field
         | 
| 25 | 
            +
                def bootstrap_attachment_field(object_name, method, object:, **options)
         | 
| 26 | 
            +
                  file_icons = {
         | 
| 27 | 
            +
                    'default' => 'fa-file-o',
         | 
| 28 | 
            +
                    'pdf' => 'fa-file-pdf-o',
         | 
| 29 | 
            +
                    'xls' => 'fa-file-excel-o',
         | 
| 30 | 
            +
                    'xlsx' => 'fa-file-excel-o',
         | 
| 31 | 
            +
                    'csv' => 'fa-file-excel-o',
         | 
| 32 | 
            +
                    'doc' => 'fa-file-word-o',
         | 
| 33 | 
            +
                    'docx' => 'fa-file-word-o',
         | 
| 34 | 
            +
                    'jpg' => 'fa-file-image-o',
         | 
| 35 | 
            +
                    'jpeg' => 'fa-file-image-o',
         | 
| 36 | 
            +
                    'png' => 'fa-file-image-o',
         | 
| 37 | 
            +
                    'gif' => 'fa-file-image-o'
         | 
| 38 | 
            +
                  }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  options[:remove_class] ||= 'btn-primary'
         | 
| 41 | 
            +
                  options[:select_class] ||= 'btn-primary'
         | 
| 42 | 
            +
                  options[:progress_class] ||= ''
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  options[:data] ||= {}
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  attachment_name = method.to_s.humanize
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  file_exists = (!object["#{method}_id"].nil?)
         | 
| 49 | 
            +
                  file_extension = (file_exists)? File.extname(object["#{method}_filename"].to_s).gsub(/\./, '') : ''
         | 
| 50 | 
            +
                  file_name = (file_exists && !object["#{method}_filename"].to_s.blank?)? object["#{method}_filename"].to_s : 'No file selected'
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  image_url = (file_exists)? attachment_url(object, method.to_sym, :fit, 300, 300) : "http://placehold.it/300x200&text=#{attachment_name}"
         | 
| 53 | 
            +
                  image_tag = image_tag(image_url, class: 'preview img-responsive')
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  remove_attachment = check_box(object_name, "remove_#{method}".to_sym, { class: 'btn btn-primary' })
         | 
| 56 | 
            +
                  attacher = object.send(:"#{method}_attacher")
         | 
| 57 | 
            +
                  options[:accept] = attacher.accept
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  if options[:direct]
         | 
| 60 | 
            +
                    host = options[:host] || Refile.host || request.base_url
         | 
| 61 | 
            +
                    backend_name = Refile.backends.key(attacher.cache)
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    url = ::File.join(host, main_app.refile_app_path, backend_name)
         | 
| 64 | 
            +
                    options[:data].merge!(direct: true, as: "file", url: url)
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  if options[:presigned] and attacher.cache.respond_to?(:presign)
         | 
| 68 | 
            +
                    options[:data].merge!(direct: true).merge!(attacher.cache.presign.as_json)
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  attachment_field = hidden_field(object_name, method, value: attacher.data.to_json, object: object, id: nil)
         | 
| 72 | 
            +
                  attachment_field += file_field(object_name, method, options)
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  attachment_icon = (file_exists && file_icons[file_extension])? file_icons[file_extension] : file_icons['default']
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  result = <<-EOD
         | 
| 77 | 
            +
                  <div class="refile-upload #{(file_exists)? 'filled' : ''} #{(!file_extension.blank?)? "filled-type-#{file_extension}" : ''}">
         | 
| 78 | 
            +
                    <h4>#{attachment_name}</h4>
         | 
| 79 | 
            +
                    <div class="row">
         | 
| 80 | 
            +
                      <div class="col-sm-5">
         | 
| 81 | 
            +
                        <span class="thumbnail">#{image_tag}</span>
         | 
| 82 | 
            +
                      </div>
         | 
| 83 | 
            +
                      <div class="col-sm-7">
         | 
| 84 | 
            +
                        <div class="progress">
         | 
| 85 | 
            +
                          <div class="progress-bar #{options[:progress_class]}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
         | 
| 86 | 
            +
                            <span class="sr-only">0% Complete</span>
         | 
| 87 | 
            +
                          </div>
         | 
| 88 | 
            +
                        </div>
         | 
| 89 | 
            +
                        <div class="file-info"><i class="fa #{attachment_icon}"></i> #{file_name}</div>
         | 
| 90 | 
            +
                        <span class="btn-group btn-remove" data-toggle="buttons">
         | 
| 91 | 
            +
                          <label class="btn #{options[:remove_class]}">
         | 
| 92 | 
            +
                            Remove #{attachment_name}
         | 
| 93 | 
            +
                            #{remove_attachment}
         | 
| 94 | 
            +
                          </label>
         | 
| 95 | 
            +
                        </span>
         | 
| 96 | 
            +
                        <span class="btn #{options[:select_class]} btn-file">
         | 
| 97 | 
            +
                          Select #{attachment_name}
         | 
| 98 | 
            +
                          #{attachment_field}
         | 
| 99 | 
            +
                        </span>
         | 
| 100 | 
            +
                      </div>
         | 
| 101 | 
            +
                    </div>
         | 
| 102 | 
            +
                  </div>
         | 
| 103 | 
            +
            EOD
         | 
| 104 | 
            +
                  return result.html_safe
         | 
| 105 | 
            +
                end
         | 
| 106 | 
            +
              end
         | 
| 107 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require "bootstrap_refile/version"
         | 
| 2 | 
            +
            require "bootstrap_refile/rails/attachment_helper"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module BootstrapRefile
         | 
| 5 | 
            +
              module Rails
         | 
| 6 | 
            +
                class Engine < ::Rails::Engine
         | 
| 7 | 
            +
                	initializer "refile.setup", before: :load_environment_config do
         | 
| 8 | 
            +
            	      ActionView::Base.send(:include, BootstrapRefile::AttachmentHelper)
         | 
| 9 | 
            +
            	      ActionView::Helpers::FormBuilder.send(:include, AttachmentHelper::FormBuilder)
         | 
| 10 | 
            +
            	    end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,111 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: bootstrap_refile
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Joshua Novak
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-04-11 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: railties
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '3.1'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '3.1'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: refile
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: bundler
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '1.7'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '1.7'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rake
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '10.0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '10.0'
         | 
| 69 | 
            +
            description: A bootstrap styled single uploader for refile.
         | 
| 70 | 
            +
            email:
         | 
| 71 | 
            +
            - JoshuaNovak919@gmail.com
         | 
| 72 | 
            +
            executables: []
         | 
| 73 | 
            +
            extensions: []
         | 
| 74 | 
            +
            extra_rdoc_files: []
         | 
| 75 | 
            +
            files:
         | 
| 76 | 
            +
            - ".gitignore"
         | 
| 77 | 
            +
            - Gemfile
         | 
| 78 | 
            +
            - LICENSE.txt
         | 
| 79 | 
            +
            - README.md
         | 
| 80 | 
            +
            - Rakefile
         | 
| 81 | 
            +
            - app/assets/javascripts/bootstrap_refile.js
         | 
| 82 | 
            +
            - app/assets/stylesheets/bootstrap_refile.scss
         | 
| 83 | 
            +
            - bootstrap_refile.gemspec
         | 
| 84 | 
            +
            - lib/bootstrap_refile.rb
         | 
| 85 | 
            +
            - lib/bootstrap_refile/rails/attachment_helper.rb
         | 
| 86 | 
            +
            - lib/bootstrap_refile/version.rb
         | 
| 87 | 
            +
            homepage: https://github.com/JoshuaNovak919/bootstrap_refile
         | 
| 88 | 
            +
            licenses:
         | 
| 89 | 
            +
            - MIT
         | 
| 90 | 
            +
            metadata: {}
         | 
| 91 | 
            +
            post_install_message: 
         | 
| 92 | 
            +
            rdoc_options: []
         | 
| 93 | 
            +
            require_paths:
         | 
| 94 | 
            +
            - lib
         | 
| 95 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 96 | 
            +
              requirements:
         | 
| 97 | 
            +
              - - ">="
         | 
| 98 | 
            +
                - !ruby/object:Gem::Version
         | 
| 99 | 
            +
                  version: '0'
         | 
| 100 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 101 | 
            +
              requirements:
         | 
| 102 | 
            +
              - - ">="
         | 
| 103 | 
            +
                - !ruby/object:Gem::Version
         | 
| 104 | 
            +
                  version: '0'
         | 
| 105 | 
            +
            requirements: []
         | 
| 106 | 
            +
            rubyforge_project: 
         | 
| 107 | 
            +
            rubygems_version: 2.2.2
         | 
| 108 | 
            +
            signing_key: 
         | 
| 109 | 
            +
            specification_version: 4
         | 
| 110 | 
            +
            summary: A bootstrap styled single uploader for refile.
         | 
| 111 | 
            +
            test_files: []
         |