rails_admin_featured_content_rails_6 1.0.4

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.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/CODE_OF_CONDUCT.md +74 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +92 -0
  7. data/Rakefile +2 -0
  8. data/app/assets/images/fc-image-default.jpg +0 -0
  9. data/app/assets/images/fc-loading.svg +1 -0
  10. data/app/assets/images/fc-snippet-float-one.jpg +0 -0
  11. data/app/assets/images/fc-snippet-float-one.psd +0 -0
  12. data/app/assets/images/fc-snippet-float-three.jpg +0 -0
  13. data/app/assets/images/fc-snippet-float-three.psd +0 -0
  14. data/app/assets/images/fc-snippet-float-two.jpg +0 -0
  15. data/app/assets/images/fc-snippet-float-two.psd +0 -0
  16. data/app/assets/images/fc-snippet-four.jpg +0 -0
  17. data/app/assets/images/fc-snippet-four.psd +0 -0
  18. data/app/assets/images/fc-snippet-highlight.jpg +0 -0
  19. data/app/assets/images/fc-snippet-highlight.psd +0 -0
  20. data/app/assets/images/fc-snippet-one.jpg +0 -0
  21. data/app/assets/images/fc-snippet-one.psd +0 -0
  22. data/app/assets/images/fc-snippet-slide.jpg +0 -0
  23. data/app/assets/images/fc-snippet-slide.psd +0 -0
  24. data/app/assets/images/fc-snippet-text-one.jpg +0 -0
  25. data/app/assets/images/fc-snippet-text-one.psd +0 -0
  26. data/app/assets/images/fc-snippet-text-three.jpg +0 -0
  27. data/app/assets/images/fc-snippet-text-three.psd +0 -0
  28. data/app/assets/images/fc-snippet-text-two.jpg +0 -0
  29. data/app/assets/images/fc-snippet-text-two.psd +0 -0
  30. data/app/assets/images/fc-snippet-text.jpg +0 -0
  31. data/app/assets/images/fc-snippet-text.psd +0 -0
  32. data/app/assets/images/fc-snippet-three.jpg +0 -0
  33. data/app/assets/images/fc-snippet-three.psd +0 -0
  34. data/app/assets/images/fc-snippet-two.jpg +0 -0
  35. data/app/assets/images/fc-snippet-two.psd +0 -0
  36. data/app/assets/javascripts/rails_admin/featured_content.js.erb +574 -0
  37. data/app/assets/javascripts/rails_admin/helpers/autocomplete.js +21 -0
  38. data/app/assets/javascripts/rails_admin/helpers/events.js +4 -0
  39. data/app/assets/javascripts/rails_admin/helpers/generate_radom_id.js +4 -0
  40. data/app/assets/javascripts/rails_admin/helpers/slide.js.erb +77 -0
  41. data/app/assets/javascripts/rails_admin/helpers/upload_file.js +32 -0
  42. data/app/assets/stylesheets/rails_admin/featured_content.scss +661 -0
  43. data/app/controllers/rails_admin_featured_content/featured_content_controller.rb +37 -0
  44. data/app/models/.keep +0 -0
  45. data/app/models/rails_admin_featured_content/featured_content.rb +16 -0
  46. data/app/models/rails_admin_featured_content/featured_content_image.rb +11 -0
  47. data/app/views/.gitkeep +0 -0
  48. data/app/views/rails_admin/main/featured_content.html.erb +113 -0
  49. data/bin/console +14 -0
  50. data/bin/setup +8 -0
  51. data/config/initializers/assets.rb +15 -0
  52. data/config/locales/featured_content.en.yml +32 -0
  53. data/config/locales/featured_content.pt-BR.yml +32 -0
  54. data/config/routes.rb +9 -0
  55. data/lib/generators/rails_admin_featured_content_generator.rb +36 -0
  56. data/lib/generators/templates/create_featured_content_images_migration.rb +10 -0
  57. data/lib/generators/templates/create_featured_content_migration.rb +11 -0
  58. data/lib/generators/templates/featured_content_image_uploader.rb +64 -0
  59. data/lib/generators/templates/rails_admin_featured_content.rb +22 -0
  60. data/lib/rails_admin_featured_content_rails_6.rb +55 -0
  61. data/lib/rails_admin_featured_content_rails_6/engine.rb +22 -0
  62. data/lib/rails_admin_featured_content_rails_6/version.rb +3 -0
  63. data/rails_admin_featured_content_rails_6.gemspec +45 -0
  64. data/screenshots/image-1.png +0 -0
  65. data/vendor/assets/stylesheets/rails_admin_featured_content.scss +459 -0
  66. metadata +426 -0
