bootsy_full_html 2.2.1
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/MIT-LICENSE +20 -0
- data/README.md +159 -0
- data/Rakefile +35 -0
- data/app/assets/images/bootsy/gallery-loader.gif +0 -0
- data/app/assets/images/bootsy/upload-loader.gif +0 -0
- data/app/assets/javascripts/bootsy.js +11 -0
- data/app/assets/javascripts/bootsy/area.js +89 -0
- data/app/assets/javascripts/bootsy/editor_options.js +47 -0
- data/app/assets/javascripts/bootsy/image_template.js +11 -0
- data/app/assets/javascripts/bootsy/init.js +38 -0
- data/app/assets/javascripts/bootsy/locales/en.js +54 -0
- data/app/assets/javascripts/bootsy/locales/pt-BR.js +54 -0
- data/app/assets/javascripts/bootsy/modal.js +192 -0
- data/app/assets/javascripts/bootsy/vendor/bootstrap-wysihtml5.js +530 -0
- data/app/assets/javascripts/bootsy/vendor/bootstrap.file-input.js +122 -0
- data/app/assets/javascripts/bootsy/vendor/polyfill.js +29 -0
- data/app/assets/javascripts/bootsy/vendor/wysihtml5.js +9565 -0
- data/app/assets/stylesheets/bootsy.css +337 -0
- data/app/controllers/bootsy/application_controller.rb +7 -0
- data/app/controllers/bootsy/images_controller.rb +96 -0
- data/app/helpers/bootsy/application_helper.rb +13 -0
- data/app/uploaders/bootsy/image_uploader.rb +39 -0
- data/app/views/bootsy/images/_image.html.erb +43 -0
- data/app/views/bootsy/images/_modal.html.erb +29 -0
- data/app/views/bootsy/images/_new.html.erb +17 -0
- data/config/locales/bootsy.en.yml +30 -0
- data/config/locales/bootsy.pt-BR.yml +30 -0
- data/config/routes.rb +11 -0
- data/db/migrate/20120624171333_create_bootsy_images.rb +9 -0
- data/db/migrate/20120628124845_create_bootsy_image_galleries.rb +8 -0
- data/lib/bootsy.rb +68 -0
- data/lib/bootsy/activerecord/image.rb +12 -0
- data/lib/bootsy/activerecord/image_gallery.rb +23 -0
- data/lib/bootsy/container.rb +52 -0
- data/lib/bootsy/core_ext.rb +4 -0
- data/lib/bootsy/engine.rb +34 -0
- data/lib/bootsy/form_builder.rb +18 -0
- data/lib/bootsy/form_helper.rb +114 -0
- data/lib/bootsy/simple_form/bootsy_input.rb +24 -0
- data/lib/bootsy/version.rb +4 -0
- data/lib/generators/bootsy/USAGE +12 -0
- data/lib/generators/bootsy/install_generator.rb +53 -0
- data/lib/generators/bootsy/templates/bootsy.rb +69 -0
- data/lib/tasks/bootsy_tasks.rake +4 -0
- metadata +130 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
module Bootsy
|
2
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
3
|
+
include CarrierWave::MiniMagick
|
4
|
+
|
5
|
+
storage Bootsy.storage
|
6
|
+
|
7
|
+
def store_dir
|
8
|
+
"#{Bootsy.store_dir}/#{model.class.to_s.underscore}/#{model.id}"
|
9
|
+
end
|
10
|
+
|
11
|
+
process resize_to_limit: [1160, 2000]
|
12
|
+
|
13
|
+
version :large do
|
14
|
+
process resize_to_fit: [
|
15
|
+
Bootsy.large_image[:width], Bootsy.large_image[:height]
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
version :medium do
|
20
|
+
process resize_to_fit: [
|
21
|
+
Bootsy.medium_image[:width], Bootsy.medium_image[:height]
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
version :small do
|
26
|
+
process resize_to_fit: [
|
27
|
+
Bootsy.small_image[:width], Bootsy.small_image[:height]
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
version :thumb do
|
32
|
+
process resize_to_fill: [60, 60]
|
33
|
+
end
|
34
|
+
|
35
|
+
def extension_white_list
|
36
|
+
%w(jpg jpeg gif png)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<div class="bootsy-image dropdown col-sm-2" data-id="<%= image.id %>">
|
2
|
+
<%= link_to image_tag(image.image_file.thumb.url), '#', class: 'thumbnail',
|
3
|
+
data: { toggle: 'dropdown' } %>
|
4
|
+
|
5
|
+
<ul class="dropdown-menu" role="menu">
|
6
|
+
<li role="presentation" class="dropdown-header"><%= t 'bootsy.image.size' %></li>
|
7
|
+
|
8
|
+
<% Bootsy.image_versions_available.each do |size| %>
|
9
|
+
<li role="presentation" class="dropdown dropdown-submenu">
|
10
|
+
<%= link_to '#', tabindex: '-1', role: 'menuitem', data: { toggle: 'dropdown' } do %>
|
11
|
+
<i class="icon-picture"></i>
|
12
|
+
|
13
|
+
<%= t size, scope: 'bootsy.image' %>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<ul class="dropdown-menu" role="menu">
|
17
|
+
<% [:left, :right, :inline].each do |position| %>
|
18
|
+
<li role="presentation">
|
19
|
+
<%= link_to '#', class: 'insert', tabindex: '-1', role: 'menuitem',
|
20
|
+
data: { image_size: size.to_s, position: position.to_s} do %>
|
21
|
+
<%= t position, scope: 'bootsy.image.position' %>
|
22
|
+
<% end %>
|
23
|
+
</li>
|
24
|
+
<% end %>
|
25
|
+
</ul>
|
26
|
+
</li>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% if Bootsy.allow_destroy %>
|
30
|
+
<li role="presentation" class="divider"></li>
|
31
|
+
|
32
|
+
<li role="presentation">
|
33
|
+
<%= link_to image, method: :delete, remote: true,
|
34
|
+
data: { confirm: t('bootsy.image.confirm.destroy'), type: 'json' },
|
35
|
+
tabindex: '-1', role: 'menuitem', class: 'destroy-btn' do %>
|
36
|
+
<i class="icon-trash"></i>
|
37
|
+
|
38
|
+
<%= t('bootsy.action.destroy') %>
|
39
|
+
<% end %>
|
40
|
+
</li>
|
41
|
+
<% end %>
|
42
|
+
</ul>
|
43
|
+
</div>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="modal fade bootsy-modal" tabindex="-1" role="dialog"
|
2
|
+
data-no-turbolink data-gallery-id="<%= container.bootsy_image_gallery_id %>">
|
3
|
+
<div class="modal-dialog" role="document">
|
4
|
+
<div class="modal-content">
|
5
|
+
<div class="modal-header">
|
6
|
+
<button type="button" class="close" data-dismiss="modal">
|
7
|
+
<span aria-hidden="true">×</span>
|
8
|
+
</button>
|
9
|
+
|
10
|
+
<h4 class="modal-title"><%= t 'bootsy.image.p' %></h4>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="modal-body">
|
14
|
+
<div class="alert alert-info bootsy-empty-alert">
|
15
|
+
<%= t 'bootsy.no_images_uploaded' %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div class="row bootsy-gallery"></div>
|
19
|
+
|
20
|
+
<%= image_tag 'bootsy/gallery-loader.gif', class: 'bootsy-gallery-loader' %>
|
21
|
+
|
22
|
+
<%= refresh_btn %>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="modal-footer">
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= form_for([bootsy, resource_or_nil(gallery), image], remote: true,
|
2
|
+
html: { multipart: true, class: 'bootsy-upload-form form-inline' }, data: { type: 'json' }) do |f| %>
|
3
|
+
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
|
4
|
+
|
5
|
+
<%= image_tag 'bootsy/upload-loader.gif', class: 'bootsy-upload-loader' %>
|
6
|
+
|
7
|
+
<div class="input-group">
|
8
|
+
<%= f.url_field :remote_image_file_url, class: 'form-control', placeholder: t('bootsy.action.enter_image_url') %>
|
9
|
+
<span class="input-group-btn">
|
10
|
+
<%= f.submit t('bootsy.action.submit_upload'), class: 'btn btn-default' %>
|
11
|
+
</span>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<span class="bootsy-upload-spacer"><%= t('bootsy.action.or') %></span>
|
15
|
+
|
16
|
+
<%= f.file_field :image_file, title: t('bootsy.action.upload') %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
en:
|
2
|
+
bootsy:
|
3
|
+
action:
|
4
|
+
refresh: Refresh
|
5
|
+
destroy: Delete
|
6
|
+
close: Close
|
7
|
+
load: Load
|
8
|
+
or: or
|
9
|
+
upload: Upload New Image
|
10
|
+
submit_upload: Go
|
11
|
+
enter_image_url: Enter a URL from the web...
|
12
|
+
image_gallery: Image Gallery
|
13
|
+
image:
|
14
|
+
s: Image
|
15
|
+
p: Images
|
16
|
+
size: Size
|
17
|
+
large: Large
|
18
|
+
medium: Medium
|
19
|
+
small: Small
|
20
|
+
original: Original
|
21
|
+
new: New image
|
22
|
+
confirm:
|
23
|
+
destroy: Are you sure you want to delete this image?
|
24
|
+
position:
|
25
|
+
left: Left
|
26
|
+
right: Right
|
27
|
+
inline: Inline
|
28
|
+
no_images_uploaded: There are currently no uploaded images.
|
29
|
+
js:
|
30
|
+
alert_unsaved: You have unsaved changes.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
pt-BR:
|
2
|
+
bootsy:
|
3
|
+
action:
|
4
|
+
refresh: Atualizar
|
5
|
+
destroy: Apagar
|
6
|
+
close: Fechar
|
7
|
+
load: Carregar
|
8
|
+
or: ou
|
9
|
+
upload: Nova imagem
|
10
|
+
submit_upload: Ir
|
11
|
+
enter_image_url: Digite uma URL da web...
|
12
|
+
image_gallery: Galeria de Imagens
|
13
|
+
image:
|
14
|
+
s: Imagem
|
15
|
+
p: Imagens
|
16
|
+
size: Tamanho
|
17
|
+
large: Grande
|
18
|
+
medium: Médio
|
19
|
+
small: Pequeno
|
20
|
+
original: Original
|
21
|
+
new: Nova imagem
|
22
|
+
confirm:
|
23
|
+
destroy: Tem certeza que deseja apagar esta imagem?
|
24
|
+
position:
|
25
|
+
left: Esquerda
|
26
|
+
right: Direita
|
27
|
+
inline: Mesma linha
|
28
|
+
no_images_uploaded: Não existem imagens salvas.
|
29
|
+
js:
|
30
|
+
alert_unsaved: As suas modificações ainda não foram gravadas.
|
data/config/routes.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Bootsy::Engine.routes.draw do
|
2
|
+
resources :image_galleries, only: [] do
|
3
|
+
resources :images, only: [:index, :create, :destroy]
|
4
|
+
end
|
5
|
+
|
6
|
+
file_routes = [:index, :create]
|
7
|
+
|
8
|
+
file_routes << :destroy if Bootsy.allow_destroy
|
9
|
+
|
10
|
+
resources :images, only: file_routes
|
11
|
+
end
|
data/lib/bootsy.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'carrierwave'
|
2
|
+
require 'remotipart'
|
3
|
+
require 'bootsy/engine'
|
4
|
+
require 'bootsy/container'
|
5
|
+
require 'bootsy/form_helper'
|
6
|
+
require 'bootsy/form_builder'
|
7
|
+
require 'bootsy/core_ext'
|
8
|
+
|
9
|
+
autoload :BootsyInput, 'bootsy/simple_form/bootsy_input'
|
10
|
+
|
11
|
+
# Public: Top Bootsy module
|
12
|
+
module Bootsy
|
13
|
+
## CONFIGURATION OPTIONS
|
14
|
+
|
15
|
+
# Default editor options
|
16
|
+
mattr_accessor :editor_options
|
17
|
+
@@editor_options = {
|
18
|
+
font_styles: true,
|
19
|
+
emphasis: true,
|
20
|
+
lists: true,
|
21
|
+
html: false,
|
22
|
+
link: true,
|
23
|
+
image: true,
|
24
|
+
color: true
|
25
|
+
}
|
26
|
+
|
27
|
+
# Image versions available
|
28
|
+
mattr_accessor :image_versions_available
|
29
|
+
@@image_versions_available = [:small, :medium, :large, :original]
|
30
|
+
|
31
|
+
# Whether user can destroy uploaded files
|
32
|
+
mattr_accessor :allow_destroy
|
33
|
+
@@allow_destroy = true
|
34
|
+
|
35
|
+
# Settings for small images
|
36
|
+
mattr_accessor :small_image
|
37
|
+
@@small_image = { width: 160, height: 160 }
|
38
|
+
|
39
|
+
# Settings for medium images
|
40
|
+
mattr_accessor :medium_image
|
41
|
+
@@medium_image = { width: 360, height: 360 }
|
42
|
+
|
43
|
+
# Settings for large images
|
44
|
+
mattr_accessor :large_image
|
45
|
+
@@large_image = { width: 760, height: 760 }
|
46
|
+
|
47
|
+
# Settings for the original version of images
|
48
|
+
mattr_accessor :original_image
|
49
|
+
@@original_image = {}
|
50
|
+
|
51
|
+
# Storage mode
|
52
|
+
mattr_accessor :storage
|
53
|
+
@@storage = :file
|
54
|
+
|
55
|
+
# Store directory (inside 'public')
|
56
|
+
mattr_accessor :store_dir
|
57
|
+
@@store_dir = 'uploads'
|
58
|
+
|
59
|
+
# Specify which controller to inherit from
|
60
|
+
mattr_accessor :base_controller
|
61
|
+
@@base_controller = ActionController::Base
|
62
|
+
|
63
|
+
# Default way to setup Bootsy. Run rails generate bootsy:install
|
64
|
+
# to create a fresh initializer with all configuration values.
|
65
|
+
def self.setup
|
66
|
+
yield self
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Bootsy
|
2
|
+
# Public: Model to reference the actual image stored trough Bootsy.
|
3
|
+
# It contains the CarrierWave uploader and belongs to a
|
4
|
+
# particular image gallery.
|
5
|
+
class Image < ActiveRecord::Base
|
6
|
+
belongs_to :image_gallery, touch: true
|
7
|
+
|
8
|
+
mount_uploader :image_file, ImageUploader
|
9
|
+
|
10
|
+
validates_presence_of :image_file, :image_gallery_id
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Bootsy
|
2
|
+
# Public: A model that groups all images related to a
|
3
|
+
# Bootsy container (also called a resource).
|
4
|
+
#
|
5
|
+
# It is important to note that the relation gallery - resource
|
6
|
+
# is not mandatory due to the need of having galleries
|
7
|
+
# related to unsaved containers. This may lead to creation
|
8
|
+
# of orphan galleries. Because of that, this model includes
|
9
|
+
# the `destroy_orphans` method, that removes all galleries
|
10
|
+
# that do not point to resources older than the given time
|
11
|
+
# limit.
|
12
|
+
class ImageGallery < ActiveRecord::Base
|
13
|
+
belongs_to :bootsy_resource, polymorphic: true, autosave: false
|
14
|
+
has_many :images, dependent: :destroy
|
15
|
+
|
16
|
+
scope :destroy_orphans, lambda { |time_limit|
|
17
|
+
where(
|
18
|
+
'created_at < ? AND bootsy_resource_id IS NULL',
|
19
|
+
time_limit
|
20
|
+
).destroy_all
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Bootsy
|
2
|
+
# Public: Methods and attributes to turn any
|
3
|
+
# model into a Bootsy Container.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# class Post < ActiveRecord::Base
|
8
|
+
# include Bootsy::Container
|
9
|
+
# end
|
10
|
+
module Container
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
has_one :bootsy_image_gallery,
|
15
|
+
class_name: 'Bootsy::ImageGallery',
|
16
|
+
as: :bootsy_resource,
|
17
|
+
dependent: :destroy
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: Get the `id` attribute of the image gallery.
|
21
|
+
#
|
22
|
+
# Returns an Integer id or nil when there is
|
23
|
+
# not an image gallery.
|
24
|
+
def bootsy_image_gallery_id
|
25
|
+
bootsy_image_gallery.try(:id)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Public: Set the image gallery `id` and save
|
29
|
+
# the association between models.
|
30
|
+
#
|
31
|
+
# Examples
|
32
|
+
#
|
33
|
+
# container.id
|
34
|
+
# # => 34
|
35
|
+
# gallery.id
|
36
|
+
# # => 12
|
37
|
+
# container.bootsy_image_gallery_id = gallery.id
|
38
|
+
# container.image_gallery_id
|
39
|
+
# # => 12
|
40
|
+
# gallery.bootsy_resource.id
|
41
|
+
# # => 34
|
42
|
+
def bootsy_image_gallery_id=(value)
|
43
|
+
if bootsy_image_gallery.nil? && value.present?
|
44
|
+
self.bootsy_image_gallery = Bootsy::ImageGallery.find(value)
|
45
|
+
bootsy_image_gallery.bootsy_resource = self
|
46
|
+
bootsy_image_gallery.save
|
47
|
+
else
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bootsy
|
2
|
+
# Public: Define and setup Bootsy as a Rails engine.
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
isolate_namespace Bootsy
|
5
|
+
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec
|
8
|
+
g.integration_tool :rspec
|
9
|
+
end
|
10
|
+
|
11
|
+
config.to_prepare do
|
12
|
+
ActionController::Base.helper(Bootsy::ApplicationHelper)
|
13
|
+
# Included at ApplicationController to prevent
|
14
|
+
# missing helpers when it is eager loaded.
|
15
|
+
ApplicationController.helper(Bootsy::ApplicationHelper)
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
if defined?(BOOTSY_ORM)
|
20
|
+
orm = BOOTSY_ORM
|
21
|
+
else
|
22
|
+
orm = :activerecord
|
23
|
+
end
|
24
|
+
|
25
|
+
# Require Active Record models. Other ORMs must
|
26
|
+
# include their own Bootsy models.
|
27
|
+
if orm == :activerecord
|
28
|
+
Dir[File.expand_path('../activerecord/*.rb', __FILE__)].each do |f|
|
29
|
+
require f
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Bootsy
|
2
|
+
# Public: Convenience module to include Bootsy
|
3
|
+
# in `ActionView::Helpers::FormBuilder`.
|
4
|
+
module FormBuilder
|
5
|
+
# Public: Return a textarea element with proper attributes to
|
6
|
+
# be loaded as a WYSIWYG editor.
|
7
|
+
#
|
8
|
+
# method - The Symbol attribute name on the object assigned to the
|
9
|
+
# form builder that will tailor the editor.
|
10
|
+
#
|
11
|
+
# options - The Hash of options used to enable/disable features of
|
12
|
+
# the editor (default: {}).
|
13
|
+
# Available options are:
|
14
|
+
def bootsy_area(method, options = {})
|
15
|
+
@template.bootsy_area(@object_name, method, objectify_options(options))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|