phccodesnipper 1.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/app/controllers/phccodesnipper/application_controller.rb +17 -17
  4. data/app/controllers/phccodesnipper/script/snippets_controller.rb +11 -10
  5. data/app/controllers/phccodesnipper/script/urls_controller.rb +3 -3
  6. data/app/models/phccodesnipper/script/snippet.rb +23 -1
  7. data/app/models/phccodesnipper/script/url.rb +8 -0
  8. data/app/views/layouts/phccodesnipper/application.html.erb +6 -5
  9. data/app/views/layouts/phccodesnipper/components/backend/footer/_footer.html.erb +5 -5
  10. data/app/views/layouts/phccodesnipper/components/backend/sidebars/_side_menu.html.erb +43 -26
  11. data/app/views/phccodesnipper/script/snippets/_form.html.erb +20 -17
  12. data/app/views/phccodesnipper/script/snippets/edit.html.erb +17 -21
  13. data/app/views/phccodesnipper/script/snippets/index.html.erb +14 -21
  14. data/app/views/phccodesnipper/script/snippets/new.html.erb +18 -22
  15. data/app/views/phccodesnipper/script/snippets/show.html.erb +4 -16
  16. data/app/views/phccodesnipper/script/urls/_form.html.erb +14 -10
  17. data/app/views/phccodesnipper/script/urls/edit.html.erb +10 -6
  18. data/app/views/phccodesnipper/script/urls/index.html.erb +21 -29
  19. data/app/views/phccodesnipper/script/urls/new.html.erb +11 -7
  20. data/app/views/phccodesnipper/script/urls/show.html.erb +4 -16
  21. data/config/initializers/friendly_id.rb +107 -0
  22. data/config/routes.rb +4 -4
  23. data/db/migrate/20190508091330_create_phccodesnipper_script_snippets.rb +1 -1
  24. data/db/migrate/20190513040626_create_friendly_id_slugs.rb +21 -0
  25. data/lib/phccodesnipper/engine.rb +16 -15
  26. data/lib/phccodesnipper/version.rb +1 -1
  27. data/lib/phccodesnipper.rb +0 -1
  28. metadata +68 -75
  29. data/app/assets/javascripts/phccodesnipper/script/snippets.coffee +0 -3
  30. data/app/assets/stylesheets/phccodesnipper/script/snippets.scss +0 -3
  31. data/app/assets/stylesheets/scaffolds.scss +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a82f88fa003b9d91a0a7d50ab5f5fe49c67c3402582a36a7b7b9acd5692b63d9
4
- data.tar.gz: b29e4a7f0274366633c10cd3c1884a05315e8b4a96ee49a0d2319731068670e7
3
+ metadata.gz: 525bc2faea7ae7a5e9a5d4ffc4194d6c9cc640bac8dafdb35bdfbdf6d6b75ad8
4
+ data.tar.gz: f5010de1c32ba63fa4480b002dba50b61728a19ab9e4cc2f346fd6419a2ebaab
5
5
  SHA512:
6
- metadata.gz: 18127e7df47c31205d89248ae15eb289b94d7005ef4297a14a5a61e8c81f2e906cbaa64c77210981a7b2526d462d65fd79a2b49816634fed9229283b9c9303fc
7
- data.tar.gz: 8d6b08ff1196717002722e2042742fa71dbd84bee02a8eeff19f7aae092c276bc6a27340b921b9aa486c14379f2440fd33a1fc17fee57ed78fdae44fd49e8f80
6
+ metadata.gz: c4f8ed97d12a55bb89d871a5aa4f2cb00aa1e3db9a4dac7c7a12956c81959f8e654ef14a68b0cdc10e6832135ce8c0ff8ad75887287993bdd74304d4433ac441
7
+ data.tar.gz: 8fed315a5ccf8550101892e338d3808d8a4848431d1d02fa045f5fda862842dcb174adf8ff83548f92fbbedbb0a30bf0efeb67990c4d0def36373b29ab8d83e7
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012-2019 BradPotts - PHCNetco/PHCDevworks/PHCNetworks
1
+ Copyright 2012-2019 BradPotts - PHCNetCo/PHCDevworks/PHCNetworks
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,22 +1,22 @@
1
1
  module Phccodesnipper
