phcpresspro 1.6.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/Rakefile +7 -7
- data/app/assets/javascripts/phcpresspro/application.js +0 -13
- data/app/assets/stylesheets/phcpresspro/{application.css.scss → application.scss} +0 -0
- data/app/assets/stylesheets/phcpresspro/{custom.css.scss → custom.scss} +0 -0
- data/app/controllers/phcpresspro/application_controller.rb +14 -0
- data/app/controllers/phcpresspro/blog/posts_controller.rb +14 -9
- data/app/controllers/phcpresspro/categories_controller.rb +63 -0
- data/app/controllers/phcpresspro/news/posts_controller.rb +22 -23
- data/app/helpers/phcpresspro/application_helper.rb +2 -2
- data/app/models/phcpresspro/blog.rb +1 -1
- data/app/models/phcpresspro/blog/post.rb +0 -8
- data/app/models/phcpresspro/category.rb +4 -0
- data/app/models/phcpresspro/news.rb +1 -1
- data/app/models/phcpresspro/news/post.rb +0 -8
- data/app/views/layouts/phcpresspro/application.html.erb +1 -1
- data/app/views/layouts/phcpresspro/blogpost/blog_layout.html.erb +1 -1
- data/app/views/layouts/phcpresspro/newspost/news_layout.html.erb +1 -1
- data/app/views/phcpresspro/blog/posts/_form.html.erb +9 -5
- data/app/views/phcpresspro/blog/posts/edit.html.erb +11 -2
- data/app/views/phcpresspro/blog/posts/index.html.erb +1 -1
- data/app/views/phcpresspro/blog/posts/new.html.erb +11 -2
- data/app/views/phcpresspro/categories/_form.html.erb +19 -0
- data/app/views/phcpresspro/categories/edit.html.erb +12 -0
- data/app/views/phcpresspro/categories/index.html.erb +36 -0
- data/app/views/phcpresspro/categories/new.html.erb +12 -0
- data/app/views/phcpresspro/news/posts/_form.html.erb +22 -12
- data/app/views/phcpresspro/news/posts/edit.html.erb +11 -2
- data/app/views/phcpresspro/news/posts/new.html.erb +11 -2
- data/config/routes.rb +5 -2
- data/db/migrate/20160424211134_create_phcpresspro_categories.rb +9 -0
- data/db/migrate/20160425194021_add_phcpresspro_category_to_phcpress_blog_posts.rb +7 -0
- data/db/migrate/20160425194321_add_phcpresspro_category_to_phcpress_news_post.rb +7 -0
- data/lib/phcpresspro.rb +0 -1
- data/lib/phcpresspro/engine.rb +16 -14
- data/lib/phcpresspro/version.rb +1 -1
- metadata +194 -51
- data/app/assets/stylesheets/phcpresspro/blog/posts.css +0 -0
- data/app/assets/stylesheets/phcpresspro/news/posts.css +0 -0
- data/app/helpers/phcpresspro/blog/posts_helper.rb +0 -4
- data/app/helpers/phcpresspro/news/posts_helper.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aa51c93d01be3180790ea6cfb685b2709cc676e
|
4
|
+
data.tar.gz: b7ab6aee232a30ae4c480774dfaa92a2610cb7fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d069b8d6a399367c601d05c50b8a89cf4912c87ea3e94b55851e36ab85215315585f75c1309850c195023279b480771729196349dac6ca35c064c9a501b9e9
|
7
|
+
data.tar.gz: e17e27029bb12bdab4d395c4ce9830d580de86173744c7c8edb215cbb251cc9b31547dbc6cc8cb791c9f865bbda6187508ccd88c4cbfa3bf72d338a80664f31f
|
data/README.md
CHANGED
@@ -1,4 +0,0 @@
|
|
1
|
-
[![security](https://hakiri.io/github/PHCNetworks/phc-press/master.svg)](https://hakiri.io/github/PHCNetworks/phc-press/master)
|
2
|
-
[![Code Climate](https://codeclimate.com/github/PHCNetworks/phc-press/badges/gpa.svg)](https://codeclimate.com/github/PHCNetworks/phc-press)
|
3
|
-
[![Issue Count](https://codeclimate.com/github/PHCNetworks/phc-press/badges/issue_count.svg)](https://codeclimate.com/github/PHCNetworks/phc-press)
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/phcpresspro.svg)](https://badge.fury.io/rb/phcpresspro)
|
data/Rakefile
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
begin
|
2
|
-
|
2
|
+
require 'bundler/setup'
|
3
3
|
rescue LoadError
|
4
|
-
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'rdoc/task'
|
8
8
|
|
9
9
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'phcpresspro'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
17
|
APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
|
@@ -1,16 +1,3 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
14
1
|
//= require jquery
|
15
2
|
//= require jquery_ujs
|
16
3
|
//= require bootstrap-sprockets
|
File without changes
|
File without changes
|
@@ -1,6 +1,20 @@
|
|
1
1
|
module Phcpresspro
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
# Prevent CSRF attacks by raising an exception.
|
5
|
+
# For APIs, you may want to use :null_session instead.
|
6
|
+
before_action :authenticate_user!, if: -> { defined?(Devise) }
|
3
7
|
protect_from_forgery with: :exception
|
8
|
+
|
9
|
+
# Make Current User Sitewide
|
10
|
+
def current_user
|
11
|
+
return unless session[:user_id]
|
12
|
+
@current_user ||= User.find(session[:user_id])
|
13
|
+
end
|
14
|
+
|
15
|
+
# Load Helpers
|
16
|
+
helper Phctitleseo::Engine.helpers
|
17
|
+
helper Phcnotifi::Engine.helpers
|
4
18
|
|
5
19
|
end
|
6
20
|
end
|
@@ -7,7 +7,7 @@ module Phcpresspro
|
|
7
7
|
|
8
8
|
# Filters & Security
|
9
9
|
layout 'layouts/phcpresspro/blogpost/blog_layout'
|
10
|
-
|
10
|
+
before_action :authenticate_user!, if: -> { defined?(Devise) }
|
11
11
|
before_action :set_blog_post, only: [:edit, :update, :destroy]
|
12
12
|
|
13
13
|
# Blog Post Index (/blog/posts)
|
@@ -28,15 +28,14 @@ module Phcpresspro
|
|
28
28
|
def edit
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
31
|
+
# Create News Post /news/posts/new
|
32
32
|
def create
|
33
|
-
@blog_post.user_id = current_user
|
34
33
|
@blog_post = Blog::Post.new(blog_post_params)
|
35
|
-
|
36
|
-
if @blog_post.save
|
34
|
+
@blog_post.user_id = current_user.id
|
35
|
+
if @blog_post.save
|
37
36
|
redirect_to blog_posts_path, notice: 'Blog post was successfully created.'
|
38
|
-
|
39
|
-
|
37
|
+
else
|
38
|
+
render 'new'
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -59,12 +58,18 @@ module Phcpresspro
|
|
59
58
|
|
60
59
|
# Common Callbacks
|
61
60
|
def set_blog_post
|
62
|
-
|
61
|
+
@blog_post = Blog::Post.find(params[:id])
|
63
62
|
end
|
64
63
|
|
65
64
|
# Whitelist on what can be posted
|
66
65
|
def blog_post_params
|
67
|
-
params.require(:blog_post).permit(:blogpsttitle, :blogpsttext, :blogpstexcerpts, :pststatus, :pstimage)
|
66
|
+
params.require(:blog_post).permit(:blogpsttitle, :blogpsttext, :blogpstexcerpts, :pststatus, :pstimage, :user_id)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Current User
|
70
|
+
def current_user
|
71
|
+
return unless session[:user_id]
|
72
|
+
@current_user ||= User.find(session[:user_id])
|
68
73
|
end
|
69
74
|
|
70
75
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_dependency "phcpresspro/application_controller"
|
2
|
+
|
3
|
+
module Phcpresspro
|
4
|
+
class CategoriesController < ApplicationController
|
5
|
+
|
6
|
+
# Security and Filters
|
7
|
+
before_action :authenticate_user!, if: -> { defined?(Devise) }
|
8
|
+
before_action :set_category, only: [:edit, :update, :destroy]
|
9
|
+
|
10
|
+
# Categories Index
|
11
|
+
def index
|
12
|
+
@categories = Category.all
|
13
|
+
end
|
14
|
+
|
15
|
+
# New News/Blog Category
|
16
|
+
def new
|
17
|
+
@category = Category.new
|
18
|
+
end
|
19
|
+
|
20
|
+
# Edit News/Blog Category
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
# Create News/Blog Category
|
25
|
+
def create
|
26
|
+
@category = Category.new(category_params)
|
27
|
+
|
28
|
+
if @category.save
|
29
|
+
redirect_to categories_path, notice: 'Category was Successfully Created.'
|
30
|
+
else
|
31
|
+
render :new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Update News/Blog Category
|
36
|
+
def update
|
37
|
+
if @category.update(category_params)
|
38
|
+
redirect_to categories_path, notice: 'Category was Successfully Updated.'
|
39
|
+
else
|
40
|
+
render :edit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delete News/Blog Category
|
45
|
+
def destroy
|
46
|
+
@category.destroy
|
47
|
+
redirect_to categories_path, notice: 'Category was Successfully Destroyed.'
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Common Callbacks
|
53
|
+
def set_category
|
54
|
+
@category = Category.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Whitelist
|
58
|
+
def category_params
|
59
|
+
params.require(:category).permit(:catname)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -1,58 +1,51 @@
|
|
1
|
-
# Load General Controller for Engine
|
2
1
|
require_dependency "phcpresspro/application_controller"
|
3
2
|
|
4
|
-
# Code for News Posting
|
5
3
|
module Phcpresspro
|
6
4
|
class News::PostsController < ApplicationController
|
7
5
|
|
8
6
|
# Filters & Security
|
9
7
|
layout 'layouts/phcpresspro/newspost/news_layout'
|
10
|
-
before_action :authenticate_user
|
8
|
+
before_action :authenticate_user!, if: -> { defined?(Devise) }
|
11
9
|
before_action :set_news_post, only: [:edit, :update, :destroy]
|
12
10
|
|
13
|
-
# News Post Index
|
11
|
+
# News Post Index
|
14
12
|
def index
|
15
13
|
@news_posts = News::Post.all
|
16
14
|
end
|
17
15
|
|
18
|
-
#
|
19
|
-
#def show
|
20
|
-
#end
|
21
|
-
|
22
|
-
# Create a New News Post (/news/posts/new)
|
16
|
+
# New News Article
|
23
17
|
def new
|
24
18
|
@news_post = News::Post.new
|
25
19
|
end
|
26
20
|
|
27
|
-
# Edit News
|
21
|
+
# Edit News Article
|
28
22
|
def edit
|
29
23
|
end
|
30
24
|
|
31
|
-
#
|
25
|
+
# Create News Article
|
32
26
|
def create
|
27
|
+
@news_post = News::Post.new(news_post_params)
|
33
28
|
@news_post.user_id = current_user
|
34
|
-
@news_post
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
render :new
|
29
|
+
if @news_post.save
|
30
|
+
redirect_to news_posts_path, notice: 'News Article was Successfully Created.'
|
31
|
+
else
|
32
|
+
render 'new'
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
43
|
-
#
|
36
|
+
# Update News Article
|
44
37
|
def update
|
45
38
|
if @news_post.update(news_post_params)
|
46
|
-
redirect_to news_posts_path, notice: 'News
|
39
|
+
redirect_to news_posts_path, notice: 'News Article was Successfully Updated.'
|
47
40
|
else
|
48
41
|
render :edit
|
49
42
|
end
|
50
43
|
end
|
51
44
|
|
52
|
-
#
|
45
|
+
# Delete News Destroy
|
53
46
|
def destroy
|
54
47
|
@news_post.destroy
|
55
|
-
redirect_to news_posts_path, notice: 'News
|
48
|
+
redirect_to news_posts_path, notice: 'News Article was Successfully Destroyed.'
|
56
49
|
end
|
57
50
|
|
58
51
|
private
|
@@ -62,9 +55,15 @@ module Phcpresspro
|
|
62
55
|
@news_post = News::Post.find(params[:id])
|
63
56
|
end
|
64
57
|
|
65
|
-
# Whitelist
|
58
|
+
# Whitelist
|
66
59
|
def news_post_params
|
67
|
-
params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage)
|
60
|
+
params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage, :user_id, :category_id)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Current User
|
64
|
+
def current_user
|
65
|
+
return unless session[:user_id]
|
66
|
+
@current_user ||= User.find(session[:user_id])
|
68
67
|
end
|
69
68
|
|
70
69
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
module Phcpresspro
|
2
2
|
class Blog::Post < ActiveRecord::Base
|
3
3
|
|
4
|
-
# Filters Before Post
|
5
|
-
before_create :authour
|
6
|
-
|
7
4
|
# For Image Uploads
|
8
5
|
mount_uploader :pstimage, Phcpresspro::PstimageUploader
|
9
6
|
|
10
7
|
# Associate Post Authour to User
|
11
8
|
belongs_to :user, class_name: 'Phcengine::User'
|
12
9
|
|
13
|
-
# Define r Devise
|
14
|
-
def authour
|
15
|
-
self.user_id = current_user.id
|
16
|
-
end
|
17
|
-
|
18
10
|
end
|
19
11
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
module Phcpresspro
|
2
2
|
class News::Post < ActiveRecord::Base
|
3
3
|
|
4
|
-
# Filters Before Post
|
5
|
-
before_create :authour
|
6
|
-
|
7
4
|
# For Image Uploads
|
8
5
|
mount_uploader :pstimage, Phcpresspro::PstimageUploader
|
9
6
|
|
10
7
|
# Associate Post Authour to User
|
11
8
|
belongs_to :user, class_name: 'Phcengine::User'
|
12
|
-
|
13
|
-
# Define r Devise
|
14
|
-
def authour
|
15
|
-
self.user_id = current_user.id
|
16
|
-
end
|
17
9
|
|
18
10
|
end
|
19
11
|
end
|
@@ -5,21 +5,25 @@
|
|
5
5
|
<%= render 'phcnotifi/validations', :object => @blog_post %>
|
6
6
|
|
7
7
|
<div class="col-md-3">
|
8
|
-
<div class="panel panel-
|
8
|
+
<div class="panel panel-primary">
|
9
9
|
<div class="panel-heading">
|
10
10
|
<i class="fa fa-paper-plane-o"></i> Publish Panel
|
11
11
|
</div>
|
12
12
|
<div class="panel-body">
|
13
13
|
<div class="form-group">
|
14
|
-
|
15
|
-
<%= f.select :pststatus, [['Draft','draft'],['Publish','publish'],['Review','review']], class: "form-control" %>
|
14
|
+
<%= f.label :pststatus, "Post Status" %>
|
15
|
+
<%= f.select( :pststatus, [['Draft','draft'],['Publish','publish'],['Review','review']], {}, {class: "form-control form-control-sm"}) %>
|
16
|
+
</div>
|
17
|
+
<div class="form-group">
|
18
|
+
<%= f.label :pstcategory, "Post Category" %>
|
19
|
+
<%= collection_select(:pstcategory, :pstcategory_id, Phcpresspro::Category.order('catname'), :id, :catname, {}, {class: "form-control form-control-sm"}) %>
|
16
20
|
</div>
|
17
21
|
<div class="actions">
|
18
22
|
<%= f.submit "Publish Blog Article", class: "btn btn-primary btn-sm" %>
|
19
23
|
</div>
|
20
24
|
</div>
|
21
25
|
</div>
|
22
|
-
<div class="panel panel-
|
26
|
+
<div class="panel panel-primary">
|
23
27
|
<div class="panel-heading">
|
24
28
|
<i class="fa fa-camera-retro"></i> Post Images
|
25
29
|
</div>
|
@@ -33,7 +37,7 @@
|
|
33
37
|
</div>
|
34
38
|
</div>
|
35
39
|
<div class="col-md-9 ">
|
36
|
-
<div class="panel panel-
|
40
|
+
<div class="panel panel-primary">
|
37
41
|
<div class="panel-heading">
|
38
42
|
<i class="fa fa-pencil-square-o"></i> Blog Post Publisher
|
39
43
|
</div>
|
@@ -1,3 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<!-- Main Content -->
|
2
|
+
<div class="panel panel-primary">
|
3
|
+
|
4
|
+
<div class="panel-heading">
|
5
|
+
<i class="fa fa-pencil-square-o"></i> Edit Blog Post
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="panel-body">
|
9
|
+
<%= render 'form' %>
|
10
|
+
</div>
|
11
|
+
|
3
12
|
</div>
|