camaleon_image_optimizer 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 +25 -0
- data/Rakefile +32 -0
- data/app/assets/config/camaleon_image_optimizer_manifest.js +0 -0
- data/app/controllers/plugins/camaleon_image_optimizer/admin_controller.rb +18 -0
- data/app/controllers/plugins/camaleon_image_optimizer/front_controller.rb +8 -0
- data/app/helpers/plugins/camaleon_image_optimizer/main_helper.rb +41 -0
- data/app/models/plugins/camaleon_image_optimizer/camaleon_image_optimizer.rb +6 -0
- data/app/views/plugins/camaleon_image_optimizer/admin/index.html.erb +9 -0
- data/app/views/plugins/camaleon_image_optimizer/admin/settings.html.erb +21 -0
- data/app/views/plugins/camaleon_image_optimizer/front/index.html.erb +2 -0
- data/app/views/plugins/camaleon_image_optimizer/layouts/readme.txt +2 -0
- data/config/camaleon_plugin.json +14 -0
- data/config/image_optim.yml +17 -0
- data/config/initializers/custom_models.rb +5 -0
- data/config/routes.rb +31 -0
- data/lib/camaleon_image_optimizer.rb +5 -0
- data/lib/camaleon_image_optimizer/engine.rb +4 -0
- data/lib/camaleon_image_optimizer/version.rb +3 -0
- data/lib/tasks/camaleon_image_optimizer_tasks.rake +4 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 867ba9921e9adf85de5414f060ad9334c6d45b4b5386125c074a203772d9f146
|
4
|
+
data.tar.gz: 7327557f0b96194031ce99813d437369ce6c8f62a59dc56d7d9188cafb572dcb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fe873c0db1e3eb96103586df94be7c98cb6f801653254bf63a0cbc4b6379a5a17b09c847540977b3857c06f158c6e267b1f17b590488ff416f57e909f60db129
|
7
|
+
data.tar.gz: 7f918fb5289319ddeb6a7fa7d7b69b7ec4687735ad86df632b36c8c73f263a61674a34916294fa5492be70c5f3b33682b49781bfd6842a7d4a50e809832b98ec
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Brian Kephart
|
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,25 @@
|
|
1
|
+
# Camaleon Image Optimizer
|
2
|
+
This is a convenient image optimizer plugin for Camaleon CMS. Compressing images improves load times and thus SEO. It uses the [image_optim_rails gem](https://github.com/toy/image_optim_rails) under the hood. Currently no settings are exposed in Camaleon, but that may happen in the future. Until then, the default settings will still compress quite a bit without sacrificing quality.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'camaleon_image_optimizer', github: 'brian-kephart/camaleon_image_optimizer'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
```bash
|
13
|
+
$ bundle
|
14
|
+
```
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
```bash
|
18
|
+
$ gem install camaleon_image_optimizer
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
Just activate the plugin in Camaleon's admin panel.
|
23
|
+
|
24
|
+
## License
|
25
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
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 = 'CamaleonImageOptimizer'
|
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", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Plugins::CamaleonImageOptimizer::AdminController < CamaleonCms::Apps::PluginsAdminController
|
2
|
+
include Plugins::CamaleonImageOptimizer::MainHelper
|
3
|
+
def index
|
4
|
+
end
|
5
|
+
|
6
|
+
# show settings form
|
7
|
+
def settings
|
8
|
+
end
|
9
|
+
|
10
|
+
# save values from settings form
|
11
|
+
def save_settings
|
12
|
+
@plugin.set_options(params[:options]) if params[:options].present? # save option values
|
13
|
+
@plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values
|
14
|
+
@plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values
|
15
|
+
redirect_to url_for(action: :settings), notice: 'Settings Saved Successfully'
|
16
|
+
end
|
17
|
+
# add custom methods below ....
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Plugins::CamaleonImageOptimizer::MainHelper
|
2
|
+
require 'image_optim'
|
3
|
+
|
4
|
+
def self.included(klass)
|
5
|
+
# klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
|
6
|
+
end
|
7
|
+
|
8
|
+
# here all actions on going to active
|
9
|
+
# you can run sql commands like this:
|
10
|
+
# results = ActiveRecord::Base.connection.execute(query);
|
11
|
+
# plugin: plugin model
|
12
|
+
def camaleon_image_optimizer_on_active(plugin)
|
13
|
+
end
|
14
|
+
|
15
|
+
# here all actions on going to inactive
|
16
|
+
# plugin: plugin model
|
17
|
+
def camaleon_image_optimizer_on_inactive(plugin)
|
18
|
+
end
|
19
|
+
|
20
|
+
# here all actions to upgrade for a new version
|
21
|
+
# plugin: plugin model
|
22
|
+
def camaleon_image_optimizer_on_upgrade(plugin)
|
23
|
+
end
|
24
|
+
|
25
|
+
# hook listener to add settings link below the title of current plugin (if it is installed)
|
26
|
+
# args: {plugin (Hash), links (Array)}
|
27
|
+
# permit to add unlimmited of links...
|
28
|
+
def camaleon_image_optimizer_on_plugin_options(args)
|
29
|
+
args[:links] << link_to('Settings', admin_plugins_camaleon_image_optimizer_settings_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def cama_optimize_image(settings)
|
33
|
+
# settings in config/image_optim.yml
|
34
|
+
spec = Gem::Specification.find_by_name("camaleon_image_optimizer")
|
35
|
+
gem_root = Pathname.new spec.gem_dir
|
36
|
+
image_optim = ImageOptim.new YAML.load_file(gem_root.join('config', 'image_optim.yml'))
|
37
|
+
image_optim.optimize_image! settings[:uploaded_io].path
|
38
|
+
settings[:uploaded_io] = File.open settings[:uploaded_io].path
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# class Plugins::CamaleonImageOptimizer::CamaleonImageOptimizer < ActiveRecord::Base
|
2
|
+
# belongs_to :site, class_name: "CamleonCms::Site"
|
3
|
+
|
4
|
+
# here create your models normally
|
5
|
+
# notice: your tables in database will be plugins_camaleon_image_optimizer in plural (check rails documentation)
|
6
|
+
# end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="panel panel-default">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<h4>My Plugin Settings</h4>
|
4
|
+
</div>
|
5
|
+
<div class="panel-body">
|
6
|
+
<%= form_tag(url_for(action: :save_settings), class: 'validate') do %>
|
7
|
+
<div class="form-group">
|
8
|
+
<label>My Option Setting</label>
|
9
|
+
<%= text_field_tag 'options[my_setting]', @plugin.get_option('my_setting'), class: 'form-control required' %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group">
|
12
|
+
<label>My Meta Setting</label>
|
13
|
+
<%= text_field_tag 'metas[my_setting]', @plugin.get_meta('my_setting'), class: 'form-control required' %>
|
14
|
+
</div>
|
15
|
+
<%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @plugin, field_groups: @plugin.get_field_groups} %>
|
16
|
+
<div class="form-group text-right">
|
17
|
+
<%= submit_tag 'Save Settings', class: 'btn btn-primary' %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"title": "Camaleon Image Optimizer",
|
3
|
+
"descr": "",
|
4
|
+
"key": "camaleon_image_optimizer",
|
5
|
+
"helpers": [
|
6
|
+
"Plugins::CamaleonImageOptimizer::MainHelper"
|
7
|
+
],
|
8
|
+
"hooks": {
|
9
|
+
"on_active": ["camaleon_image_optimizer_on_active"],
|
10
|
+
"on_inactive": ["camaleon_image_optimizer_on_inactive"],
|
11
|
+
/* "plugin_options": ["camaleon_image_optimizer_on_plugin_options"], */
|
12
|
+
"before_upload": ["cama_optimize_image"]
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# see https://github.com/toy/image_optim for config options
|
2
|
+
skip_missing_workers: true
|
3
|
+
pngout: false
|
4
|
+
svgo: false
|
5
|
+
|
6
|
+
allow_lossy: true
|
7
|
+
advpng: false
|
8
|
+
jpegoptim:
|
9
|
+
allow_lossy: true
|
10
|
+
max_quality: 70
|
11
|
+
jpegrecompress:
|
12
|
+
allow_lossy: true
|
13
|
+
quality: 0
|
14
|
+
optipng: false
|
15
|
+
pngcrush: false
|
16
|
+
pngquant:
|
17
|
+
allow_lossy: true
|
data/config/routes.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
scope PluginRoutes.system_info["relative_url_root"] do
|
4
|
+
scope '(:locale)', locale: /#{PluginRoutes.all_locales}/, :defaults => { } do
|
5
|
+
# frontend
|
6
|
+
namespace :plugins do
|
7
|
+
namespace 'camaleon_image_optimizer' do
|
8
|
+
get 'index' => 'front#index'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
#Admin Panel
|
14
|
+
scope :admin, as: 'admin', path: PluginRoutes.system_info['admin_path_name'] do
|
15
|
+
namespace 'plugins' do
|
16
|
+
namespace 'camaleon_image_optimizer' do
|
17
|
+
controller :admin do
|
18
|
+
get :index
|
19
|
+
get :settings
|
20
|
+
post :save_settings
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# main routes
|
27
|
+
#scope 'camaleon_image_optimizer', module: 'plugins/camaleon_image_optimizer/', as: 'camaleon_image_optimizer' do
|
28
|
+
# Here my routes for main routes
|
29
|
+
#end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: camaleon_image_optimizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Kephart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-02 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: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: camaleon_cms
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: image_optim_rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.4.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: image_optim_pack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.5.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.5.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: Compress uploaded images for faster page loads and better SEO.
|
84
|
+
email:
|
85
|
+
- briantkephart@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- app/assets/config/camaleon_image_optimizer_manifest.js
|
94
|
+
- app/controllers/plugins/camaleon_image_optimizer/admin_controller.rb
|
95
|
+
- app/controllers/plugins/camaleon_image_optimizer/front_controller.rb
|
96
|
+
- app/helpers/plugins/camaleon_image_optimizer/main_helper.rb
|
97
|
+
- app/models/plugins/camaleon_image_optimizer/camaleon_image_optimizer.rb
|
98
|
+
- app/views/plugins/camaleon_image_optimizer/admin/index.html.erb
|
99
|
+
- app/views/plugins/camaleon_image_optimizer/admin/settings.html.erb
|
100
|
+
- app/views/plugins/camaleon_image_optimizer/front/index.html.erb
|
101
|
+
- app/views/plugins/camaleon_image_optimizer/layouts/readme.txt
|
102
|
+
- config/camaleon_plugin.json
|
103
|
+
- config/image_optim.yml
|
104
|
+
- config/initializers/custom_models.rb
|
105
|
+
- config/routes.rb
|
106
|
+
- lib/camaleon_image_optimizer.rb
|
107
|
+
- lib/camaleon_image_optimizer/engine.rb
|
108
|
+
- lib/camaleon_image_optimizer/version.rb
|
109
|
+
- lib/tasks/camaleon_image_optimizer_tasks.rake
|
110
|
+
homepage: ''
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.7.5
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Compress uploaded images for faster page loads and better SEO.
|
134
|
+
test_files: []
|