2
- class ApplicationController < ActionController::Base
3
-
4
- # Security Filters
5
- protect_from_forgery with: :exception
6
-
7
- # Load Requried Helper Files
8
- helper Phccorehelpers::Engine.helpers
9
- helper Phcmenus::Engine.helpers
10
- helper Phctitleseo::Engine.helpers
11
- helper Phcnotifi::Engine.helpers
12
- helper Phcaccounts::Engine.helpers
13
-
14
- # Papertrail Whodunnit Username
15
- def user_for_paper_trail
16
- current_user ? current_user.username : 'Public user'
17
- end
2
+ class ApplicationController < ActionController::Base
18
3
 
19
- private
4
+ # Security Filters
5
+ protect_from_forgery with: :exception
20
6
 
7
+ # Load Requried Helper Files
8
+ helper Phccorehelpers::Engine.helpers
9
+ helper Phcmenus::Engine.helpers
10
+ helper Phctitleseo::Engine.helpers
11
+ helper Phcnotifi::Engine.helpers
12
+ helper Phcaccounts::Engine.helpers
13
+
14
+ # Papertrail Whodunnit Username
15
+ def user_for_paper_trail
16
+ current_user ? current_user.username : 'Public user'
21
17
  end
18
+
19
+ private
20
+
21
+ end
22
22
  end
@@ -2,43 +2,44 @@ require_dependency "phccodesnipper/application_controller"
2
2
 
3
3
  module Phccodesnipper
4
4
  class Script::SnippetsController < ApplicationController
5
+
5
6
  # Include Core Helpers, Security & Action Filters
6
7
  include Phccorehelpers::PhcpluginsHelper
7
8
  before_action :authenticate_user!
8
9
  before_action :set_script_snippet, only: [:show, :edit, :update, :destroy]
9
-
10
+
10
11
  # INDEX
11
12
  def index
12
13
  @script_snippets = Script::Snippet.all
13
14
  end
14
-
15
+
15
16
  # SHOW
16
17
  def show
17
18
  end
18
-
19
+
19
20
  # NEW
20
21
  def new
21
22
  @script_snippet = Script::Snippet.new
22
23
  end
23
-
24
+
24
25
  # EDIT
25
26
  def edit
26
27
  end
27
-
28
+
28
29
  # CREATE
29
30
  def create
30
31
  @script_snippet = Script::Snippet.new(script_snippet_params)
31
32
  if @script_snippet.save
32
- redirect_to @script_snippet, notice: 'Snippet was successfully created.'
33
+ redirect_to @script_snippet, :flash => { :success => 'Snippet was successfully created.' }
33
34
  else
34
35
  render :new
35
36
  end
36
37
  end
37
-
38
+
38
39
  # UPDATE
39
40
  def update
40
41
  if @script_snippet.update(script_snippet_params)
41
- redirect_to @script_snippet, notice: 'Snippet was successfully updated.'
42
+ redirect_to @script_snippet, :flash => { :success => 'Snippet was successfully updated.' }
42
43
  else
43
44
  render :edit
44
45
  end
@@ -47,7 +48,7 @@ module Phccodesnipper
47
48
  # DELETE
48
49
  def destroy
49
50
  @script_snippet.destroy
50
- redirect_to script_snippets_url, notice: 'Snippet was successfully destroyed.'
51
+ redirect_to script_snippets_url, :flash => { :error => 'Snippet was successfully destroyed.' }
51
52
  end
52
53
 
53
54
  private
@@ -59,7 +60,7 @@ module Phccodesnipper
59
60
 
60
61
  # Whitelist
61
62
  def script_snippet_params
62
- params.require(:script_snippet).permit(:snippet_tittle, :snippet_code)
63
+ params.require(:script_snippet).permit(:snippet_title, :snippet_code)
63
64
  end
64
65
 
65
66
  end
@@ -36,7 +36,7 @@ module Phccodesnipper
36
36
  @script_url = @script_snippet.urls.create(script_url_params)
37
37
  @script_url.user_id = current_user.id
