tr8n 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. data/.gitignore +6 -3
  2. data/.rspec +2 -0
  3. data/Gemfile +3 -6
  4. data/Gemfile.lock +21 -6
  5. data/README.rdoc +61 -33
  6. data/Rakefile +1 -11
  7. data/app/assets/images/tr8n/photo_system.gif +0 -0
  8. data/app/assets/stylesheets/tr8n/application.css +42 -1
  9. data/{test/dummy/app/assets/stylesheets/components.css.scss → app/assets/stylesheets/tr8n/component.css.scss} +0 -0
  10. data/{test/dummy/app/assets/stylesheets → app/assets/stylesheets/tr8n}/layout.css.scss +0 -0
  11. data/app/assets/stylesheets/tr8n/tr8n.css.scss +16 -8
  12. data/app/controllers/tr8n/admin/base_controller.rb +1 -1
  13. data/app/controllers/tr8n/admin/clientsdk_controller.rb +1 -1
  14. data/app/controllers/tr8n/admin/domain_controller.rb +1 -1
  15. data/app/controllers/tr8n/admin/forum_controller.rb +1 -1
  16. data/app/controllers/tr8n/admin/glossary_controller.rb +1 -1
  17. data/app/controllers/tr8n/admin/language_controller.rb +1 -1
  18. data/app/controllers/tr8n/admin/translation_controller.rb +1 -1
  19. data/app/controllers/tr8n/admin/translation_key_controller.rb +5 -1
  20. data/app/controllers/tr8n/admin/translator_controller.rb +1 -1
  21. data/app/{helpers/tr8n/application_helper.rb → controllers/tr8n/api/v1/sync_controller.rb} +6 -3
  22. data/app/controllers/tr8n/awards_controller.rb +12 -12
  23. data/app/controllers/tr8n/base_controller.rb +140 -137
  24. data/app/controllers/tr8n/dashboard_controller.rb +2 -1
  25. data/app/controllers/tr8n/forum_controller.rb +1 -1
  26. data/app/controllers/tr8n/glossary_controller.rb +1 -1
  27. data/app/controllers/tr8n/help_controller.rb +1 -1
  28. data/app/controllers/tr8n/language_cases_controller.rb +43 -45
  29. data/app/controllers/tr8n/language_controller.rb +1 -1
  30. data/app/controllers/tr8n/phrases_controller.rb +1 -1
  31. data/app/controllers/tr8n/translations_controller.rb +1 -1
  32. data/app/controllers/tr8n/translator_controller.rb +1 -1
  33. data/app/helpers/tr8n/base_helper.rb +0 -4
  34. data/app/models/tr8n/base_filter.rb +1 -1
  35. data/app/models/tr8n/daily_language_metric.rb +1 -1
  36. data/app/models/tr8n/date_rule.rb +1 -1
  37. data/app/models/tr8n/gender_list_rule.rb +1 -1
  38. data/app/models/tr8n/gender_rule.rb +1 -1
  39. data/app/models/tr8n/glossary.rb +1 -1
  40. data/app/models/tr8n/glossary_filter.rb +1 -1
  41. data/app/models/tr8n/integration/ru/russian_gender_list_rule.rb +1 -1
  42. data/app/models/tr8n/integration/ru/russian_numeric_rule.rb +1 -1
  43. data/app/models/tr8n/ip_location.rb +1 -1
  44. data/app/models/tr8n/ip_location_filter.rb +1 -1
  45. data/app/models/tr8n/language.rb +17 -8
  46. data/app/models/tr8n/language_case.rb +1 -1
  47. data/app/models/tr8n/language_case_filter.rb +1 -1
  48. data/app/models/tr8n/language_case_rule.rb +1 -1
  49. data/app/models/tr8n/language_case_rule_filter.rb +1 -1
  50. data/app/models/tr8n/language_case_value_map.rb +1 -1
  51. data/app/models/tr8n/language_case_value_map_filter.rb +1 -1
  52. data/app/models/tr8n/language_filter.rb +1 -1
  53. data/app/models/tr8n/language_forum_abuse_report.rb +1 -1
  54. data/app/models/tr8n/language_forum_abuse_report_filter.rb +1 -1
  55. data/app/models/tr8n/language_forum_message.rb +2 -2
  56. data/app/models/tr8n/language_forum_message_filter.rb +1 -1
  57. data/app/models/tr8n/language_forum_topic.rb +3 -3
  58. data/app/models/tr8n/language_forum_topic_filter.rb +1 -1
  59. data/app/models/tr8n/language_metric.rb +2 -2
  60. data/app/models/tr8n/language_metric_filter.rb +1 -1
  61. data/app/models/tr8n/language_rule.rb +37 -2
  62. data/app/models/tr8n/language_rule_filter.rb +1 -1
  63. data/app/models/tr8n/language_user.rb +3 -3
  64. data/app/models/tr8n/language_user_filter.rb +1 -1
  65. data/app/models/tr8n/list_rule.rb +1 -1
  66. data/app/models/tr8n/monthly_language_metric.rb +2 -2
  67. data/app/models/tr8n/numeric_rule.rb +1 -1
  68. data/app/models/tr8n/sync_log.rb +76 -0
  69. data/app/{controllers/tr8n/application_controller.rb → models/tr8n/sync_log_filter.rb} +4 -3
  70. data/app/models/tr8n/total_language_metric.rb +5 -4
  71. data/app/models/tr8n/translation.rb +61 -13
  72. data/app/models/tr8n/translation_domain.rb +1 -1
  73. data/app/models/tr8n/translation_domain_filter.rb +1 -1
  74. data/app/models/tr8n/translation_filter.rb +1 -1
  75. data/app/models/tr8n/translation_key.rb +33 -5
  76. data/app/models/tr8n/translation_key_comment.rb +1 -1
  77. data/app/models/tr8n/translation_key_comment_filter.rb +1 -1
  78. data/app/models/tr8n/translation_key_filter.rb +1 -1
  79. data/app/models/tr8n/translation_key_lock.rb +2 -2
  80. data/app/models/tr8n/translation_key_lock_filter.rb +1 -1
  81. data/app/models/tr8n/translation_key_source.rb +2 -2
  82. data/app/models/tr8n/translation_key_source_filter.rb +1 -1
  83. data/app/models/tr8n/translation_source.rb +2 -2
  84. data/app/models/tr8n/translation_source_filter.rb +1 -1
  85. data/app/models/tr8n/translation_vote.rb +3 -4
  86. data/app/models/tr8n/translation_vote_filter.rb +1 -1
  87. data/app/models/tr8n/translator.rb +19 -5
  88. data/app/models/tr8n/translator_filter.rb +1 -1
  89. data/app/models/tr8n/translator_following.rb +2 -2
  90. data/app/models/tr8n/translator_following_filter.rb +1 -1
  91. data/app/models/tr8n/translator_log.rb +1 -1
  92. data/app/models/tr8n/translator_log_filter.rb +1 -1
  93. data/app/models/tr8n/translator_metric.rb +15 -21
  94. data/app/models/tr8n/translator_metric_filter.rb +1 -1
  95. data/app/models/tr8n/translator_report.rb +2 -2
  96. data/app/models/tr8n/translator_report_filter.rb +1 -1
  97. data/app/models/tr8n/value_rule.rb +1 -1
  98. data/app/views/tr8n/admin/common/_paginator.html.erb +29 -17
  99. data/app/views/tr8n/admin/translation_key/_tabs.html.erb +3 -1
  100. data/app/views/tr8n/admin/translation_key/sync_logs.html.erb +5 -0
  101. data/app/views/tr8n/awards/index.html.erb +0 -2
  102. data/app/views/tr8n/common/_paginator.html.erb +24 -6
  103. data/app/views/tr8n/common/_tabs.html.erb +9 -5
  104. data/app/views/tr8n/forum/_messages.html.erb +1 -1
  105. data/app/views/tr8n/forum/index.html.erb +1 -1
  106. data/app/views/tr8n/glossary/index.html.erb +2 -2
  107. data/app/views/tr8n/{home → help}/credits.html.erb +0 -0
  108. data/app/views/tr8n/{home → help}/license.html.erb +0 -0
  109. data/app/views/tr8n/language_cases/index.html.erb +2 -2
  110. data/app/views/tr8n/phrases/_comments_module.html.erb +1 -1
  111. data/app/views/tr8n/phrases/index.html.erb +2 -6
  112. data/app/views/tr8n/translations/_list.html.erb +2 -6
  113. data/config/routes.rb +2 -2
  114. data/config/tr8n/config.yml +48 -13
  115. data/config/tr8n/rules/default_language_cases.yml +272 -0
  116. data/config/tr8n/tokens/data.yml +3 -1
  117. data/db/migrate/20111003194443_create_tr8n_sync_tables.rb +22 -0
  118. data/db/migrate/20111011013640_add_remote_id_to_tr8n_translators.rb +5 -0
  119. data/doc/classes.graffle +7049 -5152
  120. data/doc/classes.pdf +0 -0
  121. data/lib/generators/tr8n/templates/{create_tr8n_tables.rb → db/create_tr8n_tables.rb} +0 -0
  122. data/lib/generators/tr8n/templates/layouts/tr8n.html.erb +49 -0
  123. data/lib/generators/tr8n/templates/layouts/tr8n_admin.html.erb +61 -0
  124. data/lib/generators/tr8n/tr8n_generator.rb +11 -4
  125. data/lib/tasks/{tr8n_tasks.rake → tr8n.rake} +4 -0
  126. data/{app/controllers/tr8n/home_controller.rb → lib/tr8n/cache_adapters/memcached.rb} +12 -15
  127. data/lib/tr8n/config.rb +96 -53
  128. data/lib/tr8n/extensions/action_controller_extension.rb +1 -1
  129. data/lib/tr8n/extensions/action_view_extension.rb +4 -28
  130. data/lib/tr8n/tokens/data_token.rb +1 -1
  131. data/lib/tr8n/tokens/method_token.rb +1 -1
  132. data/lib/tr8n/tokens/transform_token.rb +1 -1
  133. data/lib/tr8n/version.rb +1 -1
  134. data/{test/dummy → local/tr8n_server}/Rakefile +1 -1
  135. data/{test/dummy → local/tr8n_server}/app/assets/javascripts/application.js +0 -0
  136. data/{test/dummy → local/tr8n_server}/app/assets/stylesheets/admin.css +0 -0
  137. data/{test/dummy → local/tr8n_server}/app/assets/stylesheets/application.css +0 -0
  138. data/local/tr8n_server/app/assets/stylesheets/components.css.scss +211 -0
  139. data/local/tr8n_server/app/assets/stylesheets/layout.css.scss +143 -0
  140. data/{test/dummy → local/tr8n_server}/app/controllers/admin/admins_controller.rb +0 -0
  141. data/{test/dummy → local/tr8n_server}/app/controllers/admin/base_controller.rb +0 -0
  142. data/{test/dummy → local/tr8n_server}/app/controllers/admin/users_controller.rb +0 -0
  143. data/{test/dummy → local/tr8n_server}/app/controllers/application_controller.rb +5 -0
  144. data/{test/dummy → local/tr8n_server}/app/controllers/demo_controller.rb +0 -0
  145. data/local/tr8n_server/app/controllers/home_controller.rb +4 -0
  146. data/{test/dummy → local/tr8n_server}/app/controllers/login_controller.rb +1 -1
  147. data/{test/dummy → local/tr8n_server}/app/helpers/application_helper.rb +0 -0
  148. data/{test/dummy → local/tr8n_server}/app/helpers/home_helper.rb +0 -0
  149. data/{test/dummy → local/tr8n_server}/app/mailers/.gitkeep +0 -0
  150. data/{test/dummy → local/tr8n_server}/app/models/.gitkeep +0 -0
  151. data/{test/dummy → local/tr8n_server}/app/models/admin.rb +0 -0
  152. data/{test/dummy → local/tr8n_server}/app/models/admin_filter.rb +0 -0
  153. data/{test/dummy → local/tr8n_server}/app/models/user.rb +0 -0
  154. data/{test/dummy → local/tr8n_server}/app/views/admin/admins/index.html.erb +0 -0
  155. data/{test/dummy → local/tr8n_server}/app/views/admin/users/index.html.erb +0 -0
  156. data/{test/dummy → local/tr8n_server}/app/views/demo/index.rhtml +0 -0
  157. data/{test/dummy → local/tr8n_server}/app/views/demo/tokens.rhtml +0 -0
  158. data/{app/views/tr8n → local/tr8n_server/app/views}/home/index.html.erb +1 -2
  159. data/local/tr8n_server/app/views/kaminari/_first_page.html.erb +11 -0
  160. data/local/tr8n_server/app/views/kaminari/_gap.html.erb +8 -0
  161. data/local/tr8n_server/app/views/kaminari/_last_page.html.erb +11 -0
  162. data/local/tr8n_server/app/views/kaminari/_next_page.html.erb +11 -0
  163. data/local/tr8n_server/app/views/kaminari/_page.html.erb +12 -0
  164. data/local/tr8n_server/app/views/kaminari/_paginator.html.erb +23 -0
  165. data/local/tr8n_server/app/views/kaminari/_prev_page.html.erb +11 -0
  166. data/{test/dummy → local/tr8n_server}/app/views/layouts/_flashes.html.erb +0 -0
  167. data/{test/dummy → local/tr8n_server}/app/views/layouts/_footer.html.erb +3 -3
  168. data/{test/dummy → local/tr8n_server}/app/views/layouts/_header.html.erb +1 -1
  169. data/{test/dummy → local/tr8n_server}/app/views/layouts/admin.html.erb +0 -0
  170. data/{test/dummy → local/tr8n_server}/app/views/layouts/application.html.erb +0 -0
  171. data/local/tr8n_server/app/views/layouts/tr8n.html.erb +51 -0
  172. data/local/tr8n_server/app/views/layouts/tr8n_admin.html.erb +61 -0
  173. data/{test/dummy → local/tr8n_server}/app/views/login/index.html.erb +0 -0
  174. data/{test/dummy → local/tr8n_server}/app/views/login/register.html.erb +8 -13
  175. data/{test/dummy → local/tr8n_server}/config.ru +1 -1
  176. data/{test/dummy → local/tr8n_server}/config/application.rb +2 -1
  177. data/{test/dummy → local/tr8n_server}/config/boot.rb +0 -0
  178. data/{test/dummy → local/tr8n_server}/config/database.yml +0 -0
  179. data/{test/dummy → local/tr8n_server}/config/environment.rb +1 -1
  180. data/{test/dummy → local/tr8n_server}/config/environments/development.rb +3 -1
  181. data/{test/dummy → local/tr8n_server}/config/environments/production.rb +1 -1
  182. data/{test/dummy → local/tr8n_server}/config/environments/test.rb +1 -1
  183. data/{test/dummy → local/tr8n_server}/config/initializers/backtrace_silencers.rb +0 -0
  184. data/{test/dummy → local/tr8n_server}/config/initializers/inflections.rb +0 -0
  185. data/{test/dummy → local/tr8n_server}/config/initializers/mime_types.rb +0 -0
  186. data/{test/dummy → local/tr8n_server}/config/initializers/secret_token.rb +1 -1
  187. data/{test/dummy → local/tr8n_server}/config/initializers/session_store.rb +2 -2
  188. data/{test/dummy → local/tr8n_server}/config/initializers/wrap_parameters.rb +0 -0
  189. data/{test/dummy → local/tr8n_server}/config/locales/en.yml +0 -0
  190. data/{test/dummy → local/tr8n_server}/config/routes.rb +2 -2
  191. data/{test/dummy → local/tr8n_server}/config/tr8n/config.yml +40 -11
  192. data/{test/dummy → local/tr8n_server}/config/tr8n/data/ip_locations.csv +0 -0
  193. data/{test/dummy → local/tr8n_server}/config/tr8n/rules/default_date_rules.yml +0 -0
  194. data/{test/dummy → local/tr8n_server}/config/tr8n/rules/default_gender_list_rules.yml +0 -0
  195. data/{test/dummy → local/tr8n_server}/config/tr8n/rules/default_gender_rules.yml +0 -0
  196. data/local/tr8n_server/config/tr8n/rules/default_language_cases.yml +272 -0
  197. data/{test/dummy → local/tr8n_server}/config/tr8n/rules/default_list_rules.yml +0 -0
  198. data/{test/dummy → local/tr8n_server}/config/tr8n/rules/default_numeric_rules.yml +0 -0
  199. data/{test/dummy → local/tr8n_server}/config/tr8n/rules/default_value_rules.yml +0 -0
  200. data/{test/dummy → local/tr8n_server}/config/tr8n/site/default_glossary.yml +0 -0
  201. data/{test/dummy → local/tr8n_server}/config/tr8n/site/default_languages.yml +0 -0
  202. data/{test/dummy → local/tr8n_server}/config/tr8n/site/features.yml +0 -0
  203. data/{test/dummy → local/tr8n_server}/config/tr8n/site/shortcuts.yml +0 -0
  204. data/{test/dummy → local/tr8n_server}/config/tr8n/site/sitemap.json +0 -0
  205. data/{test/dummy → local/tr8n_server}/config/tr8n/tokens/data.yml +2 -0
  206. data/{test/dummy → local/tr8n_server}/config/tr8n/tokens/decorations.yml +0 -0
  207. data/{test/dummy → local/tr8n_server}/config/will_filter/config.yml +0 -0
  208. data/{test/dummy → local/tr8n_server}/db/migrate/20101207014543_create_users.rb +0 -0
  209. data/{test/dummy → local/tr8n_server}/db/migrate/20110113223509_create_admins.rb +0 -0
  210. data/{test/dummy → local/tr8n_server}/db/migrate/20110930041143_create_will_filter_filters.rb +0 -0
  211. data/{test/dummy → local/tr8n_server}/db/migrate/20110930041150_create_tr8n_tables.rb +0 -0
  212. data/local/tr8n_server/db/migrate/20111003194443_create_tr8n_sync_tables.rb +22 -0
  213. data/local/tr8n_server/db/migrate/20111011013640_add_remote_id_to_tr8n_translators.rb +5 -0
  214. data/{test/dummy → local/tr8n_server}/db/schema.rb +15 -1
  215. data/{test/dummy → local/tr8n_server}/lib/assets/.gitkeep +0 -0
  216. data/{test/dummy → local/tr8n_server}/public/404.html +0 -0
  217. data/{test/dummy → local/tr8n_server}/public/422.html +0 -0
  218. data/{test/dummy → local/tr8n_server}/public/500.html +0 -0
  219. data/{test/dummy → local/tr8n_server}/public/favicon.ico +0 -0
  220. data/{test/dummy → local/tr8n_server}/script/rails +0 -0
  221. data/script/rails +1 -1
  222. data/spec/config/config_spec.rb +10 -0
  223. data/spec/fake_app.rb +50 -0
  224. data/spec/lib/data_token_spec.rb +26 -0
  225. data/spec/lib/transform_token_spec.rb +22 -0
  226. data/spec/models/translation_key_spec.rb +63 -0
  227. data/spec/spec_helper.rb +29 -0
  228. data/tr8n.gemspec +3 -1
  229. metadata +264 -245
  230. data/app/assets/images/tr8n/tr8n_logo.png +0 -0
  231. data/app/assets/images/tr8n/tr8n_logo2.gif +0 -0
  232. data/app/controllers/tr8n/login_controller.rb +0 -86
  233. data/app/views/layouts/_footer.html.erb +0 -15
  234. data/app/views/layouts/_header.html.erb +0 -12
  235. data/app/views/layouts/_html_head.html.erb +0 -5
  236. data/app/views/layouts/tr8n.html.erb +0 -21
  237. data/app/views/layouts/tr8n/application.html.erb +0 -14
  238. data/app/views/layouts/tr8n_admin.html.erb +0 -33
  239. data/app/views/tr8n/home/languages.html.erb +0 -7
  240. data/app/views/tr8n/login/index.html.erb +0 -33
  241. data/app/views/tr8n/login/register.html.erb +0 -57
  242. data/config/tr8n/rules/default_cases.yml +0 -141
  243. data/test/dummy/.sass-cache/32be4db30d38349a3a6e662df9bb5599dc8033b9/actions.css.scssc +0 -0
  244. data/test/dummy/.sass-cache/32be4db30d38349a3a6e662df9bb5599dc8033b9/buttons.css.scssc +0 -0
  245. data/test/dummy/.sass-cache/32be4db30d38349a3a6e662df9bb5599dc8033b9/calendar.css.scssc +0 -0
  246. data/test/dummy/.sass-cache/32be4db30d38349a3a6e662df9bb5599dc8033b9/exporter.css.scssc +0 -0
  247. data/test/dummy/.sass-cache/32be4db30d38349a3a6e662df9bb5599dc8033b9/filter.css.scssc +0 -0
  248. data/test/dummy/.sass-cache/32be4db30d38349a3a6e662df9bb5599dc8033b9/results.css.scssc +0 -0
  249. data/test/dummy/.sass-cache/3d45bab40fcae805deb2750a9342f5b355a9f2bf/components.css.scssc +0 -0
  250. data/test/dummy/.sass-cache/3d45bab40fcae805deb2750a9342f5b355a9f2bf/layout.css.scssc +0 -0
  251. data/test/dummy/.sass-cache/50f723c1dd802042d0091035528d53e6d5bc5b50/tr8n.css.scssc +0 -0
  252. data/test/dummy/.sass-cache/bce64928c8e2edcba72a647a44f05af1ff119c5d/actions.css.scssc +0 -0
  253. data/test/dummy/.sass-cache/bce64928c8e2edcba72a647a44f05af1ff119c5d/buttons.css.scssc +0 -0
  254. data/test/dummy/.sass-cache/bce64928c8e2edcba72a647a44f05af1ff119c5d/calendar.css.scssc +0 -0
  255. data/test/dummy/.sass-cache/bce64928c8e2edcba72a647a44f05af1ff119c5d/exporter.css.scssc +0 -0
  256. data/test/dummy/.sass-cache/bce64928c8e2edcba72a647a44f05af1ff119c5d/filter.css.scssc +0 -0
  257. data/test/dummy/.sass-cache/bce64928c8e2edcba72a647a44f05af1ff119c5d/results.css.scssc +0 -0
  258. data/test/dummy/app/assets/stylesheets/keyboard.css +0 -147
  259. data/test/dummy/config/tr8n/rules/default_cases.yml +0 -141
  260. data/test/dummy/log/.gitkeep +0 -0
  261. data/test/dummy/test/functional/home_controller_test.rb +0 -9
  262. data/test/dummy/test/unit/helpers/home_helper_test.rb +0 -4
  263. data/test/integration/navigation_test.rb +0 -10
  264. data/test/test_helper.rb +0 -10
  265. data/test/tr8n_test.rb +0 -7
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -21,21 +21,21 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- class Tr8n::AwardsController < Tr8n::BaseController
24
+ module Tr8n
25
+ class AwardsController < Tr8n::BaseController
25
26
 
