phccodesnipper 1.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/app/controllers/phccodesnipper/application_controller.rb +17 -17
- data/app/controllers/phccodesnipper/script/snippets_controller.rb +11 -10
- data/app/controllers/phccodesnipper/script/urls_controller.rb +3 -3
- data/app/models/phccodesnipper/script/snippet.rb +23 -1
- data/app/models/phccodesnipper/script/url.rb +8 -0
- data/app/views/layouts/phccodesnipper/application.html.erb +6 -5
- data/app/views/layouts/phccodesnipper/components/backend/footer/_footer.html.erb +5 -5
- data/app/views/layouts/phccodesnipper/components/backend/sidebars/_side_menu.html.erb +43 -26
- data/app/views/phccodesnipper/script/snippets/_form.html.erb +20 -17
- data/app/views/phccodesnipper/script/snippets/edit.html.erb +17 -21
- data/app/views/phccodesnipper/script/snippets/index.html.erb +14 -21
- data/app/views/phccodesnipper/script/snippets/new.html.erb +18 -22
- data/app/views/phccodesnipper/script/snippets/show.html.erb +4 -16
- data/app/views/phccodesnipper/script/urls/_form.html.erb +14 -10
- data/app/views/phccodesnipper/script/urls/edit.html.erb +10 -6
- data/app/views/phccodesnipper/script/urls/index.html.erb +21 -29
- data/app/views/phccodesnipper/script/urls/new.html.erb +11 -7
- data/app/views/phccodesnipper/script/urls/show.html.erb +4 -16
- data/config/initializers/friendly_id.rb +107 -0
- data/config/routes.rb +4 -4
- data/db/migrate/20190508091330_create_phccodesnipper_script_snippets.rb +1 -1
- data/db/migrate/20190513040626_create_friendly_id_slugs.rb +21 -0
- data/lib/phccodesnipper/engine.rb +16 -15
- data/lib/phccodesnipper/version.rb +1 -1
- data/lib/phccodesnipper.rb +0 -1
- metadata +68 -75
- data/app/assets/javascripts/phccodesnipper/script/snippets.coffee +0 -3
- data/app/assets/stylesheets/phccodesnipper/script/snippets.scss +0 -3
- data/app/assets/stylesheets/scaffolds.scss +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 525bc2faea7ae7a5e9a5d4ffc4194d6c9cc640bac8dafdb35bdfbdf6d6b75ad8
|
4
|
+
data.tar.gz: f5010de1c32ba63fa4480b002dba50b61728a19ab9e4cc2f346fd6419a2ebaab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4f8ed97d12a55bb89d871a5aa4f2cb00aa1e3db9a4dac7c7a12956c81959f8e654ef14a68b0cdc10e6832135ce8c0ff8ad75887287993bdd74304d4433ac441
|
7
|
+
data.tar.gz: 8fed315a5ccf8550101892e338d3808d8a4848431d1d02fa045f5fda862842dcb174adf8ff83548f92fbbedbb0a30bf0efeb67990c4d0def36373b29ab8d83e7
|
data/MIT-LICENSE
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
module Phccodesnipper
|
2
|
-
|
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
|
-
|
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,
|
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,
|
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,
|
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(:
|
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,
|
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,
|
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,
|
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="
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
9
|
-
|
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
|
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 -
|
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 -
|
55
|
+
<!-- Sidebar - Sidebar Navigation - PHCCodeSnipper -->
|
55
56
|
<% end %>
|
56
57
|
|
57
58
|
<% if defined?phcpress %>
|
58
|
-
<!-- Sidebar - Sidebar Navigation - PHCPress
|
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
|
83
|
+
<!-- Sidebar - Sidebar Navigation - PHCPress -->
|
83
84
|
<% end %>
|
84
85
|
|
85
86
|
<% if defined?phcmembers %>
|
86
|
-
<!-- Sidebar - Sidebar Navigation -
|
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 -
|
111
|
+
<!-- Sidebar - Sidebar Navigation - PHCMembers -->
|
111
112
|
<% end %>
|
112
113
|
|
113
114
|
<% if defined?phcscriptcdn %>
|
114
|
-
<!-- Sidebar - Sidebar Navigation - PHCScriptCDN
|
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
|
-
|
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
|
-
|
135
|
-
|
136
|
-
|
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
|
141
|
+
<!-- Sidebar - Sidebar Navigation - PHCScriptCDN -->
|
141
142
|
<% end %>
|
142
143
|
|
143
|
-
<% if current_user %>
|
144
|
-
<!-- Sidebar - Sidebar Navigation - PHCAccounts -->
|
145
|
-
<li class="nav-header">
|
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>
|
151
|
+
<span>Admin</span>
|
151
152
|
</a>
|
152
153
|
<ul class="sub-menu">
|
153
|
-
<li class="<%= phc_menus_active_controller('phcaccounts/admin/
|
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
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
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
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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 -->
|