phcdevworks_press 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +34 -0
- data/Rakefile +32 -0
- data/app/assets/config/phcdevworks_press_manifest.js +2 -0
- data/app/assets/javascripts/phcdevworks_press/application.js +2 -0
- data/app/assets/stylesheets/phcdevworks_press/application.scss +2 -0
- data/app/assets/stylesheets/phcdevworks_press/article/categories.css +4 -0
- data/app/assets/stylesheets/phcdevworks_press/article/posts.css +4 -0
- data/app/assets/stylesheets/phcdevworks_press/blog/articles.css +4 -0
- data/app/controllers/phcdevworks_press/application_controller.rb +13 -0
- data/app/controllers/phcdevworks_press/article/categories_controller.rb +82 -0
- data/app/controllers/phcdevworks_press/article/posts_controller.rb +82 -0
- data/app/controllers/phcdevworks_press/blog/articles_controller.rb +20 -0
- data/app/helpers/phcdevworks_press/application_helper.rb +4 -0
- data/app/helpers/phcdevworks_press/article/categories_helper.rb +4 -0
- data/app/helpers/phcdevworks_press/article/posts_helper.rb +4 -0
- data/app/helpers/phcdevworks_press/blog/articles_helper.rb +4 -0
- data/app/jobs/phcdevworks_press/application_job.rb +4 -0
- data/app/mailers/phcdevworks_press/application_mailer.rb +6 -0
- data/app/models/phcdevworks_press/application_record.rb +5 -0
- data/app/models/phcdevworks_press/article/category.rb +27 -0
- data/app/models/phcdevworks_press/article/post.rb +32 -0
- data/app/models/phcdevworks_press/article.rb +7 -0
- data/app/models/phcdevworks_press/category_versions.rb +5 -0
- data/app/models/phcdevworks_press/post_versions.rb +5 -0
- data/app/views/layouts/phcdevworks_press/application.html.erb +94 -0
- data/app/views/layouts/phcdevworks_press/components/backend/footer/_footer.html.erb +16 -0
- data/app/views/layouts/phcdevworks_press/components/backend/navigation/_top_menu.html.erb +37 -0
- data/app/views/layouts/phcdevworks_press/components/backend/sidebars/_side_menu.html.erb +142 -0
- data/app/views/layouts/phcdevworks_press/frontend.html.erb +5 -0
- data/app/views/phcdevworks_press/article/categories/_form.html.erb +22 -0
- data/app/views/phcdevworks_press/article/categories/edit.html.erb +37 -0
- data/app/views/phcdevworks_press/article/categories/index.html.erb +65 -0
- data/app/views/phcdevworks_press/article/categories/new.html.erb +37 -0
- data/app/views/phcdevworks_press/article/posts/_form.html.erb +87 -0
- data/app/views/phcdevworks_press/article/posts/edit.html.erb +23 -0
- data/app/views/phcdevworks_press/article/posts/index.html.erb +68 -0
- data/app/views/phcdevworks_press/article/posts/new.html.erb +23 -0
- data/app/views/phcdevworks_press/blog/articles/index.html.erb +69 -0
- data/app/views/phcdevworks_press/blog/articles/show.html.erb +1 -0
- data/config/routes.rb +25 -0
- data/db/migrate/20170517064030_create_phcdevworks_press_post_versions.rb +17 -0
- data/db/migrate/20170517064427_create_phcdevworks_press_category_versions.rb +17 -0
- data/db/migrate/20190315173237_create_join_table_categories_posts.rb +8 -0
- data/db/migrate/20190805232522_create_phcdevworks_press_article_posts.rb +18 -0
- data/db/migrate/20190805232733_create_phcdevworks_press_article_categories.rb +15 -0
- data/lib/phcdevworks_press/engine.rb +38 -0
- data/lib/phcdevworks_press/version.rb +3 -0
- data/lib/phcdevworks_press.rb +5 -0
- data/lib/tasks/phcdevworks_press_tasks.rake +4 -0
- metadata +296 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6bba65c663e162b1595b93e6cb93f0900ebdf352954bd23ec018ef0d9763b511
|
4
|
+
data.tar.gz: b1ac0dd376e8857870c2d15f3044a2c1b2c0a6f40035489496acb542095a46a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 036ecb78ba1293af94665b0cd4d0866df34312d53c7419e201580fca4832b16c614e2c27fdfc83472e3cfb4e5476f06519383a9fd1546d830113a3fef78588ba
|
7
|
+
data.tar.gz: 600d1302fec0bb97496433bda547a42e3a56a8eccab46740061a2f65e1e294b136ef0c41979fa25c9edc78f7cf0585ae2e14789d8f55e1479c495d83d3a0ad78
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 - PHCDEVWORKS
|
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
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
### Phcdevworks Press (News/Blog Engine) Documentation
|
2
|
+
Phcdevworks Press rails CMS engine to manage your website's articles, categories and media.
|
3
|
+
|
4
|
+
* Website article posts with WYSIWYG editor.
|
5
|
+
* Upload images locally or use any popular cloud service.
|
6
|
+
* Customizable article categories module included.
|
7
|
+
|
8
|
+
#### Step 1 - Add Phcdevworks Press to your gemfile and run command
|
9
|
+
|
10
|
+
gem 'phcdevworks_press'
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
#### Step 2 - Copy Phcdevworks Press Database Tables
|
14
|
+
To copy Phcdevworks Press' requried database migrations, copy each command individually to your terminal's command line.
|
15
|
+
|
16
|
+
rails phcdevworks_press:install:migrations
|
17
|
+
rails db:migrate
|
18
|
+
|
19
|
+
#### Step 3 - Mount Phcdevworks Press & Add Routes
|
20
|
+
Mount Phcdevworks Press by adding code below to your routes file.
|
21
|
+
|
22
|
+
mount PhcdevworksPress::Engine, :at => '/'
|
23
|
+
|
24
|
+
#### Step 4 - Recompile Assets
|
25
|
+
To properly function re-compile your application's assets to copy over required files.
|
26
|
+
|
27
|
+
rails assets:clobber
|
28
|
+
rails assets:precompile
|
29
|
+
|
30
|
+
#### Step 5 - Generate Contact Form View (Customization)
|
31
|
+
All Phcdevworks Press views and layouts can be overwritten by copying files to your application.
|
32
|
+
|
33
|
+
rails generate phcdevworks_press:views
|
34
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'PhcdevworksCmsPress'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/test_app/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module PhcdevworksPress
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
# Security Filters
|
5
|
+
protect_from_forgery with: :exception
|
6
|
+
|
7
|
+
# Load Requried Helper Files
|
8
|
+
helper PhcdevworksActiveMenus::Engine.helpers
|
9
|
+
helper PhcdevworksNotifications::Engine.helpers
|
10
|
+
helper PhcdevworksTitleseo::Engine.helpers
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require_dependency "phcdevworks_press/application_controller"
|
2
|
+
|
3
|
+
module PhcdevworksPress
|
4
|
+
class Article::CategoriesController < ApplicationController
|
5
|
+
|
6
|
+
# Filters & Security
|
7
|
+
#include PhcdevworksCore::PhcpluginsHelper
|
8
|
+
before_action :authenticate_user!
|
9
|
+
before_action :set_paper_trail_whodunnit
|
10
|
+
before_action :set_article_category, only: [:show, :edit, :update, :destroy]
|
11
|
+
|
12
|
+
# GET /article/categories
|
13
|
+
def index
|
14
|
+
@article_categories = Article::Category.all
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /article/categories/1
|
18
|
+
def show
|
19
|
+
@article_category = Article::Category.friendly.find(params[:id])
|
20
|
+
@versions = PhcdevworksPress::CategoryVersions.where(item_id: params[:id], item_type: 'PhcdevworksPress::Article::Category')
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /article/categories/new
|
24
|
+
def new
|
25
|
+
@article_category = Article::Category.new
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /article/categories/1/edit
|
29
|
+
def edit
|
30
|
+
end
|
31
|
+
|
32
|
+
# POST /article/categories
|
33
|
+
def create
|
34
|
+
@article_category = Article::Category.new(article_category_params)
|
35
|
+
@article_category.user_id = current_user.id
|
36
|
+
respond_to do |format|
|
37
|
+
if @article_category.save
|
38
|
+
format.html { redirect_to article_categories_path, :flash => { :success => 'Article Category has been Added.' }}
|
39
|
+
format.json { render :show, status: :created, location: @article_category }
|
40
|
+
else
|
41
|
+
format.html { render :new }
|
42
|
+
format.json { render json: @article_category.errors, status: :unprocessable_entity }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# PATCH/PUT /article/categories/1
|
48
|
+
def update
|
49
|
+
respond_to do |format|
|
50
|
+
if @article_category.update(article_category_params)
|
51
|
+
format.html { redirect_to article_categories_path, :flash => { :notice => 'Article Category Name has been Updated.' }}
|
52
|
+
format.json { render :show, status: :ok, location: @article_category }
|
53
|
+
else
|
54
|
+
format.html { render :edit }
|
55
|
+
format.json { render json: @article_category.errors, status: :unprocessable_entity }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# DELETE /article/categories/1
|
61
|
+
def destroy
|
62
|
+
@article_category.destroy
|
63
|
+
respond_to do |format|
|
64
|
+
format.html { redirect_to article_categories_path, :flash => { :error => 'Category and Article Connections have all been Removed.' }}
|
65
|
+
format.json { head :no_content }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# Common Callbacks
|
72
|
+
def set_article_category
|
73
|
+
@article_category = Article::Category.friendly.find(params[:id])
|
74
|
+
end
|
75
|
+
|
76
|
+
# Whitelist
|
77
|
+
def article_category_params
|
78
|
+
params.require(:article_category).permit(:category_name, :slug, :org_id, :user_id)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require_dependency "phcdevworks_press/application_controller"
|
2
|
+
|
3
|
+
module PhcdevworksPress
|
4
|
+
class Article::PostsController < ApplicationController
|
5
|
+
|
6
|
+
# Filters & Security
|
7
|
+
#include PhcdevworksCore::PhcpluginsHelper
|
8
|
+
before_action :authenticate_user!
|
9
|
+
before_action :set_paper_trail_whodunnit
|
10
|
+
before_action :set_article_post, only: [:show, :edit, :update, :destroy]
|
11
|
+
|
12
|
+
# GET /article/posts
|
13
|
+
def index
|
14
|
+
@article_posts = Article::Post.all
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /article/posts/1
|
18
|
+
def show
|
19
|
+
@article_post = Article::Post.friendly.find(params[:id])
|
20
|
+
@versions = PhcdevworksPress::PostVersions.where(item_id: params[:id], item_type: 'PhcdevworksPress::Article::Post')
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /article/posts/new
|
24
|
+
def new
|
25
|
+
@article_post = Article::Post.new
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /article/posts/1/edit
|
29
|
+
def edit
|
30
|
+
end
|
31
|
+
|
32
|
+
# POST /article/posts
|
33
|
+
def create
|
34
|
+
@article_post = Article::Post.new(article_post_params)
|
35
|
+
@article_post.user_id = current_user.id
|
36
|
+
respond_to do |format|
|
37
|
+
if @article_post.save
|
38
|
+
format.html { redirect_to article_posts_path, :flash => { :success => 'Article has been Added.' }}
|
39
|
+
format.json { render :show, status: :created, location: @article_post }
|
40
|
+
else
|
41
|
+
format.html { render :new }
|
42
|
+
format.json { render json: @article_post.errors, status: :unprocessable_entity }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# PATCH/PUT /article/posts/1
|
48
|
+
def update
|
49
|
+
respond_to do |format|
|
50
|
+
if @article_post.update(article_post_params)
|
51
|
+
format.html { redirect_to article_posts_path, :flash => { :notice => 'Article has been Updated.' }}
|
52
|
+
format.json { render :show, status: :ok, location: @article_post }
|
53
|
+
else
|
54
|
+
format.html { render :edit }
|
55
|
+
format.json { render json: @article_post.errors, status: :unprocessable_entity }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# DELETE /article/posts/1
|
61
|
+
def destroy
|
62
|
+
@article_post.destroy
|
63
|
+
respond_to do |format|
|
64
|
+
format.html { redirect_to article_posts_path, :flash => { :error => 'Article has been Removed.' }}
|
65
|
+
format.json { head :no_content }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# Common Callbacks
|
72
|
+
def set_article_post
|
73
|
+
@article_post = Article::Post.friendly.find(params[:id])
|
74
|
+
end
|
75
|
+
|
76
|
+
# Whitelist
|
77
|
+
def article_post_params
|
78
|
+
params.require(:article_post).permit(:post_title, :post_text, :post_status, :post_image, :remove_post_image, :slug, :org_id, :user_id, category_ids: [])
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_dependency "phcdevworks_press/application_controller"
|
2
|
+
|
3
|
+
module PhcdevworksPress
|
4
|
+
class Blog::ArticlesController < ApplicationController
|
5
|
+
|
6
|
+
# Layout
|
7
|
+
layout 'phcdevworks_press/frontend'
|
8
|
+
|
9
|
+
# INDEX
|
10
|
+
def index
|
11
|
+
@phcdevworks_cms_press_index = Article::Post.where(org_id: current_user.org_id, pststatus: "published")
|
12
|
+
end
|
13
|
+
|
14
|
+
# SHOW
|
15
|
+
def show
|
16
|
+
@phcdevworks_cms_press_single = Article::Post.friendly.find(params[:id])
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PhcdevworksPress
|
2
|
+
class Article::Category < ApplicationRecord
|
3
|
+
|
4
|
+
# Clean URL Initialize
|
5
|
+
extend FriendlyId
|
6
|
+
|
7
|
+
# Paper Trail Initialize
|
8
|
+
has_paper_trail :class_name => 'PhcdevworksPress::CategoryVersions'
|
9
|
+
|
10
|
+
# Relationships
|
11
|
+
has_and_belongs_to_many :posts, class_name: 'Article::Post', :join_table => 'categories_posts', :dependent => :destroy
|
12
|
+
belongs_to :user, class_name: 'PhcdevworksAccounts::User'
|
13
|
+
|
14
|
+
# Form Fields Validation
|
15
|
+
validates :category_name,
|
16
|
+
presence: true,
|
17
|
+
uniqueness: true
|
18
|
+
|
19
|
+
# Clean URL Define
|
20
|
+
friendly_id :phc_nice_url_slug, use: [:slugged, :finders]
|
21
|
+
|
22
|
+
def phc_nice_url_slug
|
23
|
+
[:category_name]
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PhcdevworksPress
|
2
|
+
class Article::Post < ApplicationRecord
|
3
|
+
|
4
|
+
# Clean URL Initialize
|
5
|
+
extend FriendlyId
|
6
|
+
|
7
|
+
# Paper Trail Initialize
|
8
|
+
has_paper_trail :class_name => 'PhcdevworksPress::PostVersions'
|
9
|
+
|
10
|
+
# Image Upload
|
11
|
+
has_one_attached :post_image
|
12
|
+
|
13
|
+
# Relationships
|
14
|
+
has_and_belongs_to_many :categories, class_name: 'Article::Category', :join_table => 'categories_posts'
|
15
|
+
belongs_to :user, class_name: 'PhcdevworksAccounts::User'
|
16
|
+
|
17
|
+
# Form Fields Validation
|
18
|
+
validates :post_title,
|
19
|
+
presence: true
|
20
|
+
|
21
|
+
validates :post_text,
|
22
|
+
presence: true
|
23
|
+
|
24
|
+
# Clean URL Define
|
25
|
+
friendly_id :phcpress_post_slug, use: [:slugged, :finders]
|
26
|
+
|
27
|
+
def phcpress_post_slug
|
28
|
+
[:post_title]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|