motiro 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. data/LICENSE +280 -0
  2. data/README +28 -0
  3. data/README.en +175 -0
  4. data/README.pt-br +175 -0
  5. data/Rakefile +10 -0
  6. data/app/controllers/account_controller.rb +62 -0
  7. data/app/controllers/application.rb +72 -0
  8. data/app/controllers/edition_controller.rb +13 -0
  9. data/app/controllers/javascript_controller.rb +21 -0
  10. data/app/controllers/report_controller.rb +79 -0
  11. data/app/controllers/root_controller.rb +7 -0
  12. data/app/controllers/wiki_controller.rb +102 -0
  13. data/app/core/cache_reporter.rb +53 -0
  14. data/app/core/cache_reporter_fetcher.rb +33 -0
  15. data/app/core/chief_editor.rb +69 -0
  16. data/app/core/reporter.rb +105 -0
  17. data/app/core/reporter_driver.rb +36 -0
  18. data/app/core/reporter_fetcher.rb +39 -0
  19. data/app/core/settings.rb +43 -0
  20. data/app/core/version.rb +1 -0
  21. data/app/core/wiki_page_not_found.rb +33 -0
  22. data/app/core/wiki_reporter.rb +83 -0
  23. data/app/helpers/account_helper.rb +2 -0
  24. data/app/helpers/application_helper.rb +68 -0
  25. data/app/helpers/default_page_provider.rb +28 -0
  26. data/app/helpers/report_helper.rb +2 -0
  27. data/app/helpers/root_helper.rb +2 -0
  28. data/app/helpers/wiki_helper.rb +3 -0
  29. data/app/models/change.rb +96 -0
  30. data/app/models/diff_table_builder.rb +285 -0
  31. data/app/models/event.rb +18 -0
  32. data/app/models/headline.rb +109 -0
  33. data/app/models/page.rb +114 -0
  34. data/app/models/page_sweeper.rb +26 -0
  35. data/app/models/user.rb +85 -0
  36. data/app/ports/chdir_runner.rb +36 -0
  37. data/app/ports/reporter_loader.rb +9 -0
  38. data/app/ports/runner.rb +64 -0
  39. data/app/reporters/darcs_connection.rb +54 -0
  40. data/app/reporters/darcs_reporter.rb +104 -0
  41. data/app/reporters/darcs_settings.rb +9 -0
  42. data/app/reporters/darcs_temp_repo.rb +40 -0
  43. data/app/reporters/events_reporter.rb +28 -0
  44. data/app/reporters/features_reporter.rb +24 -0
  45. data/app/reporters/subversion_reporter.rb +203 -0
  46. data/app/reporters/svn_connection.rb +62 -0
  47. data/app/reporters/svn_settings.rb +40 -0
  48. data/app/views/account/_authorization.rhtml +54 -0
  49. data/app/views/account/_availability.rhtml +5 -0
  50. data/app/views/account/availability.rhtml +1 -0
  51. data/app/views/account/login.rhtml +22 -0
  52. data/app/views/account/logout.rhtml +10 -0
  53. data/app/views/javascript/motiro.rjs +132 -0
  54. data/app/views/javascript/niftycube.rjs +300 -0
  55. data/app/views/layouts/_bottom.rhtml +5 -0
  56. data/app/views/layouts/_header.rhtml +7 -0
  57. data/app/views/layouts/_top.rhtml +25 -0
  58. data/app/views/layouts/application.rhtml +3 -0
  59. data/app/views/layouts/scaffold.rhtml +13 -0
  60. data/app/views/layouts/wiki_edit.rhtml +26 -0
  61. data/app/views/report/list.rhtml +32 -0
  62. data/app/views/report/older.rhtml +26 -0
  63. data/app/views/report/rss.rxml +29 -0
  64. data/app/views/report/show.rhtml +20 -0
  65. data/app/views/root/index.rhtml +33 -0
  66. data/app/views/wiki/_editbar.rhtml +26 -0
  67. data/app/views/wiki/_properties_edit.rhtml +5 -0
  68. data/app/views/wiki/_properties_show.rhtml +5 -0
  69. data/app/views/wiki/edit.rhtml +56 -0
  70. data/app/views/wiki/properties_edit.rhtml +1 -0
  71. data/app/views/wiki/show.rhtml +9 -0
  72. data/bin/motiro +44 -0
  73. data/config/boot.rb +19 -0
  74. data/config/database.yml +14 -0
  75. data/config/environment.rb +64 -0
  76. data/config/environments/development.rb +20 -0
  77. data/config/environments/production.rb +19 -0
  78. data/config/environments/test.rb +19 -0
  79. data/config/motiro.yml +43 -0
  80. data/config/routes.rb +79 -0
  81. data/db/migrate/005_globalize_migration.rb +11363 -0
  82. data/db/migrate/006_remove_headline_title.rb +14 -0
  83. data/db/migrate/007_stretch_rid.rb +11 -0
  84. data/db/migrate/008_add_page_editors.rb +12 -0
  85. data/db/migrate/009_add_page_original_author.rb +12 -0
  86. data/db/migrate/010_remove_empty_string_defaults_from_pages.rb +17 -0
  87. data/db/migrate/011_add_title_and_kind_to_pages.rb +13 -0
  88. data/db/migrate/012_page_modification_info.rb +13 -0
  89. data/db/migrate/013_nullify_initial_page_attributes.rb +21 -0
  90. data/db/migrate/014_events_are_wiki_pages.rb +13 -0
  91. data/db/migrate/015_migrate_previous_event_data.rb +23 -0
  92. data/db/migrate/1_initial_structure.rb +36 -0
  93. data/db/migrate/2_add_authentication.rb +12 -0
  94. data/db/migrate/3_drop_articles.rb +26 -0
  95. data/db/migrate/4_add_page_editing.rb +14 -0
  96. data/db/motirodb.sqlite.initial +0 -0
  97. data/db/schema_version +1 -0
  98. data/db/translation/pt-BR.rb +76 -0
  99. data/doc/README_FOR_APP +2 -0
  100. data/installer/rails_installer_defaults.yml +5 -0
  101. data/lib/import_translations.rb +154 -0
  102. data/lib/login_system.rb +89 -0
  103. data/lib/relative_time.rb +48 -0
  104. data/lib/string_extensions.rb +10 -0
  105. data/lib/stub_hash.rb +22 -0
  106. data/lib/tasks/packaging.rake +93 -0
  107. data/lib/tasks/testing.rake +32 -0
  108. data/lib/tick_daemon.rb +41 -0
  109. data/lib/translator.rb +67 -0
  110. data/lib/wiki_renderer.rb +42 -0
  111. data/lib/wiki_url_generator.rb +29 -0
  112. data/log/.keepdir +0 -0
  113. data/public/404.html +8 -0
  114. data/public/500.html +8 -0
  115. data/public/dispatch.cgi +10 -0
  116. data/public/dispatch.fcgi +24 -0
  117. data/public/dispatch.rb +10 -0
  118. data/public/favicon.ico +0 -0
  119. data/public/images/calendar.png +0 -0
  120. data/public/images/rss.png +0 -0
  121. data/public/javascripts/controls.js +750 -0
  122. data/public/javascripts/dragdrop.js +584 -0
  123. data/public/javascripts/effects.js +854 -0
  124. data/public/javascripts/prototype.js +1785 -0
  125. data/public/robots.txt +1 -0
  126. data/public/stylesheets/motiro.css +269 -0
  127. data/public/stylesheets/niftyCorners.css +35 -0
  128. data/public/stylesheets/scaffold.css +74 -0
  129. data/script/about +3 -0
  130. data/script/breakpointer +3 -0
  131. data/script/console +3 -0
  132. data/script/destroy +3 -0
  133. data/script/generate +3 -0
  134. data/script/performance/benchmarker +3 -0
  135. data/script/performance/profiler +3 -0
  136. data/script/plugin +3 -0
  137. data/script/process/reaper +3 -0
  138. data/script/process/spawner +3 -0
  139. data/script/process/spinner +3 -0
  140. data/script/runner +3 -0
  141. data/script/server +3 -0
  142. data/script/ticker +29 -0
  143. data/test/acceptance/account_test.rb +186 -0
  144. data/test/acceptance/darcs_test.rb +62 -0
  145. data/test/acceptance/events_test.rb +47 -0
  146. data/test/acceptance/main_page_test.rb +92 -0
  147. data/test/acceptance/subversion_test.rb +319 -0
  148. data/test/acceptance/ts_all_suites.rb +27 -0
  149. data/test/acceptance/wiki_test.rb +202 -0
  150. data/test/contract/darcs_test.rb +51 -0
  151. data/test/contract/remote_darcs_test.rb +61 -0
  152. data/test/contract/svn_test.rb +53 -0
  153. data/test/fixtures/changes.yml +25 -0
  154. data/test/fixtures/headlines.yml +45 -0
  155. data/test/fixtures/pages.yml +98 -0
  156. data/test/fixtures/users.yml +31 -0
  157. data/test/functional/account_controller_test.rb +96 -0
  158. data/test/functional/report_controller_test.rb +113 -0
  159. data/test/functional/report_features_test.rb +38 -0
  160. data/test/functional/report_subversion_test.rb +79 -0
  161. data/test/functional/root_controller_test.rb +127 -0
  162. data/test/functional/wiki_controller_test.rb +280 -0
  163. data/test/lib/acceptance_test_case.rb +43 -0
  164. data/test/lib/configuration.rb +53 -0
  165. data/test/lib/darcs_excerpts.rb +181 -0
  166. data/test/lib/darcs_repo.rb +77 -0
  167. data/test/lib/live_mode_test.rb +51 -0
  168. data/test/lib/local_svn.rb +157 -0
  169. data/test/lib/netutils.rb +42 -0
  170. data/test/lib/platform_thread.rb +62 -0
  171. data/test/lib/repoutils.rb +23 -0
  172. data/test/lib/selenium_extensions.rb +32 -0
  173. data/test/lib/stubio.rb +37 -0
  174. data/test/lib/svn_excerpts.rb +288 -0
  175. data/test/lib/test_configuration.rb +14 -0
  176. data/test/lib/webserver.rb +71 -0
  177. data/test/meta/configuration_test.rb +72 -0
  178. data/test/meta/darcs_repo_test.rb +118 -0
  179. data/test/meta/local_svn_test.rb +125 -0
  180. data/test/meta/platform_thread_test.rb +46 -0
  181. data/test/meta/stubio_test.rb +44 -0
  182. data/test/mocks/headline.rb +34 -0
  183. data/test/mocks/svn_reporter.rb +29 -0
  184. data/test/stubs/svn_settings.rb +19 -0
  185. data/test/stubs/url_generator.rb +24 -0
  186. data/test/test_helper.rb +36 -0
  187. data/test/unit/cache_reporter_fetcher_test.rb +46 -0
  188. data/test/unit/cache_reporter_test.rb +97 -0
  189. data/test/unit/caching_test.rb +78 -0
  190. data/test/unit/change_test.rb +152 -0
  191. data/test/unit/chdir_runner_test.rb +77 -0
  192. data/test/unit/chief_editor_test.rb +234 -0
  193. data/test/unit/darcs_connection_test.rb +109 -0
  194. data/test/unit/darcs_reporter_test.rb +146 -0
  195. data/test/unit/darcs_settings_test.rb +37 -0
  196. data/test/unit/darcs_temp_repo_test.rb +51 -0
  197. data/test/unit/default_page_provider_test.rb +46 -0
  198. data/test/unit/diff_table_builder_test.rb +602 -0
  199. data/test/unit/headline_test.rb +259 -0
  200. data/test/unit/page_test.rb +145 -0
  201. data/test/unit/relative_time_test.rb +56 -0
  202. data/test/unit/reporter_driver_test.rb +85 -0
  203. data/test/unit/reporter_fetcher_test.rb +31 -0
  204. data/test/unit/reporter_test.rb +81 -0
  205. data/test/unit/runner_test.rb +93 -0
  206. data/test/unit/settings_test.rb +55 -0
  207. data/test/unit/string_extensions_test.rb +10 -0
  208. data/test/unit/svn_connection_test.rb +183 -0
  209. data/test/unit/svn_reporter_interaction_test.rb +38 -0
  210. data/test/unit/svn_reporter_test.rb +286 -0
  211. data/test/unit/svn_settings_test.rb +86 -0
  212. data/test/unit/translator_test.rb +96 -0
  213. data/test/unit/user_test.rb +125 -0
  214. data/test/unit/wiki_renderer_test.rb +87 -0
  215. data/test/unit/wiki_reporter_test.rb +94 -0
  216. data/test/unit/wiki_url_generator_test.rb +31 -0
  217. data/vendor/motiro-installer.rb +159 -0
  218. data/vendor/plugins/globalize/LICENSE +9 -0
  219. data/vendor/plugins/globalize/README +49 -0
  220. data/vendor/plugins/globalize/data/country_data.csv +240 -0
  221. data/vendor/plugins/globalize/data/language_data.csv +188 -0
  222. data/vendor/plugins/globalize/data/translation_data.csv +3421 -0
  223. data/vendor/plugins/globalize/generators/globalize/USAGE +10 -0
  224. data/vendor/plugins/globalize/generators/globalize/globalize_generator.rb +42 -0
  225. data/vendor/plugins/globalize/generators/globalize/templates/migration.rb.gz +0 -0
  226. data/vendor/plugins/globalize/generators/globalize/templates/tiny_migration.rb.gz +0 -0
  227. data/vendor/plugins/globalize/init.rb +30 -0
  228. data/vendor/plugins/globalize/lib/globalize/localization/core_ext.rb +170 -0
  229. data/vendor/plugins/globalize/lib/globalize/localization/core_ext_hooks.rb +33 -0
  230. data/vendor/plugins/globalize/lib/globalize/localization/db_translate.rb +494 -0
  231. data/vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb +152 -0
  232. data/vendor/plugins/globalize/lib/globalize/localization/locale.rb +173 -0
  233. data/vendor/plugins/globalize/lib/globalize/localization/rfc_3066.rb +40 -0
  234. data/vendor/plugins/globalize/lib/globalize/models/country.rb +24 -0
  235. data/vendor/plugins/globalize/lib/globalize/models/currency.rb +188 -0
  236. data/vendor/plugins/globalize/lib/globalize/models/language.rb +84 -0
  237. data/vendor/plugins/globalize/lib/globalize/models/model_translation.rb +4 -0
  238. data/vendor/plugins/globalize/lib/globalize/models/translation.rb +9 -0
  239. data/vendor/plugins/globalize/lib/globalize/models/view_translation.rb +14 -0
  240. data/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb +125 -0
  241. data/vendor/plugins/globalize/lib/globalize/rails/action_view.rb +79 -0
  242. data/vendor/plugins/globalize/lib/globalize/rails/active_record.rb +129 -0
  243. data/vendor/plugins/globalize/lib/globalize/rails/active_record_helper.rb +33 -0
  244. data/vendor/plugins/globalize/populators/pop_dates.rb +81 -0
  245. data/vendor/plugins/globalize/populators/pop_migration.rb +18 -0
  246. data/vendor/plugins/globalize/populators/pop_pluralization.rb +26 -0
  247. data/vendor/plugins/globalize/populators/pop_seps.rb +32 -0
  248. data/vendor/plugins/globalize/tasks/data.rake +130 -0
  249. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en-US.plain.text.rhtml +1 -0
  250. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en.plain.text.rhtml +1 -0
  251. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.he.plain.text.rhtml +1 -0
  252. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.plain.text.rhtml +1 -0
  253. data/vendor/plugins/globalize/test/action_mailer_test.rb +54 -0
  254. data/vendor/plugins/globalize/test/config/database.yml.default +16 -0
  255. data/vendor/plugins/globalize/test/config/database.yml.example +22 -0
  256. data/vendor/plugins/globalize/test/core_ext_test.rb +61 -0
  257. data/vendor/plugins/globalize/test/currency_test.rb +141 -0
  258. data/vendor/plugins/globalize/test/date_helper_test.rb +634 -0
  259. data/vendor/plugins/globalize/test/db/schema.rb +90 -0
  260. data/vendor/plugins/globalize/test/db_translation_test.rb +374 -0
  261. data/vendor/plugins/globalize/test/fixtures/globalize_categories.yml +7 -0
  262. data/vendor/plugins/globalize/test/fixtures/globalize_categories_products.yml +7 -0
  263. data/vendor/plugins/globalize/test/fixtures/globalize_countries.yml +41 -0
  264. data/vendor/plugins/globalize/test/fixtures/globalize_languages.yml +64 -0
  265. data/vendor/plugins/globalize/test/fixtures/globalize_manufacturers.yml +5 -0
  266. data/vendor/plugins/globalize/test/fixtures/globalize_products.yml +29 -0
  267. data/vendor/plugins/globalize/test/fixtures/globalize_simples.yml +5 -0
  268. data/vendor/plugins/globalize/test/fixtures/globalize_translations.yml +354 -0
  269. data/vendor/plugins/globalize/test/locale_test.rb +27 -0
  270. data/vendor/plugins/globalize/test/mime_responds_test.rb +358 -0
  271. data/vendor/plugins/globalize/test/model_test.rb +17 -0
  272. data/vendor/plugins/globalize/test/standard_data_test_helper.rb +33 -0
  273. data/vendor/plugins/globalize/test/test_helper.rb +19 -0
  274. data/vendor/plugins/globalize/test/test_standard_data.rb +54 -0
  275. data/vendor/plugins/globalize/test/validation_test.rb +29 -0
  276. data/vendor/plugins/globalize/test/view_picking_test.rb +49 -0
  277. data/vendor/plugins/globalize/test/view_translation_test.rb +237 -0
  278. data/vendor/plugins/globalize/test/views/layouts/standard.rhtml +1 -0
  279. data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rhtml +1 -0
  280. data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rjs +1 -0
  281. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rhtml +1 -0
  282. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rjs +1 -0
  283. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rxml +1 -0
  284. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rhtml +1 -0
  285. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rjs +1 -0
  286. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rxml +1 -0
  287. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rhtml +1 -0
  288. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rjs +1 -0
  289. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rxml +1 -0
  290. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rhtml +1 -0
  291. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rjs +1 -0
  292. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rxml +1 -0
  293. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rhtml +1 -0
  294. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rjs +1 -0
  295. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rxml +1 -0
  296. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rhtml +1 -0
  297. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rjs +1 -0
  298. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rxml +1 -0
  299. data/vendor/plugins/globalize/test/views/test.he-IL.rhtml +1 -0
  300. data/vendor/plugins/globalize/test/views/test.rhtml +1 -0
  301. data/vendor/plugins/globalize/test/views/test2.he.rhtml +1 -0
  302. data/vendor/plugins/globalize/test/views/test2.rhtml +1 -0
  303. data/vendor/plugins/test_xml/MIT-LICENSE +20 -0
  304. data/vendor/plugins/test_xml/README +20 -0
  305. data/vendor/plugins/test_xml/Rakefile +22 -0
  306. data/vendor/plugins/test_xml/init.rb +7 -0
  307. data/vendor/plugins/test_xml/lib/xml_assertions.rb +22 -0
  308. data/vendor/plugins/test_xml/test/test_xml_test.rb +40 -0
  309. metadata +505 -0