26
- before_filter :validate_current_translator
27
+ before_filter :validate_current_translator
27
28
 
28
- def index
29
- params[:mode] = "all" if tr8n_current_language.default?
29
+ def index
30
+ if params[:mode] == "all"
31
+ @translator_metrics = Tr8n::TranslatorMetric.where("language_id is null").order("total_translations desc, total_votes desc").limit(25)
32
+ else
33
+ @translator_metrics = Tr8n::TranslatorMetric.where("language_id = ?", tr8n_current_language.id).order("total_translations desc, total_votes desc").limit(25)
34
+ end
30
35
 
31
- if params[:mode] == "all"
32
- @translator_metrics = Tr8n::TranslatorMetric.where("language_id is null").order("total_translations desc, total_votes desc").limit(25)
33
- else
34
- @translator_metrics = Tr8n::TranslatorMetric.where("language_id = ?", tr8n_current_language.id).order("total_translations desc, total_votes desc").limit(25)
36
+ @leaders = @translator_metrics[0..2]
37
+ @runners = (@translator_metrics.size > 3) ? @translator_metrics[3..-1] : []
35
38
  end
36
39
 
37
- @leaders = @translator_metrics[0..2]
38
- @runners = (@translator_metrics.size > 3) ? @translator_metrics[3..-1] : []
39
40
  end
