phcdevworks_press 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +34 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/phcdevworks_press_manifest.js +2 -0
  6. data/app/assets/javascripts/phcdevworks_press/application.js +2 -0
  7. data/app/assets/stylesheets/phcdevworks_press/application.scss +2 -0
  8. data/app/assets/stylesheets/phcdevworks_press/article/categories.css +4 -0
  9. data/app/assets/stylesheets/phcdevworks_press/article/posts.css +4 -0
  10. data/app/assets/stylesheets/phcdevworks_press/blog/articles.css +4 -0
  11. data/app/controllers/phcdevworks_press/application_controller.rb +13 -0
  12. data/app/controllers/phcdevworks_press/article/categories_controller.rb +82 -0
  13. data/app/controllers/phcdevworks_press/article/posts_controller.rb +82 -0
  14. data/app/controllers/phcdevworks_press/blog/articles_controller.rb +20 -0
  15. data/app/helpers/phcdevworks_press/application_helper.rb +4 -0
  16. data/app/helpers/phcdevworks_press/article/categories_helper.rb +4 -0
  17. data/app/helpers/phcdevworks_press/article/posts_helper.rb +4 -0
  18. data/app/helpers/phcdevworks_press/blog/articles_helper.rb +4 -0
  19. data/app/jobs/phcdevworks_press/application_job.rb +4 -0
  20. data/app/mailers/phcdevworks_press/application_mailer.rb +6 -0
  21. data/app/models/phcdevworks_press/application_record.rb +5 -0
  22. data/app/models/phcdevworks_press/article/category.rb +27 -0
  23. data/app/models/phcdevworks_press/article/post.rb +32 -0
  24. data/app/models/phcdevworks_press/article.rb +7 -0
  25. data/app/models/phcdevworks_press/category_versions.rb +5 -0
  26. data/app/models/phcdevworks_press/post_versions.rb +5 -0
  27. data/app/views/layouts/phcdevworks_press/application.html.erb +94 -0
  28. data/app/views/layouts/phcdevworks_press/components/backend/footer/_footer.html.erb +16 -0
  29. data/app/views/layouts/phcdevworks_press/components/backend/navigation/_top_menu.html.erb +37 -0
  30. data/app/views/layouts/phcdevworks_press/components/backend/sidebars/_side_menu.html.erb +142 -0
  31. data/app/views/layouts/phcdevworks_press/frontend.html.erb +5 -0
  32. data/app/views/phcdevworks_press/article/categories/_form.html.erb +22 -0
  33. data/app/views/phcdevworks_press/article/categories/edit.html.erb +37 -0
  34. data/app/views/phcdevworks_press/article/categories/index.html.erb +65 -0
  35. data/app/views/phcdevworks_press/article/categories/new.html.erb +37 -0
  36. data/app/views/phcdevworks_press/article/posts/_form.html.erb +87 -0
  37. data/app/views/phcdevworks_press/article/posts/edit.html.erb +23 -0
  38. data/app/views/phcdevworks_press/article/posts/index.html.erb +68 -0
  39. data/app/views/phcdevworks_press/article/posts/new.html.erb +23 -0
  40. data/app/views/phcdevworks_press/blog/articles/index.html.erb +69 -0
  41. data/app/views/phcdevworks_press/blog/articles/show.html.erb +1 -0
  42. data/config/routes.rb +25 -0
  43. data/db/migrate/20170517064030_create_phcdevworks_press_post_versions.rb +17 -0
  44. data/db/migrate/20170517064427_create_phcdevworks_press_category_versions.rb +17 -0
  45. data/db/migrate/20190315173237_create_join_table_categories_posts.rb +8 -0
  46. data/db/migrate/20190805232522_create_phcdevworks_press_article_posts.rb +18 -0
  47. data/db/migrate/20190805232733_create_phcdevworks_press_article_categories.rb +15 -0
  48. data/lib/phcdevworks_press/engine.rb +38 -0
  49. data/lib/phcdevworks_press/version.rb +3 -0
  50. data/lib/phcdevworks_press.rb +5 -0
  51. data/lib/tasks/phcdevworks_press_tasks.rake +4 -0
  52. metadata +296 -0
