typus 0.9.39 → 1.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (424) hide show
  1. data/CHANGELOG +104 -0
  2. data/Gemfile +17 -0
  3. data/Gemfile.lock +96 -0
  4. data/MIT-LICENSE +1 -1
  5. data/README.rdoc +45 -0
  6. data/Rakefile +19 -48
  7. data/app/controllers/admin/account_controller.rb +54 -0
  8. data/app/controllers/admin/dashboard_controller.rb +7 -0
  9. data/app/controllers/admin/resource_controller.rb +8 -0
  10. data/app/controllers/admin/resources_controller.rb +307 -0
  11. data/app/controllers/admin/session_controller.rb +38 -0
  12. data/app/controllers/admin_controller.rb +26 -0
  13. data/app/helpers/admin/dashboard_helper.rb +38 -0
  14. data/app/helpers/admin/filters_helper.rb +81 -0
  15. data/app/helpers/admin/form_helper.rb +68 -261
  16. data/app/helpers/admin/preview_helper.rb +48 -0
  17. data/app/helpers/admin/relationships_helper.rb +192 -0
  18. data/app/helpers/admin/resources_helper.rb +80 -0
  19. data/app/helpers/admin/search_helper.rb +19 -0
  20. data/app/helpers/admin/sidebar_helper.rb +32 -210
  21. data/app/helpers/admin/table_helper.rb +207 -200
  22. data/app/helpers/admin_helper.rb +56 -0
  23. data/app/mailers/admin/mailer.rb +13 -0
  24. data/app/models/admin/fake_user.rb +38 -0
  25. data/app/views/admin/account/forgot_password.html.erb +21 -0
  26. data/app/views/admin/account/new.html.erb +21 -0
  27. data/app/views/admin/dashboard/_sidebar.html.erb +3 -3
  28. data/app/views/admin/dashboard/show.html.erb +16 -0
  29. data/app/views/admin/dashboard/styles.html.erb +154 -0
  30. data/app/views/admin/helpers/_apps.html.erb +6 -0
  31. data/app/views/admin/helpers/_flash_message.html.erb +3 -0
  32. data/app/views/admin/helpers/_header.html.erb +7 -0
  33. data/app/views/admin/helpers/_login_info.html.erb +4 -0
  34. data/app/views/admin/helpers/_preview.html.erb +13 -0
  35. data/app/views/admin/helpers/dashboard/_applications.html.erb +32 -0
  36. data/app/views/admin/helpers/dashboard/_resources.html.erb +16 -0
  37. data/app/views/admin/helpers/filters/_filters.html.erb +31 -0
  38. data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +3 -0
  39. data/app/views/admin/helpers/resources/_pagination.html.erb +28 -0
  40. data/app/views/admin/helpers/search/_search.html.erb +12 -0
  41. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +17 -0
  42. data/app/views/admin/helpers/table/_table.html.erb +22 -0
  43. data/app/views/{typus_mailer/reset_password_link.erb → admin/mailer/reset_password_link.text.erb} +2 -2
  44. data/{test/config/broken/empty.yml → app/views/admin/resources/_edit.html.erb} +0 -0
  45. data/app/views/admin/resources/_form.html.erb +26 -0
  46. data/{test/config/broken/empty_roles.yml → app/views/admin/resources/_index.html.erb} +0 -0
  47. data/{test/config/empty/empty_01.yml → app/views/admin/resources/_new.html.erb} +0 -0
  48. data/{test/config/empty/empty_01_roles.yml → app/views/admin/resources/_show.html.erb} +0 -0
  49. data/app/views/admin/resources/edit.html.erb +23 -21
  50. data/app/views/admin/resources/index.html.erb +31 -18
  51. data/app/views/admin/resources/new.html.erb +20 -18
  52. data/app/views/admin/resources/show.html.erb +29 -20
  53. data/app/views/admin/session/new.html.erb +26 -0
  54. data/app/views/admin/templates/_belongs_to.html.erb +4 -0
  55. data/app/views/admin/templates/_boolean.html.erb +4 -8
  56. data/app/views/admin/templates/_date.html.erb +9 -2
  57. data/app/views/admin/templates/_datetime.html.erb +9 -2
  58. data/app/views/admin/templates/_file.html.erb +20 -5
  59. data/app/views/admin/templates/_has_many.html.erb +24 -0
  60. data/app/views/admin/templates/_has_n.html.erb +17 -0
  61. data/{test/config/empty/empty_02.yml → app/views/admin/templates/_has_one.html.erb} +0 -0
  62. data/app/views/admin/templates/_password.html.erb +4 -2
  63. data/app/views/admin/templates/_relate_form.html.erb +4 -0
  64. data/app/views/admin/templates/_selector.html.erb +6 -18
  65. data/app/views/admin/templates/_string.html.erb +11 -10
  66. data/app/views/admin/templates/_text.html.erb +9 -2
  67. data/app/views/admin/templates/_time.html.erb +9 -2
  68. data/app/views/admin/templates/_tree.html.erb +4 -0
  69. data/app/views/layouts/admin/session.html.erb +44 -0
  70. data/app/views/layouts/admin.html.erb +45 -39
  71. data/config/available_locales/ca.yml +124 -0
  72. data/config/available_locales/ca_models.yml +16 -0
  73. data/config/{locales → available_locales}/de.yml +108 -89
  74. data/config/available_locales/de_models.yml +13 -0
  75. data/config/available_locales/es.yml +124 -0
  76. data/config/available_locales/es_models.yml +13 -0
  77. data/config/available_locales/fr.yml +124 -0
  78. data/config/available_locales/fr_models.yml +13 -0
  79. data/config/available_locales/hu.yml +124 -0
  80. data/config/available_locales/hu_models.yml +13 -0
  81. data/config/available_locales/it.yml +136 -0
  82. data/config/available_locales/it_models.yml +15 -0
  83. data/config/available_locales/language.yml.template +122 -0
  84. data/config/available_locales/language_models.yml.template +13 -0
  85. data/config/{locales → available_locales}/pt-BR.yml +97 -74
  86. data/config/available_locales/pt-BR_models.yml +13 -0
  87. data/config/{locales → available_locales}/ru.yml +107 -85
  88. data/config/available_locales/ru_models.yml +13 -0
  89. data/config/routes.rb +18 -11
  90. data/lib/generators/templates/config/initializers/typus.rb +26 -0
  91. data/lib/generators/templates/config/initializers/typus_authentication.rb +18 -0
  92. data/lib/generators/templates/config/initializers/typus_resources.rb +30 -0
  93. data/{generators/typus → lib/generators}/templates/config/typus/README +34 -16
  94. data/lib/generators/templates/config/typus/application.yml +5 -0
  95. data/lib/generators/templates/config/typus/application_roles.yml +6 -0
  96. data/lib/generators/templates/config/typus/typus.yml +17 -0
  97. data/lib/generators/templates/config/typus/typus_roles.yml +6 -0
  98. data/lib/generators/templates/controller.rb +4 -0
  99. data/lib/generators/templates/functional_test.rb +21 -0
  100. data/{generators/typus/templates/db/create_typus_users.rb → lib/generators/templates/migration.rb} +4 -4
  101. data/lib/generators/templates/model.rb +8 -0
  102. data/lib/generators/templates/model.yml +10 -0
  103. data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/images}/ui-icons.png +0 -0
  104. data/lib/generators/templates/public/admin/javascripts/application.js +6 -0
  105. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +154 -0
  106. data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +126 -0
  107. data/lib/generators/templates/public/admin/javascripts/jquery.searchField.js +91 -0
  108. data/lib/generators/templates/public/admin/stylesheets/application.css +11 -0
  109. data/lib/generators/templates/public/admin/stylesheets/screen.css +356 -0
  110. data/lib/generators/templates/public/admin/vendor/fancybox/blank.gif +0 -0
  111. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_close.png +0 -0
  112. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
  113. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_left.png +0 -0
  114. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_right.png +0 -0
  115. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_e.png +0 -0
  116. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_n.png +0 -0
  117. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_ne.png +0 -0
  118. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_nw.png +0 -0
  119. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_s.png +0 -0
  120. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_se.png +0 -0
  121. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_sw.png +0 -0
  122. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_w.png +0 -0
  123. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_left.png +0 -0
  124. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_main.png +0 -0
  125. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_over.png +0 -0
  126. data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/vendor}/fancybox/fancy_title_right.png +0 -0
  127. data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-x.png +0 -0
  128. data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-y.png +0 -0
  129. data/lib/generators/templates/public/admin/vendor/fancybox/fancybox.png +0 -0
  130. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +72 -0
  131. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.css +363 -0
  132. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +1077 -0
  133. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  134. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +13 -0
  135. data/lib/generators/templates/view.html.erb +9 -0
  136. data/lib/generators/typus/migration_generator.rb +85 -0
  137. data/lib/generators/typus/typus_generator.rb +190 -0
  138. data/lib/generators/typus/views_generator.rb +27 -0
  139. data/lib/support/active_record.rb +60 -0
  140. data/lib/support/array.rb +13 -0
  141. data/lib/{typus → support}/hash.rb +2 -2
  142. data/lib/{typus → support}/object.rb +2 -2
  143. data/lib/support/string.rb +47 -0
  144. data/lib/tasks/typus.rake +19 -0
  145. data/lib/typus/authentication.rb +146 -40
  146. data/lib/typus/configuration.rb +14 -49
  147. data/lib/typus/engine.rb +6 -0
  148. data/lib/typus/format.rb +41 -18
  149. data/lib/typus/orm/active_record.rb +378 -0
  150. data/lib/typus/resources.rb +57 -0
  151. data/lib/typus/user.rb +54 -37
  152. data/lib/typus/version.rb +3 -0
  153. data/lib/typus.rb +118 -80
  154. data/lib/vendor/paginator.rb +2 -2
  155. data/test/factories/assets.rb +5 -0
  156. data/test/factories/categories.rb +3 -0
  157. data/test/factories/comments.rb +6 -0
  158. data/test/factories/pages.rb +5 -0
  159. data/test/factories/pictures.rb +7 -0
  160. data/test/factories/posts.rb +6 -0
  161. data/test/factories/typus_users.rb +8 -0
  162. data/test/{config → fixtures/config}/broken/application.yml +0 -0
  163. data/test/{config → fixtures/config}/broken/application_roles.yml +0 -0
  164. data/test/{config/empty/empty_02_roles.yml → fixtures/config/broken/empty.yml} +0 -0
  165. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  166. data/test/{config → fixtures/config}/broken/undefined.yml +0 -0
  167. data/test/{config → fixtures/config}/broken/undefined_roles.yml +0 -0
  168. data/test/{config → fixtures/config}/default/typus.yml +2 -1
  169. data/{generators/typus/templates/config/typus → test/fixtures/config/default}/typus_roles.yml +0 -0
  170. data/test/fixtures/config/empty/empty_01.yml +0 -0
  171. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  172. data/test/fixtures/config/empty/empty_02.yml +0 -0
  173. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  174. data/test/{config → fixtures/config}/locales/es.yml +0 -0
  175. data/test/fixtures/config/namespaced/application.yml +5 -0
  176. data/test/fixtures/config/namespaced/application_roles.yml +2 -0
  177. data/test/{config → fixtures/config}/ordered/001_roles.yml +0 -0
  178. data/test/{config → fixtures/config}/ordered/002_roles.yml +0 -0
  179. data/test/{config → fixtures/config}/unordered/app_one_roles.yml +0 -0
  180. data/test/{config → fixtures/config}/unordered/app_two_roles.yml +0 -0
  181. data/test/fixtures/config/working/application.yml +73 -0
  182. data/test/fixtures/config/working/application_roles.yml +24 -0
  183. data/{generators/typus/templates/config/typus → test/fixtures/config/working}/typus.yml +2 -1
  184. data/test/{config/default → fixtures/config/working}/typus_roles.yml +0 -0
  185. data/test/fixtures/rails_app/README +244 -0
  186. data/test/fixtures/rails_app/Rakefile +7 -0
  187. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +2 -0
  188. data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +2 -0
  189. data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +2 -0
  190. data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +2 -0
  191. data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +2 -0
  192. data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
  193. data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +2 -0
  194. data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +2 -0
  195. data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +2 -0
  196. data/test/fixtures/rails_app/app/controllers/application_controller.rb +4 -0
  197. data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
  198. data/test/fixtures/{app → rails_app/app}/models/asset.rb +1 -1
  199. data/test/fixtures/{app → rails_app/app}/models/category.rb +2 -2
  200. data/test/fixtures/{app → rails_app/app}/models/comment.rb +1 -1
  201. data/test/fixtures/{app → rails_app/app}/models/custom_user.rb +1 -1
  202. data/test/fixtures/{app → rails_app/app}/models/delayed/task.rb +2 -2
  203. data/test/fixtures/rails_app/app/models/page.rb +9 -0
  204. data/test/fixtures/rails_app/app/models/picture.rb +6 -0
  205. data/test/fixtures/{app → rails_app/app}/models/post.rb +6 -6
  206. data/test/fixtures/rails_app/app/models/typus_user.rb +8 -0
  207. data/test/fixtures/{app → rails_app/app}/models/view.rb +1 -1
  208. data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +1 -0
  209. data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +1 -0
  210. data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +6 -0
  211. data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +1 -0
  212. data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +1 -0
  213. data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +1 -0
  214. data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +1 -0
  215. data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +1 -0
  216. data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +1 -0
  217. data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +1 -0
  218. data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
  219. data/test/fixtures/rails_app/app/views/layouts/application.html.erb +14 -0
  220. data/test/fixtures/rails_app/config/application.rb +50 -0
  221. data/test/fixtures/rails_app/config/boot.rb +13 -0
  222. data/test/fixtures/rails_app/config/database.yml +22 -0
  223. data/test/fixtures/rails_app/config/environment.rb +5 -0
  224. data/test/fixtures/rails_app/config/environments/development.rb +19 -0
  225. data/test/fixtures/rails_app/config/environments/production.rb +42 -0
  226. data/test/fixtures/rails_app/config/environments/test.rb +34 -0
  227. data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +258 -0
  228. data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +98 -0
  229. data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  230. data/test/fixtures/rails_app/config/initializers/inflections.rb +10 -0
  231. data/test/fixtures/rails_app/config/initializers/mime_types.rb +5 -0
  232. data/test/fixtures/rails_app/config/initializers/secret_token.rb +7 -0
  233. data/test/fixtures/rails_app/config/initializers/session_store.rb +8 -0
  234. data/test/fixtures/rails_app/config/initializers/typus.rb +6 -0
  235. data/test/fixtures/rails_app/config/locales/en.yml +5 -0
  236. data/test/fixtures/rails_app/config/routes.rb +8 -0
  237. data/test/{config/working → fixtures/rails_app/config/typus}/application.yml +11 -9
  238. data/test/{config/working → fixtures/rails_app/config/typus}/application_roles.yml +0 -0
  239. data/{generators/typus_update_schema_to_01/templates/config → test/fixtures/rails_app/config/typus}/typus.yml +0 -0
  240. data/test/{config/working → fixtures/rails_app/config/typus}/typus_roles.yml +0 -0
  241. data/test/fixtures/rails_app/config.ru +4 -0
  242. data/test/fixtures/rails_app/db/seeds.rb +7 -0
  243. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  244. data/test/fixtures/rails_app/log/test.log +4268 -0
  245. data/test/fixtures/rails_app/public/404.html +26 -0
  246. data/test/fixtures/rails_app/public/422.html +26 -0
  247. data/test/fixtures/rails_app/public/500.html +26 -0
  248. data/test/fixtures/rails_app/public/favicon.ico +0 -0
  249. data/test/fixtures/rails_app/public/images/rails.png +0 -0
  250. data/test/fixtures/rails_app/public/index.html +279 -0
  251. data/test/fixtures/rails_app/public/javascripts/application.js +2 -0
  252. data/test/fixtures/rails_app/public/javascripts/controls.js +965 -0
  253. data/test/fixtures/rails_app/public/javascripts/dragdrop.js +974 -0
  254. data/test/fixtures/rails_app/public/javascripts/effects.js +1123 -0
  255. data/test/fixtures/rails_app/public/javascripts/prototype.js +4874 -0
  256. data/test/fixtures/rails_app/public/javascripts/rails.js +118 -0
  257. data/test/fixtures/rails_app/public/robots.txt +5 -0
  258. data/test/fixtures/rails_app/script/rails +9 -0
  259. data/test/fixtures/rails_app/tmp/export-posts-20100902120447.csv +2 -0
  260. data/test/fixtures/rails_app/tmp/export-posts-20100902120700.csv +2 -0
  261. data/test/functional/admin/account_controller_test.rb +90 -0
  262. data/test/functional/admin/dashboard_controller_http_basic_test.rb +24 -0
  263. data/test/functional/admin/dashboard_controller_none_test.rb +18 -0
  264. data/test/functional/admin/dashboard_controller_test.rb +106 -0
  265. data/test/functional/admin/resources_controller_assets_relationships.rb +59 -0
  266. data/test/functional/admin/resources_controller_categories_before_test.rb +10 -0
  267. data/test/functional/admin/resources_controller_categories_lists_test.rb +44 -0
  268. data/test/functional/admin/resources_controller_categories_views_test.rb +10 -0
  269. data/test/functional/admin/resources_controller_comments_toggle_test.rb +21 -0
  270. data/test/functional/admin/{master_controller_posts_before_test.rb → resources_controller_posts_before_test.rb} +3 -3
  271. data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +27 -0
  272. data/test/functional/admin/resources_controller_posts_crud_test.rb +44 -0
  273. data/test/functional/admin/resources_controller_posts_formats_test.rb +39 -0
  274. data/test/functional/admin/resources_controller_posts_forms_test.rb +58 -0
  275. data/test/functional/admin/resources_controller_posts_permissions_test.rb +100 -0
  276. data/test/functional/admin/{master_controller_posts_relationships_test.rb → resources_controller_posts_relationships_test.rb} +25 -20
  277. data/test/functional/admin/resources_controller_posts_roles.rb +52 -0
  278. data/test/functional/admin/resources_controller_posts_views_test.rb +143 -0
  279. data/test/functional/admin/resources_controller_tableless_resource_test.rb +51 -0
  280. data/test/functional/admin/resources_controller_typus_users_test.rb +159 -0
  281. data/test/functional/admin/session_controller_test.rb +85 -0
  282. data/test/helpers/admin/dashboard_helper_test.rb +42 -0
  283. data/test/helpers/admin/form_helper_test.rb +52 -276
  284. data/test/helpers/admin/resources_helper_test.rb +52 -0
  285. data/test/helpers/admin/sidebar_helper_test.rb +133 -224
  286. data/test/helpers/admin/table_helper_test.rb +136 -144
  287. data/test/helpers/admin_helper_test.rb +69 -0
  288. data/test/lib/support/active_record_test.rb +35 -0
  289. data/test/lib/support/array_test.rb +15 -0
  290. data/test/lib/support/hash_test.rb +11 -0
  291. data/test/lib/support/string_test.rb +48 -0
  292. data/test/lib/typus/active_record_test.rb +385 -0
  293. data/test/lib/typus/configuration_test.rb +52 -0
  294. data/test/lib/typus/resource_test.rb +17 -0
  295. data/test/lib/typus/routes_test.rb +29 -0
  296. data/test/lib/typus_test.rb +72 -40
  297. data/test/{vendor → lib/vendor}/paginator_test.rb +7 -4
  298. data/test/schema.rb +28 -3
  299. data/test/test_helper.rb +29 -0
  300. data/test/unit/admin/mailer_test.rb +32 -0
  301. data/test/unit/typus_user_roles_test.rb +69 -61
  302. data/test/unit/typus_user_test.rb +56 -143
  303. data/typus.gemspec +18 -276
  304. metadata +305 -231
  305. data/.gitignore +0 -1
  306. data/AUTHORS.md +0 -34
  307. data/CHANGES +0 -3
  308. data/README.md +0 -75
  309. data/VERSION +0 -1
  310. data/app/controllers/admin/master_controller.rb +0 -394
  311. data/app/controllers/typus_controller.rb +0 -152
  312. data/app/helpers/admin/master_helper.rb +0 -104
  313. data/app/helpers/admin/public_helper.rb +0 -27
  314. data/app/helpers/typus_helper.rb +0 -181
  315. data/app/models/typus_mailer.rb +0 -14
  316. data/app/models/typus_user.rb +0 -5
  317. data/app/views/admin/shared/_feedback.html.erb +0 -6
  318. data/app/views/admin/shared/_footer.html.erb +0 -2
  319. data/app/views/admin/shared/_pagination.html.erb +0 -28
  320. data/app/views/admin/templates/_tiny_mce.html.erb +0 -2
  321. data/app/views/layouts/typus.html.erb +0 -29
  322. data/app/views/typus/dashboard.html.erb +0 -9
  323. data/app/views/typus/recover_password.html.erb +0 -7
  324. data/app/views/typus/reset_password.html.erb +0 -15
  325. data/app/views/typus/sign_in.html.erb +0 -9
  326. data/app/views/typus/sign_up.html.erb +0 -7
  327. data/config/locales/es.yml +0 -105
  328. data/config/locales/fr.yml +0 -98
  329. data/config/locales/language.yml.template +0 -106
  330. data/generators/typus/templates/auto/index.html.erb +0 -11
  331. data/generators/typus/templates/auto/resource_controller.rb.erb +0 -15
  332. data/generators/typus/templates/auto/resource_controller_test.rb.erb +0 -11
  333. data/generators/typus/templates/auto/resources_controller.rb.erb +0 -37
  334. data/generators/typus/templates/config/initializers/typus.rb +0 -34
  335. data/generators/typus/templates/config/typus/application.yml +0 -6
  336. data/generators/typus/templates/config/typus/application_roles.yml +0 -23
  337. data/generators/typus/templates/lib/tasks/typus_tasks.rake +0 -32
  338. data/generators/typus/templates/public/images/admin/fancybox/fancy_closebox.png +0 -0
  339. data/generators/typus/templates/public/images/admin/fancybox/fancy_left.png +0 -0
  340. data/generators/typus/templates/public/images/admin/fancybox/fancy_progress.png +0 -0
  341. data/generators/typus/templates/public/images/admin/fancybox/fancy_right.png +0 -0
  342. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_e.png +0 -0
  343. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_n.png +0 -0
  344. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_ne.png +0 -0
  345. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_nw.png +0 -0
  346. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_s.png +0 -0
  347. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_se.png +0 -0
  348. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_sw.png +0 -0
  349. data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_w.png +0 -0
  350. data/generators/typus/templates/public/images/admin/fancybox/fancy_title_left.png +0 -0
  351. data/generators/typus/templates/public/images/admin/fancybox/fancy_title_main.png +0 -0
  352. data/generators/typus/templates/public/javascripts/admin/application.js +0 -14
  353. data/generators/typus/templates/public/javascripts/admin/jquery-1.3.2.min.js +0 -19
  354. data/generators/typus/templates/public/javascripts/admin/jquery.fancybox-1.2.1.min.js +0 -9
  355. data/generators/typus/templates/public/stylesheets/admin/jquery.fancybox.css +0 -315
  356. data/generators/typus/templates/public/stylesheets/admin/reset.css +0 -68
  357. data/generators/typus/templates/public/stylesheets/admin/screen.css +0 -361
  358. data/generators/typus/typus_generator.rb +0 -191
  359. data/generators/typus_update_schema_to_01/templates/migration.rb +0 -11
  360. data/generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb +0 -19
  361. data/generators/typus_update_schema_to_02/templates/migration.rb +0 -11
  362. data/generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb +0 -11
  363. data/lib/typus/active_record.rb +0 -323
  364. data/lib/typus/extensions/routes.rb +0 -15
  365. data/lib/typus/extensions/routes_hack.rb +0 -15
  366. data/lib/typus/preferences.rb +0 -11
  367. data/lib/typus/preview.rb +0 -76
  368. data/lib/typus/quick_edit.rb +0 -40
  369. data/lib/typus/reloader.rb +0 -14
  370. data/lib/typus/string.rb +0 -27
  371. data/lib/vendor/active_record.rb +0 -15
  372. data/lib/vendor/rss_parser.rb +0 -20
  373. data/rails/init.rb +0 -3
  374. data/tasks/typus_tasks.rake +0 -32
  375. data/test/config/working/typus.yml +0 -12
  376. data/test/fixtures/app/controllers/admin/assets_controller.rb +0 -2
  377. data/test/fixtures/app/controllers/admin/categories_controller.rb +0 -2
  378. data/test/fixtures/app/controllers/admin/comments_controller.rb +0 -2
  379. data/test/fixtures/app/controllers/admin/pages_controller.rb +0 -2
  380. data/test/fixtures/app/controllers/admin/posts_controller.rb +0 -2
  381. data/test/fixtures/app/controllers/admin/status_controller.rb +0 -6
  382. data/test/fixtures/app/controllers/admin/typus_users_controller.rb +0 -2
  383. data/test/fixtures/app/controllers/admin/watch_dog_controller.rb +0 -6
  384. data/test/fixtures/app/models/page.rb +0 -5
  385. data/test/fixtures/app/views/admin/dashboard/_content.html.erb +0 -1
  386. data/test/fixtures/app/views/admin/dashboard/_sidebar.html.erb +0 -1
  387. data/test/fixtures/app/views/admin/posts/_edit.html.erb +0 -1
  388. data/test/fixtures/app/views/admin/posts/_index.html.erb +0 -1
  389. data/test/fixtures/app/views/admin/posts/_new.html.erb +0 -1
  390. data/test/fixtures/app/views/admin/posts/_show.html.erb +0 -1
  391. data/test/fixtures/app/views/admin/posts/_sidebar.html.erb +0 -1
  392. data/test/fixtures/app/views/admin/resources/_sidebar.html.erb +0 -1
  393. data/test/fixtures/app/views/admin/shared/_footer.html.erb +0 -1
  394. data/test/fixtures/app/views/admin/status/index.html.erb +0 -1
  395. data/test/fixtures/app/views/admin/templates/_datepicker.html.erb +0 -1
  396. data/test/fixtures/assets.yml +0 -11
  397. data/test/fixtures/categories.yml +0 -14
  398. data/test/fixtures/comments.yml +0 -27
  399. data/test/fixtures/pages.yml +0 -41
  400. data/test/fixtures/posts.yml +0 -37
  401. data/test/fixtures/typus_users.yml +0 -59
  402. data/test/functional/admin/master_controller_assets_relationships.rb +0 -66
  403. data/test/functional/admin/master_controller_categories_lists_test.rb +0 -64
  404. data/test/functional/admin/master_controller_posts_crud_test.rb +0 -97
  405. data/test/functional/admin/master_controller_posts_formats_test.rb +0 -53
  406. data/test/functional/admin/master_controller_posts_permissions_test.rb +0 -127
  407. data/test/functional/admin/master_controller_posts_roles.rb +0 -50
  408. data/test/functional/admin/master_controller_posts_toggle_test.rb +0 -35
  409. data/test/functional/admin/master_controller_posts_views_test.rb +0 -209
  410. data/test/functional/admin/master_controller_tableless_resource_test.rb +0 -36
  411. data/test/functional/admin/master_controller_typus_users_test.rb +0 -211
  412. data/test/functional/typus_controller_test.rb +0 -342
  413. data/test/helper.rb +0 -51
  414. data/test/helpers/admin/master_helper_test.rb +0 -70
  415. data/test/helpers/admin/public_helper_test.rb +0 -26
  416. data/test/helpers/typus_helper_test.rb +0 -96
  417. data/test/lib/active_record_test.rb +0 -377
  418. data/test/lib/configuration_test.rb +0 -95
  419. data/test/lib/hash_test.rb +0 -11
  420. data/test/lib/routes_test.rb +0 -71
  421. data/test/lib/string_test.rb +0 -55
  422. data/test/unit/typus_mailer_test.rb +0 -29
  423. data/test/unit/typus_test.rb +0 -17
  424. data/test/vendor/active_record_test.rb +0 -18
