activeadmin_slides 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +36 -0
- data/app/admin/slide.rb +30 -0
- data/app/assets/config/activeadmin_slides_manifest.js +2 -0
- data/app/assets/javascripts/activeadmin_slides/application.js +13 -0
- data/app/assets/stylesheets/activeadmin_slides/application.css +15 -0
- data/app/controllers/activeadmin_slides/application_controller.rb +5 -0
- data/app/helpers/activeadmin_slides/application_helper.rb +4 -0
- data/app/jobs/activeadmin_slides/application_job.rb +4 -0
- data/app/mailers/activeadmin_slides/application_mailer.rb +6 -0
- data/app/models/activeadmin_slides/application_record.rb +5 -0
- data/app/models/activeadmin_slides/slide.rb +16 -0
- data/app/uploaders/slide_image_uploader.rb +55 -0
- data/app/views/layouts/activeadmin_slides/application.html.erb +14 -0
- data/config/initializers/active_admin.rb +3 -0
- data/config/initializers/carrierwave_backgrounder.rb +10 -0
- data/config/routes.rb +2 -0
- data/lib/activeadmin_slides.rb +19 -0
- data/lib/activeadmin_slides/engine.rb +5 -0
- data/lib/activeadmin_slides/version.rb +3 -0
- data/lib/generators/activeadmin_slides/activeadmin_slides_generator.rb +21 -0
- data/lib/generators/activeadmin_slides/templates/migration.rb +13 -0
- data/lib/tasks/activeadmin_slides_tasks.rake +4 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3343c986c1103be40f321a8954fe132ca65133290b567dc93bc790b26a4df4f8
|
4
|
+
data.tar.gz: 83495b47193eebd7dff87bb64af1aec44e3f3d5b697d4dd2d7cf9aa108f046ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01d010b14366bdcd7944ea4dd76a827a54e8f79efcf1f0864f8df68f5edb50b47fffe7f857233d6e8acf49adf65d438f12f3051d197d642752571fb0481da56b
|
7
|
+
data.tar.gz: f2a03c29be89a49721576a2f9090939052303ba904e5f7236c2fd0a523f4a581190142f935ecc4996f75fe11af289a6b6cd0af381bce55056b837db1114aec2b
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Hendyanto
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# ActiveadminSlides
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'activeadmin_slides'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install activeadmin_slides
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ActiveadminSlides'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
data/app/admin/slide.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
ActiveAdmin.register ActiveadminSlides::Slide, as: 'Slide' do
|
2
|
+
permit_params :title, :link, :order, :published, :image
|
3
|
+
|
4
|
+
index do
|
5
|
+
selectable_column
|
6
|
+
id_column
|
7
|
+
column :order
|
8
|
+
column :title
|
9
|
+
column :link
|
10
|
+
column :published
|
11
|
+
column :image do |record|
|
12
|
+
image_tag record.image_url, style: 'width: 100px;'
|
13
|
+
end
|
14
|
+
actions
|
15
|
+
end
|
16
|
+
|
17
|
+
form do |f|
|
18
|
+
inputs 'Slide' do
|
19
|
+
f.semantic_errors
|
20
|
+
f.input :title
|
21
|
+
f.input :link
|
22
|
+
f.input :order
|
23
|
+
f.input :image, as: :file
|
24
|
+
f.input :published
|
25
|
+
end
|
26
|
+
actions
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ActiveadminSlides::Slide < ApplicationRecord
|
2
|
+
self.table_name = 'activeadmin_slides'
|
3
|
+
mount_uploader :image, SlideImageUploader
|
4
|
+
|
5
|
+
if ActiveadminSlides.configuration.process_in_background
|
6
|
+
process_in_background :image
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.published
|
10
|
+
where(published: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.ordered
|
14
|
+
order(order: :asc)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'carrierwave'
|
2
|
+
class SlideImageUploader < CarrierWave::Uploader::Base
|
3
|
+
# Include RMagick or MiniMagick support:
|
4
|
+
# include CarrierWave::RMagick
|
5
|
+
# include CarrierWave::MiniMagick
|
6
|
+
|
7
|
+
include CarrierWave::MiniMagick
|
8
|
+
include CarrierWave::Backgrounder::Delay
|
9
|
+
|
10
|
+
version :large do
|
11
|
+
process :resize_to_fit => [2000, -1]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Choose what kind of storage to use for this uploader:
|
15
|
+
storage :file
|
16
|
+
# storage :fog
|
17
|
+
|
18
|
+
# Override the directory where uploaded files will be stored.
|
19
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
20
|
+
def store_dir
|
21
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
25
|
+
# def default_url(*args)
|
26
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
27
|
+
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
28
|
+
#
|
29
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
30
|
+
# end
|
31
|
+
|
32
|
+
# Process files as they are uploaded:
|
33
|
+
# process scale: [200, 300]
|
34
|
+
#
|
35
|
+
# def scale(width, height)
|
36
|
+
# # do something
|
37
|
+
# end
|
38
|
+
|
39
|
+
# Create different versions of your uploaded files:
|
40
|
+
# version :thumb do
|
41
|
+
# process resize_to_fit: [50, 50]
|
42
|
+
# end
|
43
|
+
|
44
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
45
|
+
# For images you might use something like this:
|
46
|
+
# def extension_whitelist
|
47
|
+
# %w(jpg jpeg gif png)
|
48
|
+
# end
|
49
|
+
|
50
|
+
# Override the filename of the uploaded files:
|
51
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
52
|
+
# def filename
|
53
|
+
# "something.jpg" if original_filename
|
54
|
+
# end
|
55
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Activeadmin slides</title>
|
5
|
+
<%= stylesheet_link_tag "activeadmin_slides/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "activeadmin_slides/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
CarrierWave::Backgrounder.configure do |c|
|
2
|
+
c.backend :delayed_job, queue: :carrierwave
|
3
|
+
# c.backend :active_job, queue: :carrierwave
|
4
|
+
# c.backend :resque, queue: :carrierwave
|
5
|
+
# c.backend :sidekiq, queue: :carrierwave
|
6
|
+
# c.backend :girl_friday, queue: :carrierwave
|
7
|
+
# c.backend :sucker_punch, queue: :carrierwave
|
8
|
+
# c.backend :qu, queue: :carrierwave
|
9
|
+
# c.backend :qc
|
10
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "activeadmin_slides/engine"
|
2
|
+
require 'activeadmin'
|
3
|
+
require 'carrierwave'
|
4
|
+
require 'carrierwave_backgrounder'
|
5
|
+
|
6
|
+
module ActiveadminSlides
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configure
|
12
|
+
self.configuration ||= Configuration.new
|
13
|
+
yield(configuration)
|
14
|
+
end
|
15
|
+
|
16
|
+
class Configuration
|
17
|
+
attr_accessor :process_in_background
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class ActiveadminSlidesGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.next_migration_number(dirname)
|
11
|
+
if ActiveRecord::Base.timestamped_migrations
|
12
|
+
Time.new.utc.strftime("%Y%m%d%H%M%S")
|
13
|
+
else
|
14
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_migration_file
|
19
|
+
migration_template 'migration.rb', 'db/migrate/create_activeadmin_slides.rb'
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activeadmin_slides
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hendyanto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: carrierwave
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: carrierwave_backgrounder
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mini_magick
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- hendyanto.inbox@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- app/admin/slide.rb
|
94
|
+
- app/assets/config/activeadmin_slides_manifest.js
|
95
|
+
- app/assets/javascripts/activeadmin_slides/application.js
|
96
|
+
- app/assets/stylesheets/activeadmin_slides/application.css
|
97
|
+
- app/controllers/activeadmin_slides/application_controller.rb
|
98
|
+
- app/helpers/activeadmin_slides/application_helper.rb
|
99
|
+
- app/jobs/activeadmin_slides/application_job.rb
|
100
|
+
- app/mailers/activeadmin_slides/application_mailer.rb
|
101
|
+
- app/models/activeadmin_slides/application_record.rb
|
102
|
+
- app/models/activeadmin_slides/slide.rb
|
103
|
+
- app/uploaders/slide_image_uploader.rb
|
104
|
+
- app/views/layouts/activeadmin_slides/application.html.erb
|
105
|
+
- config/initializers/active_admin.rb
|
106
|
+
- config/initializers/carrierwave_backgrounder.rb
|
107
|
+
- config/routes.rb
|
108
|
+
- lib/activeadmin_slides.rb
|
109
|
+
- lib/activeadmin_slides/engine.rb
|
110
|
+
- lib/activeadmin_slides/version.rb
|
111
|
+
- lib/generators/activeadmin_slides/activeadmin_slides_generator.rb
|
112
|
+
- lib/generators/activeadmin_slides/templates/migration.rb
|
113
|
+
- lib/tasks/activeadmin_slides_tasks.rake
|
114
|
+
homepage: https://brotherincode.com
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.7.9
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: ''
|
138
|
+
test_files: []
|