bootsy 0.0.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.
- data/MIT-LICENSE +20 -0
- data/README.md +79 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/bootsy/application.js +4 -0
- data/app/assets/javascripts/bootsy/bootstrap-wysihtml5.js +349 -0
- data/app/assets/javascripts/bootsy/bootsy.js +61 -0
- data/app/assets/javascripts/bootsy/wysihtml5.js +9521 -0
- data/app/assets/stylesheets/bootsy/application.css +4 -0
- data/app/assets/stylesheets/bootsy/bootstrap-wysihtml5.css +44 -0
- data/app/controllers/bootsy/application_controller.rb +4 -0
- data/app/controllers/bootsy/images_controller.rb +58 -0
- data/app/helpers/bootsy/application_helper.rb +8 -0
- data/app/helpers/bootsy/images_helper.rb +4 -0
- data/app/models/bootsy/image.rb +11 -0
- data/app/models/bootsy/image_gallery.rb +6 -0
- data/app/uploaders/image_uploader.rb +39 -0
- data/app/views/bootsy/images/_index.html.erb +22 -0
- data/app/views/bootsy/images/_modal.html.erb +12 -0
- data/app/views/bootsy/images/_new.html.erb +23 -0
- data/app/views/bootsy/images/create.js.erb +3 -0
- data/app/views/bootsy/images/destroy.js.erb +1 -0
- data/app/views/bootsy/images/index.js.erb +2 -0
- data/config/bootsy.yml +0 -0
- data/config/locales/en.yml +19 -0
- data/config/locales/pt-BR.yml +19 -0
- data/config/routes.rb +7 -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 +8 -0
- data/lib/bootsy/core_ext.rb +34 -0
- data/lib/bootsy/engine.rb +16 -0
- data/lib/bootsy/media_container.rb +27 -0
- data/lib/bootsy/version.rb +3 -0
- data/lib/generators/install_generator.rb +27 -0
- data/lib/tasks/bootsy_tasks.rake +4 -0
- metadata +248 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
ul.wysihtml5-toolbar {
|
2
|
+
margin: 0;
|
3
|
+
padding: 0;
|
4
|
+
display: block;
|
5
|
+
}
|
6
|
+
|
7
|
+
ul.wysihtml5-toolbar::after {
|
8
|
+
clear: both;
|
9
|
+
display: table;
|
10
|
+
content: "";
|
11
|
+
}
|
12
|
+
|
13
|
+
ul.wysihtml5-toolbar > li {
|
14
|
+
float: left;
|
15
|
+
display: list-item;
|
16
|
+
list-style: none;
|
17
|
+
margin: 0 5px 10px 0;
|
18
|
+
}
|
19
|
+
|
20
|
+
ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] {
|
21
|
+
font-weight: bold;
|
22
|
+
}
|
23
|
+
|
24
|
+
ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] {
|
25
|
+
font-style: italic;
|
26
|
+
}
|
27
|
+
|
28
|
+
ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] {
|
29
|
+
text-decoration: underline;
|
30
|
+
}
|
31
|
+
|
32
|
+
ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
|
33
|
+
background-image: none;
|
34
|
+
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
|
35
|
+
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
|
36
|
+
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
|
37
|
+
background-color: #E6E6E6;
|
38
|
+
background-color: #D9D9D9 9;
|
39
|
+
outline: 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
ul.wysihtml5-commands-disabled .dropdown-menu {
|
43
|
+
display: none !important;
|
44
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_dependency "bootsy/application_controller"
|
2
|
+
|
3
|
+
module Bootsy
|
4
|
+
class ImagesController < ApplicationController
|
5
|
+
# GET /images
|
6
|
+
# GET /images.json
|
7
|
+
def index
|
8
|
+
@gallery = find_gallery
|
9
|
+
@images = @gallery.images
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.js
|
13
|
+
format.html # index.html.erb
|
14
|
+
format.json { render json: @images }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# POST /images
|
19
|
+
# POST /images.json
|
20
|
+
def create
|
21
|
+
@gallery = find_gallery
|
22
|
+
@gallery.save! unless @gallery.persisted?
|
23
|
+
@image = @gallery.images.new params[:image]
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
if @image.save
|
27
|
+
@images = @gallery.images
|
28
|
+
format.js
|
29
|
+
format.json { render json: @image, status: :created, location: @image }
|
30
|
+
else
|
31
|
+
format.json { render json: @image.errors, status: :unprocessable_entity }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# DELETE /images/1
|
37
|
+
# DELETE /images/1.json
|
38
|
+
def destroy
|
39
|
+
@image = Image.find(params[:id])
|
40
|
+
@image.destroy
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
format.js
|
44
|
+
format.html { redirect_to images_url }
|
45
|
+
format.json { head :no_content }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def find_gallery
|
51
|
+
begin
|
52
|
+
return ImageGallery.find params[:image_gallery_id]
|
53
|
+
rescue
|
54
|
+
return ImageGallery.new
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Bootsy
|
2
|
+
module ApplicationHelper
|
3
|
+
def refresh_btn gallery, collection
|
4
|
+
gallery = nil unless gallery.nil? || gallery.persisted?
|
5
|
+
link_to t('bootsy.refresh'), [bootsy, gallery, collection], remote: true, :class => 'btn btn-mini refresh_btn'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
4
|
+
|
5
|
+
include CarrierWave::MiniMagick
|
6
|
+
|
7
|
+
include Sprockets::Helpers::RailsHelper
|
8
|
+
include Sprockets::Helpers::IsolatedHelper
|
9
|
+
|
10
|
+
storage :file
|
11
|
+
|
12
|
+
|
13
|
+
def store_dir
|
14
|
+
"uploads/#{model.class.to_s.underscore}/#{model.id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Process files as they are uploaded:
|
18
|
+
process :resize_to_limit => [940, 940]
|
19
|
+
|
20
|
+
version :large do
|
21
|
+
process :resize_to_fit => [600, 600]
|
22
|
+
end
|
23
|
+
|
24
|
+
version :medium do
|
25
|
+
process :resize_to_fit => [300, 300]
|
26
|
+
end
|
27
|
+
|
28
|
+
version :small do
|
29
|
+
process :resize_to_fit => [160, 160]
|
30
|
+
end
|
31
|
+
|
32
|
+
version :thumb do
|
33
|
+
process :resize_to_fill => [60, 60]
|
34
|
+
end
|
35
|
+
|
36
|
+
def extension_white_list
|
37
|
+
%w(jpg jpeg gif png)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<ul class="thumbnails">
|
2
|
+
<% images.each do |image| %>
|
3
|
+
<li class="span1 dropdown">
|
4
|
+
<%= link_to image_tag(image.image_file.thumb.url), '#', :class => 'thumbnail', data: { toggle: 'dropdown'} %>
|
5
|
+
<ul class="dropdown-menu">
|
6
|
+
<li class="nav-header"><%= t 'bootsy.image.size' %></li>
|
7
|
+
<li><%= link_to t('bootsy.image.small'), '#', :class => 'insert', data: { :'image-size' => 'small'} %></li>
|
8
|
+
<li><%= link_to t('bootsy.image.medium'), '#', :class => 'insert', data: { :'image-size' => 'medium'} %></li>
|
9
|
+
<li><%= link_to t('bootsy.image.large'), '#', :class => 'insert', data: { :'image-size' => 'large'} %></li>
|
10
|
+
<li><%= link_to t('bootsy.image.original'), '#', :class => 'insert', data: { :'image-size' => 'original'} %></li>
|
11
|
+
<li class="divider"></li>
|
12
|
+
<li><%= link_to t('bootsy.action.destroy'), image, method: :delete, remote: true, data: { confirm: t('bootsy.image.confirm.destroy')}, :class => 'destroy_btn' %></li>
|
13
|
+
</ul>
|
14
|
+
</li>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
|
18
|
+
<%= refresh_btn gallery, :images %>
|
19
|
+
|
20
|
+
<hr />
|
21
|
+
|
22
|
+
<%= render 'bootsy/images/new', {image: gallery.images.new } %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="modal hide fade" id="bootsy_image_gallery">
|
2
|
+
<div class="modal-header">
|
3
|
+
<button type="button" class="close" data-dismiss="modal">×</button>
|
4
|
+
<h2><%= t 'bootsy.image.p' %></h2>
|
5
|
+
</div>
|
6
|
+
<div class="modal-body">
|
7
|
+
<%= refresh_btn resource.bootsy_image_gallery, :images %>
|
8
|
+
</div>
|
9
|
+
<div class="modal-footer">
|
10
|
+
<a href="#" class="btn" data-dismiss="modal"><%= t 'bootsy.action.close' %></a>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<h3><%= t 'bootsy.image.new' %></h3>
|
2
|
+
|
3
|
+
<%= form_for [bootsy, (image.image_gallery || Bootsy::ImageGallery), image], remote: true, html: {:class => 'bootsy'} do |f| %>
|
4
|
+
<% if image.errors.any? %>
|
5
|
+
<div id="error_explanation">
|
6
|
+
<h2><%= pluralize(image.errors.count, "error") %> prohibited this image from being saved:</h2>
|
7
|
+
|
8
|
+
<ul>
|
9
|
+
<% image.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<div class="field">
|
17
|
+
<%= f.file_field :image_file %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="actions">
|
21
|
+
<%= f.submit t('bootsy.action.load'), :class => 'btn' %>
|
22
|
+
</div>
|
23
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
bootsyRefreshGallery($('#bootsy_image_gallery'));
|
data/config/bootsy.yml
ADDED
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
en:
|
2
|
+
bootsy:
|
3
|
+
action:
|
4
|
+
refresh: Refresh
|
5
|
+
destroy: Destroy
|
6
|
+
close: Close
|
7
|
+
load: Load
|
8
|
+
image_gallery: Image Gallery
|
9
|
+
image:
|
10
|
+
s: Image
|
11
|
+
p: Images
|
12
|
+
size: Size
|
13
|
+
large: Large
|
14
|
+
medium: Medium
|
15
|
+
small: Small
|
16
|
+
original: Original
|
17
|
+
new: New image
|
18
|
+
confirm:
|
19
|
+
destroy: Are you sure you want do destroy this image?
|
@@ -0,0 +1,19 @@
|
|
1
|
+
pt-BR:
|
2
|
+
bootsy:
|
3
|
+
action:
|
4
|
+
refresh: Atualizar
|
5
|
+
destroy: Apagar
|
6
|
+
close: Fechar
|
7
|
+
load: Carregar
|
8
|
+
image_gallery: Galeria de Imagens
|
9
|
+
image:
|
10
|
+
s: Imagem
|
11
|
+
p: Imagens
|
12
|
+
size: Tamanho
|
13
|
+
large: Grande
|
14
|
+
medium: Médio
|
15
|
+
small: Pequeno
|
16
|
+
original: Original
|
17
|
+
new: Nova imagem
|
18
|
+
confirm:
|
19
|
+
destroy: Tem certeza que deseja apagar esta imagem?
|
data/config/routes.rb
ADDED
data/lib/bootsy.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bootsy
|
2
|
+
module FormHelper
|
3
|
+
def bootsy_area object, method, options = {}
|
4
|
+
|
5
|
+
resource = options[:resource]
|
6
|
+
options.delete :resource
|
7
|
+
|
8
|
+
if resource.nil? && (object.nil? || object.is_a?(String) || object.is_a?(Array) || object.is_a?(Symbol))
|
9
|
+
raise PedroError
|
10
|
+
end
|
11
|
+
|
12
|
+
object_name = object.class.name.underscore
|
13
|
+
|
14
|
+
output = self.render 'bootsy/images/modal', {resource: resource || object}
|
15
|
+
output += self.text_area object_name, method, options.merge({:class => 'bootsy_text_area'}){|key, oldval, newval| "#{oldval} #{newval}"}
|
16
|
+
if resource.nil? || (resource == object)
|
17
|
+
output += self.hidden_field object_name, :bootsy_image_gallery_id, :class => 'bootsy_image_gallery_id'
|
18
|
+
end
|
19
|
+
output
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included arg
|
23
|
+
ActionView::Helpers::FormBuilder.send :include, Bootsy::FormBuilder
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Bootsy::FormBuilder
|
29
|
+
def bootsy_area method, options = {}
|
30
|
+
@template.bootsy_area @object, method, options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
ActionView::Helpers::FormHelper.send :include, Bootsy::FormHelper
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Bootsy
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Bootsy
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec
|
7
|
+
g.integration_tool :rspec
|
8
|
+
end
|
9
|
+
|
10
|
+
config.to_prepare do
|
11
|
+
ActionController::Base.class_eval do
|
12
|
+
helper Bootsy::ApplicationHelper
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Bootsy
|
4
|
+
module MediaContainer
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class_eval do
|
10
|
+
has_one :bootsy_image_gallery, :class_name => 'Bootsy::ImageGallery', as: :bootsy_resource, dependent: :destroy
|
11
|
+
attr_accessible :bootsy_image_gallery_id
|
12
|
+
|
13
|
+
def bootsy_image_gallery_id
|
14
|
+
if self.bootsy_image_gallery.nil?
|
15
|
+
return nil
|
16
|
+
else
|
17
|
+
return self.bootsy_image_gallery.id
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def bootsy_image_gallery_id=(value)
|
22
|
+
self.bootsy_image_gallery = Bootsy::ImageGallery.find value unless value.blank?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|