chinese_permalink 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.textile
CHANGED
@@ -10,19 +10,13 @@ For exmpale, title of post is '我是中国人', permalink of post is '1-i-am-a-
|
|
10
10
|
|
11
11
|
h2. Install
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
<pre><code>sudo gem install sishen-rtranslate --source http://gems.github.com</code></pre>
|
16
|
-
|
17
|
-
* install chinese_permalink plugin
|
18
|
-
|
19
|
-
<pre><code>script/plugin install git://github.com/flyerhzm/chinese_permalink.git</code></pre>
|
13
|
+
<pre><code>sudo gem install chinese_permalink</code></pre>
|
20
14
|
|
21
15
|
***************************************************************************
|
22
16
|
|
23
17
|
h2. Example
|
24
18
|
|
25
|
-
* Define chinese_permalink to model
|
19
|
+
*1. Define chinese_permalink to model*
|
26
20
|
|
27
21
|
<pre><code>
|
28
22
|
class Post < ActiveRecord::Base
|
@@ -50,20 +44,20 @@ end
|
|
50
44
|
</code></pre>
|
51
45
|
|
52
46
|
|
53
|
-
* Generate migration
|
47
|
+
*2. Generate migration*
|
54
48
|
|
55
|
-
<pre><code>
|
49
|
+
<pre><code>script/generate chinese_permalink_migration (migration name) (table name) (permalink column name)</code></pre>
|
56
50
|
|
57
51
|
For example:
|
58
52
|
|
59
|
-
<pre><code>
|
53
|
+
<pre><code>script/generate chinese_permalink_migration add_permalink_to_posts posts</code></pre>
|
60
54
|
|
61
55
|
Or
|
62
56
|
|
63
|
-
<pre><code>
|
57
|
+
<pre><code>script/generate chinese_permalink_migration add_permalink_to_posts posts slug_url</code></pre>
|
64
58
|
|
65
59
|
|
66
|
-
3. Define ar to_param method
|
60
|
+
*3. Define ar to_param method*
|
67
61
|
|
68
62
|
<pre><code>
|
69
63
|
class Post < ActiveRecord::Base
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{chinese_permalink}
|
8
|
+
s.version = "1.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Richard Huang"]
|
12
|
+
s.date = %q{2010-01-24}
|
13
|
+
s.description = %q{This plugin adds a capability for AR model to create a seo permalink with your chinese text. It will translate your chinese text to english url based on google translate.}
|
14
|
+
s.email = %q{flyerhzm@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.textile"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".autotest",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README.textile",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"chinese_permalink.gemspec",
|
25
|
+
"generators/chinese_permalink_migration/chinese_permalink_migration_generator.rb",
|
26
|
+
"generators/chinese_permalink_migration/templates/migration.rb",
|
27
|
+
"init.rb",
|
28
|
+
"lib/chinese_permalink.rb",
|
29
|
+
"test/chines_permalink_test.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/flyerhzm/chinese_permalink}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.5}
|
35
|
+
s.summary = %q{This plugin adds a capability for AR model to create a seo permalink with your chinese text.}
|
36
|
+
s.test_files = [
|
37
|
+
"test/chines_permalink_test.rb"
|
38
|
+
]
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<sishen-rtranslate>, [">= 0"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<sishen-rtranslate>, [">= 0"])
|
48
|
+
end
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<sishen-rtranslate>, [">= 0"])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -8,14 +8,14 @@ class ChinesePermalinkMigrationGenerator < Rails::Generator::NamedBase
|
|
8
8
|
attr_reader :permalink_field_name
|
9
9
|
|
10
10
|
def initialize(runtime_args, runtime_options = {})
|
11
|
-
@permalink_table_name = runtime_args[1]
|
12
|
-
@permalink_field_name = runtime_args[2] || 'permalink'
|
13
11
|
super
|
12
|
+
@permalink_table_name = runtime_args[0]
|
13
|
+
@permalink_field_name = runtime_args[1] || 'permalink'
|
14
14
|
end
|
15
15
|
|
16
16
|
def manifest
|
17
17
|
record do |m|
|
18
|
-
m.migration_template 'migration.rb', 'db/migrate'
|
18
|
+
m.migration_template 'migration.rb', 'db/migrate', :migration_file_name => "add_#{@permalink_field_name}_to_#{@permalink_table_name}"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Add<%= permalink_field_name.
|
1
|
+
class Add<%= permalink_field_name.camelize %>To<%= permalink_table_name.capitalize %> < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
add_column :<%= permalink_table_name %>, :<%= permalink_field_name %>, :string, :default => nil
|
4
4
|
|
data/lib/chinese_permalink.rb
CHANGED
@@ -8,13 +8,10 @@ end
|
|
8
8
|
module ChinesePermalink
|
9
9
|
|
10
10
|
def self.included(base)
|
11
|
-
base.
|
12
|
-
|
13
|
-
attr_accessor :permalink_attrs
|
14
|
-
attr_accessor :permalink_field
|
15
|
-
attr_accessor :before_methods
|
16
|
-
attr_accessor :after_methods
|
11
|
+
base.class_eval do
|
12
|
+
class_inheritable_accessor :permalink_attrs, :permalink_field, :before_methods, :after_methods
|
17
13
|
end
|
14
|
+
base.extend ClassMethods
|
18
15
|
end
|
19
16
|
|
20
17
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chinese_permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- README.textile
|
37
37
|
- Rakefile
|
38
38
|
- VERSION
|
39
|
+
- chinese_permalink.gemspec
|
39
40
|
- generators/chinese_permalink_migration/chinese_permalink_migration_generator.rb
|
40
41
|
- generators/chinese_permalink_migration/templates/migration.rb
|
41
42
|
- init.rb
|