40
-
41
41
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -21,186 +21,189 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- class Tr8n::BaseController < ApplicationController
24
+ module Tr8n
25
+ class BaseController < ApplicationController
25
26
 
26
- layout Tr8n::Config.site_info[:tr8n_layout]
27
+ layout Tr8n::Config.site_info[:tr8n_layout]
27
28
 
28
- if Tr8n::Config.tr8n_helpers.any?
29
- helper *Tr8n::Config.tr8n_helpers
30
- end
29
+ if Tr8n::Config.tr8n_helpers.any?
30
+ helper *Tr8n::Config.tr8n_helpers
31
+ end
31
32
 
32
- if Tr8n::Config.skip_before_filters.any?
33
- skip_before_filter *Tr8n::Config.skip_before_filters
34
- end
33
+ if Tr8n::Config.skip_before_filters.any?
34
+ skip_before_filter *Tr8n::Config.skip_before_filters
35
+ end
35
36
 
36
- if Tr8n::Config.before_filters.any?
37
- before_filter *Tr8n::Config.before_filters
38
- end
37
+ if Tr8n::Config.before_filters.any?
38
+ before_filter *Tr8n::Config.before_filters
39
+ end
39
40
 
40
- if Tr8n::Config.after_filters.any?
41
- after_filter *Tr8n::Config.after_filters
42
- end
41
+ if Tr8n::Config.after_filters.any?
42
+ after_filter *Tr8n::Config.after_filters
43
+ end
43
44
 