@@ -1,242 +1,249 @@
1
- module Admin::TableHelper
1
+ module Admin
2
2
 
3
- def build_typus_table(model, fields, items, link_options = {}, association = nil)
3
+ module TableHelper
4
4
 
5
- returning(String.new) do |html|
6
-
7
- html << <<-HTML
8
- <table class="typus">
9
- HTML
10
-
11
- html << typus_table_header(model, fields)
5
+ def build_table(model, fields, items, link_options = {}, association = nil)
6
+ render "admin/helpers/table/table",
7
+ :model => model,
8
+ :fields => fields,
9
+ :items => items,
10
+ :link_options => link_options,
11
+ :headers => table_header(model, fields)
12
+ end
12
13
 
13
- items.each do |item|
14
+ def table_header(model, fields)
15
+ fields.map do |key, value|
14
16
 
15
- html << <<-HTML
16
- <tr class="#{cycle('even', 'odd')} #{item.class.name.underscore}" id="#{item.to_dom}" name="item_#{item.id}">
17
- HTML
17
+ key = key.gsub(".", " ") if key.match(/\./)
18
+ content = model.human_attribute_name(key)
18
19
 
19
- fields.each do |key, value|
20
- case value
21
- when :boolean then html << typus_table_boolean_field(key, item)
22
- when :datetime then html << typus_table_datetime_field(key, item, link_options)
23
- when :date then html << typus_table_datetime_field(key, item, link_options)
24
- when :file then html << typus_table_file_field(key, item, link_options)
25
- when :time then html << typus_table_datetime_field(key, item, link_options)
26
- when :belongs_to then html << typus_table_belongs_to_field(key, item)
27
- when :tree then html << typus_table_tree_field(key, item)
28
- when :position then html << typus_table_position_field(key, item)
29
- when :has_and_belongs_to_many then
30
- html << typus_table_has_and_belongs_to_many_field(key, item)
20
+ if params[:action] == "index"
21
+ association = model.reflect_on_association(key.to_sym)
22
+ order_by = association ? association.primary_key_name : key
23
+
24
+ if (model.model_fields.map(&:first).collect { |i| i.to_s }.include?(key) || model.reflect_on_all_associations(:belongs_to).map(&:name).include?(key.to_sym))
25
+ sort_order = case params[:sort_order]
26
+ when 'asc' then ['desc', '&darr;']
27
+ when 'desc' then ['asc', '&uarr;']
28
+ else [nil, nil]
29
+ end
30
+ switch = sort_order.last if params[:order_by].eql?(order_by)
31
+ options = { :order_by => order_by, :sort_order => sort_order.first }
32
+ message = [ content, switch ].compact
33
+ link_to raw(message.join(" ")), params.merge(options)
31
34
  else
