phcpresspro 1.6.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -4
  3. data/Rakefile +7 -7
  4. data/app/assets/javascripts/phcpresspro/application.js +0 -13
  5. data/app/assets/stylesheets/phcpresspro/{application.css.scss → application.scss} +0 -0
  6. data/app/assets/stylesheets/phcpresspro/{custom.css.scss → custom.scss} +0 -0
  7. data/app/controllers/phcpresspro/application_controller.rb +14 -0
  8. data/app/controllers/phcpresspro/blog/posts_controller.rb +14 -9
  9. data/app/controllers/phcpresspro/categories_controller.rb +63 -0
  10. data/app/controllers/phcpresspro/news/posts_controller.rb +22 -23
  11. data/app/helpers/phcpresspro/application_helper.rb +2 -2
  12. data/app/models/phcpresspro/blog.rb +1 -1
  13. data/app/models/phcpresspro/blog/post.rb +0 -8
  14. data/app/models/phcpresspro/category.rb +4 -0
  15. data/app/models/phcpresspro/news.rb +1 -1
  16. data/app/models/phcpresspro/news/post.rb +0 -8
  17. data/app/views/layouts/phcpresspro/application.html.erb +1 -1
  18. data/app/views/layouts/phcpresspro/blogpost/blog_layout.html.erb +1 -1
  19. data/app/views/layouts/phcpresspro/newspost/news_layout.html.erb +1 -1
  20. data/app/views/phcpresspro/blog/posts/_form.html.erb +9 -5
  21. data/app/views/phcpresspro/blog/posts/edit.html.erb +11 -2
  22. data/app/views/phcpresspro/blog/posts/index.html.erb +1 -1
  23. data/app/views/phcpresspro/blog/posts/new.html.erb +11 -2
  24. data/app/views/phcpresspro/categories/_form.html.erb +19 -0
  25. data/app/views/phcpresspro/categories/edit.html.erb +12 -0
  26. data/app/views/phcpresspro/categories/index.html.erb +36 -0
  27. data/app/views/phcpresspro/categories/new.html.erb +12 -0
  28. data/app/views/phcpresspro/news/posts/_form.html.erb +22 -12
  29. data/app/views/phcpresspro/news/posts/edit.html.erb +11 -2
  30. data/app/views/phcpresspro/news/posts/new.html.erb +11 -2
  31. data/config/routes.rb +5 -2
  32. data/db/migrate/20160424211134_create_phcpresspro_categories.rb +9 -0
  33. data/db/migrate/20160425194021_add_phcpresspro_category_to_phcpress_blog_posts.rb +7 -0
  34. data/db/migrate/20160425194321_add_phcpresspro_category_to_phcpress_news_post.rb +7 -0
  35. data/lib/phcpresspro.rb +0 -1
  36. data/lib/phcpresspro/engine.rb +16 -14
  37. data/lib/phcpresspro/version.rb +1 -1
  38. metadata +194 -51
  39. data/app/assets/stylesheets/phcpresspro/blog/posts.css +0 -0
  40. data/app/assets/stylesheets/phcpresspro/news/posts.css +0 -0
  41. data/app/helpers/phcpresspro/blog/posts_helper.rb +0 -4
  42. 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: 446f8f04e7549df339ad72e1389e56f794eeb868
4
- data.tar.gz: 00f5eccca3ba173a8447315fb2d0681b7231194b
3
+ metadata.gz: 9aa51c93d01be3180790ea6cfb685b2709cc676e
4
+ data.tar.gz: b7ab6aee232a30ae4c480774dfaa92a2610cb7fc
5
5
  SHA512:
6
- metadata.gz: 9a743e6747191e0ffaee0b7517384de0c36c759c5479db211fc1a6271d6fdfccd8e9c5d21b2fe91d88b3f840822e741b7d1ac5f8691373bc7df90deec1213830
7
- data.tar.gz: 2cbbe746f3612ea38e5e04da5855c867a30e0e9b2f8536d364f5e0d01156beedd95368bbe270929f98638eeb77ff3597819b116df3527eb0ef62aab84d14c5d2
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
- require 'bundler/setup'
2
+ require 'bundler/setup'
3
3
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
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
- 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')
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
@@ -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
- #before_action :authenticate_user!
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
- # POST
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
- else
39
- render :new
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
- @blog_post = Blog::Post.find(params[:id])
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 (/news/posts)
11
+ # News Post Index
14
12
  def index
15
13
  @news_posts = News::Post.all
16
14
  end
17
15
 
18
- # Single News Post (/news/posts/1)
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 Post /news/posts/1/edit
21
+ # Edit News Article
28
22
  def edit
29
23
  end
30
24
 
31
- # POST
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 = News::Post.current_user.(news_post_params)
35
-
36
- if @news_post.save
37
- redirect_to news_posts_path, notice: 'News post was successfully created.'
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
- # PATCH/PUT
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 post was successfully updated.'
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
- # DELETE
45
+ # Delete News Destroy
53
46
  def destroy
54
47
  @news_post.destroy
55
- redirect_to news_posts_path, notice: 'News post was successfully destroyed.'
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 on what can be posted
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,4 +1,4 @@
1
1
  module Phcpresspro
2
- module ApplicationHelper
3
- end
2
+ module ApplicationHelper
3
+ end
4
4
  end
@@ -1,7 +1,7 @@
1
1
  module Phcpresspro
2
2
  module Blog
3
3
  def self.table_name_prefix
4
- 'phcpress_blog_'
4
+ 'phcpresspro_blog_'
5
5
  end
6
6
  end
7
7
  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
@@ -0,0 +1,4 @@
1
+ module Phcpresspro
2
+ class Category < ActiveRecord::Base
3
+ end
4
+ end
@@ -1,7 +1,7 @@
1
1
  module Phcpresspro
2
2
  module News
3
3
  def self.table_name_prefix
4
- 'phcpress_news_'
4
+ 'phcpresspro_news_'
5
5
  end
6
6
  end
7
7
  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
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
 
5
- <title>PHCPress - News Post & Blogging System</title>
5
+ <title>PHCPressPro - News Post & Blogging System</title>
6
6
 
7
7
  <%= stylesheet_link_tag "phcpresspro/application", media: "all" %>
8
8
  <%= javascript_include_tag "phcpresspro/application" %>
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
 
5
- <title>PHCPress - News Post & Blogging System</title>
5
+ <title>PHCPressPro - News Post & Blogging System</title>
6
6
 
7
7
  <%= stylesheet_link_tag "phcpresspro/application", media: "all" %>
8
8
  <%= javascript_include_tag "phcpresspro/application" %>
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
 
5
- <title>PHCPress - News Post & Blogging System</title>
5
+ <title>PHCPressPro - News Post & Blogging System</title>
6
6
 
7
7
  <%= stylesheet_link_tag "phcpresspro/application", media: "all" %>
8
8
  <%= javascript_include_tag "phcpresspro/application" %>
@@ -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-default">
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
- <label><%= f.label :pststatus, "Post Status" %></label>
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-default">
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-default">
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
- <div class="wrapper wrapper-content">
2
- <%= render 'form' %>
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>