44
- before_filter :validate_tr8n_enabled, :except => [:translate]
45
- before_filter :validate_guest_user, :except => [:select, :switch, :translate, :table]
46
- before_filter :validate_current_user, :except => [:translate]
45
+ before_filter :validate_tr8n_enabled, :except => [:translate]
46
+ before_filter :validate_guest_user, :except => [:select, :switch, :translate, :table]
47
+ before_filter :validate_current_user, :except => [:translate]
47
48
 
48
- layout Tr8n::Config.site_info[:tr8n_layout]
49
+ layout Tr8n::Config.site_info[:tr8n_layout]
49
50
 
50
- def tr8n_current_user
51
- Tr8n::Config.current_user
52
- end
53
- helper_method :tr8n_current_user
51
+ def tr8n_current_user
52
+ Tr8n::Config.current_user
53
+ end
54
+ helper_method :tr8n_current_user
54
55
 
55
- def tr8n_current_language
56
- Tr8n::Config.current_language
57
- end
58
- helper_method :tr8n_current_language
56
+ def tr8n_current_language
57
+ Tr8n::Config.current_language
58
+ end
59
+ helper_method :tr8n_current_language
59
60
 
60
- def tr8n_default_language
61
- Tr8n::Config.default_language
62
- end
63
- helper_method :tr8n_default_language
61
+ def tr8n_default_language
62
+ Tr8n::Config.default_language
63
+ end
64
+ helper_method :tr8n_default_language
64
65
 