32
- html << typus_table_string_field(key, item, link_options)
35
+ content
33
36
  end
34
- end
35
37
 
36
- action = if model.typus_user_id? && !@current_user.is_root?
37
- # If there's a typus_user_id column on the table and logged user is not root ...
38
- item.owned_by?(@current_user) ? item.class.typus_options_for(:default_action_on_item) : 'show'
39
- elsif !@current_user.can_perform?(model, 'edit')
40
- 'show'
41
- else
42
- item.class.typus_options_for(:default_action_on_item)
43
- end
44
-
45
- content = link_to _(action.capitalize), :controller => "admin/#{item.class.name.tableize}", :action => action, :id => item.id
46
- html << <<-HTML
47
- <td width="10px">#{content}</td>
48
- HTML
49
-
50
- ##
51
- # This controls the action to perform. If we are on a model list we
52
- # will remove the entry, but if we inside a model we will remove the
53
- # relationship between the models.
54
- #
55
- # Only shown is the user can destroy/unrelate items.
56
- #
57
-
58
- trash = "<div class=\"sprite trash\">Trash</div>"
59
- unrelate = "<div class=\"sprite unrelate\">Unrelate</div>"
60
-
61
- case params[:action]
62
- when 'index'
63
- condition = if model.typus_user_id? && !@current_user.is_root?
64
- item.owned_by?(@current_user)
65
- else
66
- @current_user.can_perform?(model, 'destroy')
67
- end
68
- perform = link_to trash, { :action => 'destroy', :id => item.id },
69
- :title => _("Remove"),
70
- :confirm => _("Remove entry?"),
71
- :method => :delete if condition
72
- when 'edit'
73
- # If we are editing content, we can relate and unrelate always!
74
- perform = link_to unrelate, { :action => 'unrelate', :id => params[:id], :resource => model, :resource_id => item.id },
75
- :title => _("Unrelate"),
76
- :confirm => _("Unrelate {{unrelate_model}} from {{unrelate_model_from}}?",
77
- :unrelate_model => model.typus_human_name,
78
- :unrelate_model_from => @resource[:human_name])
79
- when 'show'
80
- # If we are showing content, we only can relate and unrelate if we are
81
- # the owners of the owner record.
82
- # If the owner record doesn't have a foreign key (Typus.user_fk) we look
83
- # each item to verify the ownership.
84
- condition = if @resource[:class].typus_user_id? && !@current_user.is_root?
85
- @item.owned_by?(@current_user)
86
- end
87
- perform = link_to unrelate, { :action => 'unrelate', :id => params[:id], :resource => model, :resource_id => item.id },
88
- :title => _("Unrelate"),
89
- :confirm => _("Unrelate {{unrelate_model}} from {{unrelate_model_from}}?",
90
- :unrelate_model => model.typus_human_name,
91
- :unrelate_model_from => @resource[:human_name]) if condition
38
+ else
39
+ content
92
40
  end