38
38
  if @script_url.save
39
- redirect_to script_snippet_urls_path, notice: 'Script url was successfully created.'
39
+ redirect_to script_snippet_urls_path, :flash => { :success => 'Script url was successfully created.' }
40
40
  else
41
41
  render :new
42
42
  end
@@ -46,7 +46,7 @@ module Phccodesnipper
46
46
  def update
47
47
  @script_snippet = Script::Snippet.find(params[:snippet_id])
48
48
  if @script_url.update(script_url_params)
49
- redirect_to script_snippet_urls_path, notice: 'Script url was successfully updated.'
49
+ redirect_to script_snippet_urls_path, :flash => { :success => 'Script url was successfully updated.' }
50
50
  else
51
51
  render :edit
52
52
  end
@@ -57,7 +57,7 @@ module Phccodesnipper
57
57
  @script_snippet = Script::Snippet.find(params[:snippet_id])
58
58
  @script_url = @script_snippet.urls.find(params[:id])
59
59
  @script_url.destroy
60
- redirect_to script_snippet_urls_path, notice: 'Script url was successfully destroyed.'
60
+ redirect_to script_snippet_urls_path, :flash => { :error => 'Script url was successfully destroyed.' }
61
61
  end
62
62
 
63
63
  private
@@ -1,8 +1,30 @@
1
1
  module Phccodesnipper
2
2
  class Script::Snippet < ApplicationRecord
3
-
3
+
4
+ # Include Core Validations
5
+ include Phccorehelpers::Validations
6
+
7
+ # Clean URL Initialize
8
+ extend FriendlyId
9
+
4
10
  # Relationships
5
11
  has_many :urls, class_name: 'Phccodesnipper::Script::Url'
6
12
 
13
+ # Form Fields Validation
14
+ validates :snippet_title,
15
+ presence: true
16
+
17
+ validates :snippet_code,
18
+ presence: true
19
+
20
+ # Clean URL Define
21
+ friendly_id :phc_nice_url_slug, use: [:slugged, :finders]
22
+
23
+ def phc_nice_url_slug
24
+ [
25
+ [:snippet_title]
26
+ ]
27
+ end
28
+
7
29
  end
8
30
  end
@@ -1,8 +1,16 @@
1
1
  module Phccodesnipper
2
2
  class Script::Url < ApplicationRecord
3
3
 
4
+ # Include Core Validations
5
+ phc_domain_regx = URI::regexp(%w(http https))
6
+
4
7
  # Relationships
5
8
  belongs_to :snippet, class_name: 'Phccodesnipper::Script::Snippet'
6
9
 
10
+ # Form Fields Validation
11
+ validates :script_url,
12
+ presence: true,
13
+ format: { :with => phc_domain_regx, message: "Please follow this URL format http or https://www.**********.com" }
14
+
7
15
  end
8
16
  end
@@ -32,7 +32,7 @@
32
32
  <body>
33
33
 
34
34
  <!-- Page Container -->
35
- <div id="page-container" class="page-container fade page-sidebar-fixed page-header-fixed">
35
+ <div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
36
36
 
37
37
  <!-- Page Header -->
38
38
  <div id="header" class="header navbar-default">
@@ -49,6 +49,7 @@
49
49
 
50
50
  <!-- Page Content -->
51
51
  <div id="content" class="content">
52
+ <%= render 'phcnotifi/default/notifications' %>
52
53
  <%= yield %>
53
54
  </div>
54
55
  <!-- Page Content -->
@@ -68,10 +69,10 @@
68
69
 
69
70
  <!-- JavaScript Loader -->
70
71
  <script>
71
- $(document).ready(function() {
72
- App.init();
73
- });
74
- </script>
72
+ $(document).ready(function() {
73
+ App.init();
74
+ });
75
+ </script>
75
76
  <!-- JavaScript Loader -->
76
77
 
77
78
  </body>
@@ -1,11 +1,11 @@
1
1
  <!-- Footer -->
2
2
  <span class="float-left">