65
- def tr8n_current_translator
66
- Tr8n::Config.current_translator
67
- end
68
- helper_method :tr8n_current_translator
66
+ def tr8n_current_translator
67
+ Tr8n::Config.current_translator
68
+ end
69
+ helper_method :tr8n_current_translator
69
70
 
70
- def tr8n_current_user_is_admin?
71
- Tr8n::Config.current_user_is_admin?
72
- end
73
- helper_method :tr8n_current_user_is_admin?
71
+ def tr8n_current_user_is_admin?
72
+ Tr8n::Config.current_user_is_admin?
73
+ end
74
+ helper_method :tr8n_current_user_is_admin?
74
75
 
75
- def tr8n_current_user_is_translator?
76
- Tr8n::Config.current_user_is_translator?
77
- end
78
- helper_method :tr8n_current_user_is_translator?
76
+ def tr8n_current_user_is_translator?
77
+ Tr8n::Config.current_user_is_translator?
78
+ end
79
+ helper_method :tr8n_current_user_is_translator?
79
80
 
80
- def tr8n_current_user_is_manager?
81
- return false unless Tr8n::Config.current_user_is_translator?
82
- tr8n_current_translator.manager?
83
- end
84
- helper_method :tr8n_current_user_is_manager?
81
+ def tr8n_current_user_is_manager?
82
+ return true if Tr8n::Config.current_user_is_admin?
83
+ return false unless Tr8n::Config.current_user_is_translator?
84
+ tr8n_current_translator.manager?
85
+ end
86
+ helper_method :tr8n_current_user_is_manager?
85
87
 
