phcpress 9.0.1 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -20
- data/README.md +46 -46
- data/Rakefile +33 -33
- data/app/assets/config/phcpress_manifest.js +2 -2
- data/app/assets/javascripts/phcpress/application.js +2 -2
- data/app/assets/stylesheets/phcpress/application.scss +2 -2
- data/app/controllers/phcpress/api/v1/categories_controller.rb +15 -15
- data/app/controllers/phcpress/api/v1/posts_controller.rb +15 -15
- data/app/controllers/phcpress/application_controller.rb +12 -12
- data/app/controllers/phcpress/articles/posts_controller.rb +67 -67
- data/app/controllers/phcpress/frontend/articles_controller.rb +20 -20
- data/app/controllers/phcpress/modules/categories_controller.rb +65 -65
- data/app/controllers/phcpress/modules/connections_controller.rb +65 -65
- data/app/helpers/phcpress/application_helper.rb +14 -14
- data/app/jobs/phcpress/application_job.rb +4 -4
- data/app/mailers/phcpress/application_mailer.rb +6 -6
- data/app/models/phcpress/api/v1/category.rb +4 -4
- data/app/models/phcpress/api/v1/post.rb +4 -4
- data/app/models/phcpress/application_record.rb +5 -5
- data/app/models/phcpress/articles.rb +7 -7
- data/app/models/phcpress/articles/post.rb +30 -30
- data/app/models/phcpress/frontend.rb +7 -7
- data/app/models/phcpress/frontend/article.rb +4 -4
- data/app/models/phcpress/modules.rb +7 -7
- data/app/models/phcpress/modules/category.rb +20 -20
- data/app/models/phcpress/modules/connection.rb +15 -15
- data/app/uploaders/phcpress/pstimage_uploader.rb +30 -30
- data/app/views/layouts/components/backend/footer/_footer.html.erb +4 -4
- data/app/views/layouts/components/backend/navigation/_navigation.html.erb +48 -48
- data/app/views/layouts/components/backend/topbar/_topbar.html.erb +5 -5
- data/app/views/layouts/phcpress/application.html.erb +57 -57
- data/app/views/layouts/phcpress/frontend.html.erb +24 -24
- data/app/views/phcpress/api/v1/categories/index.json.rabl +2 -2
- data/app/views/phcpress/api/v1/posts/index.json.rabl +2 -2
- data/app/views/phcpress/articles/posts/_form.html.erb +84 -84
- data/app/views/phcpress/articles/posts/edit.html.erb +32 -32
- data/app/views/phcpress/articles/posts/index.html.erb +69 -69
- data/app/views/phcpress/articles/posts/new.html.erb +32 -32
- data/app/views/phcpress/articles/posts/show.html.erb +40 -40
- data/app/views/phcpress/frontend/articles/index.html.erb +76 -76
- data/app/views/phcpress/frontend/articles/show.html.erb +72 -72
- data/app/views/phcpress/modules/categories/_form.html.erb +20 -20
- data/app/views/phcpress/modules/categories/edit.html.erb +39 -39
- data/app/views/phcpress/modules/categories/index.html.erb +66 -66
- data/app/views/phcpress/modules/categories/new.html.erb +39 -39
- data/app/views/phcpress/modules/categories/show.html.erb +40 -40
- data/app/views/phcpress/modules/connections/_form.html.erb +24 -24
- data/app/views/phcpress/modules/connections/edit.html.erb +39 -39
- data/app/views/phcpress/modules/connections/index.html.erb +66 -66
- data/app/views/phcpress/modules/connections/new.html.erb +39 -39
- data/app/views/phcpress/modules/connections/show.html.erb +50 -50
- data/config/initializers/friendly_id.rb +92 -92
- data/config/routes.rb +27 -27
- data/config/tinymce.yml +5 -5
- data/db/migrate/20160716182848_create_phcpress_modules_categories.rb +18 -18
- data/db/migrate/20160720181307_create_phcpress_articles_posts.rb +21 -21
- data/db/migrate/20160720235314_create_phcpress_modules_connections.rb +19 -19
- data/db/migrate/20170509180858_create_friendly_id_slugs.rb +15 -15
- data/lib/phcpress.rb +4 -4
- data/lib/phcpress/engine.rb +68 -68
- data/lib/phcpress/version.rb +3 -3
- data/lib/tasks/phcpress_tasks.rake +4 -4
- metadata +23 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82e5c0fbf58b2334c4c45085cd5f62bcd49ecf1
|
4
|
+
data.tar.gz: 0170d16b34f5509fb702be15f568cf7be39bebba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d086ca8e79acb5b0bb548642613e90481ef12559a47e0edab8f2d342e6e693a4e9c4c12acdce6615ce45aa36655e749f3f86722bcc25b8f5e31a7b6e7973d8a6
|
7
|
+
data.tar.gz: be6c329840ee8ec0b615202903ee477991a2b3ff39ec86f2fd2d3e4ca91e3f17ab69406e0e599827bbac7f9d0a98782f5a48780b60d3feb124a3831ec31abb0c
|
data/MIT-LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright 2016-2017 BradPotts - PHCNetworks
|
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.
|
1
|
+
Copyright 2016-2017 BradPotts - PHCNetworks
|
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.md
CHANGED
@@ -1,46 +1,46 @@
|
|
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
|
-
[![Dependency Status](https://gemnasium.com/badges/github.com/PHCNetworks/phc-press.svg)](https://gemnasium.com/github.com/PHCNetworks/phc-press)
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/phcpress.svg)](https://badge.fury.io/rb/phcpress)
|
5
|
-
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/phc-press/blob/master/MIT-LICENSE)
|
6
|
-
|
7
|
-
### PHCPress(8) (News/Blog Engine) Documentation
|
8
|
-
PHCPress(8) rails CMS engine to manage your website's articles, categories and media.
|
9
|
-
|
10
|
-
* Website article posts with WYSIWYG editor.
|
11
|
-
* Upload images locally or use any popular cloud service.
|
12
|
-
* Customizable article categories module included.
|
13
|
-
|
14
|
-
#### Step 1 - Add PHCPress to your gemfile and run command
|
15
|
-
|
16
|
-
gem 'phcpress', '~> 8.0'
|
17
|
-
bundle install
|
18
|
-
|
19
|
-
#### Step 2 - Copy PHCPress Database Tables
|
20
|
-
To copy PHCPress' requried database migrations, copy each command individually to your terminal's command line.
|
21
|
-
|
22
|
-
rails phcpress:install:migrations
|
23
|
-
rails db:migrate
|
24
|
-
|
25
|
-
#### Step 3 - Mount PHCPress & Add Routes
|
26
|
-
Mount PHCPress by adding code below to your routes file.
|
27
|
-
|
28
|
-
mount Phcpress::Engine, :at => '/'
|
29
|
-
|
30
|
-
#### Step 4 - Recompile Assets
|
31
|
-
To properly function re-compile your application's assets to copy over requried files.
|
32
|
-
|
33
|
-
rails assets:clobber
|
34
|
-
rails assets:precompile
|
35
|
-
|
36
|
-
#### Step 5 - Generate Contact Form View (Customization)
|
37
|
-
All PHCPress views and layouts can be overwritten by copying files to your application.
|
38
|
-
|
39
|
-
rails generate phcpress:views
|
40
|
-
|
41
|
-
#### How to Setup Image Uploads
|
42
|
-
PHCPress default Carrierwave settings can be overwritten.
|
43
|
-
|
44
|
-
- [How to Override PHCPress Uploader](https://github.com/PHCNetworks/phc-press/wiki/Image-Uploader---Override)
|
45
|
-
- [How to Override Cloudinary Uploader](https://github.com/PHCNetworks/phc-press/wiki/Image-Uploader-(Cloudinary))
|
46
|
-
- [Critical Security Updates](https://github.com/PHCNetworks/phc-press/wiki/Critical-Security-Updates)
|
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
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/PHCNetworks/phc-press.svg)](https://gemnasium.com/github.com/PHCNetworks/phc-press)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/phcpress.svg)](https://badge.fury.io/rb/phcpress)
|
5
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/phc-press/blob/master/MIT-LICENSE)
|
6
|
+
|
7
|
+
### PHCPress(8) (News/Blog Engine) Documentation
|
8
|
+
PHCPress(8) rails CMS engine to manage your website's articles, categories and media.
|
9
|
+
|
10
|
+
* Website article posts with WYSIWYG editor.
|
11
|
+
* Upload images locally or use any popular cloud service.
|
12
|
+
* Customizable article categories module included.
|
13
|
+
|
14
|
+
#### Step 1 - Add PHCPress to your gemfile and run command
|
15
|
+
|
16
|
+
gem 'phcpress', '~> 8.0'
|
17
|
+
bundle install
|
18
|
+
|
19
|
+
#### Step 2 - Copy PHCPress Database Tables
|
20
|
+
To copy PHCPress' requried database migrations, copy each command individually to your terminal's command line.
|
21
|
+
|
22
|
+
rails phcpress:install:migrations
|
23
|
+
rails db:migrate
|
24
|
+
|
25
|
+
#### Step 3 - Mount PHCPress & Add Routes
|
26
|
+
Mount PHCPress by adding code below to your routes file.
|
27
|
+
|
28
|
+
mount Phcpress::Engine, :at => '/'
|
29
|
+
|
30
|
+
#### Step 4 - Recompile Assets
|
31
|
+
To properly function re-compile your application's assets to copy over requried files.
|
32
|
+
|
33
|
+
rails assets:clobber
|
34
|
+
rails assets:precompile
|
35
|
+
|
36
|
+
#### Step 5 - Generate Contact Form View (Customization)
|
37
|
+
All PHCPress views and layouts can be overwritten by copying files to your application.
|
38
|
+
|
39
|
+
rails generate phcpress:views
|
40
|
+
|
41
|
+
#### How to Setup Image Uploads
|
42
|
+
PHCPress default Carrierwave settings can be overwritten.
|
43
|
+
|
44
|
+
- [How to Override PHCPress Uploader](https://github.com/PHCNetworks/phc-press/wiki/Image-Uploader---Override)
|
45
|
+
- [How to Override Cloudinary Uploader](https://github.com/PHCNetworks/phc-press/wiki/Image-Uploader-(Cloudinary))
|
46
|
+
- [Critical Security Updates](https://github.com/PHCNetworks/phc-press/wiki/Critical-Security-Updates)
|
data/Rakefile
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
begin
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'rdoc/task'
|
9
|
-
|
10
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
11
|
-
rdoc.rdoc_dir = 'rdoc'
|
12
|
-
rdoc.title = 'Phcpress'
|
13
|
-
rdoc.options << '--line-numbers'
|
14
|
-
rdoc.rdoc_files.include('README.md')
|
15
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
|
-
end
|
17
|
-
|
18
|
-
APP_RAKEFILE = File.expand_path("../spec/testapp/Rakefile", __FILE__)
|
19
|
-
|
20
|
-
load 'rails/tasks/engine.rake'
|
21
|
-
load 'rails/tasks/statistics.rake'
|
22
|
-
|
23
|
-
require 'bundler/gem_tasks'
|
24
|
-
require 'rake/testtask'
|
25
|
-
|
26
|
-
Rake::TestTask.new(:test) do |t|
|
27
|
-
t.libs << 'lib'
|
28
|
-
t.libs << 'test'
|
29
|
-
t.pattern = 'test/**/*_test.rb'
|
30
|
-
t.verbose = false
|
31
|
-
end
|
32
|
-
|
33
|
-
task default: :test
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rdoc/task'
|
9
|
+
|
10
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
11
|
+
rdoc.rdoc_dir = 'rdoc'
|
12
|
+
rdoc.title = 'Phcpress'
|
13
|
+
rdoc.options << '--line-numbers'
|
14
|
+
rdoc.rdoc_files.include('README.md')
|
15
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
|
+
end
|
17
|
+
|
18
|
+
APP_RAKEFILE = File.expand_path("../spec/testapp/Rakefile", __FILE__)
|
19
|
+
|
20
|
+
load 'rails/tasks/engine.rake'
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
require 'bundler/gem_tasks'
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
task default: :test
|
@@ -1,2 +1,2 @@
|
|
1
|
-
//= link_directory ../javascripts/phcpress .js
|
2
|
-
//= link_directory ../stylesheets/phcpress .scss
|
1
|
+
//= link_directory ../javascripts/phcpress .js
|
2
|
+
//= link_directory ../stylesheets/phcpress .scss
|
@@ -1,2 +1,2 @@
|
|
1
|
-
// Load PHCAdmin3 Javascript
|
2
|
-
//= require phc_admins_main_three
|
1
|
+
// Load PHCAdmin3 Javascript
|
2
|
+
//= require phc_admins_main_three
|
@@ -1,2 +1,2 @@
|
|
1
|
-
// Load PHCAdmin3 Styles
|
2
|
-
@import "phc_admins_style_three";
|
1
|
+
// Load PHCAdmin3 Styles
|
2
|
+
@import "phc_admins_style_three";
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require_dependency "phcpress/application_controller"
|
2
|
-
|
3
|
-
module Phcpress
|
4
|
-
class Api::V1::CategoriesController < ApplicationController
|
5
|
-
|
6
|
-
# Only Responds to API Requests
|
7
|
-
respond_to :json
|
8
|
-
|
9
|
-
# Article Category API
|
10
|
-
def index
|
11
|
-
@modules_categories = Modules::Category.order('catname ASC')
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
1
|
+
require_dependency "phcpress/application_controller"
|
2
|
+
|
3
|
+
module Phcpress
|
4
|
+
class Api::V1::CategoriesController < ApplicationController
|
5
|
+
|
6
|
+
# Only Responds to API Requests
|
7
|
+
respond_to :json
|
8
|
+
|
9
|
+
# Article Category API
|
10
|
+
def index
|
11
|
+
@modules_categories = Modules::Category.order('catname ASC')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require_dependency "phcpress/application_controller"
|
2
|
-
|
3
|
-
module Phcpress
|
4
|
-
class Api::V1::PostsController < ApplicationController
|
5
|
-
|
6
|
-
# Only Responds to API Requests
|
7
|
-
respond_to :json
|
8
|
-
|
9
|
-
# Article Category API
|
10
|
-
def index
|
11
|
-
@articles_posts = Articles::Post.order('psttitle ASC')
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
1
|
+
require_dependency "phcpress/application_controller"
|
2
|
+
|
3
|
+
module Phcpress
|
4
|
+
class Api::V1::PostsController < ApplicationController
|
5
|
+
|
6
|
+
# Only Responds to API Requests
|
7
|
+
respond_to :json
|
8
|
+
|
9
|
+
# Article Category API
|
10
|
+
def index
|
11
|
+
@articles_posts = Articles::Post.order('psttitle ASC')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module Phcpress
|
2
|
-
class ApplicationController < ActionController::Base
|
3
|
-
|
4
|
-
# Security
|
5
|
-
protect_from_forgery with: :exception
|
6
|
-
|
7
|
-
# Load Helpers
|
8
|
-
helper Phctitleseo::Engine.helpers
|
9
|
-
helper Phcnotifi::Engine.helpers
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
1
|
+
module Phcpress
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
# Security
|
5
|
+
protect_from_forgery with: :exception
|
6
|
+
|
7
|
+
# Load Helpers
|
8
|
+
helper Phctitleseo::Engine.helpers
|
9
|
+
helper Phcnotifi::Engine.helpers
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -1,67 +1,67 @@
|
|
1
|
-
require_dependency "phcpress/application_controller"
|
2
|
-
|
3
|
-
module Phcpress
|
4
|
-
class Articles::PostsController < ApplicationController
|
5
|
-
|
6
|
-
# Filters & Security
|
7
|
-
before_action :set_articles_post, only: [:show, :edit, :update, :destroy]
|
8
|
-
|
9
|
-
# Article Index
|
10
|
-
def index
|
11
|
-
@articles_posts = Articles::Post.all
|
12
|
-
end
|
13
|
-
|
14
|
-
# Article Show
|
15
|
-
def show
|
16
|
-
end
|
17
|
-
|
18
|
-
# Article New
|
19
|
-
def new
|
20
|
-
@articles_post = Articles::Post.new
|
21
|
-
end
|
22
|
-
|
23
|
-
# Article Edit
|
24
|
-
def edit
|
25
|
-
end
|
26
|
-
|
27
|
-
# POST
|
28
|
-
def create
|
29
|
-
@articles_post = Articles::Post.new(articles_post_params)
|
30
|
-
if @articles_post.save
|
31
|
-
@articles_post.connections.build
|
32
|
-
redirect_to articles_posts_url, notice: 'Post was successfully created.'
|
33
|
-
else
|
34
|
-
render :new
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# PATCH/PUT
|
39
|
-
def update
|
40
|
-
if @articles_post.update(articles_post_params)
|
41
|
-
@articles_post.connections.build
|
42
|
-
redirect_to articles_posts_url, notice: 'Post was successfully updated.'
|
43
|
-
else
|
44
|
-
render :edit
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# DELETE
|
49
|
-
def destroy
|
50
|
-
@articles_post.destroy
|
51
|
-
redirect_to articles_posts_url, notice: 'Post was successfully destroyed.'
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
# Common Callbacks
|
57
|
-
def set_articles_post
|
58
|
-
@articles_post = Articles::Post.find(params[:id])
|
59
|
-
end
|
60
|
-
|
61
|
-
# Params Whitelist
|
62
|
-
def articles_post_params
|
63
|
-
params.require(:articles_post).permit(:psttitle, :psttext, :pststatus, :pstimage, :remove_pstimage, category_ids: [])
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
1
|
+
require_dependency "phcpress/application_controller"
|
2
|
+
|
3
|
+
module Phcpress
|
4
|
+
class Articles::PostsController < ApplicationController
|
5
|
+
|
6
|
+
# Filters & Security
|
7
|
+
before_action :set_articles_post, only: [:show, :edit, :update, :destroy]
|
8
|
+
|
9
|
+
# Article Index
|
10
|
+
def index
|
11
|
+
@articles_posts = Articles::Post.all
|
12
|
+
end
|
13
|
+
|
14
|
+
# Article Show
|
15
|
+
def show
|
16
|
+
end
|
17
|
+
|
18
|
+
# Article New
|
19
|
+
def new
|
20
|
+
@articles_post = Articles::Post.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# Article Edit
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
# POST
|
28
|
+
def create
|
29
|
+
@articles_post = Articles::Post.new(articles_post_params)
|
30
|
+
if @articles_post.save
|
31
|
+
@articles_post.connections.build
|
32
|
+
redirect_to articles_posts_url, notice: 'Post was successfully created.'
|
33
|
+
else
|
34
|
+
render :new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# PATCH/PUT
|
39
|
+
def update
|
40
|
+
if @articles_post.update(articles_post_params)
|
41
|
+
@articles_post.connections.build
|
42
|
+
redirect_to articles_posts_url, notice: 'Post was successfully updated.'
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE
|
49
|
+
def destroy
|
50
|
+
@articles_post.destroy
|
51
|
+
redirect_to articles_posts_url, notice: 'Post was successfully destroyed.'
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# Common Callbacks
|
57
|
+
def set_articles_post
|
58
|
+
@articles_post = Articles::Post.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
# Params Whitelist
|
62
|
+
def articles_post_params
|
63
|
+
params.require(:articles_post).permit(:psttitle, :psttext, :pststatus, :pstimage, :remove_pstimage, category_ids: [])
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|