camaleon_post_clone 0.0.1
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/Rakefile +37 -0
- data/app/controllers/plugins/camaleon_post_clone/admin_controller.rb +37 -0
- data/app/helpers/plugins/camaleon_post_clone/main_helper.rb +43 -0
- data/app/views/plugins/camaleon_post_clone/admin/settings.html.erb +11 -0
- data/config/camaleon_plugin.json +30 -0
- data/config/locales/translation.yml +30 -0
- data/config/routes.rb +15 -0
- data/lib/camaleon_post_clone.rb +4 -0
- data/lib/camaleon_post_clone/engine.rb +5 -0
- data/lib/camaleon_post_clone/version.rb +3 -0
- data/lib/tasks/camaleon_post_clone_tasks.rake +4 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 787903f214b76da175dcae39943fcd44d29faf01
|
4
|
+
data.tar.gz: 2e7dbacab5fc3af6998b7ec3832a805e83620576
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 228e1d62829fdd30ae2b0244464988b7406e20e36feaf39417b8b4099565f71b0737bb49b95d0ecaed4ff0f207450e8e8fb29b92f894a3001c71653419eb26f1
|
7
|
+
data.tar.gz: d03fe93a82a88accff311403914070baf4ca4c364c89f8e3c394a0b2b722f0459c3e237b56e64cd78c7e31dcc2c7625f0e822d41eb2418d1c431f827eb2b27e0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Owen
|
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/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
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 = 'CamaleonPostClone'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
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
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Plugins::CamaleonPostClone::AdminController < CamaleonCms::Apps::PluginsAdminController
|
2
|
+
include Plugins::CamaleonPostClone::MainHelper
|
3
|
+
def clone
|
4
|
+
i = [:term_relationships, :metas]
|
5
|
+
i << :field_values if @plugin.get_field_value("plugin_clone_custom_fields")
|
6
|
+
post = current_site.posts.find(params[:id])
|
7
|
+
clone = post.deep_clone(include: i)
|
8
|
+
clone.post_type = post.post_type
|
9
|
+
slugs = clone.slug.translations
|
10
|
+
titles = clone.title.translations
|
11
|
+
slugs.each do |k, v|
|
12
|
+
slugs[k] = current_site.get_valid_post_slug(v)
|
13
|
+
titles[k] = "#{v} (clone)"
|
14
|
+
end
|
15
|
+
if slugs.empty?
|
16
|
+
clone.slug = current_site.get_valid_post_slug(clone.slug)
|
17
|
+
clone.title << " (clone)"
|
18
|
+
else
|
19
|
+
clone.slug = slugs.to_translate
|
20
|
+
clone.title = titles.to_translate
|
21
|
+
end
|
22
|
+
clone.status = "pending" if @plugin.get_field_value("plugin_clone_save_as_pending")
|
23
|
+
clone.save!
|
24
|
+
flash[:notice] = "#{t('plugin.post_clone.message.content_cloned')}"
|
25
|
+
redirect_to clone.decorate.the_edit_url
|
26
|
+
end
|
27
|
+
|
28
|
+
def settings
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def settings_save
|
33
|
+
@plugin.set_field_values(params[:field_options])
|
34
|
+
flash[:notice] = "#{t('plugin.post_clone.message.settings_saved')}"
|
35
|
+
redirect_to action: :settings
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Plugins::CamaleonPostClone::MainHelper
|
2
|
+
def self.included(klass)
|
3
|
+
# klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
|
4
|
+
end
|
5
|
+
|
6
|
+
# here all actions on going to active
|
7
|
+
# you can run sql commands like this:
|
8
|
+
# results = ActiveRecord::Base.connection.execute(query);
|
9
|
+
# plugin: plugin model
|
10
|
+
def camaleon_post_clone_on_active(plugin)
|
11
|
+
options = [{"title"=>"Enable?", "value"=>"1", "default"=>"1"}]
|
12
|
+
group = plugin.add_custom_field_group({name: "#{t('plugin.post_clone.post_clone_configuration')}", slug: "plugin_clone_custom_settings", description: ""})
|
13
|
+
group.add_manual_field({"name"=>"#{t('plugin.post_clone.clone_custom_fields')}", "slug"=>"plugin_clone_custom_fields", "description"=>"#{t('plugin.post_clone.clone_custom_field_values')}"},
|
14
|
+
{field_key: "checkboxes", multiple: false, required: false, multiple_options: options})
|
15
|
+
group.add_manual_field({"name"=>"#{t('plugin.post_clone.saved_pending')}", "slug"=>"plugin_clone_save_as_pending", "description"=>"#{t('plugin.post_clone.want_save_pending')}"},
|
16
|
+
{field_key: "checkboxes", multiple: false, required: false, multiple_options: [{"title"=>"#{t('plugin.post_clone.enable')}", "value"=>"1", "default"=>"0"}]})
|
17
|
+
end
|
18
|
+
|
19
|
+
# here all actions on going to inactive
|
20
|
+
# plugin: plugin model
|
21
|
+
def camaleon_post_clone_on_inactive(plugin)
|
22
|
+
plugin.get_field_groups().destroy_all
|
23
|
+
end
|
24
|
+
|
25
|
+
# here all actions to upgrade for a new version
|
26
|
+
# plugin: plugin model
|
27
|
+
def camaleon_post_clone_on_upgrade(plugin)
|
28
|
+
end
|
29
|
+
|
30
|
+
def camaleon_post_clone_new_post(args)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def camaleon_post_clone_edit_post(args)
|
35
|
+
args[:extra_settings] <<
|
36
|
+
"<div class=''><label class='control-label'>#{t('camaleon_cms.admin.post.clone_content')}: </label> <a href='#{admin_plugins_camaleon_post_clone_clone_path(id: args[:post].id)}'><i class='fa fa-copy'></i> #{t('camaleon_cms.admin.post.clone')}</a> </div>"
|
37
|
+
end
|
38
|
+
|
39
|
+
def camaleon_post_clone_plugin_options(arg)
|
40
|
+
arg[:links] << link_to(t('plugin.post_clone.settings'), admin_plugins_camaleon_post_clone_settings_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= form_tag admin_plugins_camaleon_post_clone_settings_path do %>
|
2
|
+
<div class="col-md-8 col-md-offset-2">
|
3
|
+
<div class="panel panel-default">
|
4
|
+
<%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @plugin, field_groups: @plugin.get_field_groups} %>
|
5
|
+
<div class="panel-footer">
|
6
|
+
<a class="btn btn-default" href="<%= url_for cama_admin_plugins_path %>"><%= t('camaleon_cms.admin.button.back') %></a>
|
7
|
+
<button class="btn btn-primary pull-right" type="submit"><%= t('camaleon_cms.admin.button.submit') %></button>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"title": "Camaleon Post Clone",
|
3
|
+
"descr": "Permit to clone a post content by a single link. More info: <a target='_blank' href='http://camaleon.tuzitio.com/store/plugins/post_clone'>here.</a>",
|
4
|
+
"version": "0.1",
|
5
|
+
"key": "camaleon_post_clone",
|
6
|
+
"helpers": [
|
7
|
+
"Plugins::CamaleonPostClone::MainHelper"
|
8
|
+
],
|
9
|
+
"hooks": {
|
10
|
+
"on_active": [
|
11
|
+
"camaleon_post_clone_on_active"
|
12
|
+
],
|
13
|
+
"on_inactive": [
|
14
|
+
"camaleon_post_clone_on_inactive"
|
15
|
+
],
|
16
|
+
"on_upgrade": [
|
17
|
+
"camaleon_post_clone_on_upgrade"
|
18
|
+
],
|
19
|
+
"new_post": [
|
20
|
+
"camaleon_post_clone_new_post"
|
21
|
+
],
|
22
|
+
"edit_post": [
|
23
|
+
"camaleon_post_clone_edit_post"
|
24
|
+
],
|
25
|
+
"plugin_options":[
|
26
|
+
"camaleon_post_clone_plugin_options"
|
27
|
+
]
|
28
|
+
//here you can add all your hooks (read documentation)
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
en:
|
2
|
+
plugin:
|
3
|
+
post_clone:
|
4
|
+
enable: 'Enable?'
|
5
|
+
post_clone_configuration: 'Post Clone Configuration'
|
6
|
+
clone_custom_fields: 'Clone Custom fields?'
|
7
|
+
clone_custom_field_values: 'Do you want to clone custom field values?'
|
8
|
+
saved_pending: 'Save as pending'
|
9
|
+
want_save_pending: 'Do you want to save as pending status?'
|
10
|
+
title: 'Post Clone'
|
11
|
+
settings: 'Settings'
|
12
|
+
message:
|
13
|
+
content_cloned: 'Content cloned!'
|
14
|
+
settings_saved: 'Settings saved!'
|
15
|
+
|
16
|
+
|
17
|
+
es:
|
18
|
+
plugin:
|
19
|
+
post_clone:
|
20
|
+
enable: 'Habilitar?'
|
21
|
+
post_clone_configuration: 'Clonar Artículo: Configuración'
|
22
|
+
clone_custom_fields: 'Clonar Campos Personalizados?'
|
23
|
+
clone_custom_field_values: '¿Quiere clonar valores de los campos personalizados?'
|
24
|
+
saved_pending: 'Guardar como pendiente'
|
25
|
+
want_save_pending: '¿Quieres guardar como estado pendiente?'
|
26
|
+
title: 'Clonar Artículo'
|
27
|
+
settings: 'Ajustes'
|
28
|
+
message:
|
29
|
+
content_cloned: 'Contenido clonado!'
|
30
|
+
settings_saved: 'Ajustes guardados!'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
scope PluginRoutes.system_info["relative_url_root"] do
|
4
|
+
#Admin Panel
|
5
|
+
scope 'admin', as: 'admin' do
|
6
|
+
namespace 'plugins' do
|
7
|
+
namespace 'camaleon_post_clone' do
|
8
|
+
get 'settings' => "admin#settings"
|
9
|
+
post 'settings' => "admin#settings_save"
|
10
|
+
get 'clone/:id' => "admin#clone", as: "clone"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: camaleon_post_clone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Owen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-22 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: deep_cloneable
|
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: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ": Description of CamaleonPostClone."
|
56
|
+
email:
|
57
|
+
- owenperedo@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- Rakefile
|
64
|
+
- app/controllers/plugins/camaleon_post_clone/admin_controller.rb
|
65
|
+
- app/helpers/plugins/camaleon_post_clone/main_helper.rb
|
66
|
+
- app/views/plugins/camaleon_post_clone/admin/settings.html.erb
|
67
|
+
- config/camaleon_plugin.json
|
68
|
+
- config/locales/translation.yml
|
69
|
+
- config/routes.rb
|
70
|
+
- lib/camaleon_post_clone.rb
|
71
|
+
- lib/camaleon_post_clone/engine.rb
|
72
|
+
- lib/camaleon_post_clone/version.rb
|
73
|
+
- lib/tasks/camaleon_post_clone_tasks.rake
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.8
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: ": Summary of CamaleonPostClone."
|
98
|
+
test_files: []
|
99
|
+
has_rdoc:
|