whowish_word 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,25 +1,76 @@
1
- WhowishWord (This is a draft)
1
+ WhowishWord - A Rails framework for wording
2
2
  ====================
3
3
 
4
4
  Have you ever been bored when a project manager (or marketing department) keeps changing wording on a website?
5
+ This kind of tasks can make programmers go crazy.
5
6
 
6
- WhowishWord facilitates the process of changing wording on a website.
7
+ WhowishWord allows normal users to change wording on a Rails website, directly.
8
+
9
+ The beauty of WhowishWord is that:
10
+
11
+ * It is almost transparent to programmers
12
+ * Programmers don't have to care how wording should be. This makes them work much faster
7
13
 
8
14
 
9
15
  How you should work
10
16
  -------------------
11
17
 
12
- 1. Activate edit mode by calling activate_whowish_word_edit_mode() in any controller
13
- 2. Go back to the website, you'll see an edit icon on each word
18
+ In your view, e.g. index.html.erb, use word_for(:identifier) and word_for_attr(:identifier):
19
+
20
+ ```erb
21
+ <h1><%= word_for :title%></h1>
22
+ <h3><%= word_for :you_are_here_for_number_of_times, :number=> 10 %></h3>
23
+
24
+ <b><%= word_for :name_label%><b> <%= word_for :my_name%><br/>
25
+
26
+ <b><%= word_for :your_name_label%></b>
27
+ <input type="text" placeholder="<%= word_for_attr :your_name_here%>"><br/>
28
+ <a href="#" title="<%= word_for_attr :your_name_will_be_kept_secret%>">?</a>
29
+
30
+ <button><%= word_for_attr :submit_button%></button>
31
+ ```
32
+
33
+ Now when you want to edit wording:
34
+
35
+ 1. Activate edit mode by calling:
36
+ ```
37
+ activate_whowish_word_edit_mode()
38
+ ```
39
+ in any controller.
40
+ (The usual way is to use user's session to determine whether or not to activate WhowishWord's edit mode)
41
+
42
+ 2. You'll see an edit icon on each word
14
43
  3. Click on an edit icon to edit the corresponding word
15
44
  4. Fill in a new word, and click save
16
- 4.1 If it is the first time, you will need to fill master password at this point. (The instruction how to set password is below)
45
+ * If it is the first time, you will need to fill master password at this point. (The instruction how to set password is in 'How to use it' section)
17
46
 
18
47
  And when you have finished, deactivate edit mode.
19
48
 
20
49
  WhowishWord empowers normal users (project manager, marketing department, or sales) to change wording on a website.
21
50
  This take the burden off programmers because it is extremely boring to change wording...
22
51
 
52
+ Demo: http://whowish-word.heroku.com
53
+
54
+ ### Note
55
+
56
+ WhowishWord supports variables:
57
+
58
+ ```erb
59
+ <%= word_for :you_are_here_for_number_of_times, :number=> 10 %>
60
+ ```
61
+
62
+ If you set the word :you_are_here_for_number_of_times to be
63
+
64
+ ```
65
+ You are here {number} times already
66
+ ```
67
+
68
+ WhowishWord renders it as:
69
+
70
+ ```
71
+ You are here 10 times already
72
+ ```
73
+
23
74
 
24
75
  Prerequisite
25
76
  -------------------
@@ -71,10 +122,23 @@ Performance
71
122
  It is fast because words are kept in memory. They are not kept in database while your Rails is running.
72
123
 
73
124
 
74
- How to extend WhowishWord to suit your need
125
+ Help me
75
126
  -------------------------------------------------
76
127
 
77
- WhowishWord is nicely structure. You can extend it by writing a new handler and creator (on client-side).
128
+ 1. Fork the project
129
+ * Run all tests first:
130
+ * Go to ROOT, type
131
+ ```
132
+ bundle exec rspec spec/*
133
+ ```
134
+ * Go to ROOT/rails, type
135
+ ```
136
+ bundle exec rspec spec/*
137
+ ```
138
+ * If all tests pass, you are ready to add a feature
139
+ 2. Add a feature
140
+ 3. Write a test for it
141
+ 4. Send me a pull request
78
142
 
79
143
  Please learn the code structure. If you have any question, feel free to ask me.
80
144
 
@@ -84,4 +148,25 @@ Authors
84
148
 
85
149
  Tanin Na Nakorn
86
150
 