@@ -0,0 +1,62 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ class AccountController < ApplicationController
19
+ layout 'scaffold'
20
+
21
+ verify :method => :post, :only => [:signup],
22
+ :redirect_to => {:controller => 'root', :action => 'index'}
23
+
24
+ def authorization
25
+ render :layout => false
26
+ end
27
+
28
+ def login
29
+ case request.method
30
+ when :post
31
+ unless session[:user] = User.authenticate( params[:user][:login],
32
+ params[:user][:password] )
33
+ flash[:login_failure] = true
34
+ end
35
+ redirect_back_or_default params[:return_to]
36
+ end
37
+ end
38
+
39
+ def signup
40
+ user = User.new(params[:user])
41
+
42
+ if user.save
43
+ session[:user] = User.authenticate( params[:user][:login],
44
+ params[:user][:password] )
45
+
46
+ else
47
+ flash[:desired_login] = params[:user][:login]
48
+ end
49
+
50
+ redirect_back_or_default params[:return_to]
51
+ end
52
+
53
+ def availability
54
+ render :layout => false
55
+ end
56
+
57
+ def logout
58
+ session[:user] = nil
59
+ redirect_back_or_default params[:return_to]
60
+ end
61
+
62
+ end
@@ -0,0 +1,72 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require_dependency "login_system"
19
+ require "translator"
20
+ require 'string_extensions'
21
+
22
+ # Filters added to this controller will be run for all controllers in the application.
23
+ # Likewise, all the methods added will be available for all controllers.
24
+ class ApplicationController < ActionController::Base
25
+ include LoginSystem
26
+ include ApplicationHelper
27
+
28
+ before_filter :set_locale, :setup_renderer, :check_desired_login_available, :drop_top_crumbs
29
+
30
+ def set_locale
31
+ default_locale = 'en-US'
32
+ request_language = request.env['HTTP_ACCEPT_LANGUAGE']
33
+ request_language = request_language.nil? ? nil : request_language[/[^,;]+/]
34
+
35
+ @locale = params[:locale] || session[:locale] ||
36
+ request_language || default_locale
37
+ session[:locale] = @locale
38
+ begin
39
+ Locale.set @locale
40
+ rescue
41
+ @locale = default_locale
42
+ Locale.set @locale
43
+ end
44
+ end
45
+
46
+ def setup_renderer
47
+ @renderer = create_renderer
48
+ end
49
+
50
+ def check_desired_login_available
51
+ if current_user.nil?
52
+ desired_login = params[:desired_login] || flash[:desired_login]
53
+ @login_not_available = ! User.find_by_login(desired_login).nil?
54
+ end
55
+ true
56
+ end
57
+
58
+ def drop_top_crumbs
59
+ @crumbs = [{ 'Home'.t => {:controller => 'root', :action => 'index'} }]
60
+ end
61
+
62
+ private
63
+
64
+ def create_renderer
65
+ WikiRenderer.new(my_url_generator, current_locale)
66
+ end
67
+
68
+ def my_url_generator
69
+ @url_generator ||= WikiUrlGenerator.new(self)
70
+ end
71
+
72
+ end
@@ -0,0 +1,13 @@
1
+ class EditionController < ApplicationController
2
+
3
+ def save
4
+ if params['btnSave']
5
+ do_save
6
+ else
7
+ redirect_to :controller => 'root', :action => 'index'
8
+ end
9
+ end
10
+
11
+ def do_save; end
12
+
13
+ end
@@ -0,0 +1,21 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ # Placeholder controller for javascript templates
19
+ class JavascriptController < ApplicationController
20
+ caches_page :motiro, :niftycube
21
+ end
@@ -0,0 +1,79 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require 'models/headline'
19
+
20
+ require_dependency 'core/chief_editor'
21
+
22
+ class ReportController < ApplicationController
23
+
24
+ layout :determine_layout
25
+
26
+ before_filter do |me|
27
+ me.instance_eval do
28
+ @name = params[:reporter]
29
+ @reporter = @chief_editor.reporter_with(@name)
30
+ end
31
+ end
32
+
33
+ before_filter(:only => [:rss, :list]) do |me|
34
+ me.instance_eval do
35
+ @headlines = @chief_editor.latest_news_from @name
36
+ end
37
+ end
38
+
39
+ before_filter :drop_crumbs
40
+
41
+ def initialize(chief_editor=ChiefEditor.new)
42
+ @chief_editor = chief_editor
43
+ end
44
+
45
+ def determine_layout
46
+ return 'application' if params[:id] or
47
+ params[:action] == 'older'
48
+ return nil
49
+ end
50
+
51
+ def drop_crumbs
52
+ @crumbs << { @reporter.channel_title =>
53
+ {:controller => 'report', :action => 'older',
54
+ :reporter => @name}}
55
+ end
56
+
57
+ def older
58
+ @headlines = @chief_editor.news_from @name
59
+ end
60
+
61
+ def show
62
+ id = params[:id]
63
+
64
+ @revision_id = id
65
+ @headline = @chief_editor.headline_with(@name, id)
66
+
67
+ unless @headline
68
+ logger.error("Tried to access invalid headline #{id} from #{@name}")
69
+ flash[:notice] = 'The article %s from the %s reporter could not be found' / id / @name.capitalize
70
+ redirect_to(:controller => 'root', :action => 'index')
71
+ return
72
+ end
73
+
74
+ @crumbs << { @headline.title(Translator.for(@locale)) =>
75
+ {:controller => 'report', :action => 'show',
76
+ :reporter => @name, :id => @headline.rid}}
77
+ end
78
+
79
+ end
@@ -0,0 +1,7 @@
1
+ require 'core/reporter_fetcher'
2
+
3
+ class RootController < ApplicationController
4
+
5
+ before_filter :store_location
6
+
7
+ end
@@ -0,0 +1,102 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ class WikiController < EditionController
19
+
20
+ layout :choose_layout
21
+
22
+ before_filter :login_required, :except => [:show, :last]
23
+ before_filter :fetch_page, :drop_crumbs
24
+ before_filter :check_edit_access, :only => [:edit, :save]
25
+
26
+ cache_sweeper :page_sweeper, :only => [:edit, :save]
27
+
28
+ def choose_layout
29
+ return if params[:context] == 'partial' || params[:action] == 'properties_edit'
30
+ return 'application'
31
+ end
32
+
33
+ def protect?(action)
34
+ return false if 'show' == action
35
+ return true
36
+ end
37
+
38
+ def initialize(page_provider=Page, renderer=nil)
39
+ @renderer = renderer || create_renderer
40
+ @real_page_provider = page_provider
41
+ @default_page_provider = DefaultPageProvider.new
42
+ end
43
+
44
+ def fetch_page
45
+ type = params[:page] ? params[:page][:type] : nil
46
+ @page = find_page(params[:page_name], type)
47
+ end
48
+
49
+ def drop_crumbs
50
+ unless 'common' == @page.kind
51
+ @crumbs <<{ @page.kind.pluralize.capitalize.t =>
52
+ {:controller => 'report', :action => 'older',
53
+ :reporter => @page.kind.pluralize}}
54
+ end
55
+ @crumbs <<{ @page.title => {:controller => 'wiki', :action => 'show',
56
+ :page_name => @page.name} }
57
+ end
58
+
59
+ def check_edit_access
60
+ unless current_user.can_edit?(@page)
61
+ flash[:not_authorized] = true
62
+ redirect_to :action => 'show', :page_name => @page.name
63
+ return false
64
+ end
65
+
66
+ return true
67
+ end
68
+
69
+ def edit
70
+ render(:layout => 'application')
71
+ end
72
+
73
+ def new
74
+ @page.kind = params[:kind]
75
+ render(:action => 'edit', :layout => 'application')
76
+ end
77
+
78
+ def do_save
79
+ params[:page].delete(:original_author_id)
80
+ params[:page].delete(:editors) unless current_user.can_change_editors?(@page)
81
+
82
+ @page.original_author ||= current_user
83
+ @page.last_editor = current_user
84
+ @page.modified_at = Time.now
85
+ @page.attributes = params[:page]
86
+ @page.save
87
+
88
+ if 'MainPage' == @page.name
89
+ redirect_to :controller => 'root', :action => 'index'
90
+ else
91
+ redirect_to :action => 'show', :page_name => @page.name
92
+ end
93
+ end
94
+
95
+ private
96
+
97
+ def find_page(name, type)
98
+ @real_page_provider.find_by_name(name) ||
99
+ @default_page_provider.find_by_name_and_type(name, type)
100
+ end
101
+
102
+ end
@@ -0,0 +1,53 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require 'core/settings'
19
+ require 'core/reporter'
20
+
21
+ # A cache reporter is a reporter that just repeats news discovered by real
22
+ # reporters
23
+ #
24
+ # Every cache reporter has a real reporter that it tries to mimic. This type
25
+ # of reporter will go to the news database and retrieve all news that its real
26
+ # correspondent reported.
27
+ class CacheReporter < MotiroReporter
28
+
29
+ def initialize(reporter, settings=SettingsProvider.new,
30
+ headlines_source=Headline)
31
+ @headlines_source = headlines_source
32
+ @settings = settings
33
+ @source_reporter = reporter
34
+ end
35
+
36
+ def latest_headlines
37
+ @headlines_source.latest(@settings.package_size, name)
38
+ end
39
+
40
+ def headlines
41
+ @headlines_source.find(:all, :conditions => ['reported_by = ?', name],
42
+ :order => 'happened_at DESC')
43
+ end
44
+
45
+ def headline(rid)
46
+ @headlines_source.find_with_reporter_and_rid(name, rid)
47
+ end
48
+
49
+ def name; @source_reporter.name; end
50
+ def channel_title; @source_reporter.channel_title; end
51
+ def params_for(rid); @source_reporter.params_for(rid); end
52
+
53
+ end
@@ -0,0 +1,33 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require_dependency 'core/cache_reporter'
19
+ require_dependency 'core/settings'
20
+
21
+ class CacheReporterFetcher
22
+
23
+ def initialize(fetcher, settings=SettingsProvider.new)
24
+ @fetcher, @settings = fetcher, settings
25
+ end
26
+
27
+ def active_reporters
28
+ @fetcher.active_reporters.map do |reporter|
29
+ reporter.cache? ? CacheReporter.new(reporter, @settings) : reporter
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,69 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require_dependency 'reporters/svn_settings'
19
+ require_dependency 'models/headline'
20
+
21
+ require_dependency 'core/cache_reporter_fetcher'
22
+ require_dependency 'core/reporter_fetcher'
23
+ require_dependency 'core/settings'
24
+
25
+ # The ChiefEditor is the guy that makes all the reporters work
26
+ class ChiefEditor
27
+
28
+ def initialize(conf=SettingsProvider.new, fetcher=ReporterFetcher.new)
29
+ @reporters = Hash.new
30
+
31
+ fetcher = CacheReporterFetcher.new(fetcher, conf) unless
32
+ conf.update_interval == 0
33
+ fetcher.active_reporters.each do |reporter|
34
+ self.employ(reporter)
35
+ end
36
+ end
37
+
38
+ def latest_news_from(reporter_name)
39
+ @reporters[reporter_name].latest_headlines
40
+ end
41
+
42
+ def news_from(reporter_name)
43
+ @reporters[reporter_name].headlines
44
+ end
45
+
46
+ def reporter_with(reporter_name)
47
+ @reporters[reporter_name]
48
+ end
49
+
50
+ def headline_with(reporter_name, rid)
51
+ @reporters[reporter_name].headline(rid)
52
+ end
53
+
54
+ def title_for(reporter_name)
55
+ reporter = @reporters[reporter_name]
56
+ return reporter.channel_title
57
+ end
58
+
59
+ def buttons_for(reporter_name)
60
+ reporter = @reporters[reporter_name]
61
+ return reporter.buttons
62
+ end
63
+
64
+ # Adds the given reporter to the set of reporters employed by the editor
65
+ def employ(reporter)
66
+ @reporters.update(reporter.name => reporter)
67
+ end
68
+
69
+ end
@@ -0,0 +1,105 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require 'rubygems'
19
+ require 'active_support'
20
+
21
+ # A reporter is someone capable of going out for news
22
+ #
23
+ # For a Motiro reporter, "going out" may include, but is not limited to,
24
+ # accessing the local file system, executing external processes and consulting
25
+ # the web
26
+ class MotiroReporter
27
+
28
+ private
29
+
30
+ OLDER_BUTTON = "link_to('Older'.t, :controller => 'report', " +
31
+ ":action => 'older', :reporter => @name)"
32
+ public
33
+
34
+ def self.reporter_name
35
+ class_name = self.name
36
+ return class_name[0, class_name.size - 8].underscore
37
+ end
38
+
39
+ # Replaces the default title with a custom one. Example usage:
40
+ #
41
+ # class MyReporter < MotiroReporter
42
+ # title "This is my reporter's custom title"
43
+ # end
44
+ #
45
+ # MyReporter.new.channel_title => "This is my reporter's custom title"
46
+ #
47
+ # If not called, a default title will be generated based on the class name
48
+ def self.title(title)
49
+ define_method :channel_title do
50
+ title.t
51
+ end
52
+ end
53
+
54
+ # Adds a button to this reporter's toolbar. Accepts a text parameter that
55
+ # will be fed into the ERB templates when generating web pages.
56
+ #
57
+ # It is a better idea to use one of the buttons available on the buttons hash
58
+ # than to hard-code the button code.
59
+ def self.add(code)
60
+ write_inheritable_array 'buttons', [code]
61
+ end
62
+
63
+ # A hash of buttons available for reporters
64
+ #
65
+ # Usage : class MyReporter < MotiroReporter
66
+ # add_button buttons[:older]
67
+ # end
68
+ def self.button
69
+ @@buttons ||= { :older => OLDER_BUTTON }
70
+ end
71
+
72
+ # Turns caching on and off for the reporter
73
+ #
74
+ # Usage : class MyReporter < MotiroReporter
75
+ # caching :off
76
+ # end
77
+ def self.caching(switch)
78
+ define_method :cache? do; :off != switch; end
79
+ end
80
+
81
+ def name
82
+ return self.class.reporter_name
83
+ end
84
+
85
+ def channel_title
86
+ return 'Latest news from %s' / name.humanize
87
+ end
88
+
89
+ def buttons
90
+ self.class.read_inheritable_attribute 'buttons' || []
91
+ end
92
+
93
+ def params_for(rid)
94
+ {:controller => 'report', :action => 'show', :reporter => name, :id => rid}
95
+ end
96
+
97
+ def cache?; true; end
98
+
99
+ def latest_headline
100
+ return latest_headlines.first
101
+ end
102
+
103
+ add button[:older]
104
+
105
+ end
@@ -0,0 +1,36 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require 'core/reporter_fetcher'
19
+ require 'headline'
20
+
21
+ class ReporterDriver
22
+
23
+ def initialize(fetcher=ReporterFetcher.new, headline_cache=Headline)
24
+ @fetcher, @headline_cache = fetcher, headline_cache
25
+ end
26
+
27
+ def tick
28
+ @fetcher.active_reporters.each do |reporter|
29
+ rid = @headline_cache.latest_filled_headline_rid_for(reporter.name)
30
+ reporter.latest_headlines(rid).each do |hl|
31
+ hl.cache
32
+ end
33
+ end
34
+ end
35
+
36
+ end