whowish_word 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +6 -0
  2. data/.loadpath +5 -0
  3. data/.project +17 -0
  4. data/Gemfile +3 -0
  5. data/HOW_TO_BUILD_WHOWISH_HOOK.md +10 -0
  6. data/ISSUE.md +93 -0
  7. data/README.md +72 -0
  8. data/config.ru +4 -0
  9. data/lib/legacy/whowish_word/config.rb +1 -0
  10. data/lib/legacy/whowish_word/init.rb +4 -0
  11. data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_controller.rb +115 -0
  12. data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb +66 -0
  13. data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_facebook_controller.rb +62 -0
  14. data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word.rb +12 -0
  15. data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_email.rb +10 -0
  16. data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_facebook.rb +28 -0
  17. data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word.rb +5 -0
  18. data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_email.rb +5 -0
  19. data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_facebook.rb +18 -0
  20. data/lib/legacy/whowish_word/lib/app/views/layouts/whowish_word_blank.html.erb +94 -0
  21. data/lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb +82 -0
  22. data/lib/legacy/whowish_word/lib/app/views/whowish_word/_row.html.erb +50 -0
  23. data/lib/legacy/whowish_word/lib/app/views/whowish_word/index.html.erb +219 -0
  24. data/lib/legacy/whowish_word/lib/app/views/whowish_word/login.html.erb +5 -0
  25. data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/_row.html.erb +42 -0
  26. data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/index.html.erb +99 -0
  27. data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/_row.html.erb +48 -0
  28. data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/index.html.erb +100 -0
  29. data/lib/legacy/whowish_word/lib/db_migration.rb +2 -0
  30. data/lib/legacy/whowish_word/lib/db_migration/mongodb.rb +0 -0
  31. data/lib/legacy/whowish_word/lib/db_migration/mysql.rb +60 -0
  32. data/lib/legacy/whowish_word/lib/hook.rb +186 -0
  33. data/lib/whowish_word.rb +1 -0
  34. data/lib/whowish_word/action_controller/base.rb +35 -0
  35. data/lib/whowish_word/action_mailer/base.rb +12 -0
  36. data/lib/whowish_word/action_view/base.rb +65 -0
  37. data/lib/whowish_word/action_view/template.rb +22 -0
  38. data/lib/whowish_word/authentication.rb +14 -0
  39. data/lib/whowish_word/constant.rb +9 -0
  40. data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +15 -0
  41. data/lib/whowish_word/initializer.rb +55 -0
  42. data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +71 -0
  43. data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +4 -0
  44. data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +10 -0
  45. data/lib/whowish_word/rails/public/javascripts/0_class.js +64 -0
  46. data/lib/whowish_word/rails/public/javascripts/0_jquery-1.6.4-whowish_word.js +9046 -0
  47. data/lib/whowish_word/rails/public/javascripts/1_csrf_and_authenticity_token_hook.js +9 -0
  48. data/lib/whowish_word/rails/public/javascripts/1_jquery.escape.js +23 -0
  49. data/lib/whowish_word/rails/public/javascripts/1_jquery.loading_button.js +66 -0
  50. data/lib/whowish_word/rails/public/javascripts/1_jquery.sizes.min.js +8 -0
  51. data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +64 -0
  52. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -0
  53. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +94 -0
  54. data/lib/whowish_word/rails/public/javascripts/4_whowish_word.js +43 -0
  55. data/lib/whowish_word/rails/public/javascripts/4_whowish_word_content_handler.js +15 -0
  56. data/lib/whowish_word/rails/public/javascripts/4_whowish_word_creator.js +62 -0
  57. data/lib/whowish_word/rails/public/javascripts/5_whowish_word_common_creator.js +49 -0
  58. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_creator.js +72 -0
  59. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_creator.js +19 -0
  60. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_select_creator.js +11 -0
  61. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_creator.js +20 -0
  62. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_creator.js +20 -0
  63. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_attribute_handler.js +17 -0
  64. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_html_handler.js +15 -0
  65. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_text_handler.js +15 -0
  66. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_value_handler.js +19 -0
  67. data/lib/whowish_word/rails/public/stylesheets/whowish_word.css +197 -0
  68. data/lib/whowish_word/whowish_word.rb +39 -0
  69. data/lib/whowish_word/word_for.rb +97 -0
  70. data/rails/Gemfile +18 -0
  71. data/rails/Gemfile.lock +130 -0
  72. data/rails/Rakefile +7 -0
  73. data/rails/app/assets/javascripts/integration.js +2 -0
  74. data/rails/app/assets/javascripts/test_javascript.js +2 -0
  75. data/rails/app/assets/javascripts/test_word_for.js +2 -0
  76. data/rails/app/assets/stylesheets/integration.css +4 -0
  77. data/rails/app/assets/stylesheets/test_javascript.css +4 -0
  78. data/rails/app/assets/stylesheets/test_word_for.css +4 -0
  79. data/rails/app/controllers/application_controller.rb +14 -0
  80. data/rails/app/controllers/home_controller.rb +9 -0
  81. data/rails/app/controllers/integration_controller.rb +5 -0
  82. data/rails/app/controllers/test_javascript_controller.rb +11 -0
  83. data/rails/app/controllers/test_word_for_controller.rb +5 -0
  84. data/rails/app/helpers/integration_helper.rb +2 -0
  85. data/rails/app/helpers/test_javascript_helper.rb +2 -0
  86. data/rails/app/helpers/test_word_for_helper.rb +2 -0
  87. data/rails/app/views/home/index.html.erb +95 -0
  88. data/rails/app/views/home/static_edit.html.erb +50 -0
  89. data/rails/app/views/home/static_edit_select.html.erb +9 -0
  90. data/rails/app/views/integration/attr.html.erb +1 -0
  91. data/rails/app/views/integration/index.html.erb +1 -0
  92. data/rails/app/views/integration/select.html.erb +3 -0
  93. data/rails/app/views/integration/value.html.erb +1 -0
  94. data/rails/app/views/layouts/integration.html.erb +14 -0
  95. data/rails/app/views/layouts/main.html.erb +14 -0
  96. data/rails/app/views/layouts/nested_test_word_for.html.erb +14 -0
  97. data/rails/app/views/layouts/test_javascript.html.erb +13 -0
  98. data/rails/app/views/layouts/test_word_for.html.erb +22 -0
  99. data/rails/app/views/test_javascript/change_value.html.erb +32 -0
  100. data/rails/app/views/test_javascript/index.html.erb +78 -0
  101. data/rails/app/views/test_word_for/_partial.html.erb +5 -0
  102. data/rails/app/views/test_word_for/index.html.erb +7 -0
  103. data/rails/config.ru +4 -0
  104. data/rails/config/application.rb +30 -0
  105. data/rails/config/boot.rb +9 -0
  106. data/rails/config/database.yml +25 -0
  107. data/rails/config/environment.rb +16 -0
  108. data/rails/config/initializers/whowish_word.rb +5 -0
  109. data/rails/config/mongoid.rb +6 -0
  110. data/rails/config/mongoid.yml +14 -0
  111. data/rails/config/routes.rb +7 -0
  112. data/rails/log/.gitignore +2 -0
  113. data/rails/mongo.bat +5 -0
  114. data/rails/public/jasmine/MIT.LICENSE +20 -0
  115. data/rails/public/jasmine/jasmine-html.js +190 -0
  116. data/rails/public/jasmine/jasmine.css +166 -0
  117. data/rails/public/jasmine/jasmine.js +2476 -0
  118. data/rails/public/jasmine/jasmine_favicon.png +0 -0
  119. data/rails/public/javascripts/jquery-1.6.4.js +9046 -0
  120. data/rails/public/sinonjs/sinonjs.js +2821 -0
  121. data/rails/public/stylesheets/main.css +22 -0
  122. data/rails/public/test/jquery_version.html +26 -0
  123. data/rails/script/rails +6 -0
  124. data/rails/spec/controllers/whowish_word_controller_spec.rb +56 -0
  125. data/rails/spec/integration/whowish_word_generator_spec.rb +116 -0
  126. data/rails/spec/integration/whowish_word_spec.rb +110 -0
  127. data/rails/spec/spec_helper.rb +44 -0
  128. data/rails/spec/support/browser.rb +194 -0
  129. data/rails/spec/support/json_rspec_helper.rb +9 -0
  130. data/rails/spec/support/mongoid_helper.rb +10 -0
  131. data/spec/spec_helper.rb +19 -0
  132. data/spec/unit/word_for_attr_in_edit_mode_spec.rb +44 -0
  133. data/spec/unit/word_for_attr_spec.rb +44 -0
  134. data/spec/unit/word_for_in_edit_mode_spec.rb +44 -0
  135. data/spec/unit/word_for_spec.rb +44 -0
  136. data/whowish_word.gemspec +21 -0
  137. metadata +181 -0