93
41
 
94
- html << <<-HTML
95
- <td width="10px">#{perform}</td>
96
- </tr>
97
- HTML
98
-
99
42
  end
100
-
101
- html << "</table>"
102
-
103
43
  end
104
44
 
105
- end
106
-
107
- ##
108
- # Header of the table
109
- #
110
- def typus_table_header(model, fields)
111
- returning(String.new) do |html|
112
- headers = []
113
- fields.each do |key, value|
114
-
115
- content = model.human_attribute_name(key)
116
- content += " (#{key})" if key.include?('_id')
117
-
118
- if (model.model_fields.map(&:first).collect { |i| i.to_s }.include?(key) || model.reflect_on_all_associations(:belongs_to).map(&:name).include?(key.to_sym)) && params[:action] == 'index'
119
- sort_order = case params[:sort_order]
120
- when 'asc' then ['desc', '&darr;']
121
- when 'desc' then ['asc', '&uarr;']
122
- else
123
- [nil, nil]
124
- end
125
- order_by = model.reflect_on_association(key.to_sym).primary_key_name rescue key
126
- switch = sort_order.last if params[:order_by].eql?(order_by)
127
- options = { :order_by => order_by, :sort_order => sort_order.first }
128
- content = (link_to "#{content} #{switch}", params.merge(options))
45
+ def table_fields_for_item(item, fields, link_options)
46
+ fields.map do |key, value|
47
+ case value
48
+ when :boolean then table_boolean_field(key, item)
49
+ when :datetime then table_datetime_field(key, item, link_options)
50
+ when :date then table_datetime_field(key, item, link_options)
51
+ when :file then table_file_field(key, item, link_options)
52
+ when :time then table_datetime_field(key, item, link_options)
53
+ when :belongs_to then table_belongs_to_field(key, item)
54
+ when :tree then table_tree_field(key, item)
55
+ when :position then table_position_field(key, item)
56
+ when :selector then table_selector(key, item)
57
+ when :transversal then table_transversal(key, item)
58
+ when :has_and_belongs_to_many then table_has_and_belongs_to_many_field(key, item)
59
+ else
60
+ table_string_field(key, item, link_options)
129
61
  end