3
- &copy; 2012-<%= Time.now.year %> -
4
- <strong>PHC</strong>CodeSnipper -
5
- Engine v<%= Gem.loaded_specs["phccodesnipper"].version.to_s %>
3
+ 2012-<%= Time.now.year %> -
4
+ <strong>PHC</strong>CodeSnipper -
5
+ Engine v<%= Gem.loaded_specs["phccodesnipper"].version.to_s %>
6
6
  </span>
7
7
  <span class="float-right">
8
- Developed with <i class="fas fa-heart hanna_hearts"></i> by
9
- <a class="phcnet_copyright" href="https://phcdevworks.com/"><strong>PHC</strong>Devworks</a>
8
+ Developed with <i class="fas fa-heart hanna_hearts"></i> by
9
+ <a class="phcnet_copyright" href="https://phcdevworks.com/"><strong>PHC</strong>Devworks</a>
10
10
  </span>
11
11
  <!-- Footer -->
@@ -1,4 +1,4 @@
1
- <!-- Sidebar for Users and Admin -->
1
+ <!-- Sidebar for PHCDevworks Engines -->
2
2
  <div data-scrollbar="true" data-height="100%">
3
3
 
4
4
  <!-- Sidebar - User Profile Menu -->
@@ -34,11 +34,12 @@
34
34
  <% end %>
35
35
  </ul>
36
36
  <!-- Sidebar - User Profile Menu -->
37
+
37
38
  <!-- Sidebar - Sidebar Navigation -->
38
39
  <ul class="nav">
39
40
 
40
41
  <% if defined?phccodesnipper %>
41
- <!-- Sidebar - Sidebar Navigation - PHCPress(Pro) -->
42
+ <!-- Sidebar - Sidebar Navigation - PHCCodeSnipper -->
42
43
  <li class="nav-header">Code Snippets</li>
43
44
  <li class="has-sub">
44
45
  <a href="javascript:;">
@@ -51,11 +52,11 @@
51
52
  <li class="<%= phc_menus_active_controller('phccodesnipper/script/posts#new') %>"><%= link_to 'New Snippet', phccodesnipper.new_script_snippet_path %></li>
52
53
  </ul>
53
54
  </li>
54
- <!-- Sidebar - Sidebar Navigation - PHCPress(Pro) -->
55
+ <!-- Sidebar - Sidebar Navigation - PHCCodeSnipper -->
55
56
  <% end %>
56
57
 
57
58
  <% if defined?phcpress %>
58
- <!-- Sidebar - Sidebar Navigation - PHCPress(Pro) -->
59
+ <!-- Sidebar - Sidebar Navigation - PHCPress -->
59
60
  <li class="nav-header">Article Management</li>
60
61
  <li class="has-sub">
61
62
  <a href="javascript:;">
@@ -79,11 +80,11 @@
79
80
  <li class="<%= phc_menus_active_controller('phcpress/article/categories#new') %>"><%= link_to('New Category', phcpress.new_article_category_path) %></li>
80
81
  </ul>
81
82
  </li>
82
- <!-- Sidebar - Sidebar Navigation - PHCPress(Pro) -->
83
+ <!-- Sidebar - Sidebar Navigation - PHCPress -->
83
84
  <% end %>
84
85
 
85
86
  <% if defined?phcmembers %>
86
- <!-- Sidebar - Sidebar Navigation - PHCPress(Pro) -->
87
+ <!-- Sidebar - Sidebar Navigation - PHCMembers -->
87
88
  <li class="nav-header">Membership Manager</li>
88
89
  <li class="has-sub">
89
90
  <a href="javascript:;">
@@ -107,11 +108,11 @@
107
108
  <li class="<%= phc_menus_active_controller('phcmembers/directory/categories#new') %>"><%= link_to('New Directory Listing', phcmembers.new_directory_category_path) %></li>
108
109
  </ul>
109
110
  </li>
110
- <!-- Sidebar - Sidebar Navigation - PHCPress(Pro) -->
111
+ <!-- Sidebar - Sidebar Navigation - PHCMembers -->
111
112
  <% end %>
112
113
 
113
114
  <% if defined?phcscriptcdn %>
