whowish_word 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -5
- data/.loadpath +5 -5
- data/.project +18 -17
- data/Gemfile +2 -2
- data/HOW_TO_BUILD_WHOWISH_HOOK.md +9 -9
- data/ISSUE.md +93 -93
- data/README.md +208 -208
- data/lib/whowish_word/action_controller/base.rb +44 -44
- data/lib/whowish_word/action_mailer/base.rb +11 -11
- data/lib/whowish_word/action_view/base.rb +70 -70
- data/lib/whowish_word/action_view/template.rb +30 -30
- data/lib/whowish_word/authentication.rb +13 -13
- data/lib/whowish_word/config.rb +21 -21
- data/lib/whowish_word/constant.rb +8 -8
- data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +14 -14
- data/lib/whowish_word/db_migration/mongoid/whowish_word_html.rb +5 -5
- data/lib/whowish_word/initializer.rb +52 -52
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +60 -60
- data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +3 -3
- data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +8 -8
- data/lib/whowish_word/rails/public/javascripts/0_jquery-1.6.4-whowish_word.js +9046 -9046
- data/lib/whowish_word/rails/public/javascripts/1_csrf_token_hook.js +9 -9
- data/lib/whowish_word/rails/public/javascripts/1_jquery.loading_button.js +66 -66
- data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +33 -33
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -136
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +116 -116
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word_creator.js +69 -69
- data/lib/whowish_word/whowish_word.rb +41 -41
- data/lib/whowish_word/word_for.rb +93 -93
- data/rails/Gemfile +18 -18
- data/rails/Gemfile.lock +63 -64
- data/rails/app/controllers/application_controller.rb +22 -22
- data/rails/app/controllers/home_controller.rb +8 -8
- data/rails/app/views/home/index.html.erb +109 -109
- data/rails/app/views/home/static_edit.html.erb +50 -50
- data/rails/app/views/home/static_edit_select.html.erb +8 -8
- data/rails/app/views/integration/attr.html.erb +1 -1
- data/rails/app/views/integration/index.html.erb +1 -1
- data/rails/app/views/integration/select.html.erb +3 -3
- data/rails/app/views/integration/value.html.erb +1 -1
- data/rails/app/views/layouts/integration.html.erb +14 -14
- data/rails/app/views/layouts/main.html.erb +13 -13
- data/rails/app/views/layouts/nested_test_word_for.html.erb +17 -17
- data/rails/app/views/layouts/test_javascript.html.erb +13 -13
- data/rails/app/views/layouts/test_word_for.html.erb +24 -24
- data/rails/app/views/test_javascript/change_value.html.erb +32 -32
- data/rails/app/views/test_javascript/index.html.erb +87 -87
- data/rails/app/views/test_javascript/replace_with_html.html.erb +96 -96
- data/rails/app/views/test_word_for/_partial.html.erb +4 -4
- data/rails/app/views/test_word_for/index.html.erb +8 -8
- data/rails/config/application.rb +30 -30
- data/rails/config/boot.rb +9 -9
- data/rails/config/database.yml +24 -24
- data/rails/config/environment.rb +16 -16
- data/rails/config/initializers/whowish_word.rb +3 -3
- data/rails/config/mongoid.rb +6 -6
- data/rails/config/mongoid.yml +14 -14
- data/rails/config/routes.rb +7 -7
- data/rails/config.ru +4 -4
- data/rails/log/.gitignore +1 -1
- data/rails/mongo.bat +4 -4
- data/rails/public/javascripts/jquery.loading_button.js +72 -72
- data/rails/public/test/jquery_version.html +26 -26
- data/rails/script/rails +6 -6
- data/rails/spec/controllers/whowish_word_controller_spec.rb +55 -55
- data/rails/spec/integration/whowish_word_generator_spec.rb +139 -139
- data/rails/spec/integration/whowish_word_spec.rb +116 -116
- data/rails/spec/spec_helper.rb +34 -36
- data/rails/spec/support/browser.rb +193 -193
- data/rails/spec/support/json_rspec_helper.rb +8 -8
- data/rails/spec/support/mongoid_helper.rb +9 -9
- data/spec/spec_helper.rb +17 -19
- data/spec/unit/word_for_attr_in_edit_mode_spec.rb +43 -43
- data/spec/unit/word_for_attr_spec.rb +43 -43
- data/spec/unit/word_for_in_edit_mode_spec.rb +43 -43
- data/spec/unit/word_for_spec.rb +43 -43
- data/whowish_word.gemspec +21 -21
- metadata +73 -4
data/README.md
CHANGED
@@ -1,209 +1,209 @@
|
|
1
|
-
WhowishWord - a Rails gem that make static content editable
|
2
|
-
====================
|
3
|
-
|
4
|
-
WhowishWord makes static content editable, as long as the programmers follow its convention.
|
5
|
-
|
6
|
-
Demo: http://whowish-word.heroku.com
|
7
|
-
|
8
|
-
|
9
|
-
The problem WhowishWord tries to solve
|
10
|
-
---------------------------------------
|
11
|
-
|
12
|
-
The problem that I personally faced in my company, Whowish, is that:
|
13
|
-
|
14
|
-
Occasionally CEO or VP of Marketing would send me an email to change the word 'Save'(on a submit button) to the word 'Post'.
|
15
|
-
I would have to go to the source code and change it.
|
16
|
-
And when this happens too often, it drives us, the programmers, crazy
|
17
|
-
|
18
|
-
WhowishWord tries to solve this problem elegantly. It is much better than using a config file.
|
19
|
-
|
20
|
-
It gives a simple tool for CEO, VP of Marketing (or whoever it is) to make changes themselves.
|
21
|
-
|
22
|
-
The beauty of WhowishWord is that:
|
23
|
-
|
24
|
-
* It is almost transparent to programmers
|
25
|
-
* Programmers don't have to care how wording should be. This makes them work much faster
|
26
|
-
* It does not clutter up your source code because you replace one static content unit with one function call
|
27
|
-
|
28
|
-
Demo: http://whowish-word.heroku.com
|
29
|
-
|
30
|
-
|
31
|
-
How you should work
|
32
|
-
-------------------
|
33
|
-
|
34
|
-
In your view, e.g. index.html.erb, use word_for(:identifier) and word_for_attr(:identifier):
|
35
|
-
|
36
|
-
```erb
|
37
|
-
<h1><%= word_for :title%></h1>
|
38
|
-
<h3><%= word_for :you_are_here_for_number_of_times, :number=> 10 %></h3>
|
39
|
-
|
40
|
-
<b><%= word_for :name_label%><b> <%= word_for :my_name%><br/>
|
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>
|
45
|
-
|
46
|
-
<button><%= word_for_attr :submit_button%></button>
|
47
|
-
```
|
48
|
-
|
49
|
-
Now when you want to edit wording:
|
50
|
-
|
51
|
-
1. Activate edit mode by calling:
|
52
|
-
```
|
53
|
-
whowish_word.activate_edit_mode
|
54
|
-
```
|
55
|
-
in any controller.
|
56
|
-
(The usual way is to use user's session to determine whether or not to activate WhowishWord's edit mode)
|
57
|
-
|
58
|
-
2. You'll see an edit icon on each word
|
59
|
-
3. Click on an edit icon to edit the corresponding word
|
60
|
-
4. Fill in a new word, and click save
|
61
|
-
|
62
|
-
And when you have finished, deactivate edit mode.
|
63
|
-
|
64
|
-
WhowishWord empowers normal users (project manager, marketing department, or sales) to change wording on a website.
|
65
|
-
This take the burden off programmers because it is extremely boring to change wording...
|
66
|
-
|
67
|
-
Demo: http://whowish-word.heroku.com
|
68
|
-
|
69
|
-
### Note
|
70
|
-
|
71
|
-
WhowishWord supports variables:
|
72
|
-
|
73
|
-
```erb
|
74
|
-
<%= word_for :you_are_here_for_number_of_times, :number=> 10 %>
|
75
|
-
```
|
76
|
-
|
77
|
-
If you set the word :you_are_here_for_number_of_times to be
|
78
|
-
|
79
|
-
```
|
80
|
-
You are here {number} times already
|
81
|
-
```
|
82
|
-
|
83
|
-
WhowishWord renders it as:
|
84
|
-
|
85
|
-
```
|
86
|
-
You are here 10 times already
|
87
|
-
```
|
88
|
-
|
89
|
-
Multi-language support
|
90
|
-
-----------------------
|
91
|
-
|
92
|
-
You can change locale of WhowishWord by:
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
whowish_word.set_locale("jp")
|
96
|
-
```
|
97
|
-
|
98
|
-
In Rails, you should add before_filter in the application controller as shown below:
|
99
|
-
|
100
|
-
```ruby
|
101
|
-
before_filter :set_locale
|
102
|
-
|
103
|
-
def set_locale
|
104
|
-
if params[:locale]
|
105
|
-
session[:locale] = params[:locale]
|
106
|
-
end
|
107
|
-
|
108
|
-
session[:locale] ||= "en"
|
109
|
-
whowish_word.set_locale(session[:locale])
|
110
|
-
end
|
111
|
-
```
|
112
|
-
|
113
|
-
|
114
|
-
Prerequisite
|
115
|
-
-------------------
|
116
|
-
|
117
|
-
Rails 3.1.*
|
118
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
How to use it
|
124
|
-
-------------------
|
125
|
-
|
126
|
-
First, install it:
|
127
|
-
```
|
128
|
-
gem install whowish_word
|
129
|
-
```
|
130
|
-
|
131
|
-
Or, in your Gemfile, put in the below line:
|
132
|
-
```
|
133
|
-
gem 'whowish_word'
|
134
|
-
```
|
135
|
-
|
136
|
-
Second, create RAILS_ROOT/config/initializers/whowish_word.rb that contains:
|
137
|
-
|
138
|
-
```ruby
|
139
|
-
require 'whowish_word'
|
140
|
-
|
141
|
-
WhowishWord.init(:active_record)
|
142
|
-
|
143
|
-
```
|
144
|
-
|
145
|
-
You can use either use :active_record or :mongoid
|
146
|
-
|
147
|
-
And, in your layout, please drop this line inside the tag header:
|
148
|
-
|
149
|
-
```erb
|
150
|
-
<%= whowish_word_javascript_and_css%>
|
151
|
-
```
|
152
|
-
|
153
|
-
It is to include the required Javascript and css files, when the edit mode is activated.
|
154
|
-
|
155
|
-
|
156
|
-
Performance
|
157
|
-
-------------------
|
158
|
-
|
159
|
-
It is fast because words are kept in memory. They are not kept in database while your Rails is running.
|
160
|
-
|
161
|
-
|
162
|
-
Help me
|
163
|
-
-------------------------------------------------
|
164
|
-
|
165
|
-
1. Fork the project
|
166
|
-
* Run all tests first:
|
167
|
-
* Go to ROOT, type
|
168
|
-
```
|
169
|
-
bundle exec rspec spec/*
|
170
|
-
```
|
171
|
-
* Go to ROOT/rails, type
|
172
|
-
```
|
173
|
-
bundle exec rspec spec/*
|
174
|
-
```
|
175
|
-
* If all tests pass, you are ready to add a feature
|
176
|
-
2. Add a feature
|
177
|
-
3. Write a test for it
|
178
|
-
4. Send me a pull request
|
179
|
-
|
180
|
-
Please learn the code structure. If you have any question, feel free to ask me.
|
181
|
-
|
182
|
-
|
183
|
-
Authors
|
184
|
-
-------------------
|
185
|
-
|
186
|
-
Tanin Na Nakorn
|
187
|
-
|
188
|
-
Tanun Niyomjit (Designer)
|
189
|
-
|
190
|
-
|
191
|
-
Boring legal stuff
|
192
|
-
-----------------------
|
193
|
-
|
194
|
-
WhowishWord relies on several libraries that you won't see.
|
195
|
-
They are embedded into whowish_word.js.
|
196
|
-
|
197
|
-
The libraries:
|
198
|
-
|
199
|
-
* jQuery 1.6.4 http://jquery.com/
|
200
|
-
* Class.js (John Resig) http://ejohn.org/blog/simple-javascript-inheritance/
|
201
|
-
* jQuery.escape http://plugins.jquery.com/project/escape
|
202
|
-
* JSizes http://www.bramstein.com/projects/jsizes/
|
203
|
-
* jQuery.loading_button (This is mine)
|
204
|
-
|
205
|
-
Please be aware of the licenses of other libraries.
|
206
|
-
|
207
|
-
For WhowishWord's code itself, it is under this license: http://creativecommons.org/licenses/by/3.0/
|
208
|
-
|
1
|
+
WhowishWord - a Rails gem that make static content editable
|
2
|
+
====================
|
3
|
+
|
4
|
+
WhowishWord makes static content editable, as long as the programmers follow its convention.
|
5
|
+
|
6
|
+
Demo: http://whowish-word.heroku.com
|
7
|
+
|
8
|
+
|
9
|
+
The problem WhowishWord tries to solve
|
10
|
+
---------------------------------------
|
11
|
+
|
12
|
+
The problem that I personally faced in my company, Whowish, is that:
|
13
|
+
|
14
|
+
Occasionally CEO or VP of Marketing would send me an email to change the word 'Save'(on a submit button) to the word 'Post'.
|
15
|
+
I would have to go to the source code and change it.
|
16
|
+
And when this happens too often, it drives us, the programmers, crazy
|
17
|
+
|
18
|
+
WhowishWord tries to solve this problem elegantly. It is much better than using a config file.
|
19
|
+
|
20
|
+
It gives a simple tool for CEO, VP of Marketing (or whoever it is) to make changes themselves.
|
21
|
+
|
22
|
+
The beauty of WhowishWord is that:
|
23
|
+
|
24
|
+
* It is almost transparent to programmers
|
25
|
+
* Programmers don't have to care how wording should be. This makes them work much faster
|
26
|
+
* It does not clutter up your source code because you replace one static content unit with one function call
|
27
|
+
|
28
|
+
Demo: http://whowish-word.heroku.com
|
29
|
+
|
30
|
+
|
31
|
+
How you should work
|
32
|
+
-------------------
|
33
|
+
|
34
|
+
In your view, e.g. index.html.erb, use word_for(:identifier) and word_for_attr(:identifier):
|
35
|
+
|
36
|
+
```erb
|
37
|
+
<h1><%= word_for :title%></h1>
|
38
|
+
<h3><%= word_for :you_are_here_for_number_of_times, :number=> 10 %></h3>
|
39
|
+
|
40
|
+
<b><%= word_for :name_label%><b> <%= word_for :my_name%><br/>
|
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>
|
45
|
+
|
46
|
+
<button><%= word_for_attr :submit_button%></button>
|
47
|
+
```
|
48
|
+
|
49
|
+
Now when you want to edit wording:
|
50
|
+
|
51
|
+
1. Activate edit mode by calling:
|
52
|
+
```
|
53
|
+
whowish_word.activate_edit_mode
|
54
|
+
```
|
55
|
+
in any controller.
|
56
|
+
(The usual way is to use user's session to determine whether or not to activate WhowishWord's edit mode)
|
57
|
+
|
58
|
+
2. You'll see an edit icon on each word
|
59
|
+
3. Click on an edit icon to edit the corresponding word
|
60
|
+
4. Fill in a new word, and click save
|
61
|
+
|
62
|
+
And when you have finished, deactivate edit mode.
|
63
|
+
|
64
|
+
WhowishWord empowers normal users (project manager, marketing department, or sales) to change wording on a website.
|
65
|
+
This take the burden off programmers because it is extremely boring to change wording...
|
66
|
+
|
67
|
+
Demo: http://whowish-word.heroku.com
|
68
|
+
|
69
|
+
### Note
|
70
|
+
|
71
|
+
WhowishWord supports variables:
|
72
|
+
|
73
|
+
```erb
|
74
|
+
<%= word_for :you_are_here_for_number_of_times, :number=> 10 %>
|
75
|
+
```
|
76
|
+
|
77
|
+
If you set the word :you_are_here_for_number_of_times to be
|
78
|
+
|
79
|
+
```
|
80
|
+
You are here {number} times already
|
81
|
+
```
|
82
|
+
|
83
|
+
WhowishWord renders it as:
|
84
|
+
|
85
|
+
```
|
86
|
+
You are here 10 times already
|
87
|
+
```
|
88
|
+
|
89
|
+
Multi-language support
|
90
|
+
-----------------------
|
91
|
+
|
92
|
+
You can change locale of WhowishWord by:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
whowish_word.set_locale("jp")
|
96
|
+
```
|
97
|
+
|
98
|
+
In Rails, you should add before_filter in the application controller as shown below:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
before_filter :set_locale
|
102
|
+
|
103
|
+
def set_locale
|
104
|
+
if params[:locale]
|
105
|
+
session[:locale] = params[:locale]
|
106
|
+
end
|
107
|
+
|
108
|
+
session[:locale] ||= "en"
|
109
|
+
whowish_word.set_locale(session[:locale])
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
113
|
+
|
114
|
+
Prerequisite
|
115
|
+
-------------------
|
116
|
+
|
117
|
+
Rails 3.1.*
|
118
|
+
|
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
|
+
|
121
|
+
|
122
|
+
|
123
|
+
How to use it
|
124
|
+
-------------------
|
125
|
+
|
126
|
+
First, install it:
|
127
|
+
```
|
128
|
+
gem install whowish_word
|
129
|
+
```
|
130
|
+
|
131
|
+
Or, in your Gemfile, put in the below line:
|
132
|
+
```
|
133
|
+
gem 'whowish_word'
|
134
|
+
```
|
135
|
+
|
136
|
+
Second, create RAILS_ROOT/config/initializers/whowish_word.rb that contains:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
require 'whowish_word'
|
140
|
+
|
141
|
+
WhowishWord.init(:active_record)
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
You can use either use :active_record or :mongoid
|
146
|
+
|
147
|
+
And, in your layout, please drop this line inside the tag header:
|
148
|
+
|
149
|
+
```erb
|
150
|
+
<%= whowish_word_javascript_and_css%>
|
151
|
+
```
|
152
|
+
|
153
|
+
It is to include the required Javascript and css files, when the edit mode is activated.
|
154
|
+
|
155
|
+
|
156
|
+
Performance
|
157
|
+
-------------------
|
158
|
+
|
159
|
+
It is fast because words are kept in memory. They are not kept in database while your Rails is running.
|
160
|
+
|
161
|
+
|
162
|
+
Help me
|
163
|
+
-------------------------------------------------
|
164
|
+
|
165
|
+
1. Fork the project
|
166
|
+
* Run all tests first:
|
167
|
+
* Go to ROOT, type
|
168
|
+
```
|
169
|
+
bundle exec rspec spec/*
|
170
|
+
```
|
171
|
+
* Go to ROOT/rails, type
|
172
|
+
```
|
173
|
+
bundle exec rspec spec/*
|
174
|
+
```
|
175
|
+
* If all tests pass, you are ready to add a feature
|
176
|
+
2. Add a feature
|
177
|
+
3. Write a test for it
|
178
|
+
4. Send me a pull request
|
179
|
+
|
180
|
+
Please learn the code structure. If you have any question, feel free to ask me.
|
181
|
+
|
182
|
+
|
183
|
+
Authors
|
184
|
+
-------------------
|
185
|
+
|
186
|
+
Tanin Na Nakorn
|
187
|
+
|
188
|
+
Tanun Niyomjit (Designer)
|
189
|
+
|
190
|
+
|
191
|
+
Boring legal stuff
|
192
|
+
-----------------------
|
193
|
+
|
194
|
+
WhowishWord relies on several libraries that you won't see.
|
195
|
+
They are embedded into whowish_word.js.
|
196
|
+
|
197
|
+
The libraries:
|
198
|
+
|
199
|
+
* jQuery 1.6.4 http://jquery.com/
|
200
|
+
* Class.js (John Resig) http://ejohn.org/blog/simple-javascript-inheritance/
|
201
|
+
* jQuery.escape http://plugins.jquery.com/project/escape
|
202
|
+
* JSizes http://www.bramstein.com/projects/jsizes/
|
203
|
+
* jQuery.loading_button (This is mine)
|
204
|
+
|
205
|
+
Please be aware of the licenses of other libraries.
|
206
|
+
|
207
|
+
For WhowishWord's code itself, it is under this license: http://creativecommons.org/licenses/by/3.0/
|
208
|
+
|
209
209
|
Basically, you can do whatever you want with it. Just give us some credits.
|
@@ -1,45 +1,45 @@
|
|
1
|
-
|
2
|
-
if defined?(ActionController) and defined?(ActionController::Base)
|
3
|
-
|
4
|
-
class ActionController::Base
|
5
|
-
|
6
|
-
prepend_before_filter :initialize_whowish_word
|
7
|
-
attr_accessor :whowish_word_config
|
8
|
-
|
9
|
-
|
10
|
-
def initialize_whowish_word
|
11
|
-
@whowish_word_config = WhowishWord::Config.new
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
helper_method :whowish_word
|
16
|
-
|
17
|
-
def whowish_word
|
18
|
-
return @whowish_word_config
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def word_for(namespace, id, *variables)
|
23
|
-
|
24
|
-
if @whowish_word_config.edit_mode == true
|
25
|
-
return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
26
|
-
else
|
27
|
-
return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def word_for_attr(namespace, id, *variables)
|
34
|
-
|
35
|
-
if @whowish_word_config.edit_mode == true
|
36
|
-
return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
37
|
-
else
|
38
|
-
return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
1
|
+
|
2
|
+
if defined?(ActionController) and defined?(ActionController::Base)
|
3
|
+
|
4
|
+
class ActionController::Base
|
5
|
+
|
6
|
+
prepend_before_filter :initialize_whowish_word
|
7
|
+
attr_accessor :whowish_word_config
|
8
|
+
|
9
|
+
|
10
|
+
def initialize_whowish_word
|
11
|
+
@whowish_word_config = WhowishWord::Config.new
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
helper_method :whowish_word
|
16
|
+
|
17
|
+
def whowish_word
|
18
|
+
return @whowish_word_config
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def word_for(namespace, id, *variables)
|
23
|
+
|
24
|
+
if @whowish_word_config.edit_mode == true
|
25
|
+
return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
26
|
+
else
|
27
|
+
return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def word_for_attr(namespace, id, *variables)
|
34
|
+
|
35
|
+
if @whowish_word_config.edit_mode == true
|
36
|
+
return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
37
|
+
else
|
38
|
+
return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
45
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
if defined?(ActionMailer) and defined?(ActionMailer::Base)
|
3
|
-
|
4
|
-
class ActionMailer::Base
|
5
|
-
|
6
|
-
def word_for(id, *p)
|
7
|
-
WhowishWord.word_for(mailer_name + "/" + @template+".html.erb",id,*p)
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
1
|
+
|
2
|
+
if defined?(ActionMailer) and defined?(ActionMailer::Base)
|
3
|
+
|
4
|
+
class ActionMailer::Base
|
5
|
+
|
6
|
+
def word_for(id, *p)
|
7
|
+
WhowishWord.word_for(mailer_name + "/" + @template+".html.erb",id,*p)
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
12
|
end
|
@@ -1,71 +1,71 @@
|
|
1
|
-
|
2
|
-
if defined?(ActionView) and defined?(ActionView::Base)
|
3
|
-
|
4
|
-
class ActionView::Base
|
5
|
-
|
6
|
-
|
7
|
-
def whowish_word_javascript_and_css(force = false)
|
8
|
-
|
9
|
-
return "" if @whowish_word_config.edit_mode != true and force == false
|
10
|
-
|
11
|
-
script_text = <<-HTML
|
12
|
-
<script type="text/javascript">
|
13
|
-
$w(function() {
|
14
|
-
$w.whowishWord();
|
15
|
-
});
|
16
|
-
</script>
|
17
|
-
HTML
|
18
|
-
|
19
|
-
return
|
20
|
-
|
21
|
-
script_text.html_safe
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def global_word_for(namespace, id, *variables)
|
26
|
-
|
27
|
-
if @whowish_word_config.edit_mode == true
|
28
|
-
return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
29
|
-
else
|
30
|
-
return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def global_word_for_attr(namespace, id, *variables)
|
37
|
-
|
38
|
-
if @whowish_word_config.edit_mode == true
|
39
|
-
return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
40
|
-
else
|
41
|
-
return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
|
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
|
-
|
69
|
-
end
|
70
|
-
|
1
|
+
|
2
|
+
if defined?(ActionView) and defined?(ActionView::Base)
|
3
|
+
|
4
|
+
class ActionView::Base
|
5
|
+
|
6
|
+
|
7
|
+
def whowish_word_javascript_and_css(force = false)
|
8
|
+
|
9
|
+
return "" if @whowish_word_config.edit_mode != true and force == false
|
10
|
+
|
11
|
+
script_text = <<-HTML
|
12
|
+
<script type="text/javascript">
|
13
|
+
$w(function() {
|
14
|
+
$w.whowishWord();
|
15
|
+
});
|
16
|
+
</script>
|
17
|
+
HTML
|
18
|
+
|
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 + \
|
21
|
+
script_text.html_safe
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def global_word_for(namespace, id, *variables)
|
26
|
+
|
27
|
+
if @whowish_word_config.edit_mode == true
|
28
|
+
return WhowishWord.word_for_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
29
|
+
else
|
30
|
+
return WhowishWord.word_for(namespace, id, @whowish_word_config.locale, *variables)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def global_word_for_attr(namespace, id, *variables)
|
37
|
+
|
38
|
+
if @whowish_word_config.edit_mode == true
|
39
|
+
return WhowishWord.word_for_attr_in_edit_mode(namespace, id, @whowish_word_config.locale, *variables)
|
40
|
+
else
|
41
|
+
return WhowishWord.word_for_attr(namespace, id, @whowish_word_config.locale, *variables)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
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
|
+
|
69
|
+
end
|
70
|
+
|
71
71
|
end
|