guider_cms 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +133 -0
- data/Rakefile +32 -0
- data/app/assets/config/guider_cms_manifest.js +4 -0
- data/app/assets/images/guider_cms/down.jpg +0 -0
- data/app/assets/images/guider_cms/down.png +0 -0
- data/app/assets/images/guider_cms/up.png +0 -0
- data/app/assets/stylesheets/guider_cms/application.css +78 -0
- data/app/assets/stylesheets/guider_cms/articles.css +18 -0
- data/app/assets/stylesheets/guider_cms/categories.css +4 -0
- data/app/assets/stylesheets/guider_cms/current_user_articles.css +4 -0
- data/app/assets/stylesheets/guider_cms/subcategories.css +4 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/guider_cms/application_controller.rb +6 -0
- data/app/controllers/guider_cms/articles_controller.rb +232 -0
- data/app/controllers/guider_cms/categories_controller.rb +112 -0
- data/app/controllers/guider_cms/current_user_articles_controller.rb +14 -0
- data/app/controllers/guider_cms/subcategories_controller.rb +35 -0
- data/app/helpers/guider_cms/application_helper.rb +70 -0
- data/app/helpers/guider_cms/articles_helper.rb +32 -0
- data/app/helpers/guider_cms/categories_helper.rb +4 -0
- data/app/helpers/guider_cms/current_user_articles_helper.rb +4 -0
- data/app/helpers/guider_cms/subcategories_helper.rb +4 -0
- data/app/jobs/guider_cms/application_job.rb +4 -0
- data/app/mailers/guider_cms/application_mailer.rb +6 -0
- data/app/models/guider_cms/application_record.rb +5 -0
- data/app/models/guider_cms/article.rb +26 -0
- data/app/models/guider_cms/category.rb +10 -0
- data/app/views/guider_cms/articles/_form.html.erb +51 -0
- data/app/views/guider_cms/articles/edit.html.erb +5 -0
- data/app/views/guider_cms/articles/index.html.erb +540 -0
- data/app/views/guider_cms/articles/new.html.erb +5 -0
- data/app/views/guider_cms/articles/show.html.erb +68 -0
- data/app/views/guider_cms/categories/_form.html.erb +50 -0
- data/app/views/guider_cms/categories/edit.html.erb +6 -0
- data/app/views/guider_cms/categories/index.html.erb +76 -0
- data/app/views/guider_cms/categories/new.html.erb +7 -0
- data/app/views/guider_cms/current_user_articles/index.html.erb +32 -0
- data/app/views/guider_cms/subcategories/_form.html.erb +15 -0
- data/app/views/guider_cms/subcategories/new.html.erb +5 -0
- data/app/views/layouts/guider_cms/application.html.erb +22 -0
- data/config/initializers/friendly_id.rb +107 -0
- data/config/initializers/kaminari_config.rb +14 -0
- data/config/routes.rb +53 -0
- data/db/migrate/20200823094047_create_guider_cms_categories.rb +9 -0
- data/db/migrate/20200823094214_create_guider_cms_articles.rb +13 -0
- data/db/migrate/20200823095230_add_parent_id_to_guider_cms_categories.rb +5 -0
- data/db/migrate/20200823095828_create_guider_cms_category_hierarchies.rb +16 -0
- data/db/migrate/20200823095934_add_is_root_category_ro_guider_categories.rb +5 -0
- data/db/migrate/20200823100111_add_slug_to_articles.rb +6 -0
- data/db/migrate/20200823100118_create_friendly_id_slugs.rb +21 -0
- data/db/migrate/20200824104656_add_slug_to_guider_cms_categories.rb +6 -0
- data/db/migrate/20200827170106_add_view_type_to_guider_categories.rb +5 -0
- data/db/migrate/20200831182803_add_keywords_to_guider_cms_articles.rb +5 -0
- data/db/migrate/20200902203407_add_position_to_guider_cms_articles.rb +5 -0
- data/lib/generators/guider_cms/controller_generator.rb +33 -0
- data/lib/generators/guider_cms/install_generator.rb +34 -0
- data/lib/generators/guider_cms/routes_generator.rb +34 -0
- data/lib/generators/guider_cms/views_generator.rb +35 -0
- data/lib/generators/templates/README +20 -0
- data/lib/generators/templates/guider_cms.rb +4 -0
- data/lib/guider_cms.rb +10 -0
- data/lib/guider_cms/engine.rb +9 -0
- data/lib/guider_cms/version.rb +3 -0
- data/lib/tasks/guider_cms_tasks.rake +4 -0
- metadata +227 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
require_dependency "guider_cms/application_controller"
|
|
2
|
+
|
|
3
|
+
module GuiderCms
|
|
4
|
+
class CategoriesController < ApplicationController
|
|
5
|
+
before_action :set_category, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
@all_categories = Category.all
|
|
10
|
+
if @all_categories == []
|
|
11
|
+
redirect_to new_optimized_category_path
|
|
12
|
+
else
|
|
13
|
+
@categories = Category.where(is_root_category: true)
|
|
14
|
+
@root = Category.where(is_root_category: true).first.classification
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def new
|
|
19
|
+
if current_user && is_guider_admin
|
|
20
|
+
@root = Category.where(is_root_category: true).first
|
|
21
|
+
@category = Category.new
|
|
22
|
+
@categories = Category.all
|
|
23
|
+
@view_type = ["full grid", "blog grid", "blog list", "ordered list", "ordered grid", "normal grid with menu"]
|
|
24
|
+
@root_categories = Category.where(is_root_category: true)
|
|
25
|
+
# @root_categories = category_options_array()
|
|
26
|
+
else
|
|
27
|
+
redirect_to main_app.root_path, alert: "Not authorized"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def edit
|
|
32
|
+
if !(current_user)
|
|
33
|
+
redirect_to guider_home_path
|
|
34
|
+
else
|
|
35
|
+
if !(is_guider_admin)
|
|
36
|
+
redirect_to guider_home_path
|
|
37
|
+
else
|
|
38
|
+
@root_categories = Category.where(is_root_category: true)
|
|
39
|
+
@view_type = ["full grid", "blog grid", "blog list", "ordered list", "ordered grid", "normal grid with menu"]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create
|
|
45
|
+
if params[:category]["parent_id"] == "" || params[:category]["parent_id"].nil?
|
|
46
|
+
@category = Category.new(classification: params[:category]["classification"], is_root_category: true, view_type: params[:category]["view_type"] || "menu", header_image: params[:category]["header_image"])
|
|
47
|
+
if @category.save
|
|
48
|
+
redirect_to root_categories_path
|
|
49
|
+
else
|
|
50
|
+
render :new
|
|
51
|
+
end
|
|
52
|
+
else
|
|
53
|
+
category = Category.find(params[:category]["parent_id"])
|
|
54
|
+
category.children.create(classification: params[:category]["classification"], header_image: params[:category]["header_image"])
|
|
55
|
+
redirect_to root_categories_path
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def update
|
|
60
|
+
if params[:category]["parent_id"] == ""
|
|
61
|
+
if @category.update(classification: params[:category]["classification"], parent_id: nil, view_type: params[:category]["view_type"], header_image: params[:category]["header_image"])
|
|
62
|
+
redirect_to root_categories_path
|
|
63
|
+
end
|
|
64
|
+
else
|
|
65
|
+
parent_category = Category.find_by(classification: params[:category]["parent_id"])
|
|
66
|
+
in_que_category = Category.find_by(classification: params[:category]["classification"])
|
|
67
|
+
in_que_category.parent_id = parent_category.id
|
|
68
|
+
if in_que_category.update(category_params)
|
|
69
|
+
redirect_to root_categories_path
|
|
70
|
+
else
|
|
71
|
+
render :edit
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def destroy
|
|
80
|
+
if !!current_user && is_guider_admin
|
|
81
|
+
if @category.articles == []
|
|
82
|
+
@category.destroy
|
|
83
|
+
@all_categories = Category.all
|
|
84
|
+
if @all_categories != []
|
|
85
|
+
redirect_to root_categories_path, notice: 'Categories was successfully destroyed.'
|
|
86
|
+
else
|
|
87
|
+
redirect_to guider_home_path
|
|
88
|
+
end
|
|
89
|
+
else
|
|
90
|
+
redirect_to root_categories_path, alert: "Only Empty Categories can be deleted."
|
|
91
|
+
end
|
|
92
|
+
else
|
|
93
|
+
redirect_to guider_home_path
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
def set_category
|
|
100
|
+
@category = Category.friendly.find(params[:id])
|
|
101
|
+
if @category.parent
|
|
102
|
+
@root_id = @category.parent
|
|
103
|
+
else
|
|
104
|
+
@root_id = nil
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def category_params
|
|
109
|
+
params.require(:category).permit(:classification, :parent_id, :view_type, :header_image)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_dependency "guider_cms/application_controller"
|
|
2
|
+
|
|
3
|
+
module GuiderCms
|
|
4
|
+
class CurrentUserArticlesController < ApplicationController
|
|
5
|
+
def index
|
|
6
|
+
if current_user && is_guider_admin
|
|
7
|
+
@articles = Article.where(author_id: current_user.id)
|
|
8
|
+
@root = Category.where(is_root_category: true).first.classification
|
|
9
|
+
else
|
|
10
|
+
redirect_to guider_home_path
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_dependency "guider_cms/application_controller"
|
|
2
|
+
|
|
3
|
+
module GuiderCms
|
|
4
|
+
class SubcategoriesController < ApplicationController
|
|
5
|
+
def new
|
|
6
|
+
if current_user && is_guider_admin
|
|
7
|
+
@root = params[:root]
|
|
8
|
+
@root_category = Category.find_by(classification: @root)
|
|
9
|
+
@categories = Category.where(parent_id: @root_category.id)
|
|
10
|
+
else
|
|
11
|
+
redirect_to content_new_back_path(root: @root)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def create
|
|
16
|
+
classification = params[:subcategory]["category"]
|
|
17
|
+
subcategory = params[:subcategory]["subcategory"]
|
|
18
|
+
# puts(classification)
|
|
19
|
+
#
|
|
20
|
+
#
|
|
21
|
+
category = Category.find_by(classification: classification)
|
|
22
|
+
puts(category.id)
|
|
23
|
+
category.children.create(classification: subcategory)
|
|
24
|
+
|
|
25
|
+
@root = category.ancestors.last.classification
|
|
26
|
+
|
|
27
|
+
redirect_to content_new_back_path(root: @root)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
def article_params
|
|
32
|
+
params.require(:subcategory).permit(:category, :subcategory)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module GuiderCms
|
|
2
|
+
module ApplicationHelper
|
|
3
|
+
def method_missing method, *args, &block
|
|
4
|
+
if method.to_s.end_with?('_path') or method.to_s.end_with?('_url')
|
|
5
|
+
if main_app.respond_to?(method)
|
|
6
|
+
main_app.send(method, *args)
|
|
7
|
+
else
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
else
|
|
11
|
+
super
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def respond_to?(method)
|
|
16
|
+
if method.to_s.end_with?('_path') or method.to_s.end_with?('_url')
|
|
17
|
+
if main_app.respond_to?(method)
|
|
18
|
+
true
|
|
19
|
+
else
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def subcat_prefix(depth)
|
|
28
|
+
(" " * 4 * depth).html_safe
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def category_options_array_for_article(current_id = nil,categories=[], parent_id=nil, depth=0)
|
|
32
|
+
if categories == []
|
|
33
|
+
root = Category.find(parent_id)
|
|
34
|
+
categories << [subcat_prefix(depth) + root.classification, root.id]
|
|
35
|
+
category_options_array(current_id,categories, root.id, depth+1)
|
|
36
|
+
end
|
|
37
|
+
categories
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def article_options(id)
|
|
41
|
+
req_array = []
|
|
42
|
+
Category.find(id)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def category_options_array(current_id = nil,categories=[], parent_id=nil, depth=0)
|
|
48
|
+
# Category.where('parent_id = ? AND id != ?', parent_id, current_id ).order(:id).each do |category|
|
|
49
|
+
Category.where(parent_id: parent_id).order(:id).each do |category|
|
|
50
|
+
categories << [subcat_prefix(depth) + category.classification, category.id]
|
|
51
|
+
category_options_array(current_id,categories, category.id, depth+1)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
categories
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def title(text)
|
|
58
|
+
content_for :title, text
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def meta_tag(tag, text)
|
|
62
|
+
content_for :"meta_#{tag}", text
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def yield_meta_tag(tag, default_text='')
|
|
66
|
+
content_for?(:"meta_#{tag}") ? content_for(:"meta_#{tag}") : default_text
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module GuiderCms
|
|
2
|
+
module ArticlesHelper
|
|
3
|
+
def category_options_array_for_article(current_id = nil,categories=[], parent_id=nil, depth=0)
|
|
4
|
+
if categories == []
|
|
5
|
+
root = Category.find(parent_id)
|
|
6
|
+
categories << [subcat_prefix(depth) + root.classification, root.id]
|
|
7
|
+
category_options_array(current_id,categories, root.id, depth+1)
|
|
8
|
+
end
|
|
9
|
+
categories
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def article_options(id)
|
|
13
|
+
req_array = []
|
|
14
|
+
Category.find(id)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def subcat_prefix(depth)
|
|
18
|
+
(" " * 4 * depth).html_safe
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def category_options_array(current_id = nil,categories=[], parent_id=nil, depth=0)
|
|
22
|
+
# Category.where('parent_id = ? AND id != ?', parent_id, current_id ).order(:id).each do |category|
|
|
23
|
+
Category.where(parent_id: parent_id).order(:id).each do |category|
|
|
24
|
+
categories << [subcat_prefix(depth) + category.classification, category.id]
|
|
25
|
+
category_options_array(current_id,categories, category.id, depth+1)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
categories
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module GuiderCms
|
|
2
|
+
class Article < ApplicationRecord
|
|
3
|
+
|
|
4
|
+
extend FriendlyId
|
|
5
|
+
friendly_id :title, use: :slugged
|
|
6
|
+
paginates_per 10
|
|
7
|
+
acts_as_list
|
|
8
|
+
|
|
9
|
+
belongs_to :author, class_name: GuiderCms.author_class
|
|
10
|
+
belongs_to :category
|
|
11
|
+
has_rich_text :body
|
|
12
|
+
has_one_attached :header_image
|
|
13
|
+
has_many_attached :images
|
|
14
|
+
before_validation :set_author
|
|
15
|
+
|
|
16
|
+
validates :title, presence: true
|
|
17
|
+
validates :body, presence: true
|
|
18
|
+
validates :description, presence: true
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
def set_author
|
|
22
|
+
self.author = GuiderCms.author_class.constantize.find(author_id)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<%= form_with(model: article, local: true) do |form| %>
|
|
2
|
+
<% if article.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(article.errors.count, "error") %> prohibited this article from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% article.errors.full_messages.each do |message| %>
|
|
8
|
+
<li><%= message %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="form-group">
|
|
15
|
+
<%= form.label :title %>
|
|
16
|
+
<%= form.text_area :title, class: "form-control", required: true %>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div class="form-group">
|
|
20
|
+
<%= form.label :description %>
|
|
21
|
+
<%= form.text_area :description, class: "form-control", required: true %>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<div class="form-group">
|
|
25
|
+
<%= form.label :keywords %>
|
|
26
|
+
<%= form.text_area :keywords, class: "form-control", required: true %>
|
|
27
|
+
</div>
|
|
28
|
+
<p>Enter keywords related to your write up seperated by ","</p>
|
|
29
|
+
|
|
30
|
+
<div class="form-group">
|
|
31
|
+
<%= form.label :header_image %>
|
|
32
|
+
<%= form.file_field :header_image %>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="form-group">
|
|
36
|
+
<%= form.label :category_id %>
|
|
37
|
+
<%= form.select :category_id, options_for_select(category_options_array_for_article(nil, [], @root_category.id, 0)) , {include_blank: true} ,class: "form-control" %>
|
|
38
|
+
</div>
|
|
39
|
+
<p>If you are not finding relavant category, then you can <%= link_to "Create a category", new_category_path %></p>
|
|
40
|
+
<p>If you don't want to put it in a specific category, then just select <%= @root %></p>
|
|
41
|
+
|
|
42
|
+
<div class="form-group">
|
|
43
|
+
<%= form.label :body %>
|
|
44
|
+
<%= form.rich_text_area :body, required: true %>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
<div class="actions">
|
|
49
|
+
<%= form.submit "Create Article", class: "btn btn-outline-primary" %>
|
|
50
|
+
</div>
|
|
51
|
+
<% end %>
|
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
<% title @selected_category_class.classification || @root_category.classification %>
|
|
2
|
+
<% meta_tag :root, @root_category.classification %>
|
|
3
|
+
<% meta_tag :category, @selected_category_class.classification %>
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
<%
|
|
8
|
+
def draw_tree(node)
|
|
9
|
+
node.children.each do |category|
|
|
10
|
+
%>
|
|
11
|
+
|
|
12
|
+
<% if category.articles != [] %>
|
|
13
|
+
<% if category.classification == @selected_category_class.classification %>
|
|
14
|
+
<li><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification), class: "listing-active-links" %></li>
|
|
15
|
+
<% else %>
|
|
16
|
+
<li><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification), class: "listing-links" %></li>
|
|
17
|
+
|
|
18
|
+
<% end %>
|
|
19
|
+
<% end %>
|
|
20
|
+
<%
|
|
21
|
+
if category.children.any?
|
|
22
|
+
%>
|
|
23
|
+
<ul style="list-style-type: none;"><% draw_tree(category) %></ul>
|
|
24
|
+
<%
|
|
25
|
+
end
|
|
26
|
+
%>
|
|
27
|
+
|
|
28
|
+
<%
|
|
29
|
+
end; nil
|
|
30
|
+
end
|
|
31
|
+
%>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
<div class="row">
|
|
35
|
+
<div class="col-md-6">
|
|
36
|
+
<h1><%= @root_category.classification %></h1>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="col-md-6">
|
|
39
|
+
<div class="row">
|
|
40
|
+
<% if @current_user && @is_guider_admin %>
|
|
41
|
+
<div class="col-md-3" style="padding-top: 10px;">
|
|
42
|
+
<h6><%= link_to "New Content", new_content_path(root: @root), class: "listing-links" %></h6>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="col-md-3" style="padding-top: 10px;">
|
|
45
|
+
<h6><%= link_to "New Category", new_optimized_category_path, class: "listing-links" %></h6>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="col-md-3" style="padding-top: 10px;">
|
|
48
|
+
<h6><%= link_to "Show Cateories", root_categories_path, class: "listing-links" %></h6>
|
|
49
|
+
</div>
|
|
50
|
+
<% end %>
|
|
51
|
+
<% if @selected_category_class && @root_category.view_type == "grid" && @selected_category_class.parent && @selected_category_class.parent.id != @root_category.id %>
|
|
52
|
+
<div class="col-md-3" style="padding-top: 10px;">
|
|
53
|
+
<h6><%= link_to "#{@selected_category_class.parent.classification}", contents_path(root: @root_category.slug || @root_category.classification,
|
|
54
|
+
selected_category: @selected_category_class.parent.slug || @selected_category_class.parent.classification), class: "listing-links"%></h6>
|
|
55
|
+
</div>
|
|
56
|
+
<% elsif @selected_category_class && @selected_category_class.parent && @selected_category_class.parent.id == @root_category.id && @root_category.view_type == "grid" %>
|
|
57
|
+
<div class="col-md-3" style="padding-top: 10px;">
|
|
58
|
+
<h6><%= link_to "#{@selected_category_class.parent.classification}", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-links" %></h6>
|
|
59
|
+
</div>
|
|
60
|
+
<% end %>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<br/>
|
|
66
|
+
<% if @root_category.view_type.nil? || @root_category.view_type == "menu" || @root_category.view_type == "normal grid with menu" %>
|
|
67
|
+
<div class="row">
|
|
68
|
+
<div class="col-sm-3 col-md-3" >
|
|
69
|
+
<% if @root_category.articles !=[] && @root_category.children != [] %>
|
|
70
|
+
<% if @selected_category.nil? %>
|
|
71
|
+
<h6><%= link_to "Home", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-active-links" %></h6>
|
|
72
|
+
<% else %>
|
|
73
|
+
<h6><%= link_to "Home", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-links" %></h6>
|
|
74
|
+
<% end %>
|
|
75
|
+
<% end %>
|
|
76
|
+
<% @children_category.each do |category| %>
|
|
77
|
+
<% if (category.articles != []) || (category.articles == [] && @current_user && @is_guider_admin) %>
|
|
78
|
+
<% if category.classification == @selected_category_class.classification %>
|
|
79
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-active-links" %></h6>
|
|
80
|
+
<% else %>
|
|
81
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-links" %></h6>
|
|
82
|
+
<% end %>
|
|
83
|
+
<% if category.children.any? %>
|
|
84
|
+
<ul style="list-style-type: none;"><%= draw_tree(category) %></ul>
|
|
85
|
+
<% end %>
|
|
86
|
+
<% end %>
|
|
87
|
+
<% end %>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="col-sm-9 col-md-9">
|
|
90
|
+
<% if @selected_category_class.articles == [] %>
|
|
91
|
+
<center>
|
|
92
|
+
<h1>No Content Here</h1>
|
|
93
|
+
<% if @current_user && @is_guider_admin %>
|
|
94
|
+
<h3>Click on New Content to create Content</h3>
|
|
95
|
+
<% end %>
|
|
96
|
+
</center>
|
|
97
|
+
<% else %>
|
|
98
|
+
<div class="row">
|
|
99
|
+
<div class="card-columns">
|
|
100
|
+
<% @selected_category_class.articles.each do |article| %>
|
|
101
|
+
<div class="card" style="margin-bottom: 2vh;">
|
|
102
|
+
<% if article.header_image.attached? %>
|
|
103
|
+
<%= image_tag(main_app.url_for(article.header_image), class: "card-img-top") %>
|
|
104
|
+
<% else %>
|
|
105
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
106
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), class: "card-img-top") %>
|
|
107
|
+
<% end %>
|
|
108
|
+
<% end %>
|
|
109
|
+
<div class="card-body">
|
|
110
|
+
<% if @selected_category_class.parent.nil? %>
|
|
111
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
112
|
+
<% else %>
|
|
113
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
114
|
+
<% end %>
|
|
115
|
+
<p class="card-text"> <%= article.description[0..300].gsub(/\s\w+$/,'...') %></p>
|
|
116
|
+
<% if @selected_category_class.parent.nil? %>
|
|
117
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
118
|
+
<% else %>
|
|
119
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
120
|
+
<% end %>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
<% end %>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<% end %>
|
|
129
|
+
<% elsif @root_category.view_type == "grid" || @root_category.view_type == "full grid" %>
|
|
130
|
+
<% if @selected_category_class.articles == [] %>
|
|
131
|
+
<br/><br/>
|
|
132
|
+
<center>
|
|
133
|
+
<h1>No content here</h1>
|
|
134
|
+
</center>
|
|
135
|
+
<% else %>
|
|
136
|
+
<% if @selected_category_class.articles != []%>
|
|
137
|
+
<div class="row">
|
|
138
|
+
<div class="card-columns">
|
|
139
|
+
<% if @selected_category_class.children != [] %>
|
|
140
|
+
<% @selected_category_class.children.each do |category| %>
|
|
141
|
+
<% if (category.articles != []) || (category.articles == [] && @current_user && @is_guider_admin ) %>
|
|
142
|
+
<div class="card" style="margin-bottom: 2vh;">
|
|
143
|
+
<%= link_to contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification), class: "grid-link" do %>
|
|
144
|
+
<% if category.header_image.attached? %>
|
|
145
|
+
<%= image_tag(main_app.url_for(category.header_image), class: "card-img-top") %>
|
|
146
|
+
<% end %>
|
|
147
|
+
<div class="card-body">
|
|
148
|
+
<h4 class="card-title"><%= category.classification %></h4>
|
|
149
|
+
</div>
|
|
150
|
+
<% end %>
|
|
151
|
+
</div>
|
|
152
|
+
<% end %>
|
|
153
|
+
<% end %>
|
|
154
|
+
<% end %>
|
|
155
|
+
<% @selected_category_class.articles.each do |article| %>
|
|
156
|
+
<div class="card" style="margin-bottom: 2vh;">
|
|
157
|
+
<% if article.header_image.attached? %>
|
|
158
|
+
<%= image_tag(main_app.url_for(article.header_image), class: "card-img-top") %>
|
|
159
|
+
<% else %>
|
|
160
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
161
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), class: "card-img-top") %>
|
|
162
|
+
<% end %>
|
|
163
|
+
<% end %>
|
|
164
|
+
<div class="card-body">
|
|
165
|
+
<% if @selected_category_class.parent.nil? %>
|
|
166
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
167
|
+
<% else %>
|
|
168
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
169
|
+
<% end %>
|
|
170
|
+
<p class="card-text"> <%= article.description[0..300].gsub(/\s\w+$/,'...') %></p>
|
|
171
|
+
<% if @selected_category_class.parent.nil? %>
|
|
172
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
173
|
+
<% else %>
|
|
174
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
175
|
+
<% end %>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
<% end %>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
<% end %>
|
|
182
|
+
<% end %>
|
|
183
|
+
<% elsif @root_category.view_type == "blog grid" %>
|
|
184
|
+
<div class="row">
|
|
185
|
+
<div class="col-sm-3 col-md-3" >
|
|
186
|
+
<% if @selected_category.nil? %>
|
|
187
|
+
<h6><%= link_to "Latest", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-active-links" %></h6>
|
|
188
|
+
<% else %>
|
|
189
|
+
<h6><%= link_to "Latest", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-links" %></h6>
|
|
190
|
+
<% end %>
|
|
191
|
+
<% @children_category.each do |category| %>
|
|
192
|
+
<% if (category.articles != []) || (category.articles == [] && @current_user && @is_guider_admin) %>
|
|
193
|
+
<% if category.classification == @selected_category_class.classification %>
|
|
194
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-active-links" %></h6>
|
|
195
|
+
<% else %>
|
|
196
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-links" %></h6>
|
|
197
|
+
<% end %>
|
|
198
|
+
<% if category.children.any? %>
|
|
199
|
+
<ul style="list-style-type: none;"><%= draw_tree(category) %></ul>
|
|
200
|
+
<% end %>
|
|
201
|
+
<% end %>
|
|
202
|
+
<% end %>
|
|
203
|
+
</div>
|
|
204
|
+
<div class="col-md-9 col-sm-9">
|
|
205
|
+
<% if @articles == [] %>
|
|
206
|
+
<br/><br/>
|
|
207
|
+
<center>
|
|
208
|
+
<h1>No Content Here</h1>
|
|
209
|
+
</center>
|
|
210
|
+
<% else %>
|
|
211
|
+
<div class="row">
|
|
212
|
+
<div class="card-columns">
|
|
213
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
214
|
+
<% @articles.each do |article| %>
|
|
215
|
+
<div class="card" style="margin-bottom: 2vh;">
|
|
216
|
+
<% if article.header_image.attached? %>
|
|
217
|
+
<%= image_tag(main_app.url_for(article.header_image), class: "card-img-top") %>
|
|
218
|
+
<% else %>
|
|
219
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
220
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), class: "card-img-top") %>
|
|
221
|
+
<% end %>
|
|
222
|
+
<% end %>
|
|
223
|
+
<div class="card-body">
|
|
224
|
+
<% if @selected_category_class.parent.nil? %>
|
|
225
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
226
|
+
<% else %>
|
|
227
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
228
|
+
<% end %>
|
|
229
|
+
<p class="card-text"> <%= article.description[0..300].gsub(/\s\w+$/,'...') %></p>
|
|
230
|
+
<% if @selected_category_class.parent.nil? %>
|
|
231
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
232
|
+
<% else %>
|
|
233
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
234
|
+
<% end %>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
<% end %>
|
|
238
|
+
<% else %>
|
|
239
|
+
<% @selected_category_class.articles.each do |article| %>
|
|
240
|
+
<div class="card" style="margin-bottom: 2vh;">
|
|
241
|
+
<% if article.header_image.attached? %>
|
|
242
|
+
<%= image_tag(main_app.url_for(article.header_image), class: "card-img-top") %>
|
|
243
|
+
<% else %>
|
|
244
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
245
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), class: "card-img-top") %>
|
|
246
|
+
<% end %>
|
|
247
|
+
<% end %>
|
|
248
|
+
<div class="card-body">
|
|
249
|
+
<% if @selected_category_class.parent.nil? %>
|
|
250
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
251
|
+
<% else %>
|
|
252
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
253
|
+
<% end %>
|
|
254
|
+
<p class="card-text"> <%= article.description[0..300].gsub(/\s\w+$/,'...') %></p>
|
|
255
|
+
<% if @selected_category_class.parent.nil? %>
|
|
256
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
257
|
+
<% else %>
|
|
258
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
259
|
+
<% end %>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
<% end %>
|
|
263
|
+
<% end %>
|
|
264
|
+
</div>
|
|
265
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
266
|
+
<center>
|
|
267
|
+
<h5><%= paginate @articles %></h5>
|
|
268
|
+
</center>
|
|
269
|
+
<% end %>
|
|
270
|
+
<% end %>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
<% elsif @root_category.view_type == "blog list" %>
|
|
274
|
+
<div class="row">
|
|
275
|
+
<div class="col-sm-3 col-md-3" >
|
|
276
|
+
<% if @selected_category.nil? %>
|
|
277
|
+
<h6><%= link_to "Latest", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-active-links" %></h6>
|
|
278
|
+
<% else %>
|
|
279
|
+
<h6><%= link_to "Latest", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-links" %></h6>
|
|
280
|
+
<% end %>
|
|
281
|
+
<% @children_category.each do |category| %>
|
|
282
|
+
<% if (category.articles != []) || (category.articles == [] && @current_user && @is_guider_admin) %>
|
|
283
|
+
<% if category.classification == @selected_category_class.classification %>
|
|
284
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-active-links" %></h6>
|
|
285
|
+
<% else %>
|
|
286
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-links" %></h6>
|
|
287
|
+
<% end %>
|
|
288
|
+
<% if category.children.any? %>
|
|
289
|
+
<ul style="list-style-type: none;"><%= draw_tree(category) %></ul>
|
|
290
|
+
<% end %>
|
|
291
|
+
<% end %>
|
|
292
|
+
<% end %>
|
|
293
|
+
</div>
|
|
294
|
+
<div class="col-md-9 col-sm-9">
|
|
295
|
+
<% if @articles == [] %>
|
|
296
|
+
<br/><br/>
|
|
297
|
+
<center>
|
|
298
|
+
<h1>No Content Here</h1>
|
|
299
|
+
</center>
|
|
300
|
+
<% else %>
|
|
301
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
302
|
+
<% @articles.each do |article| %>
|
|
303
|
+
<div class="card" style="margin-bottom: 10px;">
|
|
304
|
+
<div class="row no-gutters">
|
|
305
|
+
<div class="col-md-6">
|
|
306
|
+
<% if article.header_image.attached? %>
|
|
307
|
+
<%= image_tag(main_app.url_for(article.header_image), style: "height:100%;width:100%;") %>
|
|
308
|
+
<% else %>
|
|
309
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
310
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), style: "height:100%;width:100%;") %>
|
|
311
|
+
<% end %>
|
|
312
|
+
<% end %>
|
|
313
|
+
</div>
|
|
314
|
+
<div class="col-md-6">
|
|
315
|
+
<div class="card-body">
|
|
316
|
+
<% if @selected_category_class.parent.nil? %>
|
|
317
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
318
|
+
<% else %>
|
|
319
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
320
|
+
<% end %>
|
|
321
|
+
<p class="card-text"><%= article.description %></p>
|
|
322
|
+
<% if @selected_category_class.parent.nil? %>
|
|
323
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
324
|
+
<% else %>
|
|
325
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
326
|
+
<% end %>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
<% end %>
|
|
332
|
+
<% else %>
|
|
333
|
+
<% @selected_category_class.articles.each do |article| %>
|
|
334
|
+
<div class="card">
|
|
335
|
+
<div class="row no-gutters">
|
|
336
|
+
<div class="col-md-6">
|
|
337
|
+
<% if article.header_image.attached? %>
|
|
338
|
+
<%= image_tag(main_app.url_for(article.header_image), style: "height:100%;width:100%;") %>
|
|
339
|
+
<% else %>
|
|
340
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
341
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), style: "height:100%;width:100%;") %>
|
|
342
|
+
<% end %>
|
|
343
|
+
<% end %>
|
|
344
|
+
</div>
|
|
345
|
+
<div class="col-md-6">
|
|
346
|
+
<div class="card-body">
|
|
347
|
+
<% if @selected_category_class.parent.nil? %>
|
|
348
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
349
|
+
<% else %>
|
|
350
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
351
|
+
<% end %>
|
|
352
|
+
<p class="card-text"><%= article.description %></p>
|
|
353
|
+
<% if @selected_category_class.parent.nil? %>
|
|
354
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
355
|
+
<% else %>
|
|
356
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
357
|
+
<% end %>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
<% end %>
|
|
363
|
+
<% end %>
|
|
364
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
365
|
+
<center>
|
|
366
|
+
<h5><%= paginate @articles %></h5>
|
|
367
|
+
</center>
|
|
368
|
+
<% end %>
|
|
369
|
+
<% end %>
|
|
370
|
+
</div>
|
|
371
|
+
</div>
|
|
372
|
+
<% elsif @root_category.view_type == "ordered grid" %>
|
|
373
|
+
<div class="row">
|
|
374
|
+
<div class="col-sm-3 col-md-3" >
|
|
375
|
+
<% if @root_category.articles !=[] && @root_category.children != [] %>
|
|
376
|
+
<% if @selected_category.nil? %>
|
|
377
|
+
<h6><%= link_to "Home", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-active-links" %></h6>
|
|
378
|
+
<% else %>
|
|
379
|
+
<h6><%= link_to "Home", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-links" %></h6>
|
|
380
|
+
<% end %>
|
|
381
|
+
<% end %>
|
|
382
|
+
<% @children_category.each do |category| %>
|
|
383
|
+
<% if (category.articles != []) || (category.articles == [] && @current_user && @is_guider_admin) %>
|
|
384
|
+
<% if category.classification == @selected_category_class.classification %>
|
|
385
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-active-links" %></h6>
|
|
386
|
+
<% else %>
|
|
387
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-links" %></h6>
|
|
388
|
+
<% end %>
|
|
389
|
+
<% if category.children.any? %>
|
|
390
|
+
<ul style="list-style-type: none;"><%= draw_tree(category) %></ul>
|
|
391
|
+
<% end %>
|
|
392
|
+
<% end %>
|
|
393
|
+
<% end %>
|
|
394
|
+
</div>
|
|
395
|
+
<div class="col-sm-9 col-md-9">
|
|
396
|
+
<% if @selected_category_class.articles == [] %>
|
|
397
|
+
<center>
|
|
398
|
+
<h1>No Content Here</h1>
|
|
399
|
+
<% if @current_user && @is_guider_admin %>
|
|
400
|
+
<h3>Click on New Content to create Content</h3>
|
|
401
|
+
<% end %>
|
|
402
|
+
</center>
|
|
403
|
+
<% else %>
|
|
404
|
+
<div class="row">
|
|
405
|
+
<div class="card-columns">
|
|
406
|
+
<% @selected_category_class.articles.order(position: :asc).each do |article| %>
|
|
407
|
+
<div class="card" style="margin-bottom: 2vh;">
|
|
408
|
+
<% if article.header_image.attached? %>
|
|
409
|
+
<%= image_tag(main_app.url_for(article.header_image), class: "card-img-top") %>
|
|
410
|
+
<% else %>
|
|
411
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
412
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), class: "card-img-top") %>
|
|
413
|
+
<% end %>
|
|
414
|
+
<% end %>
|
|
415
|
+
<div class="card-body">
|
|
416
|
+
<% if @selected_category_class.parent.nil? %>
|
|
417
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
418
|
+
<% else %>
|
|
419
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
420
|
+
<% end %>
|
|
421
|
+
<p class="card-text"> <%= article.description[0..300].gsub(/\s\w+$/,'...') %></p>
|
|
422
|
+
<% if @selected_category_class.parent.nil? %>
|
|
423
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
424
|
+
<% else %>
|
|
425
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
426
|
+
<% end %>
|
|
427
|
+
<% if @current_user && @is_guider_admin %>
|
|
428
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
429
|
+
<%= link_to move_article_backward_path(article, root: @root_category.slug) do %>
|
|
430
|
+
<%= image_tag("guider_cms/up.png", height: "25") %>
|
|
431
|
+
<% end %>
|
|
432
|
+
<% else %>
|
|
433
|
+
<%= link_to move_article_backward_path(article, root: @root_category.slug, selected_category: @selected_category_class.slug) do %>
|
|
434
|
+
<%= image_tag("guider_cms/up.png", height: "25") %>
|
|
435
|
+
<% end %>
|
|
436
|
+
<% end %>
|
|
437
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
438
|
+
<%= link_to move_article_forward_path(article, root: @root_category.slug) do %>
|
|
439
|
+
<%= image_tag("guider_cms/down.png", height: "25") %>
|
|
440
|
+
<% end %>
|
|
441
|
+
<% else %>
|
|
442
|
+
<%= link_to move_article_forward_path(article, root: @root_category.slug, selected_category: @selected_category_class.slug) do %>
|
|
443
|
+
<%= image_tag("guider_cms/down.png", height: "25") %>
|
|
444
|
+
<% end %>
|
|
445
|
+
<% end %>
|
|
446
|
+
<% end %>
|
|
447
|
+
</div>
|
|
448
|
+
</div>
|
|
449
|
+
<% end %>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
<% end %>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
<% elsif @root_category.view_type == "ordered list" %>
|
|
456
|
+
<div class="row">
|
|
457
|
+
<div class="col-sm-3 col-md-3" >
|
|
458
|
+
<% if @root_category.articles !=[] && @root_category.children != [] %>
|
|
459
|
+
<% if @selected_category.nil? %>
|
|
460
|
+
<h6><%= link_to "Home", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-active-links" %></h6>
|
|
461
|
+
<% else %>
|
|
462
|
+
<h6><%= link_to "Home", content_new_back_path(root: @root_category.slug || @root_category.classification), class: "listing-links" %></h6>
|
|
463
|
+
<% end %>
|
|
464
|
+
<% end %>
|
|
465
|
+
<% @children_category.each do |category| %>
|
|
466
|
+
<% if (category.articles != []) || (category.articles == [] && @current_user && @is_guider_admin) %>
|
|
467
|
+
<% if category.classification == @selected_category_class.classification %>
|
|
468
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-active-links" %></h6>
|
|
469
|
+
<% else %>
|
|
470
|
+
<h6><%= link_to "#{category.classification}", contents_path(root: @root_category.slug || @root_category.classification, selected_category: category.slug || category.classification ), class: "listing-links" %></h6>
|
|
471
|
+
<% end %>
|
|
472
|
+
<% if category.children.any? %>
|
|
473
|
+
<ul style="list-style-type: none;"><%= draw_tree(category) %></ul>
|
|
474
|
+
<% end %>
|
|
475
|
+
<% end %>
|
|
476
|
+
<% end %>
|
|
477
|
+
</div>
|
|
478
|
+
<div class="col-sm-9 col-md-9">
|
|
479
|
+
<% if @selected_category_class.articles == [] %>
|
|
480
|
+
<center>
|
|
481
|
+
<h1>No Content Here</h1>
|
|
482
|
+
<% if @current_user && @is_guider_admin %>
|
|
483
|
+
<h3>Click on New Content to create Content</h3>
|
|
484
|
+
<% end %>
|
|
485
|
+
</center>
|
|
486
|
+
<% else %>
|
|
487
|
+
<% @selected_category_class.articles.order(position: :asc).each do |article| %>
|
|
488
|
+
<div class="card" style="margin-bottom: 10px;">
|
|
489
|
+
<div class="row no-gutters">
|
|
490
|
+
<div class="col-md-6">
|
|
491
|
+
<% if article.header_image.attached? %>
|
|
492
|
+
<%= image_tag(main_app.url_for(article.header_image), style: "height:100%;width:100%;") %>
|
|
493
|
+
<% else %>
|
|
494
|
+
<% if article.body.embeds.find{|embeds| embeds.image?} %>
|
|
495
|
+
<%= image_tag(main_app.url_for(article.body.embeds.find{|embeds| embeds.image?}), style: "height:100%;width:100%;") %>
|
|
496
|
+
<% end %>
|
|
497
|
+
<% end %>
|
|
498
|
+
</div>
|
|
499
|
+
<div class="col-md-6">
|
|
500
|
+
<div class="card-body">
|
|
501
|
+
<% if @selected_category_class.parent.nil? %>
|
|
502
|
+
<h4 class="card-title"><%= link_to "#{article.title}", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "grid-link" %></h4>
|
|
503
|
+
<% else %>
|
|
504
|
+
<h4 class="card-title"><%= link_to "#{article.title}", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "grid-link" %></h4>
|
|
505
|
+
<% end %>
|
|
506
|
+
<p class="card-text"><%= article.description %></p>
|
|
507
|
+
<% if @selected_category_class.parent.nil? %>
|
|
508
|
+
<%= link_to "Read Now", root_articles_path(article, root: @root_category.slug || @root_category.classification), class: "btn btn-outline-primary"%>
|
|
509
|
+
<% else %>
|
|
510
|
+
<%= link_to "Read Now", content_path(article, root: @root_category.slug || @root_category.classification, selected_category: @selected_category_class.slug || @selected_category_class.classification), class: "btn btn-outline-primary"%>
|
|
511
|
+
<% end %>
|
|
512
|
+
<% if @current_user && @is_guider_admin %>
|
|
513
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
514
|
+
<%= link_to move_article_backward_path(article, root: @root_category.slug) do %>
|
|
515
|
+
<%= image_tag("guider_cms/up.png", height: "25") %>
|
|
516
|
+
<% end %>
|
|
517
|
+
<% else %>
|
|
518
|
+
<%= link_to move_article_backward_path(article, root: @root_category.slug, selected_category: @selected_category_class.slug) do %>
|
|
519
|
+
<%= image_tag("guider_cms/up.png", height: "25") %>
|
|
520
|
+
<% end %>
|
|
521
|
+
<% end %>
|
|
522
|
+
<% if @selected_category_class.id == @root_category.id %>
|
|
523
|
+
<%= link_to move_article_forward_path(article, root: @root_category.slug) do %>
|
|
524
|
+
<%= image_tag("guider_cms/down.png", height: "25") %>
|
|
525
|
+
<% end %>
|
|
526
|
+
<% else %>
|
|
527
|
+
<%= link_to move_article_forward_path(article, root: @root_category.slug, selected_category: @selected_category_class.slug) do %>
|
|
528
|
+
<%= image_tag("guider_cms/down.png", height: "25") %>
|
|
529
|
+
<% end %>
|
|
530
|
+
<% end %>
|
|
531
|
+
<% end %>
|
|
532
|
+
</div>
|
|
533
|
+
</div>
|
|
534
|
+
</div>
|
|
535
|
+
</div>
|
|
536
|
+
<% end %>
|
|
537
|
+
</div>
|
|
538
|
+
<% end %>
|
|
539
|
+
</div>
|
|
540
|
+
<% end %>
|