camaleon_post_order 0.0.2
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.rdoc +3 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/plugins/camaleon_post_order/post_reorder.js +65 -0
- data/app/assets/javascripts/plugins/camaleon_post_order/readme.txt +1 -0
- data/app/assets/stylesheets/plugins/camaleon_post_order/reorder.css +6 -0
- data/app/controllers/plugins/camaleon_post_order/admin_controller.rb +29 -0
- data/app/helpers/plugins/camaleon_post_order/main_helper.rb +53 -0
- data/app/models/plugins/camaleon_post_order/camaleon_post_order.rb +7 -0
- data/app/views/plugins/camaleon_post_order/admin/settings.html.erb +37 -0
- data/config/camaleon_plugin.json +30 -0
- data/config/locales/translation.yml +16 -0
- data/config/routes.rb +15 -0
- data/lib/camaleon_post_order.rb +4 -0
- data/lib/camaleon_post_order/engine.rb +4 -0
- data/lib/camaleon_post_order/version.rb +3 -0
- data/lib/tasks/camaleon_post_order_tasks.rake +4 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 65890558624d989906b24a462872c3167a783c2a
|
4
|
+
data.tar.gz: 1670674c639c8568bd521f73ae65617667e48e47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4ba712ced04ea2f4bd39a7c3ed2f47ce9ddde13519a8fae34448b75ead681542427e198713a6513aaefe3f65b0042fe506a436221d4029c3976414ea0b4736c
|
7
|
+
data.tar.gz: 6ce3c7fa9077675f7ce3d07e4b11c2bd7560bea31b8146ef708b54b16653073901d9cfc948936e733a4aef98d33243e03d1aba05a8860f961303aae3ac1ce425
|
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/README.rdoc
ADDED
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 = 'CamaleonPostOrder'
|
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,65 @@
|
|
1
|
+
(function($){
|
2
|
+
$.fn.reorder = function (options){
|
3
|
+
var default_options = {url: "", table: ".table"};
|
4
|
+
options = $.extend(default_options, options || {});
|
5
|
+
|
6
|
+
var th_data = false;
|
7
|
+
|
8
|
+
$(options.table+' thead tr').each(function(i, el) {
|
9
|
+
|
10
|
+
th = $(this).find('th').attr('data-sortable');
|
11
|
+
|
12
|
+
if(typeof th === "undefined"){
|
13
|
+
th_data = true
|
14
|
+
}else{
|
15
|
+
th_data = false
|
16
|
+
}
|
17
|
+
|
18
|
+
});
|
19
|
+
|
20
|
+
if(th_data){
|
21
|
+
th_new = '<th class="center" data-sortable="0"></th>';
|
22
|
+
$(options.table+' thead tr').prepend(th_new);
|
23
|
+
|
24
|
+
$(options.table+' tbody tr').each(function(i, el) {
|
25
|
+
id = $(this).attr('data-id');
|
26
|
+
|
27
|
+
td_new = '<td>'
|
28
|
+
+'<div class="moved" style="cursor: all-scroll">'
|
29
|
+
+'<i class="fa fa-arrows"></i>'
|
30
|
+
+'<input type="hidden" name="values[]" value="'+id+'" />'
|
31
|
+
+'</div>'
|
32
|
+
'</td>';
|
33
|
+
|
34
|
+
$(this).prepend(td_new);
|
35
|
+
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
$( options.table+" tbody" ).sortable({
|
41
|
+
axis: "y",
|
42
|
+
placeholder: "ui-state-highlight",
|
43
|
+
handle: ".moved",
|
44
|
+
//items: "tr:not(.sortable)",
|
45
|
+
items: "tr.sortable",
|
46
|
+
start: function(event, ui) {
|
47
|
+
ui.item.startPos = ui.item.index();
|
48
|
+
|
49
|
+
},
|
50
|
+
stop: function( event, ui ) {
|
51
|
+
showLoading();
|
52
|
+
$.post(options.url, $(options.table+" input" ).serialize(), function(){
|
53
|
+
if(ui.item.startPos != ui.item.index()){
|
54
|
+
hideLoading();
|
55
|
+
}
|
56
|
+
});
|
57
|
+
},
|
58
|
+
change: function(event, ui) {
|
59
|
+
}
|
60
|
+
});
|
61
|
+
|
62
|
+
$( options.table+" tbody" ).disableSelection();
|
63
|
+
};
|
64
|
+
|
65
|
+
})(jQuery);
|
@@ -0,0 +1 @@
|
|
1
|
+
Here all your js labraries
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Plugins::CamaleonPostOrder::AdminController < CamaleonCms::Apps::PluginsAdminController
|
2
|
+
include Plugins::CamaleonPostOrder::MainHelper
|
3
|
+
# This updates the position of the elements in the database.
|
4
|
+
def reorder_posts
|
5
|
+
if params[:values].present?
|
6
|
+
params[:values].each_with_index do |value,index |
|
7
|
+
post = current_site.posts.find(value).update_column("post_order", index)
|
8
|
+
# taxonomy_id = post.post_type.id
|
9
|
+
# post.term_relationships.where("term_taxonomy_id = ?", taxonomy_id).first.update_column("term_order", index)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
render inline: "correct"
|
14
|
+
end
|
15
|
+
|
16
|
+
# show plugin settings.
|
17
|
+
def settings
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
# This saves the settings plugin.
|
22
|
+
def save_settings
|
23
|
+
@plugin = current_plugin
|
24
|
+
@plugin.set_meta("_reorder_objects", params[:object] || {})
|
25
|
+
flash[:notice] = "#{t('plugin.post_reorder.updated_changes')}"
|
26
|
+
|
27
|
+
redirect_to action: :settings
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Plugins::CamaleonPostOrder::MainHelper
|
2
|
+
def self.included(klass)
|
3
|
+
# klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
|
4
|
+
end
|
5
|
+
|
6
|
+
# get the plugin name with slug: 'camaleon_post_order'
|
7
|
+
def get_plugin
|
8
|
+
plugin = current_site.plugins.find_by_slug("camaleon_post_order")
|
9
|
+
end
|
10
|
+
|
11
|
+
def camaleon_post_order_on_destroy(plugin)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
# here all actions on going to active
|
16
|
+
# you can run sql commands like this:
|
17
|
+
# results = ActiveRecord::Base.connection.execute(query);
|
18
|
+
# plugin: plugin model
|
19
|
+
def camaleon_post_order_on_active(plugin)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# here all actions on going to inactive
|
24
|
+
# plugin: plugin model
|
25
|
+
def camaleon_post_order_on_inactive(plugin)
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# This adds a javascript to rearrange the elements of any type of content
|
30
|
+
def camaleon_post_order_on_list_post(values)
|
31
|
+
|
32
|
+
plugin_meta = get_plugin.get_meta('_reorder_objects')
|
33
|
+
|
34
|
+
if plugin_meta.present?
|
35
|
+
plugin_meta[:post_type].each do |meta|
|
36
|
+
if meta.to_i == values[:post_type].id.to_i
|
37
|
+
append_asset_libraries({reorder: {js: [plugin_asset_path("post_reorder.js")], css: [plugin_asset_path("reorder.css")]}})
|
38
|
+
cama_content_append('<script>jQuery(function(){$.fn.reorder({url: "'+admin_plugins_camaleon_post_order_reorder_posts_path+'", table: "#posts-table-list"});});</script>')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# This will add link options for this plugin.
|
45
|
+
def camaleon_post_order_plugin_options(arg)
|
46
|
+
arg[:links] << link_to(t('plugin.post_reorder.settings'), admin_plugins_camaleon_post_order_settings_path)
|
47
|
+
end
|
48
|
+
|
49
|
+
# here all actions to upgrade for a new version
|
50
|
+
# plugin: plugin model
|
51
|
+
def camaleon_post_order_on_upgrade(plugin)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# class Plugins::CamaleonPostOrder::CamaleonPostOrder < ActiveRecord::Base
|
2
|
+
# attr_accessible :path, :browser_key
|
3
|
+
# belongs_to :site
|
4
|
+
|
5
|
+
# here create your models normally
|
6
|
+
# notice: your tables in database will be plugins_camaleon_post_order in plural (check rails documentation)
|
7
|
+
# end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<div class="page-content-wrap">
|
2
|
+
<%= form_tag admin_plugins_camaleon_post_order_settings_path do %>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
|
5
|
+
<div class="panel panel-default">
|
6
|
+
<div class="panel-heading">
|
7
|
+
<h3 class="panel-title"><%= t('plugin.post_reorder.title') %></h3>
|
8
|
+
<ul class="panel-controls">
|
9
|
+
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<div class="panel-body">
|
13
|
+
<div class="row">
|
14
|
+
<div class="col-md-6">
|
15
|
+
<label><%= t('plugin.post_reorder.post_types') %></label>
|
16
|
+
|
17
|
+
<% plugin_meta = @plugin.get_meta('_reorder_objects') %>
|
18
|
+
<% current_site.the_post_types.decorate.each do |post_type| %>
|
19
|
+
<div class="checkbox">
|
20
|
+
<label>
|
21
|
+
<input type="checkbox" name="object[post_type][]" value="<%= post_type.id %>" <%= "checked" if plugin_meta[:post_type].to_i.include?(post_type.id) rescue false %> />
|
22
|
+
<%= post_type.the_title %>
|
23
|
+
</label>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
<div class="col-md-6"></div>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<div class="panel-footer">
|
31
|
+
<a class="btn btn-default" href="<%= url_for cama_admin_plugins_path %>"><%= t('admin.button.back') %></a>
|
32
|
+
<button class="btn btn-primary pull-right" type="submit"><%= t('admin.button.submit') %></button>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"title": "Camaleon Post Order",
|
3
|
+
"descr": "Permit to reorder the posts by a single dran and drop (sortable). More info: <a target='_blank' href='http://camaleon.tuzitio.com/store/plugins/post_order'>here.</a>",
|
4
|
+
"version": "0.1",
|
5
|
+
"key": "camaleon_post_order",
|
6
|
+
"helpers": [
|
7
|
+
"Plugins::CamaleonPostOrder::MainHelper"
|
8
|
+
],
|
9
|
+
"options": [
|
10
|
+
{"label": "Settings", "url": "camaleon_post_order_settings_path", "eval_url": true}
|
11
|
+
],
|
12
|
+
"hooks": {
|
13
|
+
"on_upgrade": [
|
14
|
+
"camaleon_post_order_on_upgrade"
|
15
|
+
],
|
16
|
+
"on_active": [
|
17
|
+
"camaleon_post_order_on_active"
|
18
|
+
],
|
19
|
+
"on_inactive": [
|
20
|
+
"camaleon_post_order_on_inactive"
|
21
|
+
],
|
22
|
+
"list_post": [
|
23
|
+
"camaleon_post_order_on_list_post"
|
24
|
+
],
|
25
|
+
"plugin_options":[
|
26
|
+
"camaleon_post_order_plugin_options"
|
27
|
+
]
|
28
|
+
//here you can add all your hooks (read documentation)
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
en:
|
2
|
+
plugin:
|
3
|
+
post_reorder:
|
4
|
+
title: 'Post Reorder: Settings'
|
5
|
+
post_types: 'Post Types'
|
6
|
+
settings: 'Settings'
|
7
|
+
updated_changes: 'Updated Changes.'
|
8
|
+
|
9
|
+
|
10
|
+
es:
|
11
|
+
plugin:
|
12
|
+
post_reorder:
|
13
|
+
title: 'Reordenar Artículos: Ajustes'
|
14
|
+
post_types: 'Tipos de Artículos'
|
15
|
+
settings: 'Ajustes'
|
16
|
+
updated_changes: 'Cambios Actualizados.'
|
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_order' do
|
8
|
+
post 'reorder_posts' => "admin#reorder_posts"
|
9
|
+
get 'settings' => "admin#settings"
|
10
|
+
post 'settings' => "admin#save_settings"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: camaleon_post_order
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Owen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-08 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: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ": Description of CamaleonPostOrder."
|
42
|
+
email:
|
43
|
+
- owenperedo@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- app/assets/javascripts/plugins/camaleon_post_order/post_reorder.js
|
52
|
+
- app/assets/javascripts/plugins/camaleon_post_order/readme.txt
|
53
|
+
- app/assets/stylesheets/plugins/camaleon_post_order/reorder.css
|
54
|
+
- app/controllers/plugins/camaleon_post_order/admin_controller.rb
|
55
|
+
- app/helpers/plugins/camaleon_post_order/main_helper.rb
|
56
|
+
- app/models/plugins/camaleon_post_order/camaleon_post_order.rb
|
57
|
+
- app/views/plugins/camaleon_post_order/admin/settings.html.erb
|
58
|
+
- config/camaleon_plugin.json
|
59
|
+
- config/locales/translation.yml
|
60
|
+
- config/routes.rb
|
61
|
+
- lib/camaleon_post_order.rb
|
62
|
+
- lib/camaleon_post_order/engine.rb
|
63
|
+
- lib/camaleon_post_order/version.rb
|
64
|
+
- lib/tasks/camaleon_post_order_tasks.rake
|
65
|
+
homepage: ''
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.5.1
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: ": Summary of CamaleonPostOrder."
|
89
|
+
test_files: []
|