phcpresspro 12.1.0 → 12.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/phcpresspro/application_controller.rb +37 -6
- data/app/controllers/phcpresspro/articles/posts_controller.rb +6 -4
- data/app/controllers/phcpresspro/modules/categories_controller.rb +6 -4
- data/app/controllers/phcpresspro/modules/connections_controller.rb +6 -4
- data/app/models/phcpresspro/articles/post.rb +6 -3
- data/app/models/phcpresspro/modules/category.rb +4 -1
- data/app/models/phcpresspro/modules/connection.rb +4 -1
- data/app/views/layouts/phcpresspro/components/backend/footer/_footer.html.erb +1 -1
- data/db/migrate/20160714193304_create_phcpresspro_versions.rb +80 -0
- data/lib/phcpresspro/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9839c08caf6d6cd481e9246ea5cfa670746802e
|
4
|
+
data.tar.gz: fa9936657cfa695a26de5f4a40dd2131562ee176
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42b313cf60123a532e4aacaff9099a6def1611dc82c1e5ead7968e4c14076c3ac3639c28231d571c4f5da3714ca75c478a07dc29f4d089396fba65ed318b249b
|
7
|
+
data.tar.gz: 38def7b378a5d325a12efb5e4c6203964310381b77f1d0bc3c3ceb809c709fdbeb06d05d2d2a3447b2087aa130c5d9e6797895cfdf22100c2915c159b34fbde5
|
@@ -1,21 +1,52 @@
|
|
1
1
|
module Phcpresspro
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
|
4
|
-
# Load Helpers for PHCPress Widgets
|
5
|
-
before_action :phcpress_recent_posts
|
6
|
-
|
7
4
|
# Security Filters
|
8
5
|
protect_from_forgery with: :exception
|
9
6
|
|
7
|
+
# Load Helpers for PHCPress Widgets
|
8
|
+
before_action :phcpress_recent_posts
|
9
|
+
|
10
10
|
# Load Helpers
|
11
11
|
helper Phctitleseo::Engine.helpers
|
12
12
|
helper Phcnotifi::Engine.helpers
|
13
13
|
helper Phcaccountspro::Engine.helpers
|
14
14
|
|
15
|
-
#
|
16
|
-
def
|
17
|
-
|
15
|
+
# AuthRocket Definitions
|
16
|
+
def require_user
|
17
|
+
unless current_user
|
18
|
+
params.permit!
|
19
|
+
session[:last_url] = request.get? ? url_for(params) : url_for
|
20
|
+
redirect_to new_login_url
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_user
|
25
|
+
@_current_user ||= AuthRocket::Session.from_token(session[:ar_token]).try(:user)
|
26
|
+
end
|
27
|
+
helper_method :current_user
|
28
|
+
|
29
|
+
def new_login_url
|
30
|
+
ENV['AUTHROCKET_LOGIN_URL']
|
31
|
+
end
|
32
|
+
helper_method :new_login_url
|
33
|
+
|
34
|
+
def authrocket_membership_info
|
35
|
+
AuthRocket::Membership.all(user_id: current_user.id).first
|
18
36
|
end
|
19
37
|
|
38
|
+
# Papertrail Whodunnit Username
|
39
|
+
def user_for_paper_trail
|
40
|
+
# Default is: current_user rescue nil
|
41
|
+
current_user ? current_user.username : 'Public user'
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# PHCPress Widget Helpers
|
47
|
+
def phcpress_recent_posts
|
48
|
+
@recent_posts = Phcpresspro::Articles::Post.all
|
49
|
+
end
|
50
|
+
|
20
51
|
end
|
21
52
|
end
|
@@ -3,19 +3,21 @@ require_dependency "phcpresspro/application_controller"
|
|
3
3
|
module Phcpresspro
|
4
4
|
class Articles::PostsController < ApplicationController
|
5
5
|
|
6
|
-
#
|
6
|
+
# Security & Action Filters
|
7
7
|
before_action :require_user
|
8
|
-
before_action :
|
8
|
+
before_action :authrocket_membership_info
|
9
|
+
before_action :set_paper_trail_whodunnit
|
9
10
|
before_action :set_articles_post, only: [:show, :edit, :update, :destroy]
|
10
11
|
|
11
12
|
# Article Index
|
12
13
|
def index
|
13
|
-
@articles_posts = Articles::Post.
|
14
|
+
@articles_posts = Articles::Post.where(oganization_id: membership_info.org_id)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Article Show
|
17
18
|
def show
|
18
19
|
@articles_post = Articles::Post.friendly.find(params[:id])
|
20
|
+
@versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcpresspro::Articles::Post')
|
19
21
|
end
|
20
22
|
|
21
23
|
# Article New
|
@@ -66,7 +68,7 @@ module Phcpresspro
|
|
66
68
|
|
67
69
|
# Common Callbacks
|
68
70
|
def set_articles_post
|
69
|
-
@articles_post = Articles::Post.find(params[:id])
|
71
|
+
@articles_post = Articles::Post.friendly.find(params[:id])
|
70
72
|
end
|
71
73
|
|
72
74
|
# Params Whitelist
|
@@ -3,19 +3,21 @@ require_dependency "phcpresspro/application_controller"
|
|
3
3
|
module Phcpresspro
|
4
4
|
class Modules::CategoriesController < ApplicationController
|
5
5
|
|
6
|
-
# Security
|
6
|
+
# Security & Action Filters
|
7
7
|
before_action :require_user
|
8
|
-
before_action :
|
8
|
+
before_action :authrocket_membership_info
|
9
|
+
before_action :set_paper_trail_whodunnit
|
9
10
|
before_action :set_modules_category, only: [:show, :edit, :update, :destroy]
|
10
11
|
|
11
12
|
# Categories Index
|
12
13
|
def index
|
13
|
-
@modules_categories = Modules::Category.
|
14
|
+
@modules_categories = Modules::Category.where(oganization_id: membership_info.org_id)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Categories Show
|
17
18
|
def show
|
18
19
|
@modules_category = Modules::Category.friendly.find(params[:id])
|
20
|
+
@versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcpresspro::Modules::Category')
|
19
21
|
end
|
20
22
|
|
21
23
|
# Categories New
|
@@ -64,7 +66,7 @@ module Phcpresspro
|
|
64
66
|
|
65
67
|
# Common Callbacks
|
66
68
|
def set_modules_category
|
67
|
-
@modules_category = Modules::Category.find(params[:id])
|
69
|
+
@modules_category = Modules::Category.friendly.find(params[:id])
|
68
70
|
end
|
69
71
|
|
70
72
|
# Whitelist
|
@@ -3,19 +3,21 @@ require_dependency "phcpresspro/application_controller"
|
|
3
3
|
module Phcpresspro
|
4
4
|
class Modules::ConnectionsController < ApplicationController
|
5
5
|
|
6
|
-
# Security
|
6
|
+
# Security & Action Filters
|
7
7
|
before_action :require_user
|
8
|
-
before_action :
|
8
|
+
before_action :authrocket_membership_info
|
9
|
+
before_action :set_paper_trail_whodunnit
|
9
10
|
before_action :set_modules_connection, only: [:show, :edit, :update, :destroy]
|
10
11
|
|
11
12
|
# Connections Index
|
12
13
|
def index
|
13
|
-
@modules_connections = Modules::Connection.
|
14
|
+
@modules_connections = Modules::Connection.where(oganization_id: membership_info.org_id)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Connections Show
|
17
18
|
def show
|
18
19
|
@modules_connection = Modules::Connection.friendly.find(params[:id])
|
20
|
+
@versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcpresspro::Modules::Connection')
|
19
21
|
end
|
20
22
|
|
21
23
|
# Connections New
|
@@ -64,7 +66,7 @@ module Phcpresspro
|
|
64
66
|
|
65
67
|
# Common Callbacks
|
66
68
|
def set_modules_connection
|
67
|
-
@modules_connection = Modules::Connection.find(params[:id])
|
69
|
+
@modules_connection = Modules::Connection.friendly.find(params[:id])
|
68
70
|
end
|
69
71
|
|
70
72
|
# Whitelist
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module Phcpresspro
|
2
2
|
class Articles::Post < ApplicationRecord
|
3
3
|
|
4
|
+
# For Image Uploads
|
5
|
+
mount_uploader :pstimage, Phcpresspro::PstimageUploader
|
6
|
+
|
4
7
|
# Clean URL Initialize
|
5
8
|
extend FriendlyId
|
6
9
|
|
7
|
-
#
|
8
|
-
|
10
|
+
# Add Paper Trail
|
11
|
+
has_paper_trail
|
9
12
|
|
10
|
-
# Relationships
|
13
|
+
# Model Relationships
|
11
14
|
has_many :connections, class_name: 'Phcpresspro::Modules::Connection', dependent: :destroy
|
12
15
|
has_many :categories, class_name: 'Phcpresspro::Modules::Category', :through => :connections
|
13
16
|
|
@@ -4,7 +4,10 @@ module Phcpresspro
|
|
4
4
|
# Clean URL Initialize
|
5
5
|
extend FriendlyId
|
6
6
|
|
7
|
-
#
|
7
|
+
# Add Paper Trail
|
8
|
+
has_paper_trail
|
9
|
+
|
10
|
+
# Model Relationships
|
8
11
|
has_many :connections, class_name: 'Phcpresspro::Modules::Connection', dependent: :destroy
|
9
12
|
has_many :posts, class_name: 'Phcpresspro::Modules::Category', :through => :connections
|
10
13
|
|
@@ -4,7 +4,10 @@ module Phcpresspro
|
|
4
4
|
# Clean URL Initialize
|
5
5
|
extend FriendlyId
|
6
6
|
|
7
|
-
#
|
7
|
+
# Add Paper Trail
|
8
|
+
has_paper_trail
|
9
|
+
|
10
|
+
# Model Relationships
|
8
11
|
belongs_to :post, class_name: 'Phcpresspro::Articles::Post'
|
9
12
|
belongs_to :category, class_name: 'Phcpresspro::Modules::Category'
|
10
13
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# This migration creates the `versions` table, the only schema PT requires.
|
2
|
+
# All other migrations PT provides are optional.
|
3
|
+
class CreatePhcpressproVersions < ActiveRecord::Migration[5.1]
|
4
|
+
# Class names of MySQL adapters.
|
5
|
+
# - `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`.
|
6
|
+
# - `Mysql2Adapter` - Used by `mysql2` gem.
|
7
|
+
MYSQL_ADAPTERS = [
|
8
|
+
"ActiveRecord::ConnectionAdapters::MysqlAdapter",
|
9
|
+
"ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
# The largest text column available in all supported RDBMS is
|
13
|
+
# 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
|
14
|
+
# so that MySQL will use `longtext` instead of `text`. Otherwise,
|
15
|
+
# when serializing very large objects, `text` might not be big enough.
|
16
|
+
TEXT_BYTES = 1_073_741_823
|
17
|
+
|
18
|
+
def change
|
19
|
+
create_table :versions, versions_table_options do |t|
|
20
|
+
t.string :item_type, item_type_options
|
21
|
+
t.integer :item_id, null: false
|
22
|
+
t.string :event, null: false
|
23
|
+
t.string :whodunnit
|
24
|
+
t.text :object, limit: TEXT_BYTES
|
25
|
+
|
26
|
+
# Known issue in MySQL: fractional second precision
|
27
|
+
# -------------------------------------------------
|
28
|
+
#
|
29
|
+
# MySQL timestamp columns do not support fractional seconds unless
|
30
|
+
# defined with "fractional seconds precision". MySQL users should manually
|
31
|
+
# add fractional seconds precision to this migration, specifically, to
|
32
|
+
# the `created_at` column.
|
33
|
+
# (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
|
34
|
+
#
|
35
|
+
# MySQL users should also upgrade to rails 4.2, which is the first
|
36
|
+
# version of ActiveRecord with support for fractional seconds in MySQL.
|
37
|
+
# (https://github.com/rails/rails/pull/14359)
|
38
|
+
#
|
39
|
+
t.datetime :created_at
|
40
|
+
end
|
41
|
+
add_index :versions, [:item_type, :item_id]
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.
|
47
|
+
# See https://github.com/airblade/paper_trail/issues/651
|
48
|
+
def item_type_options
|
49
|
+
opt = { null: false }
|
50
|
+
opt[:limit] = 191 if mysql?
|
51
|
+
opt
|
52
|
+
end
|
53
|
+
|
54
|
+
def mysql?
|
55
|
+
MYSQL_ADAPTERS.include?(connection.class.name)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Even modern versions of MySQL still use `latin1` as the default character
|
59
|
+
# encoding. Many users are not aware of this, and run into trouble when they
|
60
|
+
# try to use PaperTrail in apps that otherwise tend to use UTF-8. Postgres, by
|
61
|
+
# comparison, uses UTF-8 except in the unusual case where the OS is configured
|
62
|
+
# with a custom locale.
|
63
|
+
#
|
64
|
+
# - https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html
|
65
|
+
# - http://www.postgresql.org/docs/9.4/static/multibyte.html
|
66
|
+
#
|
67
|
+
# Furthermore, MySQL's original implementation of UTF-8 was flawed, and had
|
68
|
+
# to be fixed later by introducing a new charset, `utf8mb4`.
|
69
|
+
#
|
70
|
+
# - https://mathiasbynens.be/notes/mysql-utf8mb4
|
71
|
+
# - https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
|
72
|
+
#
|
73
|
+
def versions_table_options
|
74
|
+
if mysql?
|
75
|
+
{ options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }
|
76
|
+
else
|
77
|
+
{}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/phcpresspro/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phcpresspro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.
|
4
|
+
version: 12.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BradPotts
|
@@ -684,6 +684,7 @@ files:
|
|
684
684
|
- app/views/phcpresspro/modules/connections/show.html.erb
|
685
685
|
- config/routes.rb
|
686
686
|
- config/tinymce.yml
|
687
|
+
- db/migrate/20160714193304_create_phcpresspro_versions.rb
|
687
688
|
- db/migrate/20160716182936_create_phcpresspro_modules_categories.rb
|
688
689
|
- db/migrate/20160718204718_create_phcpresspro_articles_posts.rb
|
689
690
|
- db/migrate/20160719221205_create_phcpresspro_modules_connections.rb
|
@@ -714,5 +715,5 @@ rubyforge_project:
|
|
714
715
|
rubygems_version: 2.6.8
|
715
716
|
signing_key:
|
716
717
|
specification_version: 4
|
717
|
-
summary:
|
718
|
+
summary: Rails 5.1 Engine - Content Management System
|
718
719
|
test_files: []
|