phcpress 9.1.2 → 10.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 +1 -1
- data/app/controllers/phcpress/article/posts_controller.rb +67 -0
- data/app/models/phcpress/{articles.rb → article.rb} +2 -2
- data/app/models/phcpress/article/post.rb +40 -0
- data/app/models/phcpress/category_versions.rb +5 -0
- data/app/models/phcpress/post_versions.rb +5 -0
- data/app/views/phcpress/{articles → article}/posts/_form.html.erb +5 -9
- data/app/views/phcpress/{articles → article}/posts/edit.html.erb +2 -2
- data/app/views/phcpress/{articles → article}/posts/index.html.erb +8 -8
- data/app/views/phcpress/{articles → article}/posts/new.html.erb +2 -2
- data/app/views/phcpress/{articles → article}/posts/show.html.erb +3 -3
- data/config/initializers/friendly_id.rb +3 -3
- data/config/initializers/locale.rb +10 -0
- data/config/initializers/paper_trail.rb +1 -0
- data/db/migrate/{20160720181307_create_phcpress_articles_posts.rb → 20160720181307_create_phcpress_article_posts.rb} +2 -2
- data/db/migrate/20170509002355_create_phcpress_friendly_id_slugs.rb +18 -0
- data/db/migrate/20170517064030_create_phcpress_post_versions.rb +17 -0
- data/db/migrate/20170517064427_create_phcpress_category_versions.rb +16 -0
- data/lib/phcpress/version.rb +1 -1
- metadata +18 -12
- data/app/controllers/phcpress/articles/posts_controller.rb +0 -67
- data/app/models/phcpress/articles/post.rb +0 -30
- data/db/migrate/20170509180858_create_friendly_id_slugs.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3450511990358a3eb585a109064da119f3143342
|
4
|
+
data.tar.gz: 0c93121893b4b7a051a0fb1ae744e6fd1dc2cf67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce52c0bcc4f45f6e18d360a2ffda384c5a895ab0bd0703bc237b52de024d55eb5132e0497a6544dddc26aa5f74c0e6302897996e1717a3f6e808ba31d67670b1
|
7
|
+
data.tar.gz: bdf60a2e06e37ffb1e613fca0a1ed8dbe8c7ead686f4d9da3068dfa8669c3e84100c6b788e7c0e8c2ab7660dfd7d6dcfb99e7b97a2644366b26e8d2ec74f12c3
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ PHCPress rails CMS engine to manage your website's articles, categories and medi
|
|
13
13
|
|
14
14
|
#### Step 1 - Add PHCPress to your gemfile and run command
|
15
15
|
|
16
|
-
gem 'phcpress', '~> 9.1', '>= 9.1.
|
16
|
+
gem 'phcpress', '~> 9.1', '>= 9.1.2'
|
17
17
|
bundle install
|
18
18
|
|
19
19
|
#### Step 2 - Copy PHCPress Database Tables
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_dependency "phcpress/application_controller"
|
2
|
+
|
3
|
+
module Phcpress
|
4
|
+
class Article::PostsController < ApplicationController
|
5
|
+
|
6
|
+
# Filters & Security
|
7
|
+
before_action :set_article_post, only: [:show, :edit, :update, :destroy]
|
8
|
+
|
9
|
+
# Article Index
|
10
|
+
def index
|
11
|
+
@article_posts = Article::Post.all
|
12
|
+
end
|
13
|
+
|
14
|
+
# Article Show
|
15
|
+
def show
|
16
|
+
end
|
17
|
+
|
18
|
+
# Article New
|
19
|
+
def new
|
20
|
+
@article_post = Article::Post.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# Article Edit
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
# POST
|
28
|
+
def create
|
29
|
+
@article_post = Article::Post.new(article_post_params)
|
30
|
+
if @article_post.save
|
31
|
+
@article_post.connections.build
|
32
|
+
redirect_to article_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 @article_post.update(article_post_params)
|
41
|
+
@article_post.connections.build
|
42
|
+
redirect_to article_posts_url, notice: 'Post was successfully updated.'
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE
|
49
|
+
def destroy
|
50
|
+
@article_post.destroy
|
51
|
+
redirect_to article_posts_url, notice: 'Post was successfully destroyed.'
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# Common Callbacks
|
57
|
+
def set_article_post
|
58
|
+
@article_post = Article::Post.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
# Params Whitelist
|
62
|
+
def article_post_params
|
63
|
+
params.require(:article_post).permit(:psttitle, :psttext, :pststatus, :pstimage, :remove_pstimage, category_ids: [])
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Phcpress
|
2
|
+
class Article::Post < ApplicationRecord
|
3
|
+
|
4
|
+
# Clean URL Initialize
|
5
|
+
extend FriendlyId
|
6
|
+
|
7
|
+
# Add Paper Trail
|
8
|
+
has_paper_trail :class_name => 'Phcprss::PostVersions'
|
9
|
+
|
10
|
+
# Image Upload Initialize
|
11
|
+
mount_uploader :pstimage, Phcpress::PstimageUploader
|
12
|
+
|
13
|
+
# Model Relationships
|
14
|
+
has_many :connections, class_name: 'Phcpress::Modules::Connection', dependent: :destroy
|
15
|
+
has_many :categories, class_name: 'Phcpress::Modules::Category', :through => :connections
|
16
|
+
|
17
|
+
# Validation for Form Fields
|
18
|
+
validates :psttitle,
|
19
|
+
presence: true,
|
20
|
+
length: { minimum: 3 }
|
21
|
+
|
22
|
+
validates :psttext,
|
23
|
+
presence: true,
|
24
|
+
length: { minimum: 3 }
|
25
|
+
|
26
|
+
validates :pststatus,
|
27
|
+
presence: true
|
28
|
+
|
29
|
+
# Clean URL Define
|
30
|
+
friendly_id :phcpress_posts_slug, use: [:slugged, :finders]
|
31
|
+
|
32
|
+
# Define for Multiple Records
|
33
|
+
def phcpress_posts_slug
|
34
|
+
[
|
35
|
+
[:psttitle]
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<div class="row">
|
2
|
-
<%= form_for(@
|
2
|
+
<%= form_for(@article_post, :html => {:multipart => true}) do |f| %>
|
3
3
|
|
4
4
|
<!-- PHC-Notifi Render Validation -->
|
5
|
-
<%= render 'phcnotifi/validations', :object => @
|
5
|
+
<%= render 'phcnotifi/validations', :object => @article_post %>
|
6
6
|
|
7
7
|
<div class="col-md-3">
|
8
8
|
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
<div class="panel panel-primary">
|
42
42
|
<div class="panel-heading">
|
43
|
-
<i class="fa fa-sitemap"></i> Post Categories & Tags
|
43
|
+
<i class="fa fa-sitemap"></i> Post Categories & Tags
|
44
44
|
</div>
|
45
45
|
<div class="panel-body">
|
46
46
|
<div class="form-group">
|
@@ -53,7 +53,6 @@
|
|
53
53
|
</div>
|
54
54
|
|
55
55
|
</div>
|
56
|
-
|
57
56
|
<div class="col-md-9 ">
|
58
57
|
|
59
58
|
<div class="panel panel-primary">
|
@@ -61,9 +60,7 @@
|
|
61
60
|
<i class="fa fa-pencil-square-o"></i> Blog Post Publisher
|
62
61
|
</div>
|
63
62
|
<div class="panel-body">
|
64
|
-
|
65
|
-
<%= render 'phcnotifi/validations', :object => @articles_post %>
|
66
|
-
|
63
|
+
<%= render 'phcnotifi/validations', :object => @article_post %>
|
67
64
|
<div class="form-group">
|
68
65
|
<%= f.label :psttext, "Post Title" %>
|
69
66
|
<%= f.text_field :psttitle, class: "form-control" %>
|
@@ -72,13 +69,12 @@
|
|
72
69
|
<%= f.label :psttext, "Post Text" %>
|
73
70
|
<%= f.text_area :psttext, :class => "tinymce form-control", :rows => 20, :cols => 60 %>
|
74
71
|
</div>
|
75
|
-
|
76
72
|
</div>
|
77
73
|
</div>
|
78
74
|
|
79
75
|
</div>
|
80
|
-
|
81
76
|
<% end %>
|
82
77
|
</div>
|
83
78
|
|
79
|
+
<!-- Tinymce Javascript -->
|
84
80
|
<%= tinymce %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!-- Title System -->
|
2
2
|
<% phc_title "Article Manager" %>
|
3
3
|
<% phc_title_tagline "Update Article" %>
|
4
|
-
<% phc_breadcrumb_one link_to "Article Index", phcpress.
|
4
|
+
<% phc_breadcrumb_one link_to "Article Index", phcpress.article_posts_path %>
|
5
5
|
<% phc_breadcrumb_two yield(:phc_title_tagline) %>
|
6
6
|
<!-- Title System -->
|
7
7
|
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<div class="col-lg-12">
|
24
24
|
|
25
25
|
<!-- Page Form (Edit) -->
|
26
|
-
<%= render 'form',
|
26
|
+
<%= render 'form', article_post: @article_post %>
|
27
27
|
<!-- Page Form (Edit) -->
|
28
28
|
|
29
29
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!-- Title System -->
|
2
2
|
<% phc_title "Article Manager" %>
|
3
3
|
<% phc_title_tagline "Article Index" %>
|
4
|
-
<% phc_breadcrumb_one link_to "Article Index", phcpress.
|
4
|
+
<% phc_breadcrumb_one link_to "Article Index", phcpress.article_posts_path %>
|
5
5
|
<% phc_breadcrumb_two yield(:phc_title_tagline) %>
|
6
6
|
<!-- Title System -->
|
7
7
|
|
@@ -39,14 +39,14 @@
|
|
39
39
|
</tr>
|
40
40
|
</thead>
|
41
41
|
<tbody>
|
42
|
-
<% @
|
42
|
+
<% @article_posts.each do |article_post| %>
|
43
43
|
<tr>
|
44
|
-
<td><%=
|
45
|
-
<td><%= truncate(
|
46
|
-
<td><%=
|
44
|
+
<td><%= article_post.psttitle %></td>
|
45
|
+
<td><%= truncate(article_post.psttext, :length => 80) %></td>
|
46
|
+
<td><%= article_post.pststatus %></td>
|
47
47
|
<td><div class="btn-group" role="group" aria-label="Blog Articles">
|
48
|
-
<%= link_to 'Edit',
|
49
|
-
<%= link_to 'Delete',
|
48
|
+
<%= link_to 'Edit', edit_article_post_path(articles_post), class: "btn btn-primary btn-xs" %>
|
49
|
+
<%= link_to 'Delete', article_post, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: 'Are you sure?' } %>
|
50
50
|
</div></td>
|
51
51
|
</tr>
|
52
52
|
<% end %>
|
@@ -57,7 +57,7 @@
|
|
57
57
|
|
58
58
|
<!-- Panel Footer -->
|
59
59
|
<div class="box-footer clearfix">
|
60
|
-
<%= link_to 'New Blog Post',
|
60
|
+
<%= link_to 'New Blog Post', new_article_post_path, class: "btn btn-primary" %>
|
61
61
|
</div>
|
62
62
|
<!-- Panel Footer -->
|
63
63
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!-- Title System -->
|
2
2
|
<% phc_title "Article Manager" %>
|
3
3
|
<% phc_title_tagline "Create a New Article" %>
|
4
|
-
<% phc_breadcrumb_one link_to "Article Index", phcpress.
|
4
|
+
<% phc_breadcrumb_one link_to "Article Index", phcpress.article_posts_path %>
|
5
5
|
<% phc_breadcrumb_two yield(:phc_title_tagline) %>
|
6
6
|
<!-- Title System -->
|
7
7
|
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<div class="col-lg-12">
|
24
24
|
|
25
25
|
<!-- Page Form (New) -->
|
26
|
-
<%= render 'form',
|
26
|
+
<%= render 'form', article_post: @article_post %>
|
27
27
|
<!-- Page Form (New) -->
|
28
28
|
|
29
29
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!-- Title System -->
|
2
2
|
<% phc_title "Article Manager" %>
|
3
3
|
<% phc_title_tagline "Article Details" %>
|
4
|
-
<% phc_breadcrumb_one link_to "Article Index", phcpress.
|
4
|
+
<% phc_breadcrumb_one link_to "Article Index", phcpress.article_posts_path %>
|
5
5
|
<% phc_breadcrumb_two yield(:phc_title_tagline) %>
|
6
6
|
<!-- Title System -->
|
7
7
|
|
@@ -28,8 +28,8 @@
|
|
28
28
|
<div class="box-body">
|
29
29
|
|
30
30
|
<!-- Show Content -->
|
31
|
-
<%= link_to 'Edit',
|
32
|
-
<%= link_to 'Back',
|
31
|
+
<%= link_to 'Edit', edit_article_post_path(@article_post) %> |
|
32
|
+
<%= link_to 'Back', article_posts_path %>
|
33
33
|
<!-- Show Content -->
|
34
34
|
|
35
35
|
</div>
|
@@ -17,7 +17,7 @@ FriendlyId.defaults do |config|
|
|
17
17
|
config.use :reserved
|
18
18
|
|
19
19
|
config.reserved_words = %w(new edit index session login logout users admin
|
20
|
-
|
20
|
+
stylesheets assets javascripts images)
|
21
21
|
|
22
22
|
# ## Friendly Finders
|
23
23
|
#
|
@@ -38,14 +38,14 @@ FriendlyId.defaults do |config|
|
|
38
38
|
# performance because it will avoid Rails-internal code that makes runtime
|
39
39
|
# calls to `Module.extend`.
|
40
40
|
#
|
41
|
-
|
41
|
+
config.use :finders
|
42
42
|
#
|
43
43
|
# ## Slugs
|
44
44
|
#
|
45
45
|
# Most applications will use the :slugged module everywhere. If you wish
|
46
46
|
# to do so, uncomment the following line.
|
47
47
|
#
|
48
|
-
|
48
|
+
config.use :slugged
|
49
49
|
#
|
50
50
|
# By default, FriendlyId's :slugged addon expects the slug column to be named
|
51
51
|
# 'slug', but you can change it if you wish.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# config/initializers/locale.rb
|
2
|
+
|
3
|
+
# Where the I18n library should search for translation files
|
4
|
+
I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
|
5
|
+
|
6
|
+
# Whitelist locales available for the application
|
7
|
+
I18n.available_locales = [:en, :pt]
|
8
|
+
|
9
|
+
# Set default locale to something other than :en
|
10
|
+
I18n.default_locale = :en
|
@@ -0,0 +1 @@
|
|
1
|
+
PaperTrail.config.track_associations = false
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class
|
1
|
+
class CreatePhcpressArticlePosts < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
|
4
|
-
create_table :
|
4
|
+
create_table :phcpress_article_posts do |t|
|
5
5
|
|
6
6
|
t.string :psttitle
|
7
7
|
t.text :psttext
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreatePhcmembersFriendlyIdSlugs < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
|
4
|
+
create_table :phcpress_friendly_id_slugs do |t|
|
5
|
+
t.string :slug, :null => false
|
6
|
+
t.integer :sluggable_id, :null => false
|
7
|
+
t.string :sluggable_type, :limit => 50
|
8
|
+
t.string :scope
|
9
|
+
t.datetime :created_at
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :phcpress_friendly_id_slugs, :sluggable_id
|
13
|
+
add_index :phcpress_friendly_id_slugs, [:slug, :sluggable_type], length: { slug: 140, sluggable_type: 50 }
|
14
|
+
add_index :phcpress_friendly_id_slugs, [:slug, :sluggable_type, :scope], name: 'phcpress_fri_id_slugable_scope_type', length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true
|
15
|
+
add_index :phcpress_friendly_id_slugs, :sluggable_type
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreatePhcpressPostVersions < ActiveRecord::Migration[5.1]
|
2
|
+
TEXT_BYTES = 1_073_741_823
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :phcpress_post_versions do |t|
|
6
|
+
t.string :item_type, {:null=>false}
|
7
|
+
t.integer :item_id, null: false
|
8
|
+
t.string :event, null: false
|
9
|
+
t.string :whodunnit
|
10
|
+
t.text :object, limit: TEXT_BYTES
|
11
|
+
t.datetime :created_at
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :phcpress_post_versions, %i(item_type item_id), :name => 'press_post_versions'
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreatePhcpressCategoryVersions < ActiveRecord::Migration[5.1]
|
2
|
+
TEXT_BYTES = 1_073_741_823
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :phcpress_category_versions do |t|
|
6
|
+
t.string :item_type, {:null=>false}
|
7
|
+
t.integer :item_id, null: false
|
8
|
+
t.string :event, null: false
|
9
|
+
t.string :whodunnit
|
10
|
+
t.text :object, limit: TEXT_BYTES
|
11
|
+
t.datetime :created_at
|
12
|
+
end
|
13
|
+
add_index :phcpress_category_versions, %i(item_type item_id), :name => 'press_category_versions'
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/phcpress/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phcpress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BradPotts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -689,7 +689,7 @@ files:
|
|
689
689
|
- app/controllers/phcpress/api/v1/categories_controller.rb
|
690
690
|
- app/controllers/phcpress/api/v1/posts_controller.rb
|
691
691
|
- app/controllers/phcpress/application_controller.rb
|
692
|
-
- app/controllers/phcpress/
|
692
|
+
- app/controllers/phcpress/article/posts_controller.rb
|
693
693
|
- app/controllers/phcpress/frontend/articles_controller.rb
|
694
694
|
- app/controllers/phcpress/modules/categories_controller.rb
|
695
695
|
- app/controllers/phcpress/modules/connections_controller.rb
|
@@ -699,13 +699,15 @@ files:
|
|
699
699
|
- app/models/phcpress/api/v1/category.rb
|
700
700
|
- app/models/phcpress/api/v1/post.rb
|
701
701
|
- app/models/phcpress/application_record.rb
|
702
|
-
- app/models/phcpress/
|
703
|
-
- app/models/phcpress/
|
702
|
+
- app/models/phcpress/article.rb
|
703
|
+
- app/models/phcpress/article/post.rb
|
704
|
+
- app/models/phcpress/category_versions.rb
|
704
705
|
- app/models/phcpress/frontend.rb
|
705
706
|
- app/models/phcpress/frontend/article.rb
|
706
707
|
- app/models/phcpress/modules.rb
|
707
708
|
- app/models/phcpress/modules/category.rb
|
708
709
|
- app/models/phcpress/modules/connection.rb
|
710
|
+
- app/models/phcpress/post_versions.rb
|
709
711
|
- app/uploaders/phcpress/pstimage_uploader.rb
|
710
712
|
- app/views/layouts/components/backend/footer/_footer.html.erb
|
711
713
|
- app/views/layouts/components/backend/navigation/_navigation.html.erb
|
@@ -715,11 +717,11 @@ files:
|
|
715
717
|
- app/views/layouts/phcpress/frontend.html.erb
|
716
718
|
- app/views/phcpress/api/v1/categories/index.json.rabl
|
717
719
|
- app/views/phcpress/api/v1/posts/index.json.rabl
|
718
|
-
- app/views/phcpress/
|
719
|
-
- app/views/phcpress/
|
720
|
-
- app/views/phcpress/
|
721
|
-
- app/views/phcpress/
|
722
|
-
- app/views/phcpress/
|
720
|
+
- app/views/phcpress/article/posts/_form.html.erb
|
721
|
+
- app/views/phcpress/article/posts/edit.html.erb
|
722
|
+
- app/views/phcpress/article/posts/index.html.erb
|
723
|
+
- app/views/phcpress/article/posts/new.html.erb
|
724
|
+
- app/views/phcpress/article/posts/show.html.erb
|
723
725
|
- app/views/phcpress/frontend/articles/index.html.erb
|
724
726
|
- app/views/phcpress/frontend/articles/show.html.erb
|
725
727
|
- app/views/phcpress/modules/categories/_form.html.erb
|
@@ -733,12 +735,16 @@ files:
|
|
733
735
|
- app/views/phcpress/modules/connections/new.html.erb
|
734
736
|
- app/views/phcpress/modules/connections/show.html.erb
|
735
737
|
- config/initializers/friendly_id.rb
|
738
|
+
- config/initializers/locale.rb
|
739
|
+
- config/initializers/paper_trail.rb
|
736
740
|
- config/routes.rb
|
737
741
|
- config/tinymce.yml
|
738
742
|
- db/migrate/20160716182848_create_phcpress_modules_categories.rb
|
739
|
-
- db/migrate/
|
743
|
+
- db/migrate/20160720181307_create_phcpress_article_posts.rb
|
740
744
|
- db/migrate/20160720235314_create_phcpress_modules_connections.rb
|
741
|
-
- db/migrate/
|
745
|
+
- db/migrate/20170509002355_create_phcpress_friendly_id_slugs.rb
|
746
|
+
- db/migrate/20170517064030_create_phcpress_post_versions.rb
|
747
|
+
- db/migrate/20170517064427_create_phcpress_category_versions.rb
|
742
748
|
- lib/phcpress.rb
|
743
749
|
- lib/phcpress/engine.rb
|
744
750
|
- lib/phcpress/version.rb
|
@@ -1,67 +0,0 @@
|
|
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,30 +0,0 @@
|
|
1
|
-
module Phcpress
|
2
|
-
class Articles::Post < ApplicationRecord
|
3
|
-
|
4
|
-
# Image Upload Initialize
|
5
|
-
mount_uploader :pstimage, Phcpress::PstimageUploader
|
6
|
-
|
7
|
-
# Clean URL Initialize
|
8
|
-
extend FriendlyId
|
9
|
-
|
10
|
-
# Paper_tail Initialize
|
11
|
-
has_paper_trail
|
12
|
-
|
13
|
-
# Model Relationships
|
14
|
-
has_many :connections, class_name: 'Phcpress::Modules::Connection', dependent: :destroy
|
15
|
-
has_many :categories, class_name: 'Phcpress::Modules::Category', :through => :connections
|
16
|
-
|
17
|
-
# Validation for Form Fields
|
18
|
-
validates :psttitle,
|
19
|
-
presence: true,
|
20
|
-
length: { minimum: 3 }
|
21
|
-
|
22
|
-
validates :psttext,
|
23
|
-
presence: true,
|
24
|
-
length: { minimum: 3 }
|
25
|
-
|
26
|
-
validates :pststatus,
|
27
|
-
presence: true
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateFriendlyIdSlugs < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :friendly_id_slugs do |t|
|
4
|
-
t.string :slug, :null => false
|
5
|
-
t.integer :sluggable_id, :null => false
|
6
|
-
t.string :sluggable_type, :limit => 50
|
7
|
-
t.string :scope
|
8
|
-
t.datetime :created_at
|
9
|
-
end
|
10
|
-
add_index :friendly_id_slugs, :sluggable_id
|
11
|
-
add_index :friendly_id_slugs, [:slug, :sluggable_type], length: { slug: 140, sluggable_type: 50 }
|
12
|
-
add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true
|
13
|
-
add_index :friendly_id_slugs, :sluggable_type
|
14
|
-
end
|
15
|
-
end
|