whowish_word 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +3 -1
  2. data/.project +0 -1
  3. data/README.md +20 -26
  4. data/lib/whowish_word/action_controller/base.rb +15 -29
  5. data/lib/whowish_word/action_mailer/base.rb +3 -8
  6. data/lib/whowish_word/action_view/base.rb +52 -41
  7. data/lib/whowish_word/action_view/template.rb +18 -18
  8. data/lib/whowish_word/authentication.rb +9 -9
  9. data/lib/whowish_word/config.rb +1 -10
  10. data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +10 -10
  11. data/lib/whowish_word/db_migration/mongoid/whowish_word_html.rb +5 -5
  12. data/lib/whowish_word/initializer.rb +4 -4
  13. data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +35 -26
  14. data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +2 -2
  15. data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +6 -6
  16. data/lib/whowish_word/whowish_word.rb +17 -18
  17. data/rails/Gemfile +1 -2
  18. data/rails/Gemfile.lock +77 -75
  19. data/rails/app/assets/javascripts/home2.js +2 -0
  20. data/rails/app/assets/stylesheets/home2.css +4 -0
  21. data/rails/app/controllers/application_controller.rb +1 -1
  22. data/rails/app/controllers/home2_controller.rb +2 -0
  23. data/rails/app/helpers/home2_helper.rb +2 -0
  24. data/rails/app/views/home/index.html.erb +31 -30
  25. data/rails/app/views/home2/index.html.erb +4 -0
  26. data/rails/app/views/integration/attr.html.erb +1 -1
  27. data/rails/app/views/integration/index.html.erb +1 -1
  28. data/rails/app/views/integration/select.html.erb +1 -1
  29. data/rails/app/views/integration/value.html.erb +1 -1
  30. data/rails/config/application.rb +0 -2
  31. data/rails/config/initializers/whowish_word.rb +1 -1
  32. data/rails/config/locales/whowish_word/en.yml +4 -0
  33. data/rails/config/locales/whowish_word/jp.yml +4 -0
  34. data/rails/config/locales/whowish_word/th.yml +4 -0
  35. data/rails/spec/controllers/whowish_word_controller_spec.rb +2 -39
  36. data/rails/spec/integration/whowish_word_spec.rb +1 -16
  37. data/rails/spec/spec_helper.rb +1 -11
  38. data/spec/spec_helper.rb +2 -0
  39. data/whowish_word.gemspec +2 -2
  40. metadata +13 -81
  41. data/ISSUE.md +0 -93
  42. data/rails/spec/integration/whowish_word_generator_spec.rb +0 -140
  43. data/rails/spec/support/mongoid_helper.rb +0 -10
  44. data/spec/unit/word_for_attr_in_edit_mode_spec.rb +0 -44
  45. data/spec/unit/word_for_attr_spec.rb +0 -44
  46. data/spec/unit/word_for_in_edit_mode_spec.rb +0 -44
  47. data/spec/unit/word_for_spec.rb +0 -44