87
- Tanun Niyomjit (The design of a dialog box)
151
+ Tanun Niyomjit (Designer)
152
+
153
+
154
+ Boring license stuffs
155
+ -----------------------
156
+
157
+ WhowishWord relies on several libraries that you won't see.
158
+ They are embedded into whowish_word.js.
159
+
160
+ The libraries:
161
+
162
+ * jQuery 1.6.4 http://jquery.com/
163
+ * Class.js (John Resig) http://ejohn.org/blog/simple-javascript-inheritance/
164
+ * jQuery.escape http://plugins.jquery.com/project/escape
165
+ * JSizes http://www.bramstein.com/projects/jsizes/
166
+ * jQuery.loading_button (This is mine)
167
+
168
+ Please be aware of the licenses of other libraries.
169
+
170
+ For WhowishWord's code itself, it is under this license: http://creativecommons.org/licenses/by/3.0/
171
+
172
+ Basically, you can do whatever you want with it. Just give us some credits.
@@ -7,14 +7,23 @@ if defined?(ActionView) and defined?(ActionView::Base)
7
7
 
8
8
  def render(view, locals, buffer=nil, &block)
9
9
 
10
+ previous_whowish_word_page = nil
11
+
12
+ if view.instance_variable_defined?(:@whowish_word_page)
13
+ previous_whowish_word_page = view.instance_variable_get(:@whowish_word_page)
14
+ end
15
+
10
16
  view.instance_variable_set(:@whowish_word_page, @identifier)
11
17
 
12
18
  if view.controller.respond_to?(:whowish_word_edit_mode)
13
19
  view.instance_variable_set(:@whowish_word_edit_mode, view.controller.whowish_word_edit_mode)
14
20
  end
15
21
 
16
- return render_original(view, locals, buffer, &block)
22
+ html = render_original(view, locals, buffer, &block)
23
+
24
+ view.instance_variable_set(:@whowish_word_page, previous_whowish_word_page)
17
25
 
26
+ return html
18
27
  end
19
28
 
20
29
  end
@@ -1,7 +1,10 @@
1
1
  <%
2
2
  content_for :nested_layout do
3
3
  %>
4
+ <span id="nested_layout_before_yield"><%= word_for :text%></span>
5
+
4
6
  <%=yield%>
7
+
5
8
  <span id="nested_layout"><%= word_for :text%></span>
6
9
  <span id="nested_layout_attr"><%= word_for_attr :text%></span>
7
10
 
@@ -11,6 +11,9 @@
11
11
  <%= stylesheet_link_tag "whowish_word.css"%>
12
12
  </head>
13
13
  <body>
14
+
15
+ <span id="layout_before_nested_layout"><%= word_for :text%></span>
16
+
14
17
  <%= content_for?(:nested_layout) ? yield(:nested_layout) : yield %>
15
18
 
16
19
  <span id="layout"><%= word_for :text%></span>
@@ -1,7 +1,9 @@
1
+ <span id="view_before_partial"><%= word_for :text%></span>
2
+
3
+ <%= render :partial=>"partial"%>
4
+
1
5
  <span id="view"><%= word_for :text%></span>
2
6
  <span id="view_attr"><%= word_for_attr :text%></span>
3
7
 
4
8
  <span id="view_with_variables"><%= word_for :text, :number=>5, :name=>"tanin" %></span>
5
- <span id="view_attr_with_variables"><%= word_for_attr :text, :number=>5, :name=>"tanin"%></span>
6
-
7
- <%= render :partial=>"partial"%>
9
+ <span id="view_attr_with_variables"><%= word_for_attr :text, :number=>5, :name=>"tanin"%></span>
File without changes
@@ -56,24 +56,36 @@ describe 'Generator spec' do
56
56
 
57
57
  goto '/test_word_for?edit_mode=yes'
58
58
 
59
+ html("view_before_partial").should == get_whowish_word_in_edit_mode("test_word_for/index.html.erb", "text")
60
+
59
61
  html("view").should == get_whowish_word_in_edit_mode("test_word_for/index.html.erb", "text")
60
62
  html("view_attr").should == get_whowish_word_attr_in_edit_mode("test_word_for/index.html.erb", "text")
61
63
 
62
64
  html("view_with_variables").should == get_whowish_word_in_edit_mode("test_word_for/index.html.erb", "text", {:number=>5,:name=>"tanin"})
63
65
  html("view_attr_with_variables").should == get_whowish_word_attr_in_edit_mode("test_word_for/index.html.erb", "text", {:number=>5,:name=>"tanin"})
64
66
 
67
+
68
+
65
69
  html("partial").should == get_whowish_word_in_edit_mode("test_word_for/_partial.html.erb", "text")
66
70
  html("partial_attr").should == get_whowish_word_attr_in_edit_mode("test_word_for/_partial.html.erb", "text")
67
71
 
68
72
  html("partial_with_variables").should == get_whowish_word_in_edit_mode("test_word_for/_partial.html.erb", "text", {:number=>5,:name=>"tanin"})
69
73
  html("partial_attr_with_variables").should == get_whowish_word_attr_in_edit_mode("test_word_for/_partial.html.erb", "text", {:number=>5,:name=>"tanin"})
70
74
 
75
+
76
+
77
+ html("nested_layout_before_yield").should == get_whowish_word_in_edit_mode("layouts/nested_test_word_for.html.erb", "text")
78
+
71
79
  html("nested_layout").should == get_whowish_word_in_edit_mode("layouts/nested_test_word_for.html.erb", "text")