86
- def tr8n_current_user_is_guest?
87
- Tr8n::Config.current_user_is_guest?
88
- end
89
- helper_method :tr8n_current_user_is_guest?
88
+ def tr8n_current_user_is_guest?
89
+ Tr8n::Config.current_user_is_guest?
90
+ end
91
+ helper_method :tr8n_current_user_is_guest?
90
92
 
91
- private
93
+ private
92
94
 
93
- def tr8n_features_tabs
94
- @tabs ||= begin
95
- tabs = Tr8n::Config.features.clone
96
- unless Tr8n::Config.multiple_base_languages?
97
- tabs = tabs.select{|tab| tab[:default_language]} if tr8n_current_language.default?
98
- end
95
+ def tr8n_features_tabs
96
+ @tabs ||= begin
97
+ tabs = Tr8n::Config.features.clone
98
+ unless Tr8n::Config.multiple_base_languages?
99
+ tabs = tabs.select{|tab| tab[:default_language]} if tr8n_current_language.default?
100
+ end
99
101
 
100
- unless tr8n_current_user_is_translator? and tr8n_current_translator.manager?
101
- tabs = tabs.select{|tab| !tab[:manager_only]}
102
+ unless tr8n_current_user_is_translator? and tr8n_current_translator.manager?
103
+ tabs = tabs.select{|tab| !tab[:manager_only]}
104
+ end
105
+ tabs
102
106
  end
103
- tabs
104
107
  end
105
- end
106
- helper_method :tr8n_features_tabs
108
+ helper_method :tr8n_features_tabs
107
109
 
108
- def redirect_to_source
109
- return redirect_to(params[:source_url]) unless params[:source_url].blank?
110
- return redirect_to(request.env['HTTP_REFERER']) unless request.env['HTTP_REFERER'].blank?
111
- redirect_to_site_default_url
112
- end
110
+ def redirect_to_source
111
+ return redirect_to(params[:source_url]) unless params[:source_url].blank?
112
+ return redirect_to(request.env['HTTP_REFERER']) unless request.env['HTTP_REFERER'].blank?
113
+ redirect_to_site_default_url
114
+ end
113
115
 
114
- def redirect_to_site_default_url
115
- redirect_to(Tr8n::Config.default_url)
116
- end
116
+ def redirect_to_site_default_url
117
+ redirect_to(Tr8n::Config.default_url)
118
+ end
117
119
 
118
- def page
119
- params[:page] || 1
120
- end
120
+ def page
121
+ params[:page] || 1
122
+ end
121
123
 
122
- def per_page
123
- params[:per_page] || 30
124
- end
124
+ def per_page
125
+ params[:per_page] || 30
126
+ end
125
127
 