data/.gitignore CHANGED
@@ -3,4 +3,6 @@
3
3
  spec/rails/tmp/*
4
4
  *.gem
5
5
  rails/db/*.sqlite3
6
- rails/tmp/*
6
+ rails/tmp/*
7
+ rails/.bundle/*
8
+ .bundle/*
data/.project CHANGED
@@ -12,7 +12,6 @@
12
12
  </buildCommand>
13
13
  </buildSpec>
14
14
  <natures>
15
- <nature>com.aptana.ruby.core.rubynature</nature>
16
15
  <nature>org.rubypeople.rdt.core.rubynature</nature>
17
16
  </natures>
18
17
  </projectDescription>
data/README.md CHANGED
@@ -31,19 +31,19 @@ Demo: http://whowish-word.heroku.com
31
31
  How you should work
32
32
  -------------------
33
33
 
34
- In your view, e.g. index.html.erb, use word_for(:identifier) and word_for_attr(:identifier):
34
+ In your view, e.g. index.html.erb, use t(:identifier) and ta(:identifier):
35
35
 
36
36
  ```erb
37
- <h1><%= word_for :title%></h1>
38
- <h3><%= word_for :you_are_here_for_number_of_times, :number=> 10 %></h3>
37
+ <h1><%=t :title%></h1>
38
+ <h3><%=t :you_are_here_for_number_of_times, :number=> 10 %></h3>
39
39
 
40
- <b><%= word_for :name_label%><b> <%= word_for :my_name%><br/>
40
+ <b><%=t :name_label%><b> <%=t :my_name%><br/>
41
41
 
42
- <b><%= word_for :your_name_label%></b>
43
- <input type="text" placeholder="<%= word_for_attr :your_name_here%>"><br/>
44
- <a href="#" title="<%= word_for_attr :your_name_will_be_kept_secret%>">?</a>
42
+ <b><%=t :your_name_label%></b>
43
+ <input type="text" placeholder="<%=ta :your_name_here%>"><br/>
44
+ <a href="#" title="<%=ta :your_name_will_be_kept_secret%>">?</a>
45
45
 
46
- <button><%= word_for_attr :submit_button%></button>
46
+ <button><%=ta :submit_button%></button>
47
47
  ```
48
48
 
49
49
  Now when you want to edit wording:
@@ -71,13 +71,13 @@ Demo: http://whowish-word.heroku.com
71
71
  WhowishWord supports variables:
72
72
 
73
73
  ```erb
74
- <%= word_for :you_are_here_for_number_of_times, :number=> 10 %>
74
+ <%=t :you_are_here_for_number_of_times, :number=> 10 %>
75
75
  ```
76
76
 
77
77
  If you set the word :you_are_here_for_number_of_times to be
78
78
 
79
79
  ```
80
- You are here {number} times already
80
+ You are here %{number} times already
81
81
  ```
82
82
 
83
83
  WhowishWord renders it as:
@@ -92,7 +92,7 @@ Multi-language support
92
92
  You can change locale of WhowishWord by:
93
93
 
94
94
  ```ruby
95
- whowish_word.set_locale("jp")
95
+ I18n.locale = :en
96
96
  ```
97
97
 
98
98
  In Rails, you should add before_filter in the application controller as shown below:
@@ -106,7 +106,7 @@ def set_locale
106
106
  end
107
107
 
108
108
  session[:locale] ||= "en"
109
- whowish_word.set_locale(session[:locale])
109
+ I18n.locale = session[:locale].to_sym
110
110
  end
111
111
  ```
112
112
 
@@ -114,7 +114,7 @@ end
114
114
  Prerequisite
115
115
  -------------------
116
116
 
117
- Rails 3.1.*
117
+ Rails 3.2.3
118
118
 
119
119
  It does not work with Rails 3.0.*, yet. Please send me an issue and I will fix it. (I'm just lazy)
120
120
 
@@ -123,7 +123,7 @@ It does not work with Rails 3.0.*, yet. Please send me an issue and I will fix i
123
123
  How to use it
124
124
  -------------------
125
125
 
126
- First, install it:
126
+ 1. Install it:
127
127
  ```
128
128
  gem install whowish_word
129
129
  ```
@@ -133,17 +133,15 @@ Or, in your Gemfile, put in the below line:
133
133
  gem 'whowish_word'
134
134
  ```
135
135
 
136
- Second, create RAILS_ROOT/config/initializers/whowish_word.rb that contains:
136
+ 2. Create ```RAILS_ROOT/config/initializers/whowish_word.rb``` that contains:
137
137
 
138
138
  ```ruby
139
139
  require 'whowish_word'
140
140
 
141
- WhowishWord.init(:active_record)
141
+ WhowishWord.init()
142
142
 
143
143
  ```
144
144
 
145
- You can use either use :active_record or :mongoid
146
-
147
145
  And, in your layout, please drop this line inside the tag header:
148
146
 
149
147
  ```erb
@@ -152,11 +150,12 @@ And, in your layout, please drop this line inside the tag header:
152
150
 
153
151
  It is to include the required Javascript and css files, when the edit mode is activated.
154
152
 
153
+ 3. When deploying, please create a folder ```RAILS_ROOT/config/locales/whowish_word``` and make it a shared path.
155
154
 
156
- Performance
157
- -------------------
155
+ All edited words will be generated in this folder.
156
+
157
+ Please also make the folder writable.
158
158
 
159
- It is fast because words are kept in memory. They are not kept in database while your Rails is running.
160
159
 
161
160
 
162
161
  Help me
@@ -164,10 +163,6 @@ Help me
164
163
 
165
164
  1. Fork the project
166
165
  * Run all tests first:
167
- * Go to ROOT, type
168
- ```
169
- bundle exec rspec spec/*
170
- ```
171
166
  * Go to ROOT/rails, type
172
167
  ```
173
168
  bundle exec rspec spec/*
@@ -184,7 +179,6 @@ Authors
184
179
  -------------------
185
180
 
186
181
  Tanin Na Nakorn
187
-
188
182
  Tanun Niyomjit (Designer)
189
183
 
190
184
 
@@ -1,46 +1,32 @@
1
-
2
1
  if defined?(ActionController) and defined?(ActionController::Base)
3
-
4
2
  class ActionController::Base
5
-
6
3
  prepend_before_filter :initialize_whowish_word
4
+ helper_method :whowish_word
7
5
  attr_accessor :whowish_word_config
8
6
 
9
-
10
7
  def initialize_whowish_word
11
8
  @whowish_word_config = WhowishWord::Config.new
12
- $whowish_word_config = @whowish_word_config
13
9
  end
14
10
 
15
-
16
- helper_method :whowish_word
17
-
18
11
  def whowish_word
19
12
  return @whowish_word_config
20
13
  end
21
14
 
22
-
23
- def word_for(namespace, id, *variables)
24
-
25
- if @whowish_word_config.edit_mode == true
26
- return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
27
- else
28
- return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
29
- end
30
-
31
- end
15
+ # def word_for(namespace, id, *variables)
16
+ # if @whowish_word_config.edit_mode == true
17
+ # return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
18
+ # else
19
+ # return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
20
+ # end
21
+ # end
32
22
 
33
23
 
34
- def word_for_attr(namespace, id, *variables)
35
-
36
- if @whowish_word_config.edit_mode == true
37
- return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
38
- else
39
- return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
40
- end
41
-
42
- end
43
-
24
+ # def word_for_attr(namespace, id, *variables)
25
+ # if @whowish_word_config.edit_mode == true
26
+ # return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
27
+ # else
28
+ # return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
29
+ # end
30
+ # end
44
31
  end
45
-
46
32
  end
@@ -1,12 +1,7 @@
1
-
2
1
  if defined?(ActionMailer) and defined?(ActionMailer::Base)
3
-
4
2
  class ActionMailer::Base
5
-
6
- def word_for(id, *p)
7
- WhowishWord.word_for(mailer_name + "/" + @template+".html.erb",id,*p)
8
- end
9
-
3
+ # def word_for(id, *p)
4
+ # WhowishWord.word_for(mailer_name + "/" + @template+".html.erb",id,*p)
5
+ # end
10
6
  end
11
-
12
7
  end
@@ -1,11 +1,8 @@
1
-
2
1
  if defined?(ActionView) and defined?(ActionView::Base)
3
-
4
2
  class ActionView::Base
5
-
3
+ include WhowishWord::Constant
6
4
 
7
5
  def whowish_word_javascript_and_css(force = false)
8
-
9
6
  return "" if @whowish_word_config.edit_mode != true and force == false
10
7
 
11
8
  script_text = <<-HTML
@@ -16,56 +13,70 @@ if defined?(ActionView) and defined?(ActionView::Base)
16
13
  </script>
17
14
  HTML
18
15
 
19
- return "<script src='/whowish_word_js?#{Time.now.to_i}' type='text/javascript'></script>".html_safe + \
20
- "<link href='/whowish_word_css?#{Time.now.to_i}' rel='stylesheet' type='text/css' />".html_safe + \
16
+ return javascript_include_tag("/whowish_word_js").sub('.js', '').html_safe + \
17
+ stylesheet_link_tag("/whowish_word_css").sub('.css', '').html_safe + \
21
18
  script_text.html_safe
22
19
  end
23
20
 
24
-
25
- def global_word_for(namespace, id, *variables)
26
-
21
+ # def global_word_for(namespace, id, *variables)
22
+ # if @whowish_word_config.edit_mode == true
23
+ # return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
24
+ # else
25
+ # return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
26
+ # end
27
+ # end
28
+
29
+
30
+ # def global_word_for_attr(namespace, id, *variables)
31
+ # if @whowish_word_config.edit_mode == true
32
+ # return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
33
+ # else
34
+ # return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
35
+ # end
36
+ # end
37
+
38
+ # def word_for(id, *variables)
39
+ # namespace = get_relative_view_path(@whowish_word_page)
40
+ # global_word_for(namespace, id, *variables)
41
+ # end
42
+
43
+ # def word_for_attr(id, *variables)
44
+ # namespace = get_relative_view_path(@whowish_word_page)
45
+ # global_word_for_attr(namespace, id, *variables)
46
+ # end
47
+
48
+ alias_method :previous_t, :t
49
+ def t(uid, *variables)
27
50
  if @whowish_word_config.edit_mode == true
28
- return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
51
+ s = PREFIX + \
52
+ SEPARATOR + \
53
+ uid.to_s + \
54
+ SEPARATOR + \
55
+ previous_t(uid, *variables)
56
+ return "<dfn>#{s}</dfn>".html_safe
29
57
  else
30
- return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
58
+ return previous_t(uid, *variables)
31
59
  end
32
-
33
60
  end
34
61
 
35
-
36
- def global_word_for_attr(namespace, id, *variables)
37
-
62
+ def ta(uid, *variables)
38
63
  if @whowish_word_config.edit_mode == true
39
- return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
64
+ s = PREFIX + \
65
+ SEPARATOR + \
66
+ uid.to_s + \
67
+ SEPARATOR + \
68
+ previous_t(uid, *variables)
69
+ return s.html_safe
40
70
  else
41
- return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
71
+ return previous_t(uid, *variables)
42
72
  end
43
-
44
73
  end
45
74
 
46
75
 
47
- def word_for(id, *variables)
48
-
49
- namespace = get_relative_view_path(@whowish_word_page)
50
- global_word_for(namespace, id, *variables)
51
-
52
- end
53
-
54
-
55
- def word_for_attr(id, *variables)
56
-
57
- namespace = get_relative_view_path(@whowish_word_page)
58
- global_word_for_attr(namespace, id, *variables)
59
-
60
- end
61
-
62
-
63
- private
64
- def get_relative_view_path(full_path)
65
- result = @whowish_word_page.match(/[\/\\](([^\/\\]+)[\/\\]([^\/\\]+))\Z/)
66
- return result[1]
67
- end
68
-
76
+ # private
77
+ # def get_relative_view_path(full_path)
78
+ # result = @whowish_word_page.match(/[\/\\](([^\/\\]+)[\/\\]([^\/\\]+))\Z/)
79
+ # return result[1]
80
+ # end
69
81
  end
70
-
71
82
  end
@@ -1,31 +1,31 @@
1
1
 
2
- if defined?(ActionView) and defined?(ActionView::Base)
2
+ # if defined?(ActionView) and defined?(ActionView::Base)
3
3
 
4
- class ActionView::Template
4
+ # class ActionView::Template
5
5
 
6
- alias_method :render_original, :render
6
+ # alias_method :render_original, :render
7
7
 
8
- def render(view, locals, buffer=nil, &block)
8
+ # def render(view, locals, buffer=nil, &block)
9
9
 
10
- previous_whowish_word_page = nil
10
+ # previous_whowish_word_page = nil
11
11
 
12
- if view.instance_variable_defined?(:@whowish_word_page)
13
- previous_whowish_word_page = view.instance_variable_get(:@whowish_word_page)
14
- end
12
+ # if view.instance_variable_defined?(:@whowish_word_page)
13
+ # previous_whowish_word_page = view.instance_variable_get(:@whowish_word_page)
14
+ # end
15
15
 
16
- view.instance_variable_set(:@whowish_word_page, @identifier)
16
+ # view.instance_variable_set(:@whowish_word_page, @identifier)
17
17
 
18
- if view.controller.respond_to?(:whowish_word_edit_mode)
19
- view.instance_variable_set(:@whowish_word_edit_mode, view.controller.whowish_word_edit_mode)
20
- end
18
+ # if view.controller.respond_to?(:whowish_word_edit_mode)
19
+ # view.instance_variable_set(:@whowish_word_edit_mode, view.controller.whowish_word_edit_mode)
20
+ # end
21
21
 
22
- html = render_original(view, locals, buffer, &block)
22
+ # html = render_original(view, locals, buffer, &block)
23
23
 
24
- view.instance_variable_set(:@whowish_word_page, previous_whowish_word_page)
24
+ # view.instance_variable_set(:@whowish_word_page, previous_whowish_word_page)
25
25
 
26
- return html
27
- end
26
+ # return html
27
+ # end
28
28
 
29
- end
29
+ # end
30
30
 
31
- end
31
+ # end
@@ -1,14 +1,14 @@
1
- module WhowishWord
1
+ # module WhowishWord
2
2
 
3
- module Authentication
3
+ # module Authentication
4
4
 
5
- attr_accessor :username, :password
5
+ # attr_accessor :username, :password
6
6
 
7
- def init_username_and_password
8
- @username ||= "whowishword"
9
- @password ||= "pass"
10
- end
7
+ # def init_username_and_password
8
+ # @username ||= "whowishword"
9
+ # @password ||= "pass"
10
+ # end
11
11
 
12
- end
12
+ # end
13
13
 
14
- end
14
+ # end
@@ -1,22 +1,13 @@
1
1
  module WhowishWord
2
-
3
2
  class Config
4
-
5
- attr_accessor :locale, :edit_mode
3
+ attr_accessor :edit_mode
6
4
 
7
5
  def initialize
8
- @locale = "en"
9
6
  @edit_mode = false
10
7
  end
11
8
 
12
9
  def activate_edit_mode
13
10
  @edit_mode = true
14
11
  end
15
-
16
- def set_locale(locale)
17
- @locale = locale
18
- end
19
-
20
12
  end
21
-
22
13
  end
@@ -1,15 +1,15 @@
1
- begin
2
- ActiveRecord::Schema.define do
1
+ # begin
2
+ # ActiveRecord::Schema.define do
3
3
 
4
- create_table "whowish_word_htmls", :force => false do |t|
5
- t.string "word_id", :null => false
6
- t.text "content", :null => false
7
- end
4
+ # create_table "whowish_word_htmls", :force => false do |t|
5
+ # t.string "word_id", :null => false
6
+ # t.text "content", :null => false
7
+ # end
8
8
 
9
- add_index :whowish_word_htmls, :word_id, :unique => true
9
+ # add_index :whowish_word_htmls, :word_id, :unique => true
10
10
 
11
- end
11
+ # end
12
12
 
13
- rescue Exception=>e
13
+ # rescue Exception=>e
14
14
 
15
- end
15
+ # end
@@ -1,6 +1,6 @@
1
- begin
2
- WhowishWordHtml.collection.drop_indexes
3
- WhowishWordHtml.create_indexes
4
- rescue Exception=>e
1
+ # begin
2
+ # WhowishWordHtml.collection.drop_indexes
3
+ # WhowishWordHtml.create_indexes
4
+ # rescue Exception=>e
5
5
 
6
- end
6
+ # end
@@ -12,11 +12,11 @@ module WhowishWord
12
12
 
13
13
  end
14
14
 
15
- def run_database_migration
15
+ # def run_database_migration
16
16
 
17
- Dir[File.expand_path("../db_migration/#{@orm_engine}/**/*.rb", __FILE__)].each {|f| require f}
17
+ # Dir[File.expand_path("../db_migration/#{@orm_engine}/**/*.rb", __FILE__)].each {|f| require f}
18
18
 