@@ -0,0 +1,6 @@
1
+
2
+ /Gemfile.lock
3
+ spec/rails/tmp/*
4
+ *.gem
5
+ rails/db/*.sqlite3
6
+ rails/tmp/*
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <loadpath>
3
+ <pathentry path="" type="src"/>
4
+ <pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
5
+ </loadpath>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>whowish_word</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.rubypeople.rdt.core.rubybuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.rubypeople.rdt.core.rubynature</nature>
16
+ </natures>
17
+ </projectDescription>
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rspec'
@@ -0,0 +1,10 @@
1
+ Process to discover where to put the hook
2
+ --------------------------------------------
3
+
4
+ In a view, please a try-catch block and print all traces.
5
+
6
+ Do this in:
7
+ 1. layout
8
+ 2. normal view
9
+ 3. partial
10
+ 4. nested layout
@@ -0,0 +1,93 @@
1
+ Current issues
2
+ ==================
3
+
4
+
5
+
6
+ Support different database engine
7
+ -------------------------------------------------
8
+
9
+ It is painful to use WhowishWord on different database (MySQL, PostgreSQL, MongoDB, Redis, ...).
10
+
11
+ Here is a cycle for a database
12
+
13
+ - Initialize structure
14
+ - Save migration version
15
+ - Rails uses it
16
+ - Do another migration
17
+ - Save the new version
18
+
19
+ There must be a better way that:
20
+ - lets user configure easily
21
+ - does not depend on 3rd library (No ORM. Really? Should we do that?)
22
+ - ActiveRecord is ok
23
+ - Mongoid is not, because it is not a standard
24
+ -
25
+
26
+ ### Solution
27
+
28
+ Just Support them directly...
29
+
30
+
31
+ ### (Not good) Solution
32
+
33
+ Use SQLite instead.
34
+ However, this poses another problem. SQLite cannot be run on Cloud service, e.g. Heroku.
35
+
36
+
37
+
38
+
39
+
40
+ A way to activate edit mode (Solved!)
41
+ -------------------------------------------------
42
+
43
+ It should be activate-able inside Rails application, e.g. a call to WhowishWord.activate_edit_mode.
44
+ We let user manage its own session.
45
+
46
+ The thing to look out is that we have to be careful about using a global variable within WhowishWord gem
47
+ because it is shared among users....
48
+
49
+ ### Solution
50
+
51
+ Create a single point of activating an edit mode, WhowishWord.activate_edit_mode()
52
+
53
+
54
+
55
+ Javascript text issue (Solved!)
56
+ ----------------------
57
+
58
+ Javascript text being enclosed with single-quotes causes an error
59
+ (Even if we'd change to double-quotes enclosing, there would still be a problem)
60
+
61
+
62
+ ### Solution 1
63
+
64
+ User is responsible to make sure that all quotes are escaped.
65
+
66
+ Input text attributes (Solved!)
67
+ ----------------------
68
+
69
+ In edit mode, we cannot add edit icon next to the element, which owns the attribute.
70
+
71
+ ### Solution
72
+
73
+ Use javascript to add the edit icon.
74
+
75
+ 1. Generate a unique text in the attribute
76
+ 2. Get the element by searching for the unique text
77
+ 3. Replace text with a whowish word
78
+ 4. Add edit icon to the element
79
+
80
+ When getting an element, we have to store the element and the attribute's name in a hash for future use.
81
+ This is because the element might not have its own ID.
82
+
83
+
84
+ Select box options (Solved!)
85
+ ---------------------
86
+
87
+ In edit mode, we cannot edit whowish word in option's value and option's text
88
+
89
+ ### Solution
90
+
91
+ Use javascript to generate edit icon
92
+
93
+
@@ -0,0 +1,72 @@
1
+ WhowishWord
2
+ ====================
3
+
4
+ Have you ever been bored when a project manager (or marketing department) keeps changing wording on a website?
5
+
6
+ WhowishWord facilitates the process of changing wording on a website.
7
+
8
+
9
+ How you should work
10
+ -------------------
11
+
12
+ 1. Activate edit mode through http://your_domain/whowish_word
13
+ 2. Go back to the website, you'll see an edit icon on each word
14
+ 3. Click on an edit icon to edit the corresponding word
15
+ 4. Fill in a new word, and click save
16
+
17
+ And when you have finished, deactivate edit mode.
18
+
19
+ WhowishWord empowers normal users (project manager, marketing department, or sales) to change wording on a website.
20
+ This take the burden off programmers because it is extremely boring to change wording...
21
+
22
+
23
+ Prerequisite
24
+ -------------------
25
+
26
+ Rails 3.0.*
27
+
28
+ (Haven't tested with Rails 3.1.*)
29
+
30
+
31
+ How to use it
32
+ -------------------
33
+
34
+ First, install it:
35
+ ```
36
+ gem install whowish_word
37
+ ```
38
+
39
+ Or, in your Gemfile, put in the below line:
40
+ ```
41
+ gem 'whowish_word'
42
+ ```
43
+
44
+ Second, create RAILS_ROOT/config/initializers/whowish_word.rb that contains:
45
+
46
+ ```ruby
47
+ require 'whowish_word'
48
+
49
+ WhowishWord.ini
50
+ ```
51
+
52
+ You can use either use :mysql or :mongodb
53
+ (I have planned to add :redis and :postgresql)
54
+
55
+ Performance
56
+ -------------------
57
+
58
+ It is fast because words are kept in memory. They are not kept in database while your Rails is running.
59
+
60
+
61
+ How to extend WhowishWord to suit your need
62
+ -------------------------------------------------
63
+
64
+ WhowishWord is nicely structure. You can extend it by writing a new handler and creator (on client-side) and a new generator (on server-side).
65
+
66
+ Please learn the code structure. If you have any question, feel free to ask me.
67
+
68
+
69
+ Author
70
+ -------------------
71
+
72
+ Tanin Na Nakorn
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run WatirRails::Application
@@ -0,0 +1 @@
1
+ WHOWISH_WORD_DATABASE_ENGINE = "mongodb" # mongodb or mysql
@@ -0,0 +1,4 @@
1
+
2
+
3
+ require File.dirname(__FILE__)+'/lib/hook'
4
+ require File.dirname(__FILE__)+'/lib/db_migration'
@@ -0,0 +1,115 @@
1
+ class WhowishWordController < ActionController::Base
2
+ before_filter :compact_policy,:check_whowish_word_admin, :choose_locale
3
+ before_filter :check_whowish_word_login, :except=>[:login,:do_login]
4
+
5
+ def check_whowish_word_login
6
+
7
+ render :login, :layout=>nil if session[:whowish_word_login] != "true"
8
+ end
9
+
10
+ def check_whowish_word_admin
11
+ $whowish_word_admin = session[:whowish_word_admin]
12
+ end
13
+
14
+ def compact_policy
15
+ response.headers['P3P'] = 'policyref="/w3c/p3p.xml", CP="'+COMPACT_POLICY+'"'
16
+ end
17
+
18
+ layout "whowish_word_blank"
19
+
20
+ def do_login
21
+ if params[:password] == "whowish#456"
22
+ session[:whowish_word_login] = "true"
23
+ index
24
+ render :index
25
+ else
26
+ @error = "The password is invalid."
27
+ render :login, :layout=>"blank"
28
+ end
29
+ end
30
+
31
+ def logout
32
+ session[:whowish_word_login] = nil
33
+ render :login, :layout=>"blank"
34
+ end
35
+
36
+ def activate
37
+ if params[:enabled]=="yes"
38
+ session[:whowish_word_admin] = true
39
+ else
40
+ session[:whowish_word_admin] = false
41
+ end
42
+
43
+ render :json=>{:ok=>true}
44
+ end
45
+
46
+
47
+ SHOW_FIELDS = [
48
+ {:id=>"word_id",:width=>300},
49
+ {:id=>"content",:type=>"textarea",:width=>350}]
50
+
51
+ def index
52
+ @fs = SHOW_FIELDS
53
+ end
54
+
55
+ def get_word
56
+ logger.debug { "locale=#{$locale}"}
57
+ entity = WhowishWord.first(:conditions=>{:word_id => params[:word_id].strip})
58
+
59
+ render :json=>{:content=>""} and return if !entity
60
+ render :json=>{:content=>entity.content}
61
+ end
62
+
63
+ def change_word
64
+
65
+ entity = nil
66
+
67
+ if params[:id]
68
+ entity = WhowishWord.first(:conditions=>{:id => params[:id]})
69
+ else
70
+ entity = WhowishWord.first(:conditions=>{:word_id => params[:word_id].strip})
71
+ end
72
+
73
+ if !entity
74
+ #render :json=>{:ok=>false,:error_message=>"Cannot find "+params[:page_id]+":"+params[:word_id]} and return
75
+
76
+ entity = WhowishWord.new
77
+ entity.word_id = params[:word_id].strip
78
+ entity.content = params[:content].strip
79
+
80
+ end
81
+
82
+ entity.word_id = params[:word_id].strip
83
+ entity.content = params[:content].strip
84
+ entity.save
85
+
86
+ ActionView::Base.whowish_word[entity.word_id] = entity.content
87
+
88
+ render :json=>{:ok=>true}
89
+ end
90
+
91
+ def add
92
+
93
+ entity = WhowishWord.new
94
+ entity.word_id = params[:word_id].strip
95
+ entity.content = params[:content].strip
96
+
97
+ if !entity.save
98
+ render :json => {:ok=>false, :error_message=>format_error(entity.errors)}
99
+ return
100
+ end
101
+
102
+ render :json=>{:ok=>true ,:new_row=>render_to_string(:partial=>"row.html",:locals=>{:entity=>entity,:field_set=>SHOW_FIELDS,:is_new=>false}), :entity=> entity}
103
+
104
+ end
105
+
106
+ def delete
107
+
108
+ if !WhowishWord.delete(params[:id])
109
+ render :json=>{:ok=>false,:error_message=>"error while delete location"}
110
+ return
111
+ end
112
+
113
+ render :json=>{:ok=>true}
114
+ end
115
+ end
@@ -0,0 +1,66 @@
1
+ class WhowishWordEmailController < ActionController::Base
2
+
3
+ before_filter :compact_policy,:check_whowish_word_admin
4
+
5
+ def check_whowish_word_admin
6
+ $whowish_word_admin = session[:whowish_word_admin]
7
+ end
8
+
9
+ def compact_policy
10
+ response.headers['P3P'] = 'policyref="/w3c/p3p.xml", CP="'+COMPACT_POLICY+'"'
11
+ end
12
+
13
+ layout "whowish_word_blank"
14
+
15
+ def index
16
+
17
+ end
18
+
19
+ def add
20
+
21
+ email = WhowishWordEmail.new
22
+ email.page_id = params[:page_id].strip
23
+ email.word_id = params[:word_id].strip
24
+ email.content = params[:content].strip
25
+ email.locale = "en"
26
+
27
+ email.save
28
+
29
+ ActionView::Base.whowish_word[entity.page_id] = {} if !ActionView::Base.whowish_word[entity.page_id]
30
+ ActionView::Base.whowish_word[entity.page_id][entity.word_id.to_sym] = entity.content
31
+
32
+ render :json=>{:ok=>true,:html=>(render_to_string :partial=>"row",:locals=>{:entity=>email,:is_new=>false})}
33
+ end
34
+
35
+ def edit
36
+
37
+ entity = WhowishWordEmail.first(:conditions=>{:id=>params[:id]})
38
+
39
+ if !entity
40
+ render :json=>{:ok=>false,:error_message=>"The email record does not exist."}
41
+ return
42
+ end
43
+
44
+ entity.page_id = params[:page_id].strip
45
+ entity.word_id = params[:word_id].strip
46
+ entity.content = params[:content].strip
47
+ entity.locale = "en"
48
+
49
+ ActionView::Base.whowish_word[entity.page_id] = {} if !ActionView::Base.whowish_word[entity.page_id]
50
+ ActionView::Base.whowish_word[entity.page_id][entity.word_id.to_sym] = entity.content
51
+
52
+ entity.save
53
+
54
+ render :json=>{:ok=>true}
55
+ end
56
+
57
+ def delete
58
+ if !WhowishWordEmail.delete(params[:id])
59
+ render :json=>{:ok=>false,:error_message=>"error while delete location"}
60
+ return
61
+ end
62
+
63
+ render :json=>{:ok=>true}
64
+ end
65
+
66
+ end
@@ -0,0 +1,62 @@
1
+ class WhowishWordFacebookController < ActionController::Base
2
+
3
+ before_filter :compact_policy,:check_whowish_word_admin
4
+
5
+ def check_whowish_word_admin
6
+ $whowish_word_admin = session[:whowish_word_admin]
7
+ end
8
+
9
+ def compact_policy
10
+ response.headers['P3P'] = 'policyref="/w3c/p3p.xml", CP="'+COMPACT_POLICY+'"'
11
+ end
12
+
13
+ layout "whowish_word_blank"
14
+
15
+
16
+ def index
17
+
18
+ end
19
+
20
+ def add
21
+
22
+ facebook = WhowishWordFacebook.new(:publish_id=>params[:publish_id].strip,
23
+ :message=>params[:message].strip,
24
+ :name=>params[:name].strip,
25
+ :caption=>params[:caption].strip,
26
+ :description=>params[:description].strip,
27
+ :locale=>"en"
28
+ )
29
+ facebook.save
30
+
31
+ render :json=>{:ok=>true,:html=>(render_to_string :partial=>"row",:locals=>{:entity=>facebook,:is_new=>false})}
32
+ end
33
+
34
+ def edit
35
+
36
+ facebook = WhowishWordFacebook.first(:conditions=>{:id=>params[:id]})
37
+
38
+ if !facebook
39
+ render :json=>{:ok=>false,:error_message=>"The facebook record does not exist."}
40
+ return
41
+ end
42
+
43
+ facebook.update_attributes(:publish_id=>params[:publish_id].strip,
44
+ :message=>params[:message].strip,
45
+ :name=>params[:name].strip,
46
+ :caption=>params[:caption].strip,
47
+ :description=>params[:description].strip,
48
+ :locale=>"en"
49
+ )
50
+
51
+ render :json=>{:ok=>true}
52
+ end
53
+
54
+ def delete
55
+ if !WhowishWordFacebook.delete(params[:id])
56
+ render :json=>{:ok=>false,:error_message=>"error while delete location"}
57
+ return
58
+ end
59
+
60
+ render :json=>{:ok=>true}
61
+ end
62
+ end