130
-
131
- headers << "<th>#{content}</th>"
132
-
133
62
  end
134
- headers << "<th>&nbsp;</th>" if @current_user.can_perform?(model, 'delete')
135
- html << <<-HTML
136
- <tr>
137
- #{headers.join("\n")}
138
- </tr>
139
- HTML
140
63
  end
141
- end
142
64
 
143
- def typus_table_belongs_to_field(attribute, item)
144
-
145
- action = item.send(attribute).class.typus_options_for(:default_action_on_item) rescue 'edit'
146
-
147
- att_value = item.send(attribute)
148
- content = if !att_value.nil?
149
- if @current_user.can_perform?(att_value.class.name, action)
150
- link_to item.send(attribute).typus_name, :controller => "admin/#{attribute.pluralize}", :action => action, :id => att_value.id
151
- else
152
- att_value.typus_name
153
- end
65
+ def table_default_action(model, item)
66
+ action = if model.typus_user_id? && @current_user.is_not_root?
67
+ # If there's a typus_user_id column on the table and logged user is not root ...
68
+ item.owned_by?(@current_user) ? item.class.typus_options_for(:default_action_on_item) : "show"
69
+ elsif @current_user.cannot?("edit", model)
70
+ 'show'
71
+ else
72
+ item.class.typus_options_for(:default_action_on_item)
73
+ end
74
+
75
+ options = { :controller => "admin/#{item.class.to_resource}",
76
+ :action => action,
77
+ :id => item.id }
78
+
79
+ link_to _(action.capitalize), options
154
80
  end
