jquery-friendly_id-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.gitmodules +3 -0
- data/Gemfile +3 -0
- data/History.md +5 -0
- data/License.txt +2 -0
- data/README.md +32 -0
- data/Rakefile +232 -0
- data/VERSIONS.md +5 -0
- data/app/assets/javascripts/jquery-friendly_id.coffee +1 -0
- data/app/assets/javascripts/jquery-friendly_id.js +1 -0
- data/app/assets/javascripts/jquery-friendly_id/.gitignore +1 -0
- data/app/assets/javascripts/jquery-friendly_id/jquery.friendly_id.coffee +70 -0
- data/app/assets/javascripts/jquery-friendly_id/jquery.friendly_id.js +79 -0
- data/lib/jquery-friendly_id-rails.rb +1 -0
- data/lib/jquery/friendly_id/rails.rb +2 -0
- data/lib/jquery/friendly_id/rails/engine.rb +8 -0
- data/lib/jquery/friendly_id/rails/version.rb +8 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 72861d06dfb06197ea55756ecc29465d96c772f7
|
4
|
+
data.tar.gz: 139bda41951b2d59707167aac698055fea00a5a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1547f3e7f1d6bf5cbcffc455ab7d8e49c48ef0ba7a7537ddf4cc5a21a9c852f58f3194359f37bde14e8d584543be300ffb2c3ad5af5e923a2ced02150b6034e
|
7
|
+
data.tar.gz: 9d377de3b7db4f2820fd592abdb33d4428cd5e75d904c8cd65f0589fa1d638735d0e0845c7a3f695c84948ff60b9e2729787552e6e4ca5264e59e99bbb440ad9
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
data/History.md
ADDED
data/License.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# jQuery FriendlyId Rails
|
2
|
+
|
3
|
+
This library was inspired by [norman/friendly_id](http://github.com/norman/friendly_id), originally developed for **Rails ActiveRecord**.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
You can simple get the slug of string:
|
7
|
+
|
8
|
+
```javascript
|
9
|
+
$.friendly_id('Café is good');
|
10
|
+
// It will return "cafe-is-good".
|
11
|
+
```
|
12
|
+
|
13
|
+
If you would like, you can change the separator:
|
14
|
+
|
15
|
+
```javascript
|
16
|
+
$.friendly_id('Café is good', '_');
|
17
|
+
// It will return "cafe_is_good".
|
18
|
+
```
|
19
|
+
|
20
|
+
And finally, you can dynamically generate the slug:
|
21
|
+
|
22
|
+
```javascript
|
23
|
+
$('.input').on('keyup', function() {
|
24
|
+
var slug = $.friendly_id($(this).val());
|
25
|
+
return $('.output').val(slug);
|
26
|
+
});
|
27
|
+
```
|
28
|
+
|
29
|
+
## Thanks
|
30
|
+
- **CakePHP:** for [transliteration map](https://github.com/cakephp/cakephp/blob/master/lib/Cake/Utility/Inflector.php).
|
31
|
+
- **Rails**: for the idea of [transliterate and parameterize](https://github.com/rails/docrails/blob/master/activesupport/lib/active_support/inflector/transliterate.rb) methods.
|
32
|
+
- **Vinicius Cainelli**: for the [original library](https://github.com/viniciuscainelli/jquery-slug/).
|
data/Rakefile
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
Encoding.default_external = "UTF-8" if defined?(Encoding)
|
2
|
+
require 'json'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
# returns the source filename for a given JSON build file
|
6
|
+
# (e.g., "ui.core.jquery.json" returns "core.js")
|
7
|
+
def source_file_for_build_file(build_file)
|
8
|
+
"#{build_file.sub('ui.', '').sub('.jquery.json', '')}.js"
|
9
|
+
end
|
10
|
+
|
11
|
+
# returns the source filename for a named file in the 'dependencies'
|
12
|
+
# array of a JSON build file
|
13
|
+
# (e.g., if the JSON build file contains
|
14
|
+
#
|
15
|
+
# "dependencies": {
|
16
|
+
# "jquery": ">=1.6",
|
17
|
+
# "ui.core": "1.9.2",
|
18
|
+
# "ui.widget": "1.9.2"
|
19
|
+
# },
|
20
|
+
#
|
21
|
+
# then "ui.widget" returns "widget.js")
|
22
|
+
#
|
23
|
+
# The only exception is "jquery", which doesn't follow the
|
24
|
+
# same naming conventions so it's a special case.
|
25
|
+
def source_file_for_dependency_entry(dep_entry)
|
26
|
+
return "jquery.js" if dep_entry == 'jquery'
|
27
|
+
|
28
|
+
"#{dep_entry.sub 'ui.', ''}.js"
|
29
|
+
end
|
30
|
+
|
31
|
+
# return a Hash of dependency info, whose keys are jquery-ui
|
32
|
+
# source files and values are Arrays containing the source files
|
33
|
+
# they depend on
|
34
|
+
def map_dependencies
|
35
|
+
dependencies = {}
|
36
|
+
Dir.glob("jquery-ui/*.jquery.json").each do |build_file|
|
37
|
+
build_info = JSON.parse(File.read build_file)
|
38
|
+
source_file_name = source_file_for_build_file(File.basename(build_file))
|
39
|
+
|
40
|
+
deps = build_info['dependencies'].keys
|
41
|
+
|
42
|
+
# None of jquery.ui files should depend on jquery.js,
|
43
|
+
# so we remove 'jquery' from the list of dependencies for all files
|
44
|
+
deps.reject! {|d| d == "jquery" }
|
45
|
+
|
46
|
+
deps.map! {|d| source_file_for_dependency_entry d }
|
47
|
+
|
48
|
+
dependencies[source_file_name] = deps
|
49
|
+
end
|
50
|
+
dependencies
|
51
|
+
end
|
52
|
+
|
53
|
+
def dependency_hash
|
54
|
+
@dependency_hash ||= map_dependencies
|
55
|
+
end
|
56
|
+
|
57
|
+
def version
|
58
|
+
JSON.load(File.read('jquery-ui/package.json'))['version']
|
59
|
+
end
|
60
|
+
|
61
|
+
task :submodule do
|
62
|
+
sh 'git submodule update --init' unless File.exist?('jquery-ui/README.md')
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_js_dependencies(basename)
|
66
|
+
dependencies = dependency_hash[basename]
|
67
|
+
if dependencies.nil?
|
68
|
+
puts "Warning: No dependencies found for #{basename}"
|
69
|
+
dependencies = []
|
70
|
+
end
|
71
|
+
# Make sure we do not package assets with broken dependencies
|
72
|
+
dependencies.each do |dep|
|
73
|
+
unless File.exist?("jquery-ui/ui/#{dep}")
|
74
|
+
fail "#{basename}: missing #{dep}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
dependencies
|
78
|
+
end
|
79
|
+
|
80
|
+
def remove_js_extension(path)
|
81
|
+
path.chomp(".js")
|
82
|
+
end
|
83
|
+
|
84
|
+
def protect_copyright_notice(source_code)
|
85
|
+
# YUI does not minify comments starting with "/*!"
|
86
|
+
# The i18n files start with non-copyright comments, so we require a newline
|
87
|
+
# to avoid protecting those
|
88
|
+
source_code.gsub!(/\A\s*\/\*\r?\n/, "/*!\n")
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_image_dependencies(source_code)
|
92
|
+
image_dependencies = Set.new source_code.scan(/url\("?images\/([-_.a-zA-Z0-9]+)"?\)/).map(&:first)
|
93
|
+
code = image_dependencies.inject("") do |acc, img|
|
94
|
+
acc += " *= depend_on_asset \"jquery-ui/#{img}\"\n"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "Remove the app directory"
|
99
|
+
task :clean do
|
100
|
+
rm_rf 'app'
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Generate the JavaScript assets"
|
104
|
+
task :javascripts => :submodule do
|
105
|
+
Rake.rake_output_message 'Generating javascripts'
|
106
|
+
|
107
|
+
target_dir = "app/assets/javascripts"
|
108
|
+
target_ui_dir = "#{target_dir}/jquery-ui"
|
109
|
+
mkdir_p target_ui_dir
|
110
|
+
|
111
|
+
Dir.glob("jquery-ui/ui/*.js").each do |path|
|
112
|
+
basename = File.basename(path)
|
113
|
+
dep_modules = get_js_dependencies(basename).map(&method(:remove_js_extension))
|
114
|
+
File.open("#{target_ui_dir}/#{basename}", "w") do |out|
|
115
|
+
dep_modules.each do |mod|
|
116
|
+
out.write("//= require jquery-ui/#{mod}\n")
|
117
|
+
end
|
118
|
+
out.write("\n") unless dep_modules.empty?
|
119
|
+
source_code = File.read(path)
|
120
|
+
source_code.gsub!('@VERSION', version)
|
121
|
+
protect_copyright_notice(source_code)
|
122
|
+
out.write(source_code)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# process the i18n files separately for performance, since they will not have dependencies
|
127
|
+
# https://github.com/joliss/jquery-ui-rails/issues/9
|
128
|
+
Dir.glob("jquery-ui/ui/i18n/*.js").each do |path|
|
129
|
+
basename = File.basename(path)
|
130
|
+
File.open("#{target_ui_dir}/#{basename}", "w") do |out|
|
131
|
+
source_code = File.read(path)
|
132
|
+
source_code.gsub!('@VERSION', version)
|
133
|
+
protect_copyright_notice(source_code)
|
134
|
+
out.write(source_code)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
File.open("#{target_ui_dir}/effect.all.js", "w") do |out|
|
139
|
+
Dir.glob("jquery-ui/ui/effect*.js").sort.each do |path|
|
140
|
+
asset_name = remove_js_extension(File.basename(path))
|
141
|
+
out.write("//= require jquery-ui/#{asset_name}\n")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
File.open("#{target_dir}/jquery-ui.js", "w") do |out|
|
145
|
+
Dir.glob("jquery-ui/ui/*.js").sort.each do |path|
|
146
|
+
asset_name = remove_js_extension(File.basename(path))
|
147
|
+
out.write("//= require jquery-ui/#{asset_name}\n")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
desc "Generate the CSS assets"
|
153
|
+
task :stylesheets => :submodule do
|
154
|
+
Rake.rake_output_message 'Generating stylesheets'
|
155
|
+
|
156
|
+
target_dir = "app/assets/stylesheets"
|
157
|
+
target_ui_dir = "#{target_dir}/jquery-ui"
|
158
|
+
mkdir_p target_ui_dir
|
159
|
+
|
160
|
+
File.open("#{target_dir}/jquery-ui.css", "w") do |out|
|
161
|
+
out.write("//= require jquery-ui/all\n")
|
162
|
+
end
|
163
|
+
|
164
|
+
css_dir = "jquery-ui/themes/base"
|
165
|
+
Dir.glob("#{css_dir}/*.css").each do |path|
|
166
|
+
basename = File.basename(path)
|
167
|
+
source_code = File.read(path)
|
168
|
+
source_code.gsub!('@VERSION', version)
|
169
|
+
protect_copyright_notice(source_code)
|
170
|
+
extra_dependencies = []
|
171
|
+
# Is "theme" listed among the dependencies for the matching JS file?
|
172
|
+
unless basename =~ /\.(all|base|core)\./
|
173
|
+
if dependencies = dependency_hash[basename.sub(/\.css/, '.js')]
|
174
|
+
dependencies.each do |dependency|
|
175
|
+
dependency = dependency.sub(/\.js$/, '')
|
176
|
+
dependent_stylesheet = "#{dependency}.css"
|
177
|
+
extra_dependencies << dependency if File.exists?("#{css_dir}/#{dependent_stylesheet}")
|
178
|
+
end
|
179
|
+
extra_dependencies << 'theme'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
extra_dependencies.reverse.each do |dep|
|
183
|
+
# Add after first comment block
|
184
|
+
source_code = source_code.sub(/\A((.*?\*\/\n)?)/m, "\\1/*\n *= require jquery-ui/#{dep}\n */\n")
|
185
|
+
end
|
186
|
+
# Use "require" instead of @import
|
187
|
+
source_code.gsub!(/^@import (.*)$/) { |s|
|
188
|
+
m = s.match(/^@import (url\()?"(?<module>[-_.a-zA-Z]+)\.css"\)?;/) \
|
189
|
+
or fail "Cannot parse import: #{s}"
|
190
|
+
"/*\n *= require jquery-ui/#{m['module']}\n */"
|
191
|
+
}
|
192
|
+
# Be cute: collapse multiple require comment blocks into one
|
193
|
+
source_code.gsub!(/^( \*= require .*)\n \*\/(\n+)\/\*\n(?= \*= require )/, '\1\2')
|
194
|
+
source_code.gsub!(/\A(\/\*!.+?\*\/\s)/m, "\\1\n/*\n#{build_image_dependencies(source_code)} */\n\n") unless build_image_dependencies(source_code).empty?
|
195
|
+
# Replace hard-coded image URLs with asset path helpers
|
196
|
+
source_code.gsub!(/url\("?images\/([-_.a-zA-Z0-9]+)"?\)/, 'url(<%= image_path("jquery-ui/\1") %>)')
|
197
|
+
File.open("#{target_ui_dir}/#{basename}.erb", "w") do |out|
|
198
|
+
out.write(source_code)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
desc "Generate the image assets"
|
204
|
+
task :images => :submodule do
|
205
|
+
Rake.rake_output_message 'Copying images'
|
206
|
+
|
207
|
+
target_dir = "app/assets/images/jquery-ui"
|
208
|
+
mkdir_p target_dir
|
209
|
+
|
210
|
+
FileUtils.cp(Dir.glob("jquery-ui/themes/base/images/*"), target_dir)
|
211
|
+
end
|
212
|
+
|
213
|
+
desc "Update Jquery::Ui::Rails::JQUERY_UI_VERSION"
|
214
|
+
task :version => :submodule do
|
215
|
+
Rake.rake_output_message "Setting Jquery::Ui::Rails::JQUERY_UI_VERSION = \"#{version}\""
|
216
|
+
|
217
|
+
versionRb = 'lib/jquery/ui/rails/version.rb'
|
218
|
+
versionRbSource = File.read(versionRb)
|
219
|
+
versionDefinition = "JQUERY_UI_VERSION = \"#{version}\""
|
220
|
+
versionRbSource.sub! /JQUERY_UI_VERSION = "[^"]*"/, versionDefinition \
|
221
|
+
or fail "Could not find JQUERY_UI_VERSION in #{versionRb}"
|
222
|
+
File.open(versionRb, 'w') do |out|
|
223
|
+
out.write(versionRbSource)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
desc "Clean and then generate everything (default)"
|
228
|
+
task :assets => [:clean, :javascripts, :stylesheets, :images, :version]
|
229
|
+
|
230
|
+
task :build => :assets
|
231
|
+
|
232
|
+
task :default => :assets
|
data/VERSIONS.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#= require jquery-friendly_id/jquery.friendly_id
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require jquery-friendly_id/jquery.friendly_id
|
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
@@ -0,0 +1,70 @@
|
|
1
|
+
(($) ->
|
2
|
+
'use strict'
|
3
|
+
|
4
|
+
transliteration =
|
5
|
+
'ä|æ|ǽ': 'ae'
|
6
|
+
'ö|œ': 'oe'
|
7
|
+
'ü': 'ue'
|
8
|
+
'Ä': 'Ae'
|
9
|
+
'Ü': 'Ue'
|
10
|
+
'Ö': 'Oe'
|
11
|
+
'À|Á|Â|Ã|Å|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+
'Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ': 'U'
|
42
|
+
'ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ': 'u'
|
43
|
+
'Ý|Ÿ|Ŷ': 'Y'
|
44
|
+
'ý|ÿ|ŷ': 'y'
|
45
|
+
'Ŵ': 'W'
|
46
|
+
'ŵ': 'w'
|
47
|
+
'Ź|Ż|Ž': 'Z'
|
48
|
+
'ź|ż|ž': 'z'
|
49
|
+
'Æ|Ǽ': 'AE'
|
50
|
+
'ß': 'ss'
|
51
|
+
'IJ': 'IJ'
|
52
|
+
'ij': 'ij'
|
53
|
+
'Œ': 'OE'
|
54
|
+
'ƒ': 'f'
|
55
|
+
|
56
|
+
transliterate = (string) ->
|
57
|
+
$.each transliteration, (index, value) ->
|
58
|
+
index = new RegExp index, 'g'
|
59
|
+
string = string.replace index, value
|
60
|
+
string
|
61
|
+
|
62
|
+
parameterize = (string, separator = '-') ->
|
63
|
+
string = $.trim transliterate(string)
|
64
|
+
string = string.replace /[^a-zA-Z0-9]/g, separator
|
65
|
+
string = string.replace new RegExp('\\' + separator + '{2,}', 'gmi'), separator
|
66
|
+
string = string.replace new RegExp('(^' + separator + ')|(' + separator + '$)', 'gmi'), ''
|
67
|
+
string.toLowerCase()
|
68
|
+
|
69
|
+
$.friendly_id = parameterize
|
70
|
+
) jQuery
|
@@ -0,0 +1,79 @@
|
|
1
|
+
(function($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var parameterize, transliterate, transliteration;
|
5
|
+
|
6
|
+
transliteration = {
|
7
|
+
'ä|æ|ǽ': 'ae',
|
8
|
+
'ö|œ': 'oe',
|
9
|
+
'ü': 'ue',
|
10
|
+
'Ä': 'Ae',
|
11
|
+
'Ü': 'Ue',
|
12
|
+
'Ö': 'Oe',
|
13
|
+
'À|Á|Â|Ã|Å|Ǻ|Ā|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Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ': 'U',
|
44
|
+
'ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ': 'u',
|
45
|
+
'Ý|Ÿ|Ŷ': 'Y',
|
46
|
+
'ý|ÿ|ŷ': 'y',
|
47
|
+
'Ŵ': 'W',
|
48
|
+
'ŵ': 'w',
|
49
|
+
'Ź|Ż|Ž': 'Z',
|
50
|
+
'ź|ż|ž': 'z',
|
51
|
+
'Æ|Ǽ': 'AE',
|
52
|
+
'ß': 'ss',
|
53
|
+
'IJ': 'IJ',
|
54
|
+
'ij': 'ij',
|
55
|
+
'Œ': 'OE',
|
56
|
+
'ƒ': 'f'
|
57
|
+
};
|
58
|
+
|
59
|
+
transliterate = function(string) {
|
60
|
+
$.each(transliteration, function(index, value) {
|
61
|
+
index = new RegExp(index, 'g');
|
62
|
+
return string = string.replace(index, value);
|
63
|
+
});
|
64
|
+
return string;
|
65
|
+
};
|
66
|
+
|
67
|
+
parameterize = function(string, separator) {
|
68
|
+
if (separator == null) {
|
69
|
+
separator = '-';
|
70
|
+
}
|
71
|
+
string = $.trim(transliterate(string));
|
72
|
+
string = string.replace(/[^a-zA-Z0-9]/g, separator);
|
73
|
+
string = string.replace(new RegExp('\\' + separator + '{2,}', 'gmi'), separator);
|
74
|
+
string = string.replace(new RegExp('(^' + separator + ')|(' + separator + '$)', 'gmi'), '');
|
75
|
+
return string.toLowerCase();
|
76
|
+
};
|
77
|
+
|
78
|
+
return $.friendly_id = parameterize;
|
79
|
+
})(jQuery);
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jquery/friendly_id/rails'
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-friendly_id-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Kumanyaev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.16
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.16
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
description: jQuery friendly_id JavaScript files packaged for the Rails 3.1+ asset
|
42
|
+
pipeline
|
43
|
+
email:
|
44
|
+
- me@zzet.org
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- .gitmodules
|
51
|
+
- Gemfile
|
52
|
+
- History.md
|
53
|
+
- License.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- VERSIONS.md
|
57
|
+
- app/assets/javascripts/jquery-friendly_id.coffee
|
58
|
+
- app/assets/javascripts/jquery-friendly_id.js
|
59
|
+
- app/assets/javascripts/jquery-friendly_id/.gitignore
|
60
|
+
- app/assets/javascripts/jquery-friendly_id/jquery.friendly_id.coffee
|
61
|
+
- app/assets/javascripts/jquery-friendly_id/jquery.friendly_id.js
|
62
|
+
- lib/jquery-friendly_id-rails.rb
|
63
|
+
- lib/jquery/friendly_id/rails.rb
|
64
|
+
- lib/jquery/friendly_id/rails/engine.rb
|
65
|
+
- lib/jquery/friendly_id/rails/version.rb
|
66
|
+
homepage: https://github.com/zzet/jquery-friendly_id-rails
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.3.6
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.0.14
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: jQuery friendly_id packaged for the Rails asset pipeline
|
90
|
+
test_files: []
|