phccodesnipper 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/phccodesnipper/script/snippets_controller.rb +4 -3
- data/app/controllers/phccodesnipper/script/urls_controller.rb +3 -3
- data/app/models/phccodesnipper/script/snippet.rb +25 -0
- data/app/models/phccodesnipper/script/url.rb +9 -0
- data/app/views/layouts/phccodesnipper/application.html.erb +6 -5
- data/app/views/layouts/phccodesnipper/components/backend/footer/_footer.html.erb +1 -1
- data/app/views/layouts/phccodesnipper/components/backend/sidebars/_side_menu.html.erb +45 -28
- data/app/views/phccodesnipper/script/snippets/_form.html.erb +4 -4
- data/app/views/phccodesnipper/script/urls/_form.html.erb +3 -3
- data/config/initializers/friendly_id.rb +107 -0
- data/db/migrate/20190513040626_create_friendly_id_slugs.rb +21 -0
- data/lib/phccodesnipper/engine.rb +1 -0
- data/lib/phccodesnipper/version.rb +1 -1
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3cfec77367132630570e0ca23e89cee35526f25a3fd85f83e0d18fb4f029c0c
|
4
|
+
data.tar.gz: 880c5cb401453f1d59bc84b5a9d59b7072fc4f132552f9e32817f27fc66cfaf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e03ff452b20a3694a0514781cf039cb5cf5ba748b72b3f0b766c23cf2e6b40ea24e50a812437921f46278cbd5f78fcd6fb831d87ddfb778dea4bf75bcb3fa7
|
7
|
+
data.tar.gz: 9823a4e2a3da3dbd35b219f5b3012b5905b881a14221468cf4792c18e87bc1e74bf3bd0369278bb261e812df30b18c94f82550d5bc8049f0edc025cb05b96ffe
|
@@ -2,6 +2,7 @@ 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!
|
@@ -29,7 +30,7 @@ module Phccodesnipper
|
|
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
|
@@ -38,7 +39,7 @@ module Phccodesnipper
|
|
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
|
@@ -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,33 @@
|
|
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'
|
12
|
+
|
13
|
+
# Form Fields Validation
|
14
|
+
validates :snippet_tittle,
|
15
|
+
presence: true,
|
16
|
+
length: { minimum: 2 }
|
17
|
+
|
18
|
+
validates :snippet_code,
|
19
|
+
presence: true,
|
20
|
+
length: { minimum: 2 }
|
21
|
+
|
22
|
+
# Clean URL Define
|
23
|
+
friendly_id :phc_nice_url_slug, use: [:slugged, :finders]
|
24
|
+
|
25
|
+
# Define for Multiple Records
|
26
|
+
def phc_nice_url_slug
|
27
|
+
[
|
28
|
+
[:snippet_tittle]
|
29
|
+
]
|
30
|
+
end
|
6
31
|
|
7
32
|
end
|
8
33
|
end
|
@@ -1,8 +1,17 @@
|
|
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
|
+
length: { minimum: 5 },
|
14
|
+
format: { :with => phc_domain_regx, message: "Please follow this URL format http or https://www.**********.com" }
|
15
|
+
|
7
16
|
end
|
8
17
|
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,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 -->
|
142
|
+
<% end %>
|
143
|
+
|
144
|
+
<% if current_user && current_user.admin? %>
|
145
|
+
<!-- Sidebar - Sidebar Navigation - PHCAccounts Admin Options -->
|
146
|
+
<li class="nav-header">User Administration</li>
|
147
|
+
<li class="has-sub">
|
148
|
+
<a href="javascript:;">
|
149
|
+
<b class="caret"></b>
|
150
|
+
<i class="fas fa-user"></i>
|
151
|
+
<span>Admin</span>
|
152
|
+
</a>
|
153
|
+
<ul class="sub-menu">
|
154
|
+
<li class="<%= phc_menus_active_controller('phcaccounts/admin/users') %>"><%= link_to 'User List', phcaccounts.admin_users_path %></li>
|
155
|
+
</ul>
|
156
|
+
</li>
|
157
|
+
<!-- Sidebar - Sidebar Navigation - PHCAccounts Admin Options -->
|
141
158
|
<% end %>
|
142
159
|
|
143
160
|
<% if current_user %>
|
144
|
-
<!-- Sidebar - Sidebar Navigation - PHCAccounts -->
|
145
|
-
<li class="nav-header">Account
|
161
|
+
<!-- Sidebar - Sidebar Navigation - PHCAccounts User Options -->
|
162
|
+
<li class="nav-header">Your Account</li>
|
146
163
|
<li class="has-sub">
|
147
164
|
<a href="javascript:;">
|
148
165
|
<b class="caret"></b>
|
149
166
|
<i class="fas fa-user"></i>
|
150
|
-
<span>Accounts
|
167
|
+
<span>Accounts Settings</span>
|
151
168
|
</a>
|
152
169
|
<ul class="sub-menu">
|
153
|
-
<li class="<%= phc_menus_active_controller('phcaccounts/
|
154
|
-
<li class="<%= phc_menus_active_controller('phcaccounts/
|
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>
|
155
172
|
</ul>
|
156
173
|
</li>
|
157
|
-
<!-- Sidebar - Sidebar Navigation - PHCAccounts -->
|
158
|
-
|
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>
|
163
|
-
</a>
|
164
|
-
</li>
|
165
|
-
<!-- Sidebar - Sidebar Minifier -->
|
174
|
+
<!-- Sidebar - Sidebar Navigation - PHCAccounts User Options -->
|
166
175
|
<% end %>
|
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 -->
|
167
184
|
|
168
185
|
</ul>
|
169
186
|
<!-- Sidebar - Sidebar Navigation -->
|
170
187
|
|
171
188
|
</div>
|
172
|
-
<!-- Sidebar for
|
189
|
+
<!-- Sidebar for PHCDevworks Engines -->
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<!-- Form - Script - Snippets -->
|
2
2
|
<%= form_with(model: script_snippet, local: true) do |form| %>
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
<!-- PHCNotifi Render Validation -->
|
5
|
+
<%= render 'phcnotifi/default/validations', :object => @script_snippet %>
|
6
|
+
<!-- PHCNotifi Render Validation -->
|
7
7
|
|
8
8
|
<div class="form-group field_with_error">
|
9
9
|
<%= form.label :snippet_tittle, "Snippet Tittle" %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<div class="form-group field_with_error">
|
14
14
|
<%= form.label :snippet_code, "Code Snippet" %>
|
15
|
-
<%= form.text_area :snippet_code, class: 'form-control', placeholder: 'Code Snippet' %>
|
15
|
+
<%= form.text_area :snippet_code, class: 'form-control', placeholder: 'Code Snippet', rows: '10' %>
|
16
16
|
</div>
|
17
17
|
|
18
18
|
<div class="actions">
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<!-- Form - Script - Url -->
|
2
2
|
<%= form_with(model: [ @script_snippet, @script_url], url: form_url, local: true) do |form| %>
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
<!-- PHCNotifi Render Validation -->
|
5
|
+
<%= render 'phcnotifi/default/validations', :object => @script_url %>
|
6
|
+
<!-- PHCNotifi Render Validation -->
|
7
7
|
|
8
8
|
<div class="form-group field_with_errors">
|
9
9
|
<%= form.label :script_url %>
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# FriendlyId Global Configuration
|
2
|
+
#
|
3
|
+
# Use this to set up shared configuration options for your entire application.
|
4
|
+
# Any of the configuration options shown here can also be applied to single
|
5
|
+
# models by passing arguments to the `friendly_id` class method or defining
|
6
|
+
# methods in your model.
|
7
|
+
#
|
8
|
+
# To learn more, check out the guide:
|
9
|
+
#
|
10
|
+
# http://norman.github.io/friendly_id/file.Guide.html
|
11
|
+
|
12
|
+
FriendlyId.defaults do |config|
|
13
|
+
# ## Reserved Words
|
14
|
+
#
|
15
|
+
# Some words could conflict with Rails's routes when used as slugs, or are
|
16
|
+
# undesirable to allow as slugs. Edit this list as needed for your app.
|
17
|
+
config.use :reserved
|
18
|
+
|
19
|
+
config.reserved_words = %w(new edit index session login logout users admin
|
20
|
+
stylesheets assets javascripts images)
|
21
|
+
|
22
|
+
# This adds an option to treat reserved words as conflicts rather than exceptions.
|
23
|
+
# When there is no good candidate, a UUID will be appended, matching the existing
|
24
|
+
# conflict behavior.
|
25
|
+
|
26
|
+
# config.treat_reserved_as_conflict = true
|
27
|
+
|
28
|
+
# ## Friendly Finders
|
29
|
+
#
|
30
|
+
# Uncomment this to use friendly finders in all models. By default, if
|
31
|
+
# you wish to find a record by its friendly id, you must do:
|
32
|
+
#
|
33
|
+
# MyModel.friendly.find('foo')
|
34
|
+
#
|
35
|
+
# If you uncomment this, you can do:
|
36
|
+
#
|
37
|
+
# MyModel.find('foo')
|
38
|
+
#
|
39
|
+
# This is significantly more convenient but may not be appropriate for
|
40
|
+
# all applications, so you must explicity opt-in to this behavior. You can
|
41
|
+
# always also configure it on a per-model basis if you prefer.
|
42
|
+
#
|
43
|
+
# Something else to consider is that using the :finders addon boosts
|
44
|
+
# performance because it will avoid Rails-internal code that makes runtime
|
45
|
+
# calls to `Module.extend`.
|
46
|
+
#
|
47
|
+
# config.use :finders
|
48
|
+
#
|
49
|
+
# ## Slugs
|
50
|
+
#
|
51
|
+
# Most applications will use the :slugged module everywhere. If you wish
|
52
|
+
# to do so, uncomment the following line.
|
53
|
+
#
|
54
|
+
# config.use :slugged
|
55
|
+
#
|
56
|
+
# By default, FriendlyId's :slugged addon expects the slug column to be named
|
57
|
+
# 'slug', but you can change it if you wish.
|
58
|
+
#
|
59
|
+
# config.slug_column = 'slug'
|
60
|
+
#
|
61
|
+
# By default, slug has no size limit, but you can change it if you wish.
|
62
|
+
#
|
63
|
+
# config.slug_limit = 255
|
64
|
+
#
|
65
|
+
# When FriendlyId can not generate a unique ID from your base method, it appends
|
66
|
+
# a UUID, separated by a single dash. You can configure the character used as the
|
67
|
+
# separator. If you're upgrading from FriendlyId 4, you may wish to replace this
|
68
|
+
# with two dashes.
|
69
|
+
#
|
70
|
+
# config.sequence_separator = '-'
|
71
|
+
#
|
72
|
+
# Note that you must use the :slugged addon **prior** to the line which
|
73
|
+
# configures the sequence separator, or else FriendlyId will raise an undefined
|
74
|
+
# method error.
|
75
|
+
#
|
76
|
+
# ## Tips and Tricks
|
77
|
+
#
|
78
|
+
# ### Controlling when slugs are generated
|
79
|
+
#
|
80
|
+
# As of FriendlyId 5.0, new slugs are generated only when the slug field is
|
81
|
+
# nil, but if you're using a column as your base method can change this
|
82
|
+
# behavior by overriding the `should_generate_new_friendly_id?` method that
|
83
|
+
# FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
|
84
|
+
# more like 4.0.
|
85
|
+
# Note: Use(include) Slugged module in the config if using the anonymous module.
|
86
|
+
# If you have `friendly_id :name, use: slugged` in the model, Slugged module
|
87
|
+
# is included after the anonymous module defined in the initializer, so it
|
88
|
+
# overrides the `should_generate_new_friendly_id?` method from the anonymous module.
|
89
|
+
#
|
90
|
+
# config.use :slugged
|
91
|
+
# config.use Module.new {
|
92
|
+
# def should_generate_new_friendly_id?
|
93
|
+
# slug.blank? || <your_column_name_here>_changed?
|
94
|
+
# end
|
95
|
+
# }
|
96
|
+
#
|
97
|
+
# FriendlyId uses Rails's `parameterize` method to generate slugs, but for
|
98
|
+
# languages that don't use the Roman alphabet, that's not usually sufficient.
|
99
|
+
# Here we use the Babosa library to transliterate Russian Cyrillic slugs to
|
100
|
+
# ASCII. If you use this, don't forget to add "babosa" to your Gemfile.
|
101
|
+
#
|
102
|
+
# config.use Module.new {
|
103
|
+
# def normalize_friendly_id(text)
|
104
|
+
# text.to_slug.normalize! :transliterations => [:russian, :latin]
|
105
|
+
# end
|
106
|
+
# }
|
107
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIGRATION_CLASS =
|
2
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
3
|
+
ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
4
|
+
else
|
5
|
+
ActiveRecord::Migration
|
6
|
+
end
|
7
|
+
|
8
|
+
class CreateFriendlyIdSlugs < MIGRATION_CLASS
|
9
|
+
def change
|
10
|
+
create_table :friendly_id_slugs do |t|
|
11
|
+
t.string :slug, :null => false
|
12
|
+
t.integer :sluggable_id, :null => false
|
13
|
+
t.string :sluggable_type, :limit => 50
|
14
|
+
t.string :scope
|
15
|
+
t.datetime :created_at
|
16
|
+
end
|
17
|
+
add_index :friendly_id_slugs, [:sluggable_type, :sluggable_id]
|
18
|
+
add_index :friendly_id_slugs, [:slug, :sluggable_type], length: { slug: 140, sluggable_type: 50 }
|
19
|
+
add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phccodesnipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BradPotts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -232,14 +232,14 @@ dependencies:
|
|
232
232
|
requirements:
|
233
233
|
- - "~>"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version: '
|
235
|
+
version: '5.2'
|
236
236
|
type: :runtime
|
237
237
|
prerelease: false
|
238
238
|
version_requirements: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
240
|
- - "~>"
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version: '
|
242
|
+
version: '5.2'
|
243
243
|
- !ruby/object:Gem::Dependency
|
244
244
|
name: phcmenus
|
245
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -260,14 +260,14 @@ dependencies:
|
|
260
260
|
requirements:
|
261
261
|
- - "~>"
|
262
262
|
- !ruby/object:Gem::Version
|
263
|
-
version: '
|
263
|
+
version: '47.2'
|
264
264
|
type: :runtime
|
265
265
|
prerelease: false
|
266
266
|
version_requirements: !ruby/object:Gem::Requirement
|
267
267
|
requirements:
|
268
268
|
- - "~>"
|
269
269
|
- !ruby/object:Gem::Version
|
270
|
-
version: '
|
270
|
+
version: '47.2'
|
271
271
|
- !ruby/object:Gem::Dependency
|
272
272
|
name: phctitleseo
|
273
273
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,6 +282,20 @@ dependencies:
|
|
282
282
|
- - "~>"
|
283
283
|
- !ruby/object:Gem::Version
|
284
284
|
version: '46.0'
|
285
|
+
- !ruby/object:Gem::Dependency
|
286
|
+
name: i18n
|
287
|
+
requirement: !ruby/object:Gem::Requirement
|
288
|
+
requirements:
|
289
|
+
- - "~>"
|
290
|
+
- !ruby/object:Gem::Version
|
291
|
+
version: '1.6'
|
292
|
+
type: :runtime
|
293
|
+
prerelease: false
|
294
|
+
version_requirements: !ruby/object:Gem::Requirement
|
295
|
+
requirements:
|
296
|
+
- - "~>"
|
297
|
+
- !ruby/object:Gem::Version
|
298
|
+
version: '1.6'
|
285
299
|
- !ruby/object:Gem::Dependency
|
286
300
|
name: friendly_id
|
287
301
|
requirement: !ruby/object:Gem::Requirement
|
@@ -456,14 +470,14 @@ dependencies:
|
|
456
470
|
requirements:
|
457
471
|
- - "~>"
|
458
472
|
- !ruby/object:Gem::Version
|
459
|
-
version: '
|
473
|
+
version: '38.2'
|
460
474
|
type: :runtime
|
461
475
|
prerelease: false
|
462
476
|
version_requirements: !ruby/object:Gem::Requirement
|
463
477
|
requirements:
|
464
478
|
- - "~>"
|
465
479
|
- !ruby/object:Gem::Version
|
466
|
-
version: '
|
480
|
+
version: '38.2'
|
467
481
|
- !ruby/object:Gem::Dependency
|
468
482
|
name: sqlite3
|
469
483
|
requirement: !ruby/object:Gem::Requirement
|
@@ -666,9 +680,11 @@ files:
|
|
666
680
|
- app/views/phccodesnipper/script/urls/index.html.erb
|
667
681
|
- app/views/phccodesnipper/script/urls/new.html.erb
|
668
682
|
- app/views/phccodesnipper/script/urls/show.html.erb
|
683
|
+
- config/initializers/friendly_id.rb
|
669
684
|
- config/routes.rb
|
670
685
|
- db/migrate/20190502060733_create_phccodesnipper_script_urls.rb
|
671
686
|
- db/migrate/20190508091330_create_phccodesnipper_script_snippets.rb
|
687
|
+
- db/migrate/20190513040626_create_friendly_id_slugs.rb
|
672
688
|
- lib/phccodesnipper.rb
|
673
689
|
- lib/phccodesnipper/engine.rb
|
674
690
|
- lib/phccodesnipper/version.rb
|