126
- def sanitize_label(label)
127
- # do not double escape
128
- # CGI::escapeHTML(label.strip)
129
- ERB::Util.html_escape(label.strip)
130
- end
128
+ def sanitize_label(label)
129
+ # do not double escape
130
+ # CGI::escapeHTML(label.strip)
131
+ ERB::Util.html_escape(label.strip)
132
+ end
131
133
 
132
- # handle disabled state for tr8n
133
- def validate_tr8n_enabled
134
- if Tr8n::Config.disabled?
135
- trfe("You don't have rights to access that section.")
136
- return redirect_to(Tr8n::Config.default_url)
134
+ # handle disabled state for tr8n
135
+ def validate_tr8n_enabled
136
+ if Tr8n::Config.disabled?
137
+ trfe("You don't have rights to access that section.")
138
+ return redirect_to(Tr8n::Config.default_url)
139
+ end
137
140
  end
138
- end
139
141
 
140
- # guest users can still switch between languages outside of the site
141
- def validate_guest_user
142
- if tr8n_current_user_is_guest?
143
- trfe("You must be a registered user in order to access this section of the site.")
144
- return redirect_to(Tr8n::Config.default_url)
142
+ # guest users can still switch between languages outside of the site
143
+ def validate_guest_user
144
+ if tr8n_current_user_is_guest?
145
+ trfe("You must be a registered user in order to access this section of the site.")
146
+ return redirect_to(Tr8n::Config.default_url)
147
+ end
145
148
  end
146
- end
147
149
 
148
- # make sure users have the rights to access this section
149
- def validate_current_user
150
- unless Tr8n::Config.open_registration_mode? or Tr8n::Config.current_user_is_translator?
151
- trfe("You don't have rights to access that section.")
152
- return redirect_to(Tr8n::Config.default_url)
150
+ # make sure users have the rights to access this section
151
+ def validate_current_user
152
+ unless Tr8n::Config.open_registration_mode? or Tr8n::Config.current_user_is_translator?
153
+ trfe("You don't have rights to access that section.")
154
+ return redirect_to(Tr8n::Config.default_url)
155
+ end
153
156
  end
154
- end
155
157
 
156
- # make sure that the current user is a translator
157
- def validate_current_translator
158
- if tr8n_current_user_is_translator? and tr8n_current_translator.blocked?
159
- trfe("Your translation privileges have been revoked. Please contact the site administrator for more details.")
160
- return redirect_to(Tr8n::Config.default_url)
158
+ # make sure that the current user is a translator
159
+ def validate_current_translator
160
+ if tr8n_current_user_is_translator? and tr8n_current_translator.blocked?
161
+ trfe("Your translation privileges have been revoked. Please contact the site administrator for more details.")
162
+ return redirect_to(Tr8n::Config.default_url)
163
+ end
161
164
  end
162
- end
163
165
 
164
- # make sure that the current user is a language manager
165
- def validate_language_management
166
- # admins can do everything
167
- return if tr8n_current_user_is_admin?
166
+ # make sure that the current user is a language manager
167
+ def validate_language_management
168
+ # admins can do everything
169
+ return if tr8n_current_user_is_admin?
168
170
 
169
- if tr8n_current_language.default?
170
- trfe("Only administrators can modify this language")
171
- return redirect_to(@tabs.first[:link])
172
- end
171
+ if tr8n_current_language.default?
172
+ trfe("Only administrators can modify this language")
173
+ return redirect_to(@tabs.first[:link])
174
+ end
173
175
 
174
- unless tr8n_current_user_is_translator? and tr8n_current_translator.manager?
175
- trfe("In order to manage a language you first must request to become a manager of that language. Please send your request to Geni support.")
176
- return redirect_to(@tabs.first[:link])
176
+ unless tr8n_current_user_is_translator? and tr8n_current_translator.manager?
177
+ trfe("In order to manage a language you first must request to become a manager of that language. Please send your request to Geni support.")
178
+ return redirect_to(@tabs.first[:link])
179
+ end
177
180
  end
178
- end
179
181
 
180
- def validate_default_language
181
- return if Tr8n::Config.multiple_base_languages?
182
- redirect_to(tr8n_features_tabs.first[:link]) if tr8n_current_language.default?
183
- end
182
+ def validate_default_language
183
+ return if Tr8n::Config.multiple_base_languages?
184
+ redirect_to(tr8n_features_tabs.first[:link]) if tr8n_current_language.default?
185
+ end
184
186
 
185
- def validate_language
186
- return unless params[:language]
187
- return if params[:language][:fallback_language_id].blank? # default
187
+ def validate_language
188
+ return unless params[:language]
189
+ return if params[:language][:fallback_language_id].blank? # default
188
190
 
189
- fallback_language = Tr8n::Language.find(params[:language][:fallback_language_id])
191
+ fallback_language = Tr8n::Language.find(params[:language][:fallback_language_id])
190
192
 
191
- while fallback_language do
192
- if fallback_language == tr8n_current_language
193
- return "You are creating an infinite loop with fallback languages. Please ensure that languages do not fall back onto each other."
193
+ while fallback_language do
194
+ if fallback_language == tr8n_current_language
195
+ return "You are creating an infinite loop with fallback languages. Please ensure that languages do not fall back onto each other."
196
+ end
197
+ fallback_language = fallback_language.fallback_language
194
198
  end
