permalinker 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdbb2252814e5694f69d92fa52b24f6c5aa619ed
4
- data.tar.gz: ea376952402d9b759caebc7f0b4799c78cb332ec
3
+ metadata.gz: e5b78d614d0bd3f845f5517bd08277a459c10bbc
4
+ data.tar.gz: c9165b4ea5bff62c1a0e738efe82bfbb951583e3
5
5
  SHA512:
6
- metadata.gz: 0512d88fdfe8b621420f01cbcf8bb3441f7c2dfb8845074a6b5bee3d07283fe6a6f7519f88677c5e5c0bc07023c61c3ebf89be373bd55b9cfd131d1fcc225532
7
- data.tar.gz: 181f1c70f3fff90a0bacdfbd3409da02739e09ff4b96a92548132552c724e65a13605d770a81adc01d5e861f3631f9d73825912185163b78bbf1b61e2bcd1f9f
6
+ metadata.gz: 89612c64a892705c7f02ee280b2ed657df4ae2924785f6d8cd8c8f2e2e623b4f150306729590456d0c289fd2bfec0dbbe7aec83783f414d01d86a03b26fd3a95
7
+ data.tar.gz: 4e3b2f141b718dd2382372aebd576f8e91342b9d5e3e9c35605da44960de5cb4629f47b943ddd3c92166861249dd95d922a242d475333538744cc68da201e802
data/README.markdown CHANGED
@@ -12,40 +12,25 @@ Usage
12
12
  Add the method call `permalink` to your model. Your model should have a `permalink` attribute.
13
13
 
14
14
  class Page < ActiveRecord::Base
15
- permalink :title
16
- end
17
-
18
- You can specify the permalink field:
19
-
20
- class page < ActiveRecord::Base
21
- permalink :title, :to => :title_permalink
15
+ permalink :permalink # Add your permalink column name here
22
16
  end
23
17
 
24
18
  If you don't want to use `permalink`, you can call `'some text'.to_permalink` string method and
25
19
  manage the permalink process by yourself.
26
20
 
27
- Permalinks are not unique by default. `permalink` overrides `to_param` as following:
28
-
29
- def to_param
30
- "#{id}-#{permalink}"
31
- end
32
-
33
- You can define the `to_param` format:
21
+ You can define the the attributes you want to use
34
22
 
35
23
  class Page < ActiveRecord::Base
36
- permalink :title, :to_param => %w(id permalink page)
24
+ permalink :title, :to_param => %w( permalink page)
37
25
  end
38
26
 
39
- The above settings will generate something link `100-some-title-page`. By overriding `to_param` method you don't have to change a thing on your app routes.
40
-
41
- If you want to generate unique permalink, use the `:unique` option:
27
+ The id will automatically be included
42
28
 
43
- class Page < ActiveRecord::Base
44
- permalink :title, :unique => true, :to_param => :permalink
45
- end
29
+ The above settings will generate something link `100-some-title-page`. By overriding `to_param` method you don't have to change a thing on your app routes.
46
30
 
47
- The permalink is generated using `ActiveSupport::Multibyte::Chars` class; this means that characters will properly replaced from `áéíó` to `aeio`, for instance.
48
31
 
32
+ The permalink is generated by replacing letters like "ä" to "ae", "ß" to "ss", "æ" to "ae", etc... so you can use it with every word and get nice urls!
33
+
49
34
  The permalink is created when `before_validation` callback is evaluated. This plugin also tries
50
35
  to generate a permalink when `before_save` callback is evaluated and the instance has no permalink set.
51
36
 
@@ -58,6 +43,7 @@ You can force the permalink generation by setting the `:force` option.
58
43
  ## License
59
44
 
60
45
  Copyright (c) 2011 Nando Vieira, released under the MIT license
46
+
61
47
  Modified 2014 - Florian Eck
62
48
 
63
49
  Permission is hereby granted, free of charge, to any person obtaining
@@ -1,6 +1,7 @@
1
1
  class String
2
2
  def to_permalink
3
- str = self.de_2_int
3
+ str = ActiveSupport::Multibyte::Chars.new(self)
4
+ str = str.normalize(:kd).gsub(/[^\x00-\x7F]/,'').to_s
4
5
  str.gsub!(/'/, "")
5
6
  str.gsub!(/[^-\w\d]+/sim, "-")
6
7
  str.gsub!(/-+/sm, "-")
data/permalinker.gemspec CHANGED
@@ -3,11 +3,11 @@ require "./lib/permalinker/version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "permalinker"
6
- s.version = "1.0.0"
6
+ s.version = "1.0.1"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Florian Eck"]
9
9
  s.email = ["it-support@friends-systems.de"]
10
- s.homepage = "http://rubygems.org/gems/permalinker"
10
+ s.homepage = "https://github.com/florianeck/permalink"
11
11
  s.summary = "Generate permalink attributes on ActiveRecord, based on Permalink gem by Nando Vieira"
12
12
  s.description = s.summary
13
13
 
@@ -15,9 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
-
19
- s.add_dependency "friendly_extensions"
20
-
18
+
21
19
  s.add_development_dependency "activerecord"
22
20
  s.add_development_dependency "sqlite3-ruby"
23
21
  s.add_development_dependency "test-unit"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permalinker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Eck
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: friendly_extensions
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: activerecord
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -176,7 +162,7 @@ files:
176
162
  - spec/support/post.rb
177
163
  - spec/support/schema.rb
178
164
  - spec/support/shared.rb
179
- homepage: http://rubygems.org/gems/permalinker
165
+ homepage: https://github.com/florianeck/permalink
180
166
  licenses: []
181
167
  metadata: {}
182
168
  post_install_message: