vidibus-permalink 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/permalink.rb +12 -5
- data/lib/vidibus/permalink/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad640ae4ba877c077d2bc5fce555b80e53ce0031
|
4
|
+
data.tar.gz: 5f19f0c8dccc457029cdef8a96165d6ffe08317b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0248ed6a753a7f733ee3427e9e06c247a49c0acf571caa11aad00bbc94cda1551cda1f362408151b68181e0ab30a58d087ca07b367c0f297d82b413077cd957e'
|
7
|
+
data.tar.gz: 5f9554a661f83a7ec6c7f38622676f8a2824c8dd49a4337d872165c75dd516667368bfcf2601dfc9abb7bc2c8ae38c17a226bea8f802cf08c5b9e0bb96b7e23a
|
data/app/models/permalink.rb
CHANGED
@@ -66,9 +66,15 @@ class Permalink
|
|
66
66
|
|
67
67
|
# Scope method for finding Permalinks for given value.
|
68
68
|
# The value will be sanitized.
|
69
|
-
def for_value(value,
|
70
|
-
|
71
|
-
|
69
|
+
def for_value(value, do_sanitize = true)
|
70
|
+
if do_sanitize
|
71
|
+
self.or([
|
72
|
+
{value: /^#{sanitize(value)}(-\d+)?$/},
|
73
|
+
{value: /^#{sanitize(value, true)}(-\d+)?$/}
|
74
|
+
])
|
75
|
+
else
|
76
|
+
where(value: /^#{value}(-\d+)?$/)
|
77
|
+
end
|
72
78
|
end
|
73
79
|
|
74
80
|
def for_scope(scope)
|
@@ -83,9 +89,10 @@ class Permalink
|
|
83
89
|
|
84
90
|
# Sanitizes string: Remove stopwords and format as permalink.
|
85
91
|
# See Vidibus::CoreExtensions::String for details.
|
86
|
-
def sanitize(string)
|
92
|
+
def sanitize(string, keep_stopwords = false)
|
87
93
|
return if string.blank?
|
88
|
-
remove_stopwords(string)
|
94
|
+
string = remove_stopwords(string) unless keep_stopwords
|
95
|
+
string.permalink
|
89
96
|
end
|
90
97
|
|
91
98
|
def scope_list(scope)
|