195
- fallback_language = fallback_language.fallback_language
196
199
  end
197
- end
198
200
 
199
- def validate_admin
200
- unless tr8n_current_user_is_admin?
201
- trfe("You must be an admin in order to view this section of the site")
202
- redirect_to_site_default_url
201
+ def validate_admin
202
+ unless tr8n_current_user_is_admin?
203
+ trfe("You must be an admin in order to view this section of the site")
204
+ redirect_to_site_default_url
205
+ end
203
206
  end
204
- end
205
207
 
208
+ end
206
209
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -27,6 +27,7 @@ module Tr8n
27
27
  before_filter :validate_current_translator
28
28
 
29
29
  def index
30
+
30
31
  end
31
32
 
32
33
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010-2011 Michael Berkovich
2
+ # Copyright (c) 2010-2011 Michael Berkovich, tr8n.net
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -21,62 +21,60 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- class Tr8n::LanguageCasesController < Tr8n::BaseController
24
+ module Tr8n
25
+ class LanguageCasesController < Tr8n::BaseController
25
26
 
26
- before_filter :validate_current_translator
27
- before_filter :validate_language_management, :only => [:index]
27
+ before_filter :validate_current_translator
28
+ before_filter :validate_language_management, :only => [:index]
28
29
 
29
- # used by a client app
30
- def index
31
- conditions = ["language_id = ? and (reported is null or reported = ?)", tr8n_current_language.id, false]
32
-
33
- unless params[:search].blank?
34
- conditions[0] << " and keyword like ?"
35
- conditions << "%#{params[:search]}%"
30
+ # used by a client app
31
+ def index
32
+ @maps = Tr8n::LanguageCaseValueMap.where("language_id = ? and (reported is null or reported = ?)", tr8n_current_language.id, false)
33
+ @maps = @maps.where("keyword like ?", "%#{params[:search]}%") unless params[:search].blank?
34
+ @maps = @maps.order("updated_at desc").page(page).per(per_page)
36
35
  end
37
-
38
- @maps = Tr8n::LanguageCaseValueMap.paginate(:per_page => per_page, :page => page, :conditions => conditions, :order => "updated_at desc")
39
- end
40
36
 
41
- def manager
42
- @lcase = Tr8n::LanguageCase.by_id(params[:case_id]) unless params[:case_id].blank?
43
- @rule = Tr8n::LanguageCaseRule.by_id(params[:rule_id]) unless params[:rule_id].blank?
37
+ def manager
38
+ @lcase = Tr8n::LanguageCase.by_id(params[:case_id]) unless params[:case_id].blank?
39
+ @rule = Tr8n::LanguageCaseRule.by_id(params[:rule_id]) unless params[:rule_id].blank?
44
40
 
45
- @map = Tr8n::LanguageCaseValueMap.by_language_and_keyword(tr8n_current_language, params[:case_key])
46
- @map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language, :translator => tr8n_current_translator, :keyword => params[:case_key])
41
+ @map = Tr8n::LanguageCaseValueMap.by_language_and_keyword(tr8n_current_language, params[:case_key])
42
+ @map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language, :translator => tr8n_current_translator, :keyword => params[:case_key])
47
43
 
48
- render :layout => false
49
- end
44
+ render :layout => false
45
+ end
50
46
 
51
- def switch_manager_mode
52
- @map = Tr8n::LanguageCaseValueMap.by_language_and_keyword(tr8n_current_language, params[:map_keyword])
53
- @map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language, :keyword => params[:case_key], :reported => false)
47
+ def switch_manager_mode
48
+ @map = Tr8n::LanguageCaseValueMap.by_language_and_keyword(tr8n_current_language, params[:map_keyword])
49
+ @map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language, :keyword => params[:case_key], :reported => false)
54
50
 
55
- render :partial => params[:mode]
56
- end
51
+ render :partial => params[:mode]
52
+ end
57
53
 
58
- def update_value_map
59
- map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) unless params[:map_id].blank?
60
- map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language, :reported => false)
61
- map.keyword = params[:case_key]
62
- map.map = params[:map][:map]
63
- map.save_with_log!(tr8n_current_translator)
54
+ def update_value_map
55
+ map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) unless params[:map_id].blank?
56
+ map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language, :reported => false)
57
+ map.keyword = params[:case_key]
58
+ map.map = params[:map][:map]
59
+ map.save_with_log!(tr8n_current_translator)
64
60
 
65
- redirect_to_source
66
- end
61
+ redirect_to_source
62
+ end
67
63
 
68
- def delete_value_map
69
- map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) if params[:map_id]
70
- map.destroy_with_log!(tr8n_current_translator) if map
64
+ def delete_value_map
65
+ map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) if params[:map_id]
66
+ map.destroy_with_log!(tr8n_current_translator) if map
71
67
 
72
- redirect_to_source
73
- end
68
+ redirect_to_source
69
+ end
74
70
 
75
- def report_value_map
76
- map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) unless params[:map_id].blank?
77
- map.report_with_log!(tr8n_current_translator) if map
71
+ def report_value_map
72
+ map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) unless params[:map_id].blank?
73
+ map.report_with_log!(tr8n_current_translator) if map
78
74
 
79
- redirect_to_source
80
- end
75
+ redirect_to_source
76
+ end
81
77
 
82
- end
78
+ end
79
+ end
80
+