phcpress 3.7.7 → 3.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/phcpress/blog/posts_controller.rb +31 -25
- data/lib/phcpress/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7b4b18fae3168b89e8c9d1c4da0f4e80172062b
|
4
|
+
data.tar.gz: e6c0d21fd5c35eec03c7257b5548693528774eac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e3842e0212ff38891ef143b3dd7babc9bb048c9e241207d8ea7e46fd7b5c94123838421f3e5e67082520c7a0eed363824b84c715bf9e54516fe394c015c70af
|
7
|
+
data.tar.gz: b6e10b38c52e45af634a917c82d68804a7ceb9dd9ec949ad94f5fe47185b9163fc4a5380bb8c202abd2fd09626e83c7d80efb982ed78293a33b9c0055b2a3e43
|
@@ -1,66 +1,72 @@
|
|
1
|
+
# Load General Controller for Engine
|
1
2
|
require_dependency "phcpress/application_controller"
|
2
3
|
|
4
|
+
# Code for Blog Posting
|
3
5
|
module Phcpress
|
4
|
-
class
|
6
|
+
class Blog::PostsController < ApplicationController
|
5
7
|
|
6
8
|
# Filters & Security
|
7
|
-
layout 'layouts/phcpress/
|
9
|
+
layout 'layouts/phcpress/blogpost/blog_layout'
|
8
10
|
before_action :authenticate_user!
|
9
11
|
before_action :current_user
|
10
|
-
before_action :
|
12
|
+
before_action :set_blog_post, only: [:edit, :update, :destroy]
|
11
13
|
|
12
|
-
# Blog Post Index
|
14
|
+
# Blog Post Index (/blog/posts)
|
13
15
|
def index
|
14
|
-
@
|
16
|
+
@blog_posts = Blog::Post.all
|
15
17
|
end
|
16
18
|
|
17
|
-
#
|
19
|
+
# Single Blog Post (/blog/posts/1)
|
20
|
+
#def show
|
21
|
+
#end
|
22
|
+
|
23
|
+
# Create a New Blog Post (/blog/posts/new)
|
18
24
|
def new
|
19
|
-
@
|
25
|
+
@blog_post = Blog::Post.new
|
20
26
|
end
|
21
27
|
|
22
|
-
# Edit Blog
|
28
|
+
# Edit Blog Post (/blog/posts/1/edit)
|
23
29
|
def edit
|
24
30
|
end
|
25
31
|
|
26
|
-
# Create
|
32
|
+
# Create News Post /news/posts/new
|
27
33
|
def create
|
28
|
-
@
|
29
|
-
@
|
30
|
-
if @
|
31
|
-
redirect_to
|
34
|
+
@blog_post = Blog::Post.new(blog_post_params)
|
35
|
+
@blog_post.user_id = current_user.id
|
36
|
+
if @blog_post.save
|
37
|
+
redirect_to blog_posts_path, notice: 'Blog post was successfully created.'
|
32
38
|
else
|
33
39
|
render 'new'
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
37
|
-
#
|
43
|
+
# PATCH/PUT
|
38
44
|
def update
|
39
|
-
if @
|
40
|
-
redirect_to
|
45
|
+
if @blog_post.update(blog_post_params)
|
46
|
+
redirect_to blog_posts_path, notice: 'Blog post was successfully updated.'
|
41
47
|
else
|
42
48
|
render :edit
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
46
|
-
#
|
52
|
+
# DELETE
|
47
53
|
def destroy
|
48
|
-
@
|
49
|
-
redirect_to
|
54
|
+
@blog_post.destroy
|
55
|
+
redirect_to blog_posts_path, notice: 'Blog post was successfully destroyed.'
|
50
56
|
end
|
51
57
|
|
52
58
|
private
|
53
59
|
|
54
60
|
# Common Callbacks
|
55
|
-
def
|
56
|
-
@
|
61
|
+
def set_blog_post
|
62
|
+
@blog_post = Blog::Post.find(params[:id])
|
57
63
|
end
|
58
64
|
|
59
|
-
# Whitelist
|
60
|
-
def
|
61
|
-
params.require(:
|
65
|
+
# Whitelist on what can be posted
|
66
|
+
def blog_post_params
|
67
|
+
params.require(:blog_post).permit(:blogpsttitle, :blogpsttext, :blogpstexcerpts, :pststatus, :pstimage, :user_id)
|
62
68
|
end
|
63
|
-
|
69
|
+
|
64
70
|
# Current User
|
65
71
|
def current_user
|
66
72
|
return unless session[:user_id]
|
data/lib/phcpress/version.rb
CHANGED