114
- <!-- Sidebar - Sidebar Navigation - PHCScriptCDN(Pro) -->
115
+ <!-- Sidebar - Sidebar Navigation - PHCScriptCDN -->
115
116
  <li class="nav-header">Script Management</li>
116
117
  <li class="has-sub">
117
118
  <a href="javascript:;">
@@ -121,7 +122,7 @@
121
122
  </a>
122
123
  <ul class="sub-menu">
123
124
  <li class="<%= phc_menus_active_controller('phcscriptcdn/script/listings') %>"><%= link_to "All Script Listings", phcscriptcdn.script_listings_path %></li>
124
- <li class="<%= phc_menus_active_controller('phcscriptcdn/script/listings#new') %>"><%= link_to "Add a New Listing", phcscriptcdn.new_script_listing_path %></li>
125
+ <li class="<%= phc_menus_active_controller('phcscriptcdn/script/listings#new') %>"><%= link_to "Add a New Listing", phcscriptcdn.new_script_listing_path %></li>
125
126
  </ul>
126
127
  </li>
127
128
  <li class="has-sub">
@@ -131,42 +132,58 @@
131
132
  <span>Script Extras</span>
132
133
  </a>
133
134
  <ul class="sub-menu">
134
- <li class="<%= phc_menus_active_controller('phcscriptcdn/script/authors') %>"><%= link_to "Script Authors", phcscriptcdn.script_authors_path %></li>
135
- <li class="<%= phc_menus_active_controller('phcscriptcdn/script/licences') %>"><%= link_to "Script Licences", phcscriptcdn.script_licences_path %></li>
136
- <li class="<%= phc_menus_active_controller('phcscriptcdn/script/extensions') %>"><%= link_to "Script Extensions", phcscriptcdn.script_extensions_path %></li>
135
+ <li class="<%= phc_menus_active_controller('phcscriptcdn/script/authors') %>"><%= link_to "Script Authors", phcscriptcdn.script_authors_path %></li>
136
+ <li class="<%= phc_menus_active_controller('phcscriptcdn/script/licences') %>"><%= link_to "Script Licences", phcscriptcdn.script_licences_path %></li>
137
+ <li class="<%= phc_menus_active_controller('phcscriptcdn/script/extensions') %>"><%= link_to "Script Extensions", phcscriptcdn.script_extensions_path %></li>
137
138
  <li class="<%= phc_menus_active_controller('phcscriptcdn/script/versions') %>"><%= link_to "Script Versions", phcscriptcdn.script_versions_path %></li>
138
139
  </ul>
139
140
  </li>
140
- <!-- Sidebar - Sidebar Navigation - PHCScriptCDN(Pro) -->
141
+ <!-- Sidebar - Sidebar Navigation - PHCScriptCDN -->
141
142
  <% end %>
142
143
 
143
- <% if current_user %>
144
- <!-- Sidebar - Sidebar Navigation - PHCAccounts -->
145
- <li class="nav-header">Account Settings</li>
144
+ <% if current_user && current_user.admin? %>
145
+ <!-- Sidebar - Sidebar Navigation - PHCAccounts Admin Options -->
146
+ <li class="nav-header">User Administration</li>
146
147
  <li class="has-sub">
147
148
  <a href="javascript:;">
148
149
  <b class="caret"></b>
149
150
  <i class="fas fa-user"></i>
150
- <span>Accounts Dashboard</span>
151
+ <span>Admin</span>
151
152
  </a>
152
153
  <ul class="sub-menu">
153
- <li class="<%= phc_menus_active_controller('phcaccounts/admin/edit') %>"><%= link_to('Settings', phcaccounts.edit_user_registration_path) %></li>
154
- <li class="<%= phc_menus_active_controller('phcaccounts/admin/new') %>"><%= link_to('Logout', phcaccounts.destroy_user_session_path, method: :delete) %></li>
154
+ <li class="<%= phc_menus_active_controller('phcaccounts/admin/users') %>"><%= link_to 'User List', phcaccounts.admin_users_path %></li>
155
155
  </ul>
156
156
  </li>
157
- <!-- Sidebar - Sidebar Navigation - PHCAccounts -->
157
+ <!-- Sidebar - Sidebar Navigation - PHCAccounts Admin Options -->
158
+ <% end %>
158
159
 