@@ -0,0 +1,55 @@
1
+ require "rails_admin_featured_content_rails_6/engine"
2
+
3
+ module RailsAdminFeaturedContentRails6
4
+ end
5
+
6
+ require 'rails_admin/config/actions'
7
+
8
+ module RailsAdmin
9
+ module Config
10
+ module Actions
11
+ class FeaturedContent < Base
12
+ RailsAdmin::Config::Actions.register(self)
13
+ register_instance_option :member do
14
+ true
15
+ end
16
+
17
+ register_instance_option :link_icon do
18
+ 'icon-align-justify'
19
+ end
20
+
21
+ register_instance_option :http_methods do
22
+ [:get, :post]
23
+ end
24
+
25
+ register_instance_option :controller do
26
+ Proc.new do
27
+ @object = @abstract_model.model.find(params[:id])
28
+ @response = {}
29
+
30
+ if request.post?
31
+ if params.present?
32
+
33
+ if params[:publish]
34
+ status = true
35
+ elsif params[:unpublish]
36
+ status = false
37
+ elsif params[:save]
38
+ status = @object.status
39
+ end
40
+
41
+ if @object.update(content: params[:content], status: status)
42
+ flash[:success] = "Sucesso"
43
+ else
44
+ flash[:error] = "Erro"
45
+ end
46
+ end
47
+ end
48
+
49
+ render :action => @action.template_name
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ require 'simple_form'
2
+ require 'owlcarousel-rails'
3
+
4
+ module RailsAdminFeaturedContentRails6
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace RailsAdminFeaturedContentRails6
7
+
8
+ initializer 'rails_admin_featured_content.load_static_assets' do |app|
9
+ app.middleware.use ::ActionDispatch::Static, "#{root}/vendor"
10
+
11
+ app.config.assets.precompile += %w(
12
+ rails_admin/featured_content.js
13
+ rails_admin/featured_content.css
14
+ )
15
+ end
16
+
17
+ config.generators do |g|
18
+ g.assets false
19
+ g.helper false
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminFeaturedContentRails6
2
+ VERSION = "1.0.4"
3
+ end
@@ -0,0 +1,45 @@
1
+ require_relative 'lib/rails_admin_featured_content_rails_6/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "rails_admin_featured_content_rails_6"
5
+ spec.version = RailsAdminFeaturedContentRails6::VERSION
6
+ spec.authors = ["Giuliano Crivelli"]
7
+ spec.email = ["giuliano@agenciaw3.digital"]
8
+
9
+ spec.summary = "Easy way for create featured contents using rails_admin"
10
+ spec.description = "Easy way for create featured contents using rails_admin on rails 6"
11
+ spec.homepage = "https://github.com/thefalked/rails_admin_featured_content_rails_6"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 2.0"
27
+ spec.add_development_dependency "rake", "~> 12.0"
28
+ spec.add_development_dependency "rails", "~> 6.0.3", ">= 6.0.3.3"
29
+ spec.add_development_dependency "rails_admin", "~> 2.0.2"
30
+ spec.add_development_dependency "capybara", "~> 2.7", ">= 2.7.0"
31
+ spec.add_development_dependency "launchy", "~> 2.4", ">= 2.4.3"
32
+ spec.add_development_dependency "shoulda-matchers", "~> 3.1"
33
+ spec.add_development_dependency "selenium-webdriver", "~> 2.53", ">= 2.53.4"
34
+ spec.add_development_dependency "factory_girl_rails", "~> 4.7", ">= 4.7.0"
35
+ spec.add_development_dependency "faker", "~> 1.6", ">= 1.6.3"
36
+
37
+ spec.add_runtime_dependency "carrierwave", "~> 2.0"
38
+ spec.add_runtime_dependency "croppie_rails", "~> 1.2", ">= 1.2.0"
39
+ spec.add_runtime_dependency "medium-editor-rails", "~> 2.1", ">= 2.1.0"
40
+ spec.add_runtime_dependency "mini_magick", "~> 4.5", ">= 4.5.1"
41
+ spec.add_runtime_dependency "friendly_id", "~> 5.1", ">= 5.1.0"
42
+ spec.add_runtime_dependency "simple_form", "~> 5.0.2"
43
+ spec.add_runtime_dependency "rails-html-sanitizer", "~> 1.0", ">= 1.0.3"
44
+ spec.add_runtime_dependency "owlcarousel-rails", "~> 0"
45
+ end
Binary file
@@ -0,0 +1,459 @@
1
+ // fc
2
+
3
+ .fc-row {
4
+ &:after {
5
+ visibility: hidden;
6
+ display: block;
7
+ font-size: 0;
8
+ content: " ";
9
+ clear: both;
10
+ height: 0;
11
+ }
12
+ }
13
+
14
+ .fc-date {
15
+ margin-bottom: 1rem;
16
+
17
+ color: rgba(#000, .4);
18
+ font-size: .7em;
19
+
20
+ line-height: 1;
21
+ padding-bottom: 1rem;
22
+ border-bottom: solid 1px rgba(#111, .1);
23
+ }
24
+
25
+ .fc-item {
26
+ position: relative;
27
+
28
+ &:after {
29
+ visibility: hidden;
30
+ display: block;
31
+ font-size: 0;
32
+ content: " ";
33
+ clear: both;
34
+ height: 0;
35
+ }
36
+ }
37
+
38
+ .fc-item--border {
39
+ margin-bottom: 1rem;
40
+ padding-bottom: 1rem;
41
+
42
+ border-bottom: solid 1px rgba(#111, .1);
43
+ }
44
+
45
+ .fc-item--last-borderless {
46
+ &:last-of-type {
47
+ margin-bottom: 0;
48
+ }
49
+ }
50
+
51
+ .fc-link {
52
+ display: block;
53
+ text-decoration: none;
54
+
55
+ &:hover,
56
+ &:focus {
57
+ .fc-title {
58
+ text-decoration: underline;
59
+ }
60
+
61
+ .fc-title--highlight {
62
+ color: #fff;
63
+ }
64
+ }
65
+ }
66
+
67
+ .fc-link--absolute {
68
+ position: absolute;
69
+ z-index: 40;
70
+ top: 0;
71
+ left: 0;
72
+
73
+ display: block;
74
+ width: 100%;
75
+ height: calc(100% - 1rem);
76
+
77
+ &:hover,
78
+ &:focus {
79
+ ~ .fc-title {
80
+ text-decoration: underline;
81
+ }
82
+
83
+ ~ .fc-title--highlight {
84
+ color: #fff;
85
+ }
86
+ }
87
+ }
88
+
89
+ .fc-figure {
90
+ margin: 0 0 0 1rem;
91
+ float: right;
92
+
93
+ width: 100px;
94
+ height: 65px;
95
+ border-radius: 4px;
96
+
97
+ overflow: hidden;
98
+ }
99
+
100
+ .fc-image {
101
+ width: 100%;
102
+ border-radius: 4px;
103
+ }
104
+
105
+ .fc-content {
106
+ height: 9em;
107
+ overflow: hidden;
108
+ }
109
+
110
+ .fc-time {
111
+ line-height: 1;
112
+
113
+ float: right;
114
+ color: rgba(#000, .4);
115
+ font-family: Arial, sans-serif;
116
+ font-size: .7em;
117
+ font-weight: 400;
118
+ text-transform: uppercase;
119
+ }
120
+
121
+ .fc-time--block {
122
+ float: none;
123
+ margin-bottom: .5rem;
124
+
125
+ display: block;
126
+ }
127
+
128
+ .fc-caption {
129
+ margin: 0 0 .5rem;
130
+
131
+ line-height: 1;
132
+
133
+ color: rgba(#000, .4);
134
+ font-family: Arial, sans-serif;
135
+ font-size: .7em;
136
+ font-weight: 600;
137
+ text-transform: uppercase;
138
+ }
139
+
140
+ .fc-title {
141
+ margin: 0;
142
+
143
+ line-height: 1.3;
144
+
145
+ color: rgba(#000, .7);
146
+ font-size: .9em;
147
+ font-weight: 700;
148
+ letter-spacing: -.04em;
149
+
150
+ + .fc-figure {
151
+ margin-top: .5rem;
152
+ }
153
+ }
154
+
155
+ .fc-title--highlight {
156
+ margin: 0;
157
+
158
+ padding: .6rem .8rem;
159
+ background: #222;
160
+ border-radius: 4px;
161
+
162
+ color: #fff;
163
+ font-size: .8em;
164
+ }
165
+
166
+ .fc-text {
167
+ margin: .5rem 0 0;
168
+
169
+ line-height: 1.4;
170
+ overflow: hidden;
171
+
172
+ color: lighten(#111, 50%);
173
+ font-size: .75em;
174
+ }
175
+
176
+ @media screen and (min-width: 460px) {
177
+ .fc-figure {
178
+ float: left;
179
+ margin: 0 1rem 0 0;
180
+
181
+ width: 150px;
182
+ height: 100px;
183
+ }
184
+
185
+ .fc-figure--small {
186
+ width: 90px;
187
+ height: 60px;
188
+ }
189
+
190
+ .fc-figure--large {
191
+ width: 150px;
192
+ height: 100px;
193
+ }
194
+
195
+ .fc-text {
196
+ font-size: .85em;
197
+ }
198
+ }
199
+
200
+ @media screen and (min-width: 768px) {
201
+ .fc-row--flex {
202
+ display: flex;
203
+ flex-wrap: wrap;
204
+ }
205
+
206
+ .fc-item--border {
207
+ margin-bottom: 1.5rem;
208
+ padding-bottom: 1.5rem;
209
+ }
210
+
211
+ .fc-item--two {
212
+ float: left;
213
+ display: block;
214
+ margin-right: 3.57866%;
215
+ width: 48.21067%;
216
+
217
+ &:nth-child(2n+1) {
218
+ clear: left;
219
+ }
220
+
221
+ &:nth-child(2n) {
222
+ margin-right: 0;
223
+ }
224
+ }
225
+
226
+ .fc-item--three {
227
+ float: left;
228
+ display: block;
229
+ margin-right: 3.16844%;
230
+ width: 31.22104%;
231
+
232
+ &:nth-child(3n+1) {
233
+ clear: left;
234
+ }
235
+
236
+ &:nth-child(3n) {
237
+ margin-right: 0;
238
+ }
239
+ }
240
+
241
+ .fc-item--four {
242
+ float: left;
243
+ display: block;
244
+ margin-right: 3.57866%;
245
+ width: 22.316%;
246
+
247
+ &:nth-child(4n+1) {
248
+ clear: left;
249
+ }
250
+
251
+ &:nth-child(4n) {
252
+ margin-right: 0;
253
+ }
254
+ }
255
+
256
+ .fc-link--absolute {
257
+ height: calc(100% - 1.5rem);
258
+ }
259
+
260
+ .fc-date {
261
+ font-size: .9em;
262
+ margin-bottom: 1.5rem;
263
+ padding-bottom: 1.5rem;
264
+ }
265
+
266
+ .fc-date--small {
267
+ font-size: .7em;
268
+ }
269
+
270
+ .fc-time {
271
+ font-size: .8em;
272
+ }
273
+
274
+ .fc-time--small {
275
+ font-size: .7em;
276
+ }
277
+
278
+ .fc-caption {
279
+ font-size: .8em;
280
+ }
281
+
282
+ .fc-caption--small {
283
+ font-size: .7em;
284
+ }
285
+
286
+ .fc-title {
287
+ line-height: 1.4;
288
+ font-size: 1.2em;
289
+ }
290
+
291
+ .fc-title--small {
292
+ font-size: 1em;
293
+ }
294
+
295
+ .fc-title--large {
296
+ line-height: 1.3;
297
+ font-size: 1.4em;
298
+ }
299
+
300
+ .fc-title--highlight {
301
+ font-size: 1em;
302
+ padding: .7rem .9rem;
303
+ }
304
+
305
+ .fc-figure--block {
306
+ position: relative;
307
+ float: none;
308
+ margin: 0 1rem .5rem 0;
309
+
310
+ width: 100%;
311
+ height: 0;
312
+ padding-bottom: 50%;
313
+
314
+ .fc-image {
315
+ position: absolute;
316
+ top: 50%;
317
+ left: 0;
318
+
319
+ width: 100%;
320
+ height: auto;
321
+
322
+ -webkit-transform: translateY(-50%);
323
+ -moz-transform: translateY(-50%);
324
+ transform: translateY(-50%);
325
+ }
326
+ }
327
+ }
328
+
329
+ // fc slide
330
+
331
+ .fc-slide {
332
+ position: relative;
333
+
334
+ overflow: hidden;
335
+
336
+ -webkit-transform: translate3d(0, 0, 0);
337
+ -moz-transform: translate3d(0, 0, 0);
338
+ transform: translate3d(0, 0, 0);
339
+
340
+ .owl-controls {
341
+ margin: 0;
342
+
343
+ .owl-buttons {
344
+ display: none;
345
+ }
346
+
347
+ .owl-pagination {
348
+ margin-top: .5em;
349
+ text-align: center;
350
+ }
351
+
352
+ .owl-page {
353
+ display: inline-block;
354
+ opacity: .6;
355
+
356
+ span {
357
+ display: block;
358
+
359
+ width: 10px;
360
+ height: 10px;
361
+ margin: 0 4px;
362
+ background: #999;
363
+ border-radius: 100%;
364
+ }
365
+
366
+ &:hover,
367
+ &:focus {
368
+ opacity: 1;
369
+ }
370
+ }
371
+
372
+ .owl-page.active {
373
+ opacity: 1;
374
+ }
375
+ }
376
+ }
377
+
378
+ .fc-slide__item {
379
+ position: relative;
380
+ overflow: hidden;
381
+ }
382
+
383
+ .fc-slide__link {
384
+ position: absolute;
385
+ z-index: 40;
386
+ top: 0;
387
+ left: 0;
388
+
389
+ display: block;
390
+ width: 100%;
391
+ height: 100%;
392
+
393
+ text-decoration: none;
394
+ }
395
+
396
+ .fc-slide__figure {
397
+ position: relative;
398
+ z-index: -1;
399
+ margin: 0 0 .5rem;
400
+
401
+ width: 100%;
402
+ height: 0;
403
+ padding-bottom: 60%;
404
+ border-radius: 4px;
405
+ overflow: hidden;
406
+ }
407
+
408
+ .fc-slide__image {
409
+ position: absolute;
410
+
411
+ display: block;
412
+ width: 100%;
413
+ min-height: 100%;
414
+ }
415
+
416
+ @media screen and (min-width: 768px) {
417
+ .fc-slide__text {
418
+ max-height: none;
419
+ }
420
+ }
421
+
422
+ @media screen and (min-width: 990px) {
423
+ .fc-slide {
424
+ .owl-controls {
425
+ .owl-buttons {
426
+ position: absolute;
427
+ top: 2rem;
428
+ right: 0;
429
+
430
+ display: block;
431
+
432
+ div {
433
+ opacity: .6;
434
+
435
+ display: inline-block;
436
+ width: 3rem;
437
+ height: 3rem;
438
+ line-height: 3rem;
439
+ opacity: 1;
440
+
441
+ color: #fff;
442
+ font-size: 1.4em;
443
+ text-align: center;
444
+
445
+ padding: 0;
446
+ margin: 0;
447
+
448
+ background: none;
449
+ border-radius: 0;
450
+
451
+ &:hover,
452
+ &:focus {
453
+ opacity: .7 !important;
454
+ }
455
+ }
456
+ }
457
+ }
458
+ }
459
+ }