155
81
 
156
- <<-HTML
157
- <td>#{content}</td>
158
- HTML
159
-
160
- end
161
-
162
- def typus_table_has_and_belongs_to_many_field(attribute, item)
163
- <<-HTML
164
- <td>#{item.send(attribute).map { |i| i.typus_name }.join('<br />')}</td>
165
- HTML
166
- end
82
+ #--
83
+ # This controls the action to perform. If we are on a model list we
84
+ # will remove the entry, but if we inside a model we will remove the
85
+ # relationship between the models.
86
+ #
87
+ # Only shown is the user can destroy/unrelate items.
88
+ #++
89
+ def table_action(model, item)
90
+
91
+ condition = true
92
+
93
+ case params[:action]
94
+ when "index"
95
+ action = "trash"
96
+ options = { :action => 'destroy', :id => item.id }
97
+ method = :delete
98
+ when "edit", "show"
99
+ action = "unrelate"
100
+ options = { :action => 'unrelate', :id => params[:id], :resource => model, :resource_id => item.id }
101
+ end
167
102
 
168
- def typus_table_string_field(attribute, item, link_options = {})
169
- <<-HTML
170
- <td class="#{attribute}">#{h(item.send(attribute))}</td>
171
- HTML
172
- end
103
+ title = _(action.titleize)
104
+
105
+ case params[:action]
106
+ when 'index'
107
+ condition = if model.typus_user_id? && @current_user.is_not_root?
108
+ item.owned_by?(@current_user)
109
+ elsif (@current_user.id.eql?(item.id) && model.eql?(Typus.user_class))
110
+ false
111
+ else
112
+ @current_user.can?('destroy', model)
113
+ end
114
+ confirm = _("Remove %{resource}?", :resource => item.class.model_name.human)
115
+ when 'edit'
116
+ # If we are editing content, we can relate and unrelate always!
117
+ confirm = _("Unrelate %{unrelate_model} from %{unrelate_model_from}?",
118
+ :unrelate_model => model.model_name.human,
119
+ :unrelate_model_from => @resource.model_name.human)
120
+ when 'show'
121
+ # If we are showing content, we only can relate and unrelate if we are
122
+ # the owners of the owner record.
123
+ # If the owner record doesn't have a foreign key (Typus.user_fk) we look
124
+ # each item to verify the ownership.
125
+ condition = if @resource.typus_user_id? && @current_user.is_not_root?
126
+ @item.owned_by?(@current_user)
127
+ end
128
+ confirm = _("Unrelate %{unrelate_model} from %{unrelate_model_from}?",
129
+ :unrelate_model => model.model_name.human,
130
+ :unrelate_model_from => @resource.model_name.human)
131
+ end
173
132
 