159
- <!-- Sidebar - Sidebar Minifier -->
160
- <li>
161
- <a href="javascript:;" class="sidebar-minify-btn" data-click="sidebar-minify">
162
- <i class="fa fa-angle-double-left"></i>
160
+ <% if current_user %>
161
+ <!-- Sidebar - Sidebar Navigation - PHCAccounts User Options -->
162
+ <li class="nav-header">Your Account</li>
163
+ <li class="has-sub">
164
+ <a href="javascript:;">
165
+ <b class="caret"></b>
166
+ <i class="fas fa-user"></i>
167
+ <span>Accounts Settings</span>
163
168
  </a>
169
+ <ul class="sub-menu">
170
+ <li class="<%= phc_menus_active_controller('phcaccounts/user/edit') %>"><%= link_to 'Settings', phcaccounts.edit_user_registration_path %></li>
171
+ <li class="<%= phc_menus_active_controller('phcaccounts/user/new') %>"><%= link_to 'Logout', phcaccounts.destroy_user_session_path, method: :delete %></li>
172
+ </ul>
164
173
  </li>
165
- <!-- Sidebar - Sidebar Minifier -->
174
+ <!-- Sidebar - Sidebar Navigation - PHCAccounts User Options -->
166
175
  <% end %>
167
176
 
177
+ <!-- Sidebar - Sidebar Minifier -->
178
+ <li>
179
+ <a href="javascript:;" class="sidebar-minify-btn" data-click="sidebar-minify">
180
+ <i class="fa fa-angle-double-left"></i>
181
+ </a>
182
+ </li>
183
+ <!-- Sidebar - Sidebar Minifier -->
184
+
168
185
  </ul>
169
186
  <!-- Sidebar - Sidebar Navigation -->
170
187
 
171
188
  </div>
172
- <!-- Sidebar for Users and Admin -->
189
+ <!-- Sidebar for PHCDevworks Engines -->
@@ -1,23 +1,26 @@
1
1
  <!-- Form - Script - Snippets -->
2
2
  <%= form_with(model: script_snippet, local: true) do |form| %>
3
3
 
4
- <!-- Render Validation -->
5
- <%= render 'phcnotifi/validations', :object => @script_snippet %>
6
- <!-- Render Validation -->
7
-
8
- <div class="form-group field_with_error">
9
- <%= form.label :snippet_tittle, "Snippet Tittle" %>
10
- <%= form.text_field :snippet_tittle, class: 'form-control', placeholder: 'Snippet Tittle' %>
11
- </div>
12
-
13
- <div class="form-group field_with_error">
14
- <%= form.label :snippet_code, "Code Snippet" %>
15
- <%= form.text_area :snippet_code, class: 'form-control', placeholder: 'Code Snippet' %>
16
- </div>
17
-
18
- <div class="actions">
19
- <%= form.submit class: "btn btn-primary" %>
20
- </div>
4
+ <!-- PHCNotifi Render Validation -->
5
+ <%= render 'phcnotifi/default/validations', :object => @script_snippet %>
6
+ <!-- PHCNotifi Render Validation -->
7
+
8
+ <!-- Form Input Fields -->
9
+ <div class="form-group field_with_errors">
10
+ <%= form.label :snippet_title, "Snippet Title" %>
11
+ <%= form.text_field :snippet_title, class: 'form-control', placeholder: 'Snippet Title' %>
12
+ </div>
13
+ <div class="form-group field_with_errors">
14
+ <%= form.label :snippet_code, "Code Snippet" %>
15
+ <%= form.text_area :snippet_code, class: 'form-control', placeholder: 'Code Snippet', rows: '10' %>
16
+ </div>
17
+ <!-- Form Input Fields -->
18
+
19
+ <!-- Form Submition Button -->
20
+ <div class="actions">
21
+ <%= form.submit class: "btn btn-primary" %>
22
+ </div>
23
+ <!-- For Submition Button -->
21
24
 
22
25
  <% end %>
23
26
  <!-- Form - Script - Snippets -->