rxcms-sharing_plugin 0.2.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/rx-cms-sharing/configure.js +7 -0
- data/app/assets/javascripts/rx-cms-sharing/index.js +7 -0
- data/app/assets/javascripts/rx-cms-sharing/installer.js +7 -0
- data/app/assets/javascripts/sharing_engine.js +2 -0
- data/app/assets/javascripts/sharing_installer.js +2 -0
- data/app/assets/javascripts/sharing_services.js +2 -0
- data/app/assets/stylesheets/sharing_engine.css +4 -0
- data/app/assets/stylesheets/sharing_installer.css +4 -0
- data/app/assets/stylesheets/sharing_services.css +4 -0
- data/app/controllers/sharing_engine_controller.rb +50 -0
- data/app/controllers/sharing_installer_controller.rb +46 -0
- data/app/controllers/sharing_services_controller.rb +72 -0
- data/app/helpers/sharing_engine_helper.rb +2 -0
- data/app/helpers/sharing_installer_helper.rb +2 -0
- data/app/helpers/sharing_plugin_helper.rb +30 -0
- data/app/helpers/sharing_services_helper.rb +2 -0
- data/app/views/sharing_engine/configure.html.erb +6 -0
- data/app/views/sharing_engine/index.html.erb +0 -0
- data/app/views/sharing_engine/installer.html.erb +0 -0
- data/config/routes.rb +16 -0
- data/config/sharing/sharing_config.yml +1 -0
- data/lib/rxcms-sharing_plugin/engine.rb +12 -0
- data/lib/rxcms-sharing_plugin/version.rb +3 -0
- data/lib/rxcms-sharing_plugin.rb +5 -0
- data/lib/tasks/rxcms-sharing_plugin_tasks.rake +4 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de0056fc4609041a028d02c77a86092e31378a99
|
4
|
+
data.tar.gz: 382e1d2bb55c081c2028bb1ce25e26d213c41771
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91c5abf79b978de5db66531b617fed29b8e9031e2bbd2990c6c8616655caa106a3f0c2d481e3f570333faa3703c266f9fc75bc8783854982d9ac5101952e842a
|
7
|
+
data.tar.gz: a48d23c99a87f81071467e1e0d99ed910979ae6fbe90a6e7dfbaeb76ef75ce6335ce28d67e14f083d370816816952a9561461eb9c3484010c25e9935f1de08d7
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
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,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'RxCmsSharingPlugin'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class SharingEngineController < ApplicationController
|
2
|
+
include SharingPluginHelper
|
3
|
+
|
4
|
+
layout false
|
5
|
+
|
6
|
+
before_filter :get_current_user_role
|
7
|
+
|
8
|
+
# Load configuration items (MANDATORY, must be included)
|
9
|
+
APP_CONFIG = HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path('../../../config/sharing/sharing_config.yml', __FILE__))))
|
10
|
+
|
11
|
+
def index
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure
|
16
|
+
# Check access
|
17
|
+
if (@curUserRole == 'contentadmin' ||
|
18
|
+
@curUserRole == 'user' ||
|
19
|
+
@curUserRole == 'loggedin' ||
|
20
|
+
@curUserRole == 'anonymous')
|
21
|
+
raise 'unauthorized access'
|
22
|
+
end
|
23
|
+
|
24
|
+
if request.xhr?
|
25
|
+
respond_to do |t|
|
26
|
+
t.html
|
27
|
+
end
|
28
|
+
else
|
29
|
+
raise 'unauthorized access'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def installer
|
34
|
+
# Check access
|
35
|
+
if (@curUserRole == 'contentadmin' ||
|
36
|
+
@curUserRole == 'user' ||
|
37
|
+
@curUserRole == 'loggedin' ||
|
38
|
+
@curUserRole == 'anonymous')
|
39
|
+
raise 'unauthorized access'
|
40
|
+
end
|
41
|
+
|
42
|
+
if request.xhr?
|
43
|
+
respond_to do |t|
|
44
|
+
t.html
|
45
|
+
end
|
46
|
+
else
|
47
|
+
raise 'unauthorized access'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class SharingInstallerController < ApplicationController
|
2
|
+
include SharingPluginHelper
|
3
|
+
|
4
|
+
layout false
|
5
|
+
|
6
|
+
before_filter :get_current_user_role
|
7
|
+
|
8
|
+
# Load configuration items (MANDATORY, must be included)
|
9
|
+
APP_CONFIG = HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path('../../../config/sharing/sharing_config.yml', __FILE__))))
|
10
|
+
|
11
|
+
def before_process
|
12
|
+
# Check access
|
13
|
+
if (@curUserRole == 'contentadmin' ||
|
14
|
+
@curUserRole == 'user' ||
|
15
|
+
@curUserRole == 'loggedin' ||
|
16
|
+
@curUserRole == 'anonymous')
|
17
|
+
raise 'unauthorized access'
|
18
|
+
end
|
19
|
+
|
20
|
+
render :json => { :status => 'unimplemented' }
|
21
|
+
end
|
22
|
+
|
23
|
+
def core_process
|
24
|
+
render :json => { :status => 'unimplemented' }
|
25
|
+
end
|
26
|
+
|
27
|
+
def post_process
|
28
|
+
render :json => { :status => 'unimplemented' }
|
29
|
+
end
|
30
|
+
|
31
|
+
def uninstall
|
32
|
+
begin
|
33
|
+
# Check access
|
34
|
+
if (@curUserRole == 'contentadmin' ||
|
35
|
+
@curUserRole == 'user' ||
|
36
|
+
@curUserRole == 'loggedin' ||
|
37
|
+
@curUserRole == 'anonymous')
|
38
|
+
raise 'unauthorized access'
|
39
|
+
end
|
40
|
+
|
41
|
+
render :json => { :status => 'success' }
|
42
|
+
rescue
|
43
|
+
render :json => { :status => 'failure' }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class SharingServicesController < ApplicationController
|
2
|
+
include SharingPluginHelper
|
3
|
+
|
4
|
+
layout false
|
5
|
+
|
6
|
+
before_filter :get_current_user_role
|
7
|
+
before_filter :check_compliance_presence, :except =>
|
8
|
+
[
|
9
|
+
:get_shared_releases,
|
10
|
+
:get_shared_item_content
|
11
|
+
]
|
12
|
+
|
13
|
+
# Load configuration items (MANDATORY, must be included)
|
14
|
+
APP_CONFIG = HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path('../../../config/sharing/sharing_config.yml', __FILE__))))
|
15
|
+
|
16
|
+
def set_release_shared
|
17
|
+
begin
|
18
|
+
item = Release.find_by_metadata_id(params[:id].to_i)
|
19
|
+
if (item.nil?)
|
20
|
+
render :json => { :status => 'failure', :message => 'element has not been released yet' }
|
21
|
+
else
|
22
|
+
if (UserSession.find.record.id != item.users_id)
|
23
|
+
render :json => { :status => 'failure', :message => "item sharing setings hasn't been changed because you are not the last publisher" }
|
24
|
+
else
|
25
|
+
Release.update(item.id, { :scope => params[:shared] })
|
26
|
+
render :json => { :status => 'success' }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue Exception => ex
|
30
|
+
# render :json => { :status => 'failure', :message => ex.message }
|
31
|
+
render :json => { :status => 'failure', :message => "unable to process your request" }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_release_shared
|
36
|
+
begin
|
37
|
+
render :json => { :status => 'success', :data => Release.find_by_metadata_id(params[:id]).nil? ? nil : Release.find_by_metadata_id(params[:id]).scope }
|
38
|
+
rescue Exception => ex
|
39
|
+
render :json => { :status => 'failure', :message => "unable to process your request" }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_shared_releases
|
44
|
+
begin
|
45
|
+
limit = params[:limit].to_i
|
46
|
+
offset = params[:offset].to_i
|
47
|
+
|
48
|
+
render :json => { :status => 'success', :data => Release.select("metadata.id, key, cat, value, login as name")
|
49
|
+
.joins("INNER JOIN metadata on metadata.id = releases.metadata_id")
|
50
|
+
.joins("INNER JOIN users on users.id = releases.users_id")
|
51
|
+
.where("scope <> ? and users_id <> ?", "w", UserSession.find.record.id).offset(offset).limit(limit) }
|
52
|
+
rescue Exception => ex
|
53
|
+
render :json => { :status => 'failure', :message => "unable to process your request" }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_shared_item_content
|
58
|
+
begin
|
59
|
+
render :json => { :status => 'success', :data => Metadata.find(params[:id]).value }
|
60
|
+
rescue Exception => ex
|
61
|
+
render :json => { :status => 'failure', :message => "unable to process your request" }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def check_compliance_presence
|
68
|
+
if (!defined?(RxcmsCompliancePlugin))
|
69
|
+
raise
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module SharingPluginHelper
|
2
|
+
|
3
|
+
def current_user
|
4
|
+
if UserSession.find.nil?
|
5
|
+
@current_user ||= nil
|
6
|
+
else
|
7
|
+
@current_user ||= User.find(UserSession.find.record.id)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Get current user's role
|
12
|
+
def get_current_user_role
|
13
|
+
@current_user = current_user
|
14
|
+
if (!@current_user.nil?)
|
15
|
+
siteId = session[:accessible_appid]
|
16
|
+
roleId = session[:accessible_roleid]
|
17
|
+
|
18
|
+
if (!siteId.nil? && !roleId.nil?)
|
19
|
+
userRole = Role.find(roleId)
|
20
|
+
@curUserRole = userRole.name
|
21
|
+
else
|
22
|
+
@curUserRole = 'loggedin'
|
23
|
+
end
|
24
|
+
|
25
|
+
else
|
26
|
+
@curUserRole = 'anonymous'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
File without changes
|
File without changes
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
get "/sharing/engine/readme" => "sharing_engine#index"
|
4
|
+
get "/sharing/engine/configure" => "sharing_engine#configure"
|
5
|
+
get "/sharing/engine/installer" => "sharing_engine#installer"
|
6
|
+
|
7
|
+
post "/sharing/installer/before_process" => "sharing_installer#before_process"
|
8
|
+
post "/sharing/installer/core_process" => "sharing_installer#core_process"
|
9
|
+
post "/sharing/installer/post_process" => "sharing_installer#post_process"
|
10
|
+
post "/sharing/installer/uninstall" => "sharing_installer#uninstall"
|
11
|
+
|
12
|
+
post "/sharing/release/status" => "sharing_services#set_release_shared"
|
13
|
+
get "/sharing/release/status/:id" => "sharing_services#get_release_shared"
|
14
|
+
get "/sharing/release/shared/all/:offset/:limit" => "sharing_services#get_shared_releases"
|
15
|
+
get "/sharing/release/shared/one/:id" => "sharing_services#get_shared_item_content"
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
SHARING_CAT_CONFIG : sharing_config
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RxcmsSharingPlugin
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
|
4
|
+
config.generators do |g|
|
5
|
+
g.test_framework :rspec
|
6
|
+
# g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
7
|
+
end
|
8
|
+
|
9
|
+
config.autoload_paths += Dir["#{config.root}/lib/rxcms-sharing_plugin/classes/**/"]
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rxcms-sharing_plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anh Nguyen
|
8
|
+
- Julian Cowan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.2.13
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.2.13
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: sqlite3
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: Extension to RXCMS that enables users to share content.
|
43
|
+
email:
|
44
|
+
- rxcms@ngonluakiko.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- app/views/sharing_engine/configure.html.erb
|
50
|
+
- app/views/sharing_engine/installer.html.erb
|
51
|
+
- app/views/sharing_engine/index.html.erb
|
52
|
+
- app/controllers/sharing_engine_controller.rb
|
53
|
+
- app/controllers/sharing_installer_controller.rb
|
54
|
+
- app/controllers/sharing_services_controller.rb
|
55
|
+
- app/assets/javascripts/sharing_services.js
|
56
|
+
- app/assets/javascripts/rx-cms-sharing/installer.js
|
57
|
+
- app/assets/javascripts/rx-cms-sharing/index.js
|
58
|
+
- app/assets/javascripts/rx-cms-sharing/configure.js
|
59
|
+
- app/assets/javascripts/sharing_engine.js
|
60
|
+
- app/assets/javascripts/sharing_installer.js
|
61
|
+
- app/assets/stylesheets/sharing_services.css
|
62
|
+
- app/assets/stylesheets/sharing_engine.css
|
63
|
+
- app/assets/stylesheets/sharing_installer.css
|
64
|
+
- app/helpers/sharing_engine_helper.rb
|
65
|
+
- app/helpers/sharing_services_helper.rb
|
66
|
+
- app/helpers/sharing_plugin_helper.rb
|
67
|
+
- app/helpers/sharing_installer_helper.rb
|
68
|
+
- config/routes.rb
|
69
|
+
- config/sharing/sharing_config.yml
|
70
|
+
- lib/rxcms-sharing_plugin.rb
|
71
|
+
- lib/rxcms-sharing_plugin/engine.rb
|
72
|
+
- lib/rxcms-sharing_plugin/version.rb
|
73
|
+
- lib/tasks/rxcms-sharing_plugin_tasks.rake
|
74
|
+
- MIT-LICENSE
|
75
|
+
- Rakefile
|
76
|
+
- README.rdoc
|
77
|
+
homepage: https://bitbucket.org/kikoflame/rxcms-sharing-plugin
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata:
|
81
|
+
compatCode: 2dd89a9ecdeb920d539954fd9fb3da7de9f52a61ee9895d06e4bc1bab11a598b
|
82
|
+
fullName: Sharing Plugin
|
83
|
+
mountPoint: /sharing/engine/configure
|
84
|
+
installerPoint: /sharing/engine/installer
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.0.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Plugin that helps users create sharable content.
|
105
|
+
test_files: []
|