@@ -0,0 +1,87 @@
1
+ <%= form_with(model: article_post, local: true) do |form| %>
2
+ <div class="row">
3
+
4
+ <div class="col-md-3">
5
+
6
+ <!-- Panel - Publishing -->
7
+ <div class="panel panel-inverse">
8
+ <div class="panel-heading">
9
+ <h4 class="panel-title">Publish Panel</h4>
10
+ </div>
11
+ <div class="panel-body">
12
+ <div class="form-group field_with_errors">
13
+ <%= form.label :post_status, "Post Status" %>
14
+ <%= form.select( :post_status, [['Draft','draft'],['Published','published'],['Review','review']], {}, {class: "form-control form-control-sm"}) %>
15
+ </div>
16
+ <div class="actions">
17
+ <%= form.submit class: "btn btn-primary" %>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <!-- Panel - Publishing -->
22
+
23
+ <!-- Panel - Image Uploading -->
24
+ <div class="panel panel-inverse">
25
+ <div class="panel-heading">
26
+ <h4 class="panel-title">Post Images</h4>
27
+ </div>
28
+ <div class="panel-body">
29
+ <div class="form-group field_with_errors">
30
+ <%= form.label :post_image, "Featured Image" %>
31
+ <%= form.file_field :post_image, class: "form-control" %>
32
+ </div>
33
+ <% if form.object.post_image? %>
34
+ <%= image_tag form.object.post_image_url, class: "img-responsive img-thumbnail" %>
35
+ <%= form.label :remove_post_image %>
36
+ <%= form.check_box :remove_post_image %>
37
+ <% end %>
38
+ </div>
39
+ </div>
40
+ <!-- Panel - Image Uploading -->
41
+
42
+ <!-- Panel - Article - Categories -->
43
+ <div class="panel panel-inverse">
44
+ <div class="panel-heading">
45
+ <h4 class="panel-title">Post Categories</h4>
46
+ </div>
47
+ <div class="panel-body">
48
+ <%= form.collection_check_boxes :category_ids, PhcdevworksPress::Article::Category.all, :id, :category_name do |post_category| %>
49
+ <%= post_category.check_box %>
50
+ <%= post_category.label %><br>
51
+ <% end %>
52
+ </div>
53
+ </div>
54
+ <!-- Panel - Article - Categories -->
55
+
56
+ </div>
57
+
58
+ <div class="col-md-9 ">
59
+
60
+ <!-- PHCNotifi Render Validation -->
61
+ <%= render 'phcdevworks_notifications/bootstrap/validations', :object => @article_post %>
62
+ <!-- PHCNotifi Render Validation -->
63
+
64
+ <div class="panel panel-inverse">
65
+ <div class="panel-heading">
66
+ <div class="panel-heading-btn">
67
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
68
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-redo"></i></a>
69
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
70
+ </div>
71
+ <h4 class="panel-title"><%= yield(:phc_title_tagline) %></h4>
72
+ </div>
73
+ <div class="panel-body">
74
+ <div class="form-group field_with_errors">
75
+ <%= form.label :post_title, "Article Title" %>
76
+ <%= form.text_field :post_title, class: "form-control" %>
77
+ </div>
78
+ <div class="form-group field_with_errors">
79
+ <%= form.text_area :post_text, :class => "form-control", :id => "editor" %>
80
+ <div id="word-count" class="mt-3"></div>
81
+ </div>
82
+ </div>
83
+ </div>
84
+
85
+ </div>
86
+ </div>
87
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <!-- Title System -->
2
+ <% phc_title "Article Manager" %>
3
+ <% phc_title_tagline "Update Article" %>
4
+ <% phc_breadcrumb_one yield(:phc_title) %>
5
+ <% phc_breadcrumb_two link_to "Article Index", phcdevworks_press.article_posts_path %>
6
+ <% phc_breadcrumb_three yield(:phc_title_tagline) %>
7
+ <!-- Title System -->
8
+
9
+ <!-- Page Bradcrumbs -->
10
+ <ol class="breadcrumb pull-right">
11
+ <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_one) %></li>
12
+ <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_two) %></li>
13
+ <li class="breadcrumb-item active"><%= yield(:phc_breadcrumb_three) %></li>
14
+ </ol>
15
+ <!-- Page Bradcrumbs -->
16
+
17
+ <!-- Page Header -->
18
+ <h1 class="page-header"><%= yield(:phc_title) %></h1>
19
+ <!-- Page Header -->
20
+
21
+ <!-- Form to Edit Article Post -->
22
+ <%= render 'form', article_post: @article_post %>
23
+ <!-- Form to Edit Article Post -->
@@ -0,0 +1,68 @@
1
+ <!-- Title System -->
2
+ <% phc_title "Article Manager" %>
3
+ <% phc_title_tagline "Article Index" %>
4
+ <% phc_breadcrumb_one yield(:phc_title) %>
5
+ <% phc_breadcrumb_two yield(:phc_title_tagline) %>
6
+ <!-- Title System -->
7
+
8
+ <!-- Page Bradcrumbs -->
9
+ <ol class="breadcrumb pull-right">
10
+ <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_one) %></li>
11
+ <li class="breadcrumb-item active"><%= yield(:phc_breadcrumb_two) %></li>
12
+ </ol>
13
+ <!-- Page Bradcrumbs -->
14
+
15
+ <!-- Page Header -->
16
+ <h1 class="page-header"><%= yield(:phc_title) %></h1>
17
+ <!-- Page Header -->
18
+
19
+ <!-- Page & Panel Content -->
20
+ <div class="panel panel-inverse">
21
+ <!-- Panel Heading -->
22
+ <div class="panel-heading">
23
+ <div class="panel-heading-btn">
24
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
25
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-redo"></i></a>
26
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
27
+ </div>
28
+ <h4 class="panel-title"><%= yield(:phc_title_tagline) %></h4>
29
+ </div>
30
+ <!-- Panel Heading -->
31
+ <!-- Panel Body -->
32
+ <div class="panel-body">
33
+ <!-- Table - Article Index -->
34
+ <div class="table-responsive">
35
+ <table class="table table-striped table-bordered">
36
+ <thead>
37
+ <tr>
38
+ <th>Post Headline</th>
39
+ <th>Post Preview</th>
40
+ <th>Post Status</th>
41
+ <th></th>
42
+ </tr>
43
+ </thead>
44
+ <tbody>
45
+ <% @article_posts.each do |article_post| %>
46
+ <tr>
47
+ <td><%= article_post.post_title %></td>
48
+ <td><%= truncate(article_post.post_text, :length => 80, :escape => false) %></td>
49
+ <td><%= article_post.post_status.capitalize %></td>
50
+ <td>
51
+ <div class="btn-group d-flex" role="group">
52
+ <%= link_to 'Update Post', edit_article_post_path(article_post), class: "btn btn-primary btn-xs" %>
53
+ <%= link_to 'Remove Post', article_post, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: 'Are you sure?' } %>
54
+ </div>
55
+ </td>
56
+ </tr>
57
+ <% end %>
58
+ </tbody>
59
+ </table>
60
+ <%= link_to phcdevworks_press.new_article_post_path, class: "btn btn-primary" do %>
61
+ <i class="fas fa-plus-circle"></i>
62
+ <%= "Add a New Article Post" %>
63
+ <% end %>
64
+ </div>
65
+ <!-- Table - Article Index -->
66
+ </div>
67
+ </div>
68
+ <!-- Page Content -->
@@ -0,0 +1,23 @@
1
+ <!-- Title System -->
2
+ <% phc_title "Article Manager" %>
3
+ <% phc_title_tagline "Create a New Article" %>
4
+ <% phc_breadcrumb_one yield(:phc_title) %>
5
+ <% phc_breadcrumb_two link_to "Article Index", phcdevworks_press.article_posts_path %>
6
+ <% phc_breadcrumb_three yield(:phc_title_tagline) %>
7
+ <!-- Title System -->
8
+
9
+ <!-- Page Bradcrumbs -->
10
+ <ol class="breadcrumb pull-right">
11
+ <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_one) %></li>
12
+ <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_two) %></li>
13
+ <li class="breadcrumb-item active"><%= yield(:phc_breadcrumb_three) %></li>
14
+ </ol>
15
+ <!-- Page Bradcrumbs -->
16
+
17
+ <!-- Page Header -->
18
+ <h1 class="page-header"><%= yield(:phc_title) %></h1>
19
+ <!-- Page Header -->
20
+
21
+ <!-- Form for New Article Post -->
22
+ <%= render 'form', article_post: @article_post %>
23
+ <!-- Form for New Article Post -->
@@ -0,0 +1,69 @@
1
+ <% @phcpress_posts_index.each do |blog_post_index| %>
2
+ <div class="row blog-post">
3
+ <div class="col-md-2 date-md">
4
+ <div class="date-wrapper">
5
+ <span class="date-m bg-primary"><%= blog_post_index.created_at.strftime("%B") %></span>
6
+ <span class="date-d"><%= blog_post_index.created_at.strftime("%d") %></span>
7
+ </div>
8
+ <p class="text-muted text-sm">
9
+ <i class="fas fa-user-tie text-xs"></i>
10
+ <%= blog_post_index.user_id %>
11
+ </p>
12
+ </div>
13
+ <div class="col-md-10">
14
+ <div class="text-xs">
15
+ <a href="#" class="text-primary text-uppercase">Blog</a> /
16
+ <a href="#" class="text-dark text-uppercase">Post</a>
17
+ </div>
18
+ <h4 class="title media-heading">
19
+ <%= blog_post_index.post_title %>
20
+ </h4>
21
+ <ul class="list-inline meta text-muted">
22
+ <li class="list-inline-item">
23
+ <i class="fas fa-calendar-alt text-xs"></i>
24
+ <%= blog_post_index.created_at.strftime("%a %B %d %Y") %>
25
+ </li>
26
+ <li class="list-inline-item">
27
+ <i class="fas fa-user-tie text-xs"></i>
28
+ <%= blog_post_index.user_id %>
29
+ </li>
30
+ </ul>
31
+ <div class="row">
32
+ <div class="col-md-12">
33
+ <% if blog_post_index.pstimage.attached? %>
34
+ <div class="blog-media">
35
+ <img src="<%= url_for(blog_post_index.post_image) %>" alt="Picture for Blog Post - <%= blog_post_index.post_title %>" class="img-fluid" />
36
+ </div>
37
+ <% end %>
38
+ </div>
39
+ </div>
40
+ <div class="row">
41
+ <div class="col-md-12">
42
+ <%= truncate(blog_post_index.post_text, :length => 120, :escape => false) %>
43
+ <ul class="list-inline links">
44
+ <li class="list-inline-item">
45
+ <%= link_to blog_article_path(blog_post_index), class: "btn btn-secondary btn-sm" do %>
46
+ <i class="fas fa-arrow-alt-circle-right"></i> Read More
47
+ <% end %>
48
+ </li>
49
+ <li class="list-inline-item">
50
+ <a href="blog-post.html#comments" class="btn btn-secondary btn-sm"><i class="fa fa-comment"></i> 64 Comments</a>
51
+ </li>
52
+ <% if current_user.admin! %>
53
+ <li class="list-inline-item">
54
+ <%= link_to edit_article_post_path(blog_post_index), class: "btn btn-secondary btn-sm" do %>
55
+ <i class="fas fa-edit"></i> Edit Post
56
+ <% end %>
57
+ </li>
58
+ <li class="list-inline-item">
59
+ <%= link_to blog_post_index, class: "btn btn-danger btn-sm", method: :delete, data: { confirm: 'Are you sure?' } do %>
60
+ <i class="fas fa-dumpster"></i> Delete Post
61
+ <% end %>
62
+ </li>
63
+ <% end %>
64
+ </ul>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <% end %>
data/config/routes.rb ADDED
@@ -0,0 +1,25 @@
1
+ PhcdevworksPress::Engine.routes.draw do
2
+
3
+ # Article Routes
4
+ namespace :article do
5
+ resources :categories, class_name: 'Articles::Category'
6
+ resources :posts, class_name: 'Articles::Post'
7
+ end
8
+
9
+ # Frontend Routes
10
+ namespace :blog do
11
+ resources :articles, only: [:index, :show]
12
+ end
13
+
14
+ # API Routes
15
+ namespace :api, :path => "", :constraints => {:subdomain => "api"} do
16
+ namespace :v1 do
17
+ resources :posts, defaults: {format: 'json'}
18
+ resources :categories, defaults: {format: 'json'}
19
+ end
20
+ end
21
+
22
+ # Mount Routes
23
+ mount PhcdevworksAccounts::Engine, :at => '/'
24
+
25
+ end
@@ -0,0 +1,17 @@
1
+ class CreatePhcdevworksPressPostVersions < ActiveRecord::Migration[6.0]
2
+ TEXT_BYTES = 1_073_741_823
3
+ def change
4
+
5
+ create_table :phcdevworks_press_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 :phcdevworks_press_post_versions, %i(item_type item_id), :name => 'press_post_versions'
15
+
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreatePhcdevworksPressCategoryVersions < ActiveRecord::Migration[6.0]
2
+ TEXT_BYTES = 1_073_741_823
3
+ def change
4
+
5
+ create_table :phcdevworks_press_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
+
14
+ add_index :phcdevworks_press_category_versions, %i(item_type item_id), :name => 'press_category_versions'
15
+
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ class CreateJoinTableCategoriesPosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_join_table :categories, :posts do |t|
4
+ # t.index [:category_id, :post_id]
5
+ # t.index [:post_id, :category_id]
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ class CreatePhcdevworksPressArticlePosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :phcdevworks_press_article_posts do |t|
4
+
5
+ t.string :post_title
6
+ t.string :post_text
7
+ t.string :post_status
8
+ t.string :post_image
9
+
10
+ t.string :slug
11
+ t.string :user_id
12
+ t.string :org_id
13
+
14
+ t.timestamps
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ class CreatePhcdevworksPressArticleCategories < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :phcdevworks_press_article_categories do |t|
4
+
5
+ t.string :category_name
6
+
7
+ t.string :slug
8
+ t.string :user_id
9
+ t.string :org_id
10
+
11
+ t.timestamps
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ module PhcdevworksPress
2
+ class Engine < ::Rails::Engine
3
+
4
+ # Load Main Dependencies
5
+ require "jbuilder"
6
+ require "paper_trail"
7
+ require "friendly_id"
8
+
9
+ # Load Theme Dependencies
10
+ require "phcthemes_admin_panel_pack"
11
+ require "phcthemes_web_theme_pack"
12
+
13
+ # Load Upload Dependencies
14
+ require "aws-sdk-s3"
15
+ require "google-cloud-storage"
16
+ require "mini_magick"
17
+
18
+ # Load Helper Dependencies
19
+ # require "phcdevworks_core"
20
+ require "phcdevworks_active_menus"
21
+ require "phcdevworks_notifications"
22
+ require "phcdevworks_titleseo"
23
+
24
+ # Load User Accounts
25
+ require "phcdevworks_accounts"
26
+
27
+ # Engine Namespace
28
+ isolate_namespace PhcdevworksPress
29
+
30
+ # Load Requried Helper Files
31
+ config.to_prepare do
32
+ PhcdevworksActiveMenus::ApplicationController.helper(ApplicationHelper)
33
+ PhcdevworksNotifications::ApplicationController.helper(ApplicationHelper)
34
+ PhcdevworksTitleseo::ApplicationController.helper(ApplicationHelper)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module PhcdevworksPress
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require "phcdevworks_press/engine"
2
+
3
+ module PhcdevworksPress
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :phcdevworks_press do
3
+ # # Task goes here
4
+ # end