tolaria 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/README.md +8 -3
- data/Rakefile +1 -0
- data/app/assets/fonts/admin/fontawesome.woff +0 -0
- data/app/assets/fonts/admin/fontawesome.woff2 +0 -0
- data/app/assets/stylesheets/admin/components/_navigation.scss +8 -13
- data/app/assets/stylesheets/admin/components/_resource_form.scss +16 -5
- data/app/assets/stylesheets/admin/settings/_fonts.scss +2 -8
- data/app/assets/stylesheets/admin/settings/_icons.scss +123 -0
- data/app/controllers/admin/admin_controller.rb +1 -1
- data/app/controllers/admin/sessions_controller.rb +1 -1
- data/app/controllers/tolaria/resource_controller.rb +42 -19
- data/app/controllers/tolaria/tolaria_controller.rb +2 -2
- data/app/helpers/admin/table_helper.rb +7 -7
- data/app/helpers/admin/view_helper.rb +6 -9
- data/app/views/admin/tolaria_resource/_form_buttons.html.erb +1 -3
- data/app/views/admin/tolaria_resource/_index_table.html.erb +1 -1
- data/app/views/admin/tolaria_resource/edit.html.erb +12 -3
- data/app/views/admin/tolaria_resource/index.html.erb +1 -4
- data/app/views/admin/tolaria_resource/show.html.erb +1 -1
- data/lib/tolaria.rb +1 -1
- data/lib/tolaria/engine.rb +0 -1
- data/lib/tolaria/ransack.rb +43 -0
- data/lib/tolaria/version.rb +1 -1
- data/test/demo/app/models/application_record.rb +3 -0
- data/test/demo/app/models/blog_post.rb +1 -1
- data/test/demo/app/models/footnote.rb +1 -1
- data/test/demo/app/models/image.rb +1 -1
- data/test/demo/app/models/legal_page.rb +1 -1
- data/test/demo/app/models/miscellany.rb +6 -2
- data/test/demo/app/models/topic.rb +1 -1
- data/test/demo/app/models/video.rb +1 -1
- data/test/demo/app/views/admin/legal_pages/_form.html.erb +1 -1
- data/test/demo/app/views/admin/miscellany/_form.html.erb +3 -0
- data/test/demo/config/application.rb +0 -4
- data/test/demo/config/environments/test.rb +2 -2
- data/test/demo/db/schema.rb +8 -15
- data/test/integration/filter_preservation_test.rb +1 -2
- data/test/integration/forbidden_routes_test.rb +28 -2
- data/test/integration/pagination_test.rb +76 -0
- data/test/integration/session_test.rb +1 -2
- data/tolaria.gemspec +5 -5
- metadata +34 -31
- data/app/assets/fonts/admin/fontawesome.eot +0 -0
- data/app/assets/fonts/admin/fontawesome.svg +0 -655
- data/app/assets/fonts/admin/fontawesome.ttf +0 -0
- data/test/demo/app/models/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8632ffd73133959fb3a8893109fca1491bdb7c
|
4
|
+
data.tar.gz: 083d48b6aded6a19ed88945c639df67ae2b06202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f337e69d3db9ca302952ae78ed0bb2d33455aeb7fd502502812fd63107913fc1363b8821dd0c3a90d7da2854cdc4adfd44211b814c843dd68c01f3e8eabb4cdd
|
7
|
+
data.tar.gz: 5e58da0e79dded8cf09851e28a9923228ce204488fdce06cb4aa403c663fa17bbe7a9283d1ed526aac25d5bc0a7cdb9098b4426f9f69ec8678f24a2eb1ef562f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -21,20 +21,25 @@ Tolaria is a [content management system](https://en.wikipedia.org/wiki/Content_m
|
|
21
21
|
- Easily overridable on a case-by-case basis.
|
22
22
|
- Designed for use on Heroku, in containers, and on websites with TLS.
|
23
23
|
- Modest dependencies.
|
24
|
+
- Compatible with Rails 5 and Rails 4.2.
|
24
25
|
|
25
26
|
### Browser Support
|
26
27
|
|
27
|
-
Tolaria supports IE10+, Safari, Chrome, Firefox, iOS, and Chrome for Android. Note that these are the browsers your site editors will need, not the general site audience, which can differ.
|
28
|
+
Tolaria supports IE10+, Edge, Safari, Chrome, Firefox, iOS, and Chrome for Android. Note that these are the browsers your site editors will need, not the general site audience, which can differ.
|
28
29
|
|
29
30
|
### Getting Started
|
30
31
|
|
31
32
|
Add Tolaria to your project's `Gemfile`:
|
32
33
|
|
33
34
|
```ruby
|
34
|
-
|
35
|
+
# If you are running Rails 5, use Tolaria 2
|
36
|
+
gem "tolaria", "~> 2.0"
|
37
|
+
|
38
|
+
# If you are running Rails 4.2, use Tolaria 1.2
|
39
|
+
gem "tolaria", "~> 1.2"
|
35
40
|
```
|
36
41
|
|
37
|
-
Then update your bundle
|
42
|
+
Then update your bundle with `bundle update`
|
38
43
|
|
39
44
|
Now run the installation generator. This will create an initializer for Tolaria plus a migration to set up an `administrators` table. Migrate your database.
|
40
45
|
|
data/Rakefile
CHANGED
Binary file
|
Binary file
|
@@ -8,20 +8,15 @@
|
|
8
8
|
@include clearfix;
|
9
9
|
background-color: $cCoolGrey;
|
10
10
|
border-bottom: 3px double $cGrey;
|
11
|
-
|
12
|
-
margin
|
11
|
+
left: 0;
|
12
|
+
margin: 0;
|
13
13
|
padding: 10px 20px 20px 20px;
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
transition: transform 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
|
21
|
-
transform: translateY(-100%);
|
22
|
-
&.-open {
|
23
|
-
transform: translateY(0);
|
24
|
-
}
|
14
|
+
position: absolute;
|
15
|
+
transform: translateY(-100%);
|
16
|
+
transition: transform 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
|
17
|
+
width: 100%;
|
18
|
+
&.-open {
|
19
|
+
transform: translateY(0);
|
25
20
|
}
|
26
21
|
|
27
22
|
}
|
@@ -79,8 +79,24 @@
|
|
79
79
|
outline: none;
|
80
80
|
}
|
81
81
|
|
82
|
+
&:disabled {
|
83
|
+
color: darken($cPlum, 2);
|
84
|
+
background: black(0.06);
|
85
|
+
cursor: not-allowed;
|
86
|
+
}
|
87
|
+
|
82
88
|
}
|
83
89
|
|
90
|
+
input::-webkit-input-placeholder {color: #ccc}
|
91
|
+
input:-moz-placeholder {color: #ccc}
|
92
|
+
input::-moz-placeholder {color: #ccc}
|
93
|
+
input:-ms-input-placeholder {color: #ccc}
|
94
|
+
|
95
|
+
textarea::-webkit-input-placeholder {color: #ccc}
|
96
|
+
textarea:-moz-placeholder {color: #ccc}
|
97
|
+
textarea::-moz-placeholder {color: #ccc}
|
98
|
+
textarea:-ms-input-placeholder {color: #ccc}
|
99
|
+
|
84
100
|
.field-cluster {
|
85
101
|
|
86
102
|
@include clearfix;
|
@@ -209,11 +225,6 @@
|
|
209
225
|
}
|
210
226
|
}
|
211
227
|
|
212
|
-
input::-webkit-input-placeholder {color: #ccc}
|
213
|
-
input:-moz-placeholder {color: #ccc}
|
214
|
-
input::-moz-placeholder {color: #ccc}
|
215
|
-
input:-ms-input-placeholder {color: #ccc}
|
216
|
-
|
217
228
|
.field_with_errors {
|
218
229
|
input, textarea, select,
|
219
230
|
button {
|
@@ -16,16 +16,10 @@ $fHelvetica: "Helvetica Neue", "Segoe UI", Arial, Freesans, sans-serif;
|
|
16
16
|
|
17
17
|
@font-face {
|
18
18
|
font-family: "FontAwesome";
|
19
|
-
src: font-url("admin/fontawesome.
|
20
|
-
|
21
|
-
font-url("admin/fontawesome.woff2") format("woff2"),
|
22
|
-
font-url("admin/fontawesome.woff") format("woff"),
|
23
|
-
font-url("admin/fontawesome.ttf") format("truetype"),
|
24
|
-
font-url("admin/fontawesome.svg#fontawesome") format("svg");
|
19
|
+
src: font-url("admin/fontawesome.woff2") format("woff2"),
|
20
|
+
font-url("admin/fontawesome.woff") format("woff");
|
25
21
|
font-weight: normal;
|
26
22
|
font-style: normal;
|
27
23
|
}
|
28
24
|
|
29
25
|
$fFontAwesome: FontAwesome;
|
30
|
-
|
31
|
-
|
@@ -1775,6 +1775,7 @@
|
|
1775
1775
|
}
|
1776
1776
|
|
1777
1777
|
.icon-ra:before,
|
1778
|
+
.icon-resistance:before,
|
1778
1779
|
.icon-rebel:before {
|
1779
1780
|
content: "\f1d0";
|
1780
1781
|
}
|
@@ -2533,3 +2534,125 @@
|
|
2533
2534
|
.icon-percent:before {
|
2534
2535
|
content: "\f295";
|
2535
2536
|
}
|
2537
|
+
|
2538
|
+
.icon-gitlab:before {
|
2539
|
+
content: "\f296";
|
2540
|
+
}
|
2541
|
+
|
2542
|
+
.icon-wpbeginner:before {
|
2543
|
+
content: "\f297";
|
2544
|
+
}
|
2545
|
+
|
2546
|
+
.icon-wpforms:before {
|
2547
|
+
content: "\f298";
|
2548
|
+
}
|
2549
|
+
|
2550
|
+
.icon-envira:before {
|
2551
|
+
content: "\f299";
|
2552
|
+
}
|
2553
|
+
|
2554
|
+
.icon-universal-access:before {
|
2555
|
+
content: "\f29a";
|
2556
|
+
}
|
2557
|
+
|
2558
|
+
.icon-wheelchair-alt:before {
|
2559
|
+
content: "\f29b";
|
2560
|
+
}
|
2561
|
+
|
2562
|
+
.icon-question-circle-o:before {
|
2563
|
+
content: "\f29c";
|
2564
|
+
}
|
2565
|
+
|
2566
|
+
.icon-blind:before {
|
2567
|
+
content: "\f29d";
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
.icon-audio-description:before {
|
2571
|
+
content: "\f29e";
|
2572
|
+
}
|
2573
|
+
|
2574
|
+
.icon-volume-control-phone:before {
|
2575
|
+
content: "\f2a0";
|
2576
|
+
}
|
2577
|
+
|
2578
|
+
.icon-braille:before {
|
2579
|
+
content: "\f2a1";
|
2580
|
+
}
|
2581
|
+
|
2582
|
+
.icon-assistive-listening-systems:before {
|
2583
|
+
content: "\f2a2";
|
2584
|
+
}
|
2585
|
+
|
2586
|
+
.icon-asl-interpreting:before,
|
2587
|
+
.icon-american-sign-language-interpreting:before {
|
2588
|
+
content: "\f2a3";
|
2589
|
+
}
|
2590
|
+
|
2591
|
+
.icon-deafness:before,
|
2592
|
+
.icon-hard-of-hearing:before,
|
2593
|
+
.icon-deaf:before {
|
2594
|
+
content: "\f2a4";
|
2595
|
+
}
|
2596
|
+
|
2597
|
+
.icon-glide:before {
|
2598
|
+
content: "\f2a5";
|
2599
|
+
}
|
2600
|
+
|
2601
|
+
.icon-glide-g:before {
|
2602
|
+
content: "\f2a6";
|
2603
|
+
}
|
2604
|
+
|
2605
|
+
.icon-signing:before,
|
2606
|
+
.icon-sign-language:before {
|
2607
|
+
content: "\f2a7";
|
2608
|
+
}
|
2609
|
+
|
2610
|
+
.icon-low-vision:before {
|
2611
|
+
content: "\f2a8";
|
2612
|
+
}
|
2613
|
+
|
2614
|
+
.icon-viadeo:before {
|
2615
|
+
content: "\f2a9";
|
2616
|
+
}
|
2617
|
+
|
2618
|
+
.icon-viadeo-square:before {
|
2619
|
+
content: "\f2aa";
|
2620
|
+
}
|
2621
|
+
|
2622
|
+
.icon-snapchat:before {
|
2623
|
+
content: "\f2ab";
|
2624
|
+
}
|
2625
|
+
|
2626
|
+
.icon-snapchat-ghost:before {
|
2627
|
+
content: "\f2ac";
|
2628
|
+
}
|
2629
|
+
|
2630
|
+
.icon-snapchat-square:before {
|
2631
|
+
content: "\f2ad";
|
2632
|
+
}
|
2633
|
+
|
2634
|
+
.icon-pied-piper:before {
|
2635
|
+
content: "\f2ae";
|
2636
|
+
}
|
2637
|
+
|
2638
|
+
.icon-first-order:before {
|
2639
|
+
content: "\f2b0";
|
2640
|
+
}
|
2641
|
+
|
2642
|
+
.icon-yoast:before {
|
2643
|
+
content: "\f2b1";
|
2644
|
+
}
|
2645
|
+
|
2646
|
+
.icon-themeisle:before {
|
2647
|
+
content: "\f2b2";
|
2648
|
+
}
|
2649
|
+
|
2650
|
+
.icon-google-plus-circle:before,
|
2651
|
+
.icon-google-plus-official:before {
|
2652
|
+
content: "\f2b3";
|
2653
|
+
}
|
2654
|
+
|
2655
|
+
.icon-fa:before,
|
2656
|
+
.icon-font-awesome:before {
|
2657
|
+
content: "\f2b4";
|
2658
|
+
}
|
@@ -1,13 +1,12 @@
|
|
1
1
|
class Tolaria::ResourceController < Tolaria::TolariaController
|
2
2
|
|
3
|
-
|
4
|
-
before_filter :strip_invalid_ransack_params!
|
3
|
+
before_action :load_managed_class!
|
5
4
|
|
6
5
|
def index
|
7
|
-
@search = @managed_class.klass.ransack(
|
6
|
+
@search = @managed_class.klass.ransack(ransack_params)
|
8
7
|
@resources = @search.result
|
9
8
|
if @managed_class.paginated?
|
10
|
-
@resources = @resources.page(
|
9
|
+
@resources = @resources.page(page_param).per(Tolaria.config.page_size)
|
11
10
|
end
|
12
11
|
unless currently_sorting?
|
13
12
|
@resources = @resources.order(@managed_class.default_order)
|
@@ -93,7 +92,7 @@ class Tolaria::ResourceController < Tolaria::TolariaController
|
|
93
92
|
# Handles route forbidding cases.
|
94
93
|
def form_completion_redirect_path(managed_class, resource = nil)
|
95
94
|
if managed_class.allows?(:index) && params[:save_and_review].blank?
|
96
|
-
url_for(action:"index", q:
|
95
|
+
url_for(action:"index", q:ransack_params, p:page_param)
|
97
96
|
elsif managed_class.allows?(:show) && resource.present?
|
98
97
|
url_for(action:"show", id:resource.id)
|
99
98
|
elsif managed_class.allows?(:edit) && resource.present?
|
@@ -119,20 +118,6 @@ class Tolaria::ResourceController < Tolaria::TolariaController
|
|
119
118
|
)
|
120
119
|
end
|
121
120
|
|
122
|
-
# Some Ransack methods raise exceptions if the `q` param is invalid.
|
123
|
-
# Strip `q` params not created by Ransack
|
124
|
-
def strip_invalid_ransack_params!
|
125
|
-
return true if params[:q].blank?
|
126
|
-
unless params[:q].is_a?(Hash)
|
127
|
-
params.delete(:q)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# Returns true if there is a sorting parameter for Ransack
|
132
|
-
def currently_sorting?
|
133
|
-
params[:q].present? && params[:q][:s].present?
|
134
|
-
end
|
135
|
-
|
136
121
|
# Logs all validation errors for the current resource to the Rails console
|
137
122
|
def log_validation_errors!
|
138
123
|
unless Rails.env.test?
|
@@ -143,4 +128,42 @@ class Tolaria::ResourceController < Tolaria::TolariaController
|
|
143
128
|
end
|
144
129
|
end
|
145
130
|
|
131
|
+
# Returns the current `params[:p]` as an Integer if it is valid.
|
132
|
+
# Returns `nil` otherwise.
|
133
|
+
def page_param
|
134
|
+
integer_page = params[:p].to_i
|
135
|
+
return integer_page if integer_page > 0
|
136
|
+
return nil
|
137
|
+
end
|
138
|
+
|
139
|
+
# Returns params[:q] as a hash if it can be converted.
|
140
|
+
# Ransack expects this generic hash and has its own internal
|
141
|
+
# logic for handing the many possible keys of the hash.
|
142
|
+
def ransack_params
|
143
|
+
if params[:q].present? && params[:q].respond_to?(:permit!)
|
144
|
+
return params[:q].to_unsafe_hash
|
145
|
+
else
|
146
|
+
return nil
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# True if there is a sorting parameter for Ransack
|
151
|
+
def currently_sorting?
|
152
|
+
ransack_params.present? && ransack_params[:s].present?
|
153
|
+
end
|
154
|
+
|
155
|
+
# True if there are filtering parameters for Ransack
|
156
|
+
def currently_filtering?
|
157
|
+
if currently_sorting?
|
158
|
+
ransack_params.keys.many?
|
159
|
+
else
|
160
|
+
ransack_params.present? && ransack_params.keys.any?
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
helper_method :page_param
|
165
|
+
helper_method :ransack_params
|
166
|
+
helper_method :currently_sorting?
|
167
|
+
helper_method :currently_filtering?
|
168
|
+
|
146
169
|
end
|
@@ -95,11 +95,11 @@ module Admin::TableHelper
|
|
95
95
|
end
|
96
96
|
|
97
97
|
if sort.is_a?(Symbol)
|
98
|
-
return content_tag(:th, sort_link(@search, sort
|
98
|
+
return content_tag(:th, sort_link(@search, sort), class:"index-th")
|
99
99
|
end
|
100
100
|
|
101
101
|
if sort.eql?(true) && field_or_label.is_a?(Symbol)
|
102
|
-
return content_tag(:th, sort_link(@search, field_or_label
|
102
|
+
return content_tag(:th, sort_link(@search, field_or_label), class:"index-th")
|
103
103
|
end
|
104
104
|
|
105
105
|
return content_tag(:th, display_label, class:"index-th")
|
@@ -137,9 +137,9 @@ module Admin::TableHelper
|
|
137
137
|
end
|
138
138
|
|
139
139
|
if @managed_class.allows? :edit
|
140
|
-
link = url_for(action:"edit", id:resource.id, q:
|
140
|
+
link = url_for(action:"edit", id:resource.id, q:ransack_params, p:page_param)
|
141
141
|
elsif @managed_class.allows? :show
|
142
|
-
link = url_for(action:"show", id:resource.id, q:
|
142
|
+
link = url_for(action:"show", id:resource.id, q:ransack_params, p:page_param)
|
143
143
|
else
|
144
144
|
link = "#" # Guh, painted ourseves into a corner here
|
145
145
|
end
|
@@ -162,15 +162,15 @@ module Admin::TableHelper
|
|
162
162
|
links = []
|
163
163
|
|
164
164
|
if @managed_class.allows?(:edit)
|
165
|
-
links << link_to("Edit", url_for(action:"edit", id:resource.id, q:
|
165
|
+
links << link_to("Edit", url_for(action:"edit", id:resource.id, q:ransack_params, p:page_param), class:"button -small -edit")
|
166
166
|
end
|
167
167
|
|
168
168
|
if @managed_class.allows?(:show)
|
169
|
-
links << link_to("Inspect", url_for(action:"show", id:resource.id, q:
|
169
|
+
links << link_to("Inspect", url_for(action:"show", id:resource.id, q:ransack_params, p:page_param), class:"button -small -inspect")
|
170
170
|
end
|
171
171
|
|
172
172
|
if @managed_class.allows?(:destroy)
|
173
|
-
links << link_to("Delete", url_for(action:"destroy", id:resource.id, q:
|
173
|
+
links << link_to("Delete", url_for(action:"destroy", id:resource.id, q:ransack_params, p:page_param), class: "button -small -delete", method: :delete, :'data-confirm' => deletion_warning(resource))
|
174
174
|
end
|
175
175
|
|
176
176
|
return content_tag(:td, links.join("").html_safe, class:"actions-td")
|