72
80
  html("nested_layout_attr").should == get_whowish_word_attr_in_edit_mode("layouts/nested_test_word_for.html.erb", "text")
73
81
 
74
82
  html("nested_layout_with_variables").should == get_whowish_word_in_edit_mode("layouts/nested_test_word_for.html.erb", "text", {:number=>5,:name=>"tanin"})
75
83
  html("nested_layout_attr_with_variables").should == get_whowish_word_attr_in_edit_mode("layouts/nested_test_word_for.html.erb", "text", {:number=>5,:name=>"tanin"})
76
84
 
85
+
86
+
87
+ html("layout_before_nested_layout").should == get_whowish_word_in_edit_mode("layouts/test_word_for.html.erb", "text")
88
+
77
89
  html("layout").should == get_whowish_word_in_edit_mode("layouts/test_word_for.html.erb", "text")
78
90
  html("layout_attr").should == get_whowish_word_attr_in_edit_mode("layouts/test_word_for.html.erb", "text")
79
91
 
@@ -86,24 +98,36 @@ describe 'Generator spec' do
86
98
 
87
99
  goto '/test_word_for'
88
100
 
101
+ html("view_before_partial").should == get_whowish_word("test_word_for/index.html.erb", "text")
102
+
89
103
  html("view").should == get_whowish_word("test_word_for/index.html.erb", "text")
90
104
  html("view_attr").should == get_whowish_word("test_word_for/index.html.erb", "text")
91
105
 
92
106
  html("view_with_variables").should == get_whowish_word("test_word_for/index.html.erb", "text", {:number=>5,:name=>"tanin"})
93
107
  html("view_attr_with_variables").should == get_whowish_word("test_word_for/index.html.erb", "text", {:number=>5,:name=>"tanin"})
94
108
 
109
+
110
+
95
111
  html("partial").should == get_whowish_word("test_word_for/_partial.html.erb", "text")
96
112
  html("partial_attr").should == get_whowish_word("test_word_for/_partial.html.erb", "text")
97
113
 
98
114
  html("partial_with_variables").should == get_whowish_word("test_word_for/_partial.html.erb", "text", {:number=>5,:name=>"tanin"})
99
115
  html("partial_attr_with_variables").should == get_whowish_word("test_word_for/_partial.html.erb", "text", {:number=>5,:name=>"tanin"})
100
116
 
117
+
118
+
119
+ html("nested_layout_before_yield").should == get_whowish_word("layouts/nested_test_word_for.html.erb", "text")
120
+
101
121
  html("nested_layout").should == get_whowish_word("layouts/nested_test_word_for.html.erb", "text")
102
122
  html("nested_layout_attr").should == get_whowish_word("layouts/nested_test_word_for.html.erb", "text")
103
123
 
104
124
  html("nested_layout_with_variables").should == get_whowish_word("layouts/nested_test_word_for.html.erb", "text", {:number=>5,:name=>"tanin"})
105
125
  html("nested_layout_attr_with_variables").should == get_whowish_word("layouts/nested_test_word_for.html.erb", "text", {:number=>5,:name=>"tanin"})
106
126
 
127
+
128
+
129
+ html("layout_before_nested_layout").should == get_whowish_word("layouts/test_word_for.html.erb", "text")
130
+
107
131
  html("layout").should == get_whowish_word("layouts/test_word_for.html.erb", "text")
108
132
  html("layout_attr").should == get_whowish_word("layouts/test_word_for.html.erb", "text")
109
133
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "whowish_word"
6
- s.version = "0.1.4"
6
+ s.version = "0.1.5"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Tanin Na Nakorn"]
9
9
  s.email = ["tanin47@yahoo.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whowish_word
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -63,7 +63,7 @@ files:
63
63
  - lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb
64
64
  - lib/whowish_word/rails/public/javascripts/0_class.js
65
65
  - lib/whowish_word/rails/public/javascripts/0_jquery-1.6.4-whowish_word.js
66
- - lib/whowish_word/rails/public/javascripts/1_csrf_and_authenticity_token_hook.js
66
+ - lib/whowish_word/rails/public/javascripts/1_csrf_token_hook.js
67
67
  - lib/whowish_word/rails/public/javascripts/1_jquery.escape.js
68
68
  - lib/whowish_word/rails/public/javascripts/1_jquery.loading_button.js
69
69
  - lib/whowish_word/rails/public/javascripts/1_jquery.sizes.min.js
@@ -128,6 +128,7 @@ files:
128
128
  - rails/config/mongoid.rb
129
129
  - rails/config/mongoid.yml
130
130
  - rails/config/routes.rb
131
+ - rails/db/.gitdummy
131
132
  - rails/log/.gitignore
132
133
  - rails/mongo.bat
133
134
  - rails/public/jasmine/MIT.LICENSE