19
- end
19
+ # end
20
20
 
21
21
 
22
22
 
@@ -31,7 +31,7 @@ module WhowishWord
31
31
 
32
32
  def load_rails
33
33
 
34
- paths = ["controllers","models/#{@orm_engine}"]
34
+ paths = ["controllers"]
35
35
 
36
36
  # load all controllers, helpers, and models
37
37
  paths.each do |dir|
@@ -1,7 +1,5 @@
1
- class WhowishWordController < ActionController::Base
2
-
1
+ class WhowishWordController < ApplicationController
3
2
  def css
4
-
5
3
  text = ""
6
4
 
7
5
  Dir[File.expand_path("../../../public/stylesheets/*.css", __FILE__)].each { |f|
@@ -11,11 +9,9 @@ class WhowishWordController < ActionController::Base
11
9
 
12
10
  response.headers["Content-Type"] = "text/css; charset=utf-8"
13
11
  render :text=>text
14
-
15
12
  end
16
13
 
17
14
  def js
18
-
19
15
  text = ""
20
16
 
21
17
  all_files = Dir[File.expand_path("../../../public/javascripts/*.js", __FILE__)]
@@ -28,34 +24,47 @@ class WhowishWordController < ActionController::Base
28
24
 
29
25
  response.headers["Content-Type"] = "text/javascript; charset=utf-8"
30
26
  render :text=>text
31
-
32
27
  end
33
28
 
34
29
  def change_word
30
+ locale_file = File.join(Rails.root, "config", "locales", "whowish_word", "#{I18n.locale}.yml")
31
+
32
+ file = nil
33
+ data = {}
34
+
35
+ begin
36
+ if !File.exists?(locale_file)
37
+ file = File.open(locale_file, 'w', 0777)
38
+ file.flock(File::LOCK_EX)
39
+ else
40
+ file = File.open(locale_file, 'r+', 0777)
41
+ file.flock(File::LOCK_EX)
42
+ end
35
43
 
36
- entity = WhowishWordHtml.first(:conditions=>{:word_id => params[:word_id].strip})
44
+ begin
45
+ file.rewind
46
+ data = YAML.parse(file.read).to_ruby
47
+ rescue
48
+ data = {}
49
+ end
37
50
 
38
- entity = WhowishWordHtml.new if !entity
51
+ data[I18n.locale.to_s] ||= {}
52
+ data[I18n.locale.to_s][params[:word_id]] = params[:content]
39
53
 
40
- entity.word_id = params[:word_id].strip
41
- entity.content = params[:content].strip
42
-
43
- if !entity.save
44
-
45
- error_message = "WhowishWord fails to change the word you specified.<br/>" + \
46
- "Possible causes:<br/>" + \
47
- "- Someone else changed the word at the very same time<br/>" + \
48
- "- Database connection failed<br/>" + \
49
- "By all means, please try again.<br/>"
50
-
51
- render :json=>{:ok=>false,:error_message=>error_message}
52
-
54
+ file.rewind
55
+ file.write(YAML.dump(data))
56
+ file.flush
57
+ file.truncate(file.pos)
58
+ ensure
59
+ file.flock(File::LOCK_UN)
60
+ file.close
53
61
  end
62
+
63
+ I18n.translations[I18n.locale.to_sym] ||= {}
64
+ I18n.translations[I18n.locale.to_sym][params[:word_id].to_sym] = params[:content]
54
65
 
55
- WhowishWord.add_or_set_word(entity.word_id, entity.content)
56
-
57
- render :json=>{:ok=>true}
66
+ render :json=>{
67
+ :ok => true
68
+ }
58
69
  end
59
-
60
-
61
70
  end
@@ -1,4 +1,4 @@
1
- class WhowishWordHtml < ActiveRecord::Base
1
+ # class WhowishWordHtml < ActiveRecord::Base
2
2
 
3
3
 
4
- end
4
+ # end
@@ -1,9 +1,9 @@
1
- class WhowishWordHtml
2
- include Mongoid::Document
1
+ # class WhowishWordHtml
2
+ # include Mongoid::Document
3
3
 
4
- field :word_id,:type=>String
5
- field :content, :type=>String
4
+ # field :word_id,:type=>String
5
+ # field :content, :type=>String
6
6
 
7
- index [[ :word_id, Mongo::DESCENDING ]], :unique=>true
7
+ # index [[ :word_id, Mongo::DESCENDING ]], :unique=>true
8
8
 
9
- end
9
+ # end
@@ -8,32 +8,31 @@ module WhowishWord
8
8
  include WhowishWord::Constant
9
9
  include WhowishWord::Initializer
10
10
  include WhowishWord::WordFor
11
- include WhowishWord::Authentication
11
+ # include WhowishWord::Authentication
12
12
 
13
13
  attr_accessor :words
14
14
 
15
- def init(orm_engine = :active_record)
16
-
17
- @orm_engine = orm_engine
18
-
19
- init_username_and_password
15
+ def init()
20
16
  install_route
21
17
  install_hook
22
18
  load_rails
23
19
 
24
- run_database_migration
25
-
26
- words = WhowishWordHtml.all()
27
-
28
- @words = {}
29
- words.each { |word|
30
- @words[word.word_id] = word.content
31
- }
32
-
33
- end
20
+ Rails.configuration.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'whowish_word', '**', '*.{rb,yml}')]
34
21
 
35
- def add_or_set_word(word_id, content)
36
- @words[word_id] = content
22
+ I18n.class_eval do
23
+ class << self
24
+ def translations
25
+ backend.send(:translations)
26
+ end
27
+ end
28
+ end
29
+
30
+ I18n::MissingTranslation::Base.class_eval do
31
+ def html_message
32
+ key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
33
+ key
34
+ end
35
+ end
37
36
  end
38
37
 
39
38
  extend self