bootsy 2.0.9 → 2.0.10
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/README.md +4 -4
- data/app/assets/javascripts/bootsy/init.js +1 -1
- data/app/assets/stylesheets/bootsy/bootsy.css +34 -29
- data/app/controllers/bootsy/images_controller.rb +47 -32
- data/lib/bootsy/activerecord/image.rb +3 -0
- data/lib/bootsy/activerecord/image_gallery.rb +13 -1
- data/lib/bootsy/core_ext.rb +4 -2
- data/lib/bootsy/engine.rb +9 -8
- data/lib/bootsy/form_builder.rb +13 -2
- data/lib/bootsy/form_helper.rb +24 -0
- data/lib/bootsy/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 341f757582ae4752e60e70660c9a85298bbb60ac
|
4
|
+
data.tar.gz: f3055d92a7ddfd402951c9efbc4e9ca1e215884a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a546638c142a0fd160c1ca11f6b4b6ac645f794adccb945fa9eed46c33240ca3c54f62dcc5265dafc28e56114038371af854ecbb28500f3be541a2f88c0ec27
|
7
|
+
data.tar.gz: f556b554473dd4c2eb28c5ea3b49f72c75723cbebe79798bad031ad861f9ed0f62b4682912dca6b4df7b9386139875dc3ed345deb241b99ac9487c7c6b5d10ff
|
data/README.md
CHANGED
@@ -24,24 +24,24 @@
|
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
27
|
-
1
|
27
|
+
1\. Add Bootsy to your Gemfile:
|
28
28
|
```ruby
|
29
29
|
gem 'bootsy'
|
30
30
|
```
|
31
31
|
|
32
|
-
2
|
32
|
+
2\. Run the bundle command to install it:
|
33
33
|
```console
|
34
34
|
bundle install
|
35
35
|
```
|
36
36
|
|
37
|
-
3
|
37
|
+
3\. Run the install generator:
|
38
38
|
```console
|
39
39
|
rails generate bootsy:install
|
40
40
|
```
|
41
41
|
It will include the javascripts and stylesheets in the assets pipeline,
|
42
42
|
create the `bootsy.rb` initializer and add a copy of the english translations.
|
43
43
|
|
44
|
-
4
|
44
|
+
4\. Add and run migrations (if you're using ActiveRecord):
|
45
45
|
```console
|
46
46
|
rake bootsy:install:migrations
|
47
47
|
rake db:migrate
|
@@ -72,51 +72,56 @@
|
|
72
72
|
margin: 0 0 8px 8px;
|
73
73
|
}
|
74
74
|
|
75
|
-
blockquote {
|
76
|
-
padding:
|
75
|
+
.bootsy blockquote {
|
76
|
+
padding: 10px 20px;
|
77
77
|
margin: 0 0 20px;
|
78
|
-
|
78
|
+
font-size: 17.5px;
|
79
|
+
border-left: 5px solid #eee;
|
79
80
|
}
|
80
|
-
|
81
|
-
blockquote
|
81
|
+
.bootsy blockquote p:last-child,
|
82
|
+
.bootsy blockquote ul:last-child,
|
83
|
+
.bootsy blockquote ol:last-child {
|
82
84
|
margin-bottom: 0;
|
83
85
|
}
|
84
|
-
|
85
|
-
blockquote small
|
86
|
+
.bootsy blockquote footer,
|
87
|
+
.bootsy blockquote small,
|
88
|
+
.bootsy blockquote .small {
|
86
89
|
display: block;
|
87
|
-
|
88
|
-
|
90
|
+
font-size: 80%;
|
91
|
+
line-height: 1.42857143;
|
92
|
+
color: #777;
|
89
93
|
}
|
90
|
-
|
91
|
-
blockquote small:before
|
94
|
+
.bootsy blockquote footer:before,
|
95
|
+
.bootsy blockquote small:before,
|
96
|
+
.bootsy blockquote .small:before {
|
92
97
|
content: '\2014 \00A0';
|
93
98
|
}
|
94
|
-
|
95
|
-
blockquote.pull-right {
|
96
|
-
float: right;
|
99
|
+
.bootsy .blockquote-reverse,
|
100
|
+
.bootsy blockquote.pull-right {
|
97
101
|
padding-right: 15px;
|
98
102
|
padding-left: 0;
|
99
|
-
border-right: 5px solid #eeeeee;
|
100
|
-
border-left: 0;
|
101
|
-
}
|
102
|
-
|
103
|
-
blockquote.pull-right p,
|
104
|
-
blockquote.pull-right small {
|
105
103
|
text-align: right;
|
104
|
+
border-right: 5px solid #eee;
|
105
|
+
border-left: 0;
|
106
106
|
}
|
107
|
-
|
108
|
-
blockquote.pull-right
|
107
|
+
.bootsy .blockquote-reverse footer:before,
|
108
|
+
.bootsy blockquote.pull-right footer:before,
|
109
|
+
.blockquote-reverse small:before,
|
110
|
+
.bootsy blockquote.pull-right small:before,
|
111
|
+
.bootsy .blockquote-reverse .small:before,
|
112
|
+
.bootsy blockquote.pull-right .small:before {
|
109
113
|
content: '';
|
110
114
|
}
|
111
|
-
|
112
|
-
blockquote.pull-right
|
115
|
+
.bootsy .blockquote-reverse footer:after,
|
116
|
+
.bootsy blockquote.pull-right footer:after,
|
117
|
+
.bootsy .blockquote-reverse small:after,
|
118
|
+
.bootsy blockquote.pull-right small:after,
|
119
|
+
.bootsy .blockquote-reverse .small:after,
|
120
|
+
.bootsy blockquote.pull-right .small:after {
|
113
121
|
content: '\00A0 \2014';
|
114
122
|
}
|
115
|
-
|
116
|
-
|
117
|
-
q:after,
|
118
|
-
blockquote:before,
|
119
|
-
blockquote:after {
|
123
|
+
.bootsy blockquote:before,
|
124
|
+
.bootsy blockquote:after {
|
120
125
|
content: "";
|
121
126
|
}
|
122
127
|
|
@@ -2,65 +2,54 @@ require_dependency 'bootsy/application_controller'
|
|
2
2
|
|
3
3
|
module Bootsy
|
4
4
|
class ImagesController < Bootsy::ApplicationController
|
5
|
-
# GET /images
|
6
|
-
# GET /images.json
|
7
5
|
def index
|
8
6
|
@gallery = find_gallery
|
9
7
|
@images = @gallery.images
|
10
8
|
|
11
9
|
respond_to do |format|
|
12
10
|
format.html # index.html.erb
|
13
|
-
format.json do
|
14
|
-
rendered_images = []
|
15
|
-
|
16
|
-
@images.each do |image|
|
17
|
-
rendered_images << render_to_string(file: 'bootsy/images/_image',
|
18
|
-
formats: [:html],
|
19
|
-
locals: { image: image })
|
20
|
-
end
|
21
|
-
|
22
|
-
new_image = render_to_string(file: 'bootsy/images/_new',
|
23
|
-
formats: [:html],
|
24
|
-
locals: { gallery: @gallery, image: @gallery.images.new })
|
25
11
|
|
26
|
-
|
12
|
+
format.json do
|
13
|
+
render json: {
|
14
|
+
images: @images.map {|image| image_markup(image) },
|
15
|
+
form: new_image_markup(@gallery)
|
16
|
+
}
|
27
17
|
end
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
|
-
# POST /images
|
32
|
-
# POST /images.json
|
33
21
|
def create
|
34
22
|
@gallery = find_gallery
|
35
23
|
@gallery.save! unless @gallery.persisted?
|
36
|
-
@image =
|
37
|
-
@image.image_gallery_id = @gallery.id
|
24
|
+
@image = @gallery.images.new(image_params)
|
38
25
|
|
39
26
|
respond_to do |format|
|
40
27
|
if @image.save
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
format.json { render json: { image: image_view, form: new_image, gallery_id: @gallery.id } }
|
28
|
+
format.json {
|
29
|
+
render json: {
|
30
|
+
image: image_markup(@image),
|
31
|
+
form: new_image_markup(@gallery),
|
32
|
+
gallery_id: @gallery.id
|
33
|
+
}
|
34
|
+
}
|
50
35
|
else
|
51
|
-
format.json {
|
36
|
+
format.json {
|
37
|
+
render json: @image.errors,
|
38
|
+
status: :unprocessable_entity
|
39
|
+
}
|
52
40
|
end
|
53
41
|
end
|
54
42
|
end
|
55
43
|
|
56
|
-
# DELETE /images/1
|
57
|
-
# DELETE /images/1.json
|
58
44
|
def destroy
|
59
45
|
@image = Image.find(params[:id])
|
60
46
|
@image.destroy
|
61
47
|
|
62
48
|
respond_to do |format|
|
63
|
-
format.json {
|
49
|
+
format.json {
|
50
|
+
render json: { id: params[:id] }
|
51
|
+
}
|
52
|
+
|
64
53
|
format.html { redirect_to images_url }
|
65
54
|
end
|
66
55
|
end
|
@@ -71,6 +60,32 @@ module Bootsy
|
|
71
60
|
ImageGallery.find(params[:image_gallery_id])
|
72
61
|
end
|
73
62
|
|
63
|
+
# Private: Returns the String markup to render
|
64
|
+
# an image in the gallery modal.
|
65
|
+
#
|
66
|
+
# image - The `Bootsy::Image` instance that will
|
67
|
+
# be rendered.
|
68
|
+
def image_markup(image)
|
69
|
+
render_to_string(
|
70
|
+
file: 'bootsy/images/_image',
|
71
|
+
formats: [:html],
|
72
|
+
locals: { image: image }
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Private: Returns the String markup to render
|
77
|
+
# a form to upload a new image in a given gallery.
|
78
|
+
#
|
79
|
+
# gallery - The `Bootsy::ImageGallery` instance which
|
80
|
+
# the image will be uploaded to.
|
81
|
+
def new_image_markup(gallery)
|
82
|
+
render_to_string(
|
83
|
+
file: 'bootsy/images/_new',
|
84
|
+
formats: [:html],
|
85
|
+
locals: { gallery: gallery, image: gallery.images.new }
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
74
89
|
# Never trust parameters from the scary internet, only allow the white list through.
|
75
90
|
def image_params
|
76
91
|
params.require(:image).permit(:image_file)
|
@@ -1,8 +1,20 @@
|
|
1
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.
|
2
12
|
class ImageGallery < ActiveRecord::Base
|
3
13
|
belongs_to :bootsy_resource, polymorphic: true, autosave: false
|
4
14
|
has_many :images, dependent: :destroy
|
5
15
|
|
6
|
-
scope :destroy_orphans, ->(time_limit) {
|
16
|
+
scope :destroy_orphans, ->(time_limit) {
|
17
|
+
where('created_at < ? AND bootsy_resource_id IS NULL', time_limit).destroy_all
|
18
|
+
}
|
7
19
|
end
|
8
20
|
end
|
data/lib/bootsy/core_ext.rb
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Extend and include Bootsy in proper scopes.
|
2
|
+
|
3
|
+
ActionView::Base.send(:include, Bootsy::FormHelper)
|
4
|
+
ActionView::Helpers::FormBuilder.send(:include, Bootsy::FormBuilder)
|
data/lib/bootsy/engine.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
module Bootsy
|
2
|
+
# Public: Define and setup Bootsy as a Rails engine.
|
2
3
|
class Engine < Rails::Engine
|
3
|
-
|
4
4
|
isolate_namespace Bootsy
|
5
5
|
|
6
|
-
config.generators do |g|
|
6
|
+
config.generators do |g|
|
7
7
|
g.test_framework :rspec
|
8
8
|
g.integration_tool :rspec
|
9
9
|
end
|
10
10
|
|
11
11
|
config.to_prepare do
|
12
|
-
ActionController::Base.
|
13
|
-
|
14
|
-
|
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)
|
15
16
|
end
|
16
17
|
|
17
18
|
config.after_initialize do
|
@@ -21,9 +22,9 @@ module Bootsy
|
|
21
22
|
orm = :activerecord
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
# Require Active Record models. Other ORMs must
|
26
|
+
# include their own Bootsy models.
|
27
|
+
if orm == :activerecord
|
27
28
|
Dir[File.expand_path('../activerecord/*.rb', __FILE__)].each {|f| require f }
|
28
29
|
end
|
29
30
|
end
|
data/lib/bootsy/form_builder.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
module Bootsy
|
2
|
+
# Public: Convenience module to include Bootsy
|
3
|
+
# in `ActionView::Helpers::FormBuilder`.
|
2
4
|
module FormBuilder
|
3
|
-
|
4
|
-
|
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))
|
5
16
|
end
|
6
17
|
end
|
7
18
|
end
|
data/lib/bootsy/form_helper.rb
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
module Bootsy
|
2
|
+
# Public: Module to include Bootsy in `ActionView::Base`.
|
2
3
|
module FormHelper
|
4
|
+
# Public: Return a textarea element with proper attributes to
|
5
|
+
# be loaded as a WYSIWYG editor.
|
6
|
+
#
|
7
|
+
# object_name - The String or Symbol identifier of the object assigned
|
8
|
+
# to the template.
|
9
|
+
#
|
10
|
+
# method - The Symbol attribute name on the object assigned to the
|
11
|
+
# form builder that will tailor the editor.
|
12
|
+
#
|
13
|
+
# options - The Hash of options used to enable/disable features of
|
14
|
+
# the editor (default: {}):
|
15
|
+
# :container - The `Bootsy::Container` instance model that
|
16
|
+
# will be referenced by the editor's image
|
17
|
+
# gallery. Defaults to the object assigned to
|
18
|
+
# the template, if it is a `Container`.
|
19
|
+
# :uploader - The Boolean value used to enable/disable the
|
20
|
+
# image upload feature. Default: true, if a
|
21
|
+
# `Container` is found. false otherwise.
|
22
|
+
# :editor_options - The Hash of options with Boolean values used
|
23
|
+
# to enable/disable features of the editor.
|
24
|
+
# Available options are described in the Bootsy
|
25
|
+
# initializer file (which is the default for
|
26
|
+
# this argument).
|
3
27
|
def bootsy_area(object_name, method, options = {})
|
4
28
|
container = options[:container] || options[:object]
|
5
29
|
|
data/lib/bootsy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volmer Soares
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: carrierwave
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.3.0
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: A beautiful WYSIWYG editor with image uploads for Rails.
|