174
- def typus_table_file_field(attribute, item, link_options = {})
175
- <<-HTML
176
- <td>#{item.typus_preview_on_table(attribute)}</td>
177
- HTML
178
- end
133
+ message = %(<div class="sprite #{action}">#{_(action.titleize)}</div>)
179
134
 
180
- def typus_table_tree_field(attribute, item)
181
- <<-HTML
182
- <td>#{item.parent.typus_name if item.parent}</td>
183
- HTML
184
- end
135
+ if condition
136
+ link_to raw(message), options, :title => title, :confirm => confirm, :method => method
137
+ end
185
138
 
186
- def typus_table_position_field(attribute, item)
139
+ end
187
140
 
188
- html_position = []
141
+ def table_belongs_to_field(attribute, item)
142
+ att_value = item.send(attribute)
143
+ content = "&mdash;".html_safe
189
144
 
190
- [['Up', 'move_higher'], ['Down', 'move_lower']].each do |position|
145
+ unless att_value.nil?
146
+ content = att_value.to_label
147
+ action = item.send(attribute).class.typus_options_for(:default_action_on_item)
148
+ if @current_user.can?(action, att_value.class.name)
149
+ content = link_to content, :controller => "admin/#{att_value.class.to_resource}", :action => action, :id => att_value.id
150
+ end
151
+ end
191
152
 
192
- options = { :controller => item.class.name.tableize,
193
- :action => 'position',
194
- :id => item.id,
195
- :go => position.last }
153
+ return content_tag(:td, content)
154
+ end
196
155
 
197
- first_or_last = (item.respond_to?(:first?) && (position.last == 'move_higher' && item.first?)) || (item.respond_to?(:last?) && (position.last == 'move_lower' && item.last?))
198
- html_position << link_to_unless(first_or_last, _(position.first), params.merge(options)) do |name|
199
- %(<span class="inactive">#{name}</span>)
200
- end
156
+ def table_has_and_belongs_to_many_field(attribute, item)
157
+ content = item.send(attribute).map { |i| i.to_label }.join(", ")
158
+ return content_tag(:td, content)
201
159
  end
202
160
 
203
- <<-HTML
204
- <td>#{html_position.join(' / ')}</td>
205
- HTML
161
+ def table_string_field(attribute, item, link_options = {})
162
+ raw_content = item.send(attribute)
163
+ content = raw_content.blank? ? "&#151;".html_safe : raw_content
164
+ return content_tag(:td, content, :class => attribute)
165
+ end
206
166
 
207
- end
167
+ def table_selector(attribute, item)
168
+ raw_content = item.mapping(attribute)
169
+ return content_tag(:td, raw_content, :class => attribute)
170
+ end
208
171
 
209
- def typus_table_datetime_field(attribute, item, link_options = {} )
172
+ def table_file_field(attribute, item, link_options = {})
173
+ file_preview = Typus.file_preview
174
+ file_thumbnail = Typus.file_thumbnail
175
+
176
+ has_file_preview = item.send(attribute).styles.member?(file_preview)
177
+ file_preview_is_image = item.send("#{attribute}_content_type") =~ /^image\/.+/
178
+
179
+ content = if has_file_preview && file_preview_is_image
180
+ render "admin/helpers/preview",
181
+ :attribute => attribute,
182
+ :attachment => attribute,
183
+ :content => item.send(attribute),
184
+ :file_preview_is_image => file_preview_is_image,
185
+ :has_file_preview => has_file_preview,
186
+ :href => item.send(attribute).url(file_preview),
187
+ :item => item
188
+ else
189
+ link_to item.send(attribute), item.send(attribute).url
190
+ end
191
+
192
+ return content_tag(:td, content)
193
+ end
210
194
 
211
- date_format = item.class.typus_date_format(attribute)
212
- content = !item.send(attribute).nil? ? item.send(attribute).to_s(date_format) : item.class.typus_options_for(:nil)
195
+ def table_tree_field(attribute, item)
196
+ content = item.parent ? item.parent.to_label : "&#151;".html_safe
197
+ return content_tag(:td, content)
198
+ end
213
199
 
214
- <<-HTML
215
- <td>#{content}</td>
216
- HTML
200
+ def table_position_field(attribute, item)
201
+ html_position = []
217
202
 
218
- end
203
+ { :move_higher => "Up", :move_lower => "Down" }.each do |key, value|
204
+ options = { :controller => item.class.to_resource, :action => "position", :id => item.id, :go => key }
205
+ first_or_last = (item.respond_to?(:first?) && (key == :move_higher && item.first?)) || (item.respond_to?(:last?) && (key == :move_lower && item.last?))
206
+ html_position << link_to_unless(first_or_last, _(value), params.merge(options)) do |name|
207
+ %(<span class="inactive">#{name}</span>)
208
+ end
209
+ end
219
210
 
220
- def typus_table_boolean_field(attribute, item)
211
+ content = html_position.join(" / ").html_safe
212
+ return content_tag(:td, content)
213
+ end
221
214
 
222
- boolean_hash = item.class.typus_boolean(attribute)
223
- status = item.send(attribute)
224
- link_text = !item.send(attribute).nil? ? boolean_hash["#{status}".to_sym] : item.class.typus_options_for(:nil)
215
+ def table_datetime_field(attribute, item, link_options = {} )
216
+ date_format = item.class.typus_date_format(attribute)
217
+ content = !item.send(attribute).nil? ? item.send(attribute).to_s(date_format) : item.class.typus_options_for(:nil)
225
218
 
226
- options = { :controller => item.class.name.tableize, :action => 'toggle', :field => attribute.gsub(/\?$/,''), :id => item.id }
219
+ return content_tag(:td, content)
220
+ end
227
221
 
228
- content = if item.class.typus_options_for(:toggle) && !item.send(attribute).nil?
229
- link_to link_text, params.merge(options),
230
- :confirm => _("Change {{attribute}}?",
231
- :attribute => item.class.human_attribute_name(attribute).downcase)
232
- else
233
- link_text
234
- end
222
+ def table_boolean_field(attribute, item)
223
+ boolean_hash = item.class.typus_boolean(attribute)
224
+ status = item.send(attribute)
225
+
226
+ content = if status.nil?
227
+ Typus::Resources.human_nil
228
+ else
229
+ message = _(boolean_hash["#{status}".to_sym])
230
+ options = { :controller => "admin/#{item.class.to_resource}",
231
+ :action => "toggle",
232
+ :id => item.id,
233
+ :field => attribute.gsub(/\?$/,'') }
234
+ confirm = _("Change %{attribute}?",
235
+ :attribute => item.class.human_attribute_name(attribute).downcase)
236
+ link_to message, options, :confirm => confirm
237
+ end
238
+
239
+ return content_tag(:td, content)
240
+ end
235
241
 
236
- <<-HTML
237
- <td align="center">#{content}</td>
238
- HTML
242
+ def table_transversal(attribute, item)
243
+ _attribute, virtual = attribute.split(".")
244
+ return content_tag(:td, item.send(_attribute).send(virtual))
245
+ end
239
246
 
240
247
  end
241
248
 
242
- end
249
+ end
@@ -0,0 +1,56 @@
1
+ module AdminHelper
2
+
3
+ def typus_block(resource = @resource.to_resource, partial = params[:action])
4
+ partials_path = "admin/#{resource}"
5
+ resources_partials_path = "admin/resources"
6
+
7
+ partials = ActionController::Base.view_paths.map do |view_path|
8
+ Dir["#{view_path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
9
+ end.flatten
10
+ resources_partials = Dir[Rails.root.join("app/views/#{resources_partials_path}/*").to_s].map do |file|
11
+ File.basename(file, ".html.erb")
12
+ end
13
+
14
+ path = if partials.include?("_#{partial}") then partials_path
15
+ elsif resources_partials.include?(partial) then resources_partials_path
16
+ end
17
+
18
+ render "#{path}/#{partial}" if path
19
+ end
20
+
21
+ def title(page_title)
22
+ content_for(:title) { page_title }
23
+ end
24
+
25
+ def header
26
+ render "admin/helpers/header"
27
+ end
28
+
29
+ def apps
30
+ render "admin/helpers/apps"
31
+ end
32
+
33
+ def login_info(user = @current_user)
34
+ return if user.kind_of?(Admin::FakeUser)
35
+
36
+ admin_edit_typus_user_path = { :controller => "/admin/#{Typus.user_class.to_resource}",
37
+ :action => 'edit',
38
+ :id => user.id }
39
+
40
+ message = _("Are you sure you want to sign out and end your session?")
41
+
42
+ user_details = if user.can?('edit', Typus.user_class_name)
43
+ link_to user.name, admin_edit_typus_user_path
44
+ else
45
+ user.name
46
+ end
47
+
48
+ render "admin/helpers/login_info", :message => message, :user_details => user_details
49
+ end
50
+
51
+ def display_flash_message(message = flash)
52
+ return if message.empty?
53
+ render "admin/helpers/flash_message", :flash_type => message.keys.first, :message => message
54
+ end
55
+
56
+ end
@@ -0,0 +1,13 @@
1
+ class Admin::Mailer < ActionMailer::Base
2
+
3
+ default :from => Typus.mailer_sender
4
+
5
+ def reset_password_link(user, url)
6
+ @user = user
7
+ @url = url
8
+
9
+ mail :to => user.email,
10
+ :subject => "[#{Typus.admin_title}] #{_("Reset password")}"
11
+ end
12
+
13
+ end
@@ -0,0 +1,38 @@
1
+ module Admin
2
+
3
+ class FakeUser
4
+
5
+ def id
6
+ 0
7
+ end
8
+
9
+ def can?(*args)
10
+ true
11
+ end
12
+
13
+ def cannot?(*args)
14
+ !can?(*args)
15
+ end
16
+
17
+ def is_root?
18
+ true
19
+ end
20
+
21
+ def is_not_root?
22
+ !is_root?
23
+ end
24
+
25
+ def resources
26
+ Typus::Configuration.roles[role].compact
27
+ end
28
+
29
+ def role
30
+ Typus.master_role
31
+ end
32
+
33
+ def name
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,21 @@
1
+ <%
2
+ page_title = _("Forgot password")
3
+ title(page_title)
4
+ %>
5
+
6
+ <%= form_for :typus_user, :url => { :action => :forgot_password } do |form| %>
7
+
8
+ <ul>
9
+
10
+ <li>
11
+ <%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
12
+ <%= form.text_field :email, :size => 20, :class => "text" %>
13
+ </li>
14
+
15
+ <li>
16
+ <%= submit_tag _("Submit"), :class => "button" %> <%= link_to _("I remember my password"), new_admin_session_path %>
17
+ </li>
18
+
19
+ </ul>
20
+
21
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <%
2
+ page_title = _("Sign up")
3
+ title(page_title)
4
+ %>
5
+
6
+ <%= form_for :typus_user, :url => { :action => :create } do |form| %>
7
+
8
+ <ul>
9
+
10
+ <li>
11
+ <%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
12
+ <%= form.text_field :email, :size => 20, :class => "text" %>
13
+ </li>
14
+
15
+ <li>
16
+ <%= submit_tag _("Sign up"), :class => "button" %>
17
+ </li>
18
+
19
+ </ul>
20
+
21
+ <% end %>
@@ -1,5 +1,5 @@
1
- <h2>Welcome to Typus!</h2>
1
+ <h2>Welcome!</h2>
2
2
 
3
- <p>If you need help don't hesitate in joining the <%= link_to 'mailing list', 'http://groups.google.com/group/typus', :rel => 'external' %>.</p>
3
+ <p>If you need help don't hesitate in joining the <%= link_to 'mailing list', 'http://groups.google.com/group/typus' %>.</p>
4
4
 
5
- <p>Replace this sidebar dropping a file named <code>_sidebar.html.erb</code> on the <code>app/views/admin/dashboard</code> folder.</p>
5
+ <p>Replace this sidebar dropping a file named <code>_sidebar.html.erb</code> on the <code>app/views/admin/dashboard</code> folder.</p>
@@ -0,0 +1,16 @@
1
+ <%
2
+ page_title = _("Dashboard")
3
+ title(page_title)
4
+ %>
5
+
6
+ <% content_for :sidebar do %>
7
+ <%= render "sidebar" %>
8
+ <% end %>
9
+
10
+ <h2>
11
+ <%= page_title %>
12
+ </h2>
13
+
14
+ <%= applications %>
15
+
16
+ <%= resources %>