typus 3.0.2 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (343) hide show
  1. data/Gemfile +20 -9
  2. data/Gemfile.lock +93 -65
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +61 -0
  5. data/Rakefile +5 -0
  6. data/app/controllers/admin/account_controller.rb +7 -10
  7. data/app/controllers/admin/base_controller.rb +16 -1
  8. data/app/controllers/admin/resources_controller.rb +270 -159
  9. data/app/controllers/admin/session_controller.rb +8 -9
  10. data/app/helpers/admin/base_helper.rb +13 -28
  11. data/app/helpers/admin/dashboard_helper.rb +4 -10
  12. data/app/helpers/admin/file_preview_helper.rb +70 -0
  13. data/app/helpers/admin/filters_helper.rb +64 -45
  14. data/app/helpers/admin/form_helper.rb +37 -62
  15. data/app/helpers/admin/relationships_helper.rb +63 -78
  16. data/app/helpers/admin/resources_helper.rb +10 -31
  17. data/app/helpers/admin/search_helper.rb +6 -9
  18. data/app/helpers/admin/sidebar_helper.rb +15 -20
  19. data/app/helpers/admin/table_helper.rb +79 -170
  20. data/app/mailers/admin/mailer.rb +1 -1
  21. data/app/views/admin/account/forgot_password.html.erb +2 -2
  22. data/app/views/admin/account/new.html.erb +8 -4
  23. data/app/views/admin/base/user_guide.html.erb +85 -0
  24. data/app/views/admin/dashboard/_sidebar.html.erb +3 -1
  25. data/app/views/admin/dashboard/show.html.erb +2 -2
  26. data/app/views/admin/dashboard/styles.html.erb +2 -2
  27. data/app/views/admin/helpers/_apps.html.erb +5 -4
  28. data/app/views/admin/helpers/_file_preview.html.erb +3 -0
  29. data/app/views/admin/helpers/_header.html.erb +3 -3
  30. data/app/views/admin/helpers/_login_info.html.erb +2 -2
  31. data/app/views/admin/helpers/dashboard/_applications.html.erb +6 -9
  32. data/app/views/admin/helpers/dashboard/_resources.html.erb +2 -3
  33. data/app/views/admin/helpers/filters/_filters.html.erb +1 -1
  34. data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +1 -1
  35. data/app/views/admin/helpers/resources/_errors.html.erb +10 -0
  36. data/app/views/admin/helpers/search/_search.html.erb +1 -1
  37. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +6 -3
  38. data/app/views/admin/helpers/table/_table.html.erb +17 -5
  39. data/app/views/admin/mailer/reset_password_link.text.erb +2 -2
  40. data/app/views/admin/resources/_form.html.erb +3 -12
  41. data/app/views/admin/resources/edit.html.erb +7 -5
  42. data/app/views/admin/resources/index.html.erb +13 -18
  43. data/app/views/admin/resources/new.html.erb +4 -4
  44. data/app/views/admin/resources/show.html.erb +9 -13
  45. data/app/views/admin/session/new.html.erb +8 -4
  46. data/app/views/admin/templates/_belongs_to.html.erb +1 -1
  47. data/app/views/admin/templates/_boolean.html.erb +2 -2
  48. data/app/views/admin/templates/_date.html.erb +2 -2
  49. data/app/views/admin/templates/_datetime.html.erb +2 -2
  50. data/app/views/admin/templates/_file.html.erb +3 -19
  51. data/app/views/admin/templates/_has_n.html.erb +4 -4
  52. data/app/views/admin/templates/_has_one.html.erb +14 -0
  53. data/app/views/admin/templates/_password.html.erb +2 -2
  54. data/app/views/admin/templates/_profile_sidebar.html.erb +3 -0
  55. data/app/views/admin/templates/_relate_form.html.erb +2 -1
  56. data/app/views/admin/templates/_selector.html.erb +1 -1
  57. data/app/views/admin/templates/_string.html.erb +6 -6
  58. data/app/views/admin/templates/_text.html.erb +11 -4
  59. data/app/views/admin/templates/_time.html.erb +2 -2
  60. data/app/views/admin/templates/_tree.html.erb +1 -1
  61. data/app/views/layouts/admin/base.html.erb +7 -6
  62. data/app/views/layouts/admin/session.html.erb +4 -14
  63. data/config/{available_locales/ca_models.yml → locales/typus.ca.models.yml} +5 -4
  64. data/config/locales/typus.ca.yml +81 -0
  65. data/config/{available_locales/de_models.yml → locales/typus.de.models.yml} +6 -2
  66. data/config/locales/typus.de.yml +80 -0
  67. data/config/locales/typus.el.models.yml +17 -0
  68. data/config/locales/typus.el.yml +82 -0
  69. data/config/{available_locales/es_models.yml → locales/typus.es.models.yml} +9 -4
  70. data/config/locales/typus.es.yml +82 -0
  71. data/config/{available_locales/fr_models.yml → locales/typus.fr.models.yml} +8 -3
  72. data/config/locales/typus.fr.yml +87 -0
  73. data/config/{available_locales/hu_models.yml → locales/typus.hu.models.yml} +6 -2
  74. data/config/locales/typus.hu.yml +80 -0
  75. data/config/{available_locales/it_models.yml → locales/typus.it.models.yml} +7 -4
  76. data/config/locales/typus.it.yml +89 -0
  77. data/config/{available_locales/language_models.yml.template → locales/typus.locale.models.yml.template} +8 -4
  78. data/config/locales/typus.locale.yml.template +81 -0
  79. data/config/{available_locales/pt-BR_models.yml → locales/typus.pt-BR.models.yml} +6 -2
  80. data/config/locales/typus.pt-BR.yml +80 -0
  81. data/config/{available_locales/ru_models.yml → locales/typus.ru.models.yml} +6 -2
  82. data/config/locales/typus.ru.yml +80 -0
  83. data/config/locales/typus.zh-CN.models.yml +17 -0
  84. data/config/locales/typus.zh-CN.yml +79 -0
  85. data/config/routes.rb +11 -7
  86. data/lib/generators/templates/config/initializers/typus.rb +8 -5
  87. data/lib/generators/templates/config/initializers/typus_resources.rb +0 -3
  88. data/lib/generators/templates/config/typus/README +6 -6
  89. data/lib/generators/templates/config/typus/typus.yml +5 -5
  90. data/lib/generators/templates/controller.rb +1 -1
  91. data/lib/generators/templates/migration.rb +1 -0
  92. data/lib/generators/templates/public/admin/javascripts/application.js +0 -4
  93. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.4.min.js +167 -0
  94. data/lib/generators/templates/public/admin/javascripts/jquery.application.js +16 -0
  95. data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +50 -22
  96. data/lib/generators/templates/public/admin/stylesheets/screen.css +43 -34
  97. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
  98. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +32 -32
  99. data/lib/generators/templates/public/admin/vendor/fancybox/{jquery.fancybox-1.3.1.css → jquery.fancybox-1.3.4.css} +359 -363
  100. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.js +1156 -0
  101. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
  102. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
  103. data/lib/generators/typus/assets_generator.rb +23 -0
  104. data/lib/generators/typus/controller_generator.rb +29 -0
  105. data/lib/generators/typus/migration_generator.rb +39 -20
  106. data/lib/generators/typus/typus_generator.rb +17 -57
  107. data/lib/generators/typus/views_generator.rb +2 -6
  108. data/lib/support/active_record.rb +8 -20
  109. data/lib/support/fake_user.rb +6 -1
  110. data/lib/support/hash.rb +1 -2
  111. data/lib/support/object.rb +4 -17
  112. data/lib/support/string.rb +34 -3
  113. data/lib/tasks/typus.rake +1 -1
  114. data/lib/typus.rb +60 -48
  115. data/lib/typus/actions.rb +27 -0
  116. data/lib/typus/authentication/base.rb +3 -4
  117. data/lib/typus/authentication/http_basic.rb +1 -1
  118. data/lib/typus/authentication/none.rb +1 -1
  119. data/lib/typus/authentication/session.rb +53 -108
  120. data/lib/typus/configuration.rb +13 -11
  121. data/lib/typus/filters.rb +12 -0
  122. data/lib/typus/format.rb +9 -13
  123. data/lib/typus/i18n.rb +30 -0
  124. data/lib/typus/orm/active_record.rb +97 -194
  125. data/lib/typus/orm/active_record/search.rb +91 -0
  126. data/lib/typus/resources.rb +6 -10
  127. data/lib/typus/user.rb +20 -40
  128. data/lib/typus/version.rb +1 -1
  129. metadata +77 -231
  130. data/CHANGELOG +0 -102
  131. data/README.rdoc +0 -48
  132. data/app/helpers/admin/preview_helper.rb +0 -46
  133. data/app/views/admin/helpers/_preview.html.erb +0 -13
  134. data/app/views/admin/templates/_has_many.html.erb +0 -22
  135. data/config/available_locales/ca.yml +0 -122
  136. data/config/available_locales/de.yml +0 -122
  137. data/config/available_locales/es.yml +0 -122
  138. data/config/available_locales/fr.yml +0 -127
  139. data/config/available_locales/hu.yml +0 -122
  140. data/config/available_locales/it.yml +0 -132
  141. data/config/available_locales/language.yml.template +0 -120
  142. data/config/available_locales/pt-BR.yml +0 -122
  143. data/config/available_locales/ru.yml +0 -122
  144. data/lib/generators/templates/functional_test.rb +0 -10
  145. data/lib/generators/templates/model.rb +0 -8
  146. data/lib/generators/templates/public/admin/images/ui-icons.png +0 -0
  147. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +0 -154
  148. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +0 -1077
  149. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
  150. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +0 -13
  151. data/lib/typus/pagination.rb +0 -18
  152. data/test/factories.rb +0 -43
  153. data/test/fixtures/config/broken/application.yml +0 -68
  154. data/test/fixtures/config/broken/application_roles.yml +0 -20
  155. data/test/fixtures/config/broken/empty.yml +0 -0
  156. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  157. data/test/fixtures/config/broken/undefined.yml +0 -3
  158. data/test/fixtures/config/broken/undefined_roles.yml +0 -6
  159. data/test/fixtures/config/default/typus.yml +0 -13
  160. data/test/fixtures/config/default/typus_roles.yml +0 -2
  161. data/test/fixtures/config/empty/empty_01.yml +0 -0
  162. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  163. data/test/fixtures/config/empty/empty_02.yml +0 -0
  164. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  165. data/test/fixtures/config/locales/es.yml +0 -10
  166. data/test/fixtures/config/namespaced/application.yml +0 -5
  167. data/test/fixtures/config/namespaced/application_roles.yml +0 -2
  168. data/test/fixtures/config/ordered/001_roles.yml +0 -2
  169. data/test/fixtures/config/ordered/002_roles.yml +0 -2
  170. data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
  171. data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
  172. data/test/fixtures/config/working/application.yml +0 -73
  173. data/test/fixtures/config/working/application_roles.yml +0 -24
  174. data/test/fixtures/config/working/typus.yml +0 -13
  175. data/test/fixtures/config/working/typus_roles.yml +0 -2
  176. data/test/fixtures/rails_app/Rakefile +0 -7
  177. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +0 -2
  178. data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +0 -2
  179. data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +0 -2
  180. data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +0 -2
  181. data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +0 -2
  182. data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +0 -2
  183. data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +0 -2
  184. data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +0 -2
  185. data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +0 -2
  186. data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -3
  187. data/test/fixtures/rails_app/app/models/asset.rb +0 -5
  188. data/test/fixtures/rails_app/app/models/category.rb +0 -11
  189. data/test/fixtures/rails_app/app/models/comment.rb +0 -6
  190. data/test/fixtures/rails_app/app/models/custom_user.rb +0 -2
  191. data/test/fixtures/rails_app/app/models/delayed/task.rb +0 -5
  192. data/test/fixtures/rails_app/app/models/page.rb +0 -5
  193. data/test/fixtures/rails_app/app/models/picture.rb +0 -6
  194. data/test/fixtures/rails_app/app/models/post.rb +0 -21
  195. data/test/fixtures/rails_app/app/models/typus_user.rb +0 -8
  196. data/test/fixtures/rails_app/app/models/view.rb +0 -5
  197. data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +0 -1
  198. data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +0 -1
  199. data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +0 -6
  200. data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +0 -1
  201. data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +0 -1
  202. data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +0 -1
  203. data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +0 -1
  204. data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +0 -1
  205. data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +0 -1
  206. data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +0 -1
  207. data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +0 -1
  208. data/test/fixtures/rails_app/config.ru +0 -4
  209. data/test/fixtures/rails_app/config/application.rb +0 -53
  210. data/test/fixtures/rails_app/config/boot.rb +0 -13
  211. data/test/fixtures/rails_app/config/database.yml +0 -14
  212. data/test/fixtures/rails_app/config/environment.rb +0 -5
  213. data/test/fixtures/rails_app/config/environments/test.rb +0 -34
  214. data/test/fixtures/rails_app/config/initializers/secret_token.rb +0 -7
  215. data/test/fixtures/rails_app/config/initializers/session_store.rb +0 -8
  216. data/test/fixtures/rails_app/config/initializers/typus.rb +0 -6
  217. data/test/fixtures/rails_app/config/routes.rb +0 -5
  218. data/test/fixtures/rails_app/config/typus/application.yml +0 -79
  219. data/test/fixtures/rails_app/config/typus/application_roles.yml +0 -25
  220. data/test/fixtures/rails_app/config/typus/typus.yml +0 -12
  221. data/test/fixtures/rails_app/config/typus/typus_roles.yml +0 -2
  222. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  223. data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +0 -2
  224. data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +0 -2
  225. data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +0 -2
  226. data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +0 -2
  227. data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +0 -2
  228. data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +0 -2
  229. data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +0 -2
  230. data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +0 -2
  231. data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +0 -2
  232. data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +0 -2
  233. data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +0 -2
  234. data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +0 -2
  235. data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +0 -2
  236. data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +0 -2
  237. data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +0 -2
  238. data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +0 -2
  239. data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +0 -2
  240. data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +0 -2
  241. data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +0 -2
  242. data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +0 -2
  243. data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +0 -2
  244. data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +0 -2
  245. data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +0 -2
  246. data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +0 -2
  247. data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +0 -2
  248. data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +0 -2
  249. data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +0 -2
  250. data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +0 -2
  251. data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +0 -2
  252. data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +0 -2
  253. data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +0 -2
  254. data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +0 -2
  255. data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +0 -2
  256. data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +0 -2
  257. data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +0 -2
  258. data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +0 -2
  259. data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +0 -2
  260. data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +0 -2
  261. data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +0 -2
  262. data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +0 -2
  263. data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +0 -2
  264. data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +0 -2
  265. data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +0 -2
  266. data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +0 -2
  267. data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +0 -2
  268. data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +0 -2
  269. data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +0 -2
  270. data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +0 -2
  271. data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +0 -2
  272. data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +0 -2
  273. data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +0 -2
  274. data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +0 -2
  275. data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +0 -2
  276. data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +0 -2
  277. data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +0 -2
  278. data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +0 -2
  279. data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +0 -2
  280. data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +0 -2
  281. data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +0 -2
  282. data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +0 -2
  283. data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +0 -2
  284. data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +0 -2
  285. data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +0 -2
  286. data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +0 -2
  287. data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +0 -2
  288. data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +0 -2
  289. data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +0 -2
  290. data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +0 -2
  291. data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +0 -2
  292. data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +0 -2
  293. data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +0 -2
  294. data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +0 -2
  295. data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +0 -2
  296. data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +0 -2
  297. data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +0 -2
  298. data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +0 -2
  299. data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +0 -2
  300. data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +0 -2
  301. data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +0 -2
  302. data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +0 -2
  303. data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +0 -2
  304. data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +0 -2
  305. data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +0 -2
  306. data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +0 -2
  307. data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +0 -2
  308. data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +0 -2
  309. data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +0 -2
  310. data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +0 -2
  311. data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +0 -2
  312. data/test/functional/admin/account_controller_test.rb +0 -90
  313. data/test/functional/admin/assets_controller_test.rb +0 -55
  314. data/test/functional/admin/categories_controller_test.rb +0 -62
  315. data/test/functional/admin/comments_controller_test.rb +0 -21
  316. data/test/functional/admin/dashboard_controller_test.rb +0 -138
  317. data/test/functional/admin/posts_controller_test.rb +0 -548
  318. data/test/functional/admin/session_controller_test.rb +0 -85
  319. data/test/functional/admin/status_controller_test.rb +0 -46
  320. data/test/functional/admin/typus_users_controller_test.rb +0 -159
  321. data/test/helpers/admin/base_helper_test.rb +0 -67
  322. data/test/helpers/admin/dashboard_helper_test.rb +0 -19
  323. data/test/helpers/admin/form_helper_test.rb +0 -117
  324. data/test/helpers/admin/resources_helper_test.rb +0 -64
  325. data/test/helpers/admin/sidebar_helper_test.rb +0 -274
  326. data/test/helpers/admin/table_helper_test.rb +0 -219
  327. data/test/integration/login_test.rb +0 -13
  328. data/test/integration_test_helper.rb +0 -21
  329. data/test/lib/support/active_record_test.rb +0 -86
  330. data/test/lib/support/array_test.rb +0 -11
  331. data/test/lib/support/hash_test.rb +0 -11
  332. data/test/lib/support/string_test.rb +0 -39
  333. data/test/lib/typus/active_record_test.rb +0 -451
  334. data/test/lib/typus/configuration_test.rb +0 -52
  335. data/test/lib/typus/resource_test.rb +0 -17
  336. data/test/lib/typus/routes_test.rb +0 -29
  337. data/test/lib/typus_test.rb +0 -107
  338. data/test/schema.rb +0 -100
  339. data/test/test_helper.rb +0 -16
  340. data/test/unit/admin/mailer_test.rb +0 -32
  341. data/test/unit/typus_user_roles_test.rb +0 -105
  342. data/test/unit/typus_user_test.rb +0 -142
  343. data/typus.gemspec +0 -25
@@ -0,0 +1,46 @@
1
+ /*
2
+ * FancyBox - jQuery Plugin
3
+ * Simple and fancy lightbox alternative
4
+ *
5
+ * Examples and documentation at: http://fancybox.net
6
+ *
7
+ * Copyright (c) 2008 - 2010 Janis Skarnelis
8
+ * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
9
+ *
10
+ * Version: 1.3.4 (11/11/2010)
11
+ * Requires: jQuery v1.3+
12
+ *
13
+ * Dual licensed under the MIT and GPL licenses:
14
+ * http://www.opensource.org/licenses/mit-license.php
15
+ * http://www.gnu.org/licenses/gpl.html
16
+ */
17
+
18
+ ;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
19
+ F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
20
+ c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
21
+ false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
22
+ function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
23
+ '"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
24
+ "function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
25
+ ";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
26
+ opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
27
+ d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
28
+ y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
29
+ i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
30
+ f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
31
+ 37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
32
+ s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
33
+ f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
34
+ j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
35
+ "image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
36
+ 10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
37
+ b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
38
+ 0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
39
+ 1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
40
+ true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
41
+ b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
42
+ d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
43
+ D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
44
+ b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
45
+ b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
46
+ easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);
@@ -0,0 +1,14 @@
1
+ /*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
2
+ * Licensed under the MIT License (LICENSE.txt).
3
+ *
4
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
6
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
7
+ *
8
+ * Version: 3.0.4
9
+ *
10
+ * Requires: 1.2.2+
11
+ */
12
+
13
+ (function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=
14
+ f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
@@ -0,0 +1,23 @@
1
+ module Typus
2
+
3
+ module Generators
4
+
5
+ class AssetsGenerator < Rails::Generators::Base
6
+
7
+ source_root File.expand_path("../../templates", __FILE__)
8
+
9
+ desc <<-MSG
10
+ Description:
11
+ Copies all Typus assets to your application.
12
+
13
+ MSG
14
+
15
+ def copy_assets
16
+ directory "public", "public"
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,29 @@
1
+ module Typus
2
+
3
+ module Generators
4
+
5
+ class ControllerGenerator < Rails::Generators::NamedBase
6
+
7
+ source_root File.expand_path("../../templates", __FILE__)
8
+
9
+ alias_method :resource, :name
10
+
11
+ desc <<-MSG
12
+ Description:
13
+ Generates admin controllers for the given resource
14
+
15
+ MSG
16
+
17
+ def generate_controller
18
+ template "controller.rb", "app/controllers/admin/#{file_name}_controller.rb"
19
+ end
20
+
21
+ hook_for :test_framework do |instance, generator|
22
+ instance.invoke generator, ["admin/#{instance.name}"]
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -1,4 +1,5 @@
1
1
  require "rails/generators/migration"
2
+ require "generators/typus/controller_generator"
2
3
 
3
4
  module Typus
4
5
 
@@ -10,8 +11,8 @@ module Typus
10
11
 
11
12
  source_root File.expand_path("../../templates", __FILE__)
12
13
 
13
- class_option :user_class_name, :default => "AdminUser"
14
- class_option :user_fk, :default => "admin_user_id"
14
+ class_option :user_class_name, :default => "AdminUser", :aliases => "-u"
15
+ class_option :user_fk, :default => "admin_user_id", :aliases => "-fk"
15
16
 
16
17
  desc <<-DESC
17
18
  Description:
@@ -31,28 +32,46 @@ Examples:
31
32
  DESC
32
33
 
33
34
  def self.next_migration_number(path)
34
- Time.zone.now.utc.to_s(:number)
35
+ Time.zone.now.to_s(:number)
35
36
  end
36
37
 
37
- def generate_migration
38
- migration_template "migration.rb", "db/migrate/create_#{admin_users_table_name}"
38
+ def generate_model
39
+ unless model_exists?
40
+ invoke "active_record:model", [options[:user_class_name]], :migration => false
41
+ end
42
+ end
43
+
44
+ def inject_mixins_into_model
45
+ inject_into_class "app/models/#{model_filename}.rb", options[:user_class_name] do
46
+ <<-MSG
47
+
48
+ ROLE = Typus::Configuration.roles.keys.sort
49
+ LOCALE = Typus.locales
50
+
51
+ enable_as_typus_user
52
+
53
+ MSG
54
+ end
39
55
  end
40
56
 
41
57
  def generate_initializer
42
58
  template "config/initializers/typus_authentication.rb", "config/initializers/typus_authentication.rb"
43
59
  end
44
60
 
45
- def generate_models
61
+ def generate_typus_yaml
46
62
  template "config/typus/typus.yml", "config/typus/typus.yml"
63
+ end
64
+
65
+ def generate_typus_roles_yaml
47
66
  template "config/typus/typus_roles.yml", "config/typus/typus_roles.yml"
48
- template "model.rb", "app/models/#{options[:user_class_name].underscore}.rb"
49
67
  end
50
68
 
51
- def generate_controllers
52
- klass = options[:user_class_name].constantize
53
- @resource = klass.model_name.pluralize
54
- template "controller.rb", "app/controllers/admin/#{klass.to_resource}_controller.rb"
55
- template "functional_test.rb", "test/functional/admin/#{klass.to_resource}_controller_test.rb"
69
+ def generate_controller
70
+ Typus::Generators::ControllerGenerator.new([options[:user_class_name].pluralize]).invoke_all
71
+ end
72
+
73
+ def generate_migration
74
+ migration_template "migration.rb", "db/migrate/create_#{admin_users_table_name}"
56
75
  end
57
76
 
58
77
  protected
@@ -61,20 +80,20 @@ Examples:
61
80
  options[:user_class_name].tableize
62
81
  end
63
82
 
64
- def configuration
65
- @configuration
83
+ def migration_name
84
+ "Create#{options[:user_class_name]}s"
66
85
  end
67
86
 
68
- def inherits_from
69
- "Admin::ResourcesController"
87
+ def model_exists?
88
+ File.exists?(File.join(destination_root, model_path))
70
89
  end
71
90
 
72
- def migration_name
73
- "Create#{options[:user_class_name]}s"
91
+ def model_path
92
+ @model_path ||= File.join("app", "models", "#{model_filename}.rb")
74
93
  end
75
94
 
76
- def resource
77
- @resource
95
+ def model_filename
96
+ options[:user_class_name].underscore
78
97
  end
79
98
 
80
99
  end
@@ -1,4 +1,6 @@
1
1
  require "rails/generators/migration"
2
+ require "generators/typus/controller_generator"
3
+ require "generators/typus/assets_generator"
2
4
 
3
5
  module Typus
4
6
 
@@ -23,10 +25,6 @@ Description:
23
25
 
24
26
  DESC
25
27
 
26
- def self.next_migration_number(path)
27
- Time.zone.now.utc.to_s(:number)
28
- end
29
-
30
28
  def copy_config_readme
31
29
  copy_file "config/typus/README"
32
30
  end
@@ -37,33 +35,19 @@ Description:
37
35
  end
38
36
 
39
37
  def copy_assets
40
- Dir["#{templates_path}/public/**/*.*"].each do |file|
41
- copy_file file.split("#{templates_path}/").last
42
- end
38
+ Typus::Generators::AssetsGenerator.new.invoke_all
43
39
  end
44
40
 
45
- #--
46
- # Generate files for models:
47
- # `#{controllers_path}/#{resource}_controller.rb`
48
- # `#{tests_path}/#{resource}_controller_test.rb`
49
- #++
50
41
  def generate_controllers
51
42
  Typus.application_models.each do |model|
52
- klass = model.constantize
53
- @resource = klass.name.pluralize
54
- template "controller.rb", "#{controllers_path}/#{klass.to_resource}_controller.rb"
55
- template "functional_test.rb", "#{tests_path}/#{klass.to_resource}_controller_test.rb"
43
+ Typus::Generators::ControllerGenerator.new([model.pluralize]).invoke_all
56
44
  end
57
45
  end
58
46
 
59
47
  def generate_config
60
- configuration = generate_yaml_files
61
- unless configuration[:base].empty?
62
- %w( application.yml application_roles.yml ).each do |file|
63
- from = to = "config/typus/#{file}"
64
- if File.exists?(from) then to = "config/typus/#{timestamp}_#{file}" end
65
- @configuration = configuration
66
- template from, to
48
+ if (@configuration = generate_yaml_files)[:base].present?
49
+ %w(application.yml application_roles.yml).each do |file|
50
+ template "config/typus/#{file}", "config/typus/#{timestamp}_#{file}"
67
51
  end
68
52
  end
69
53
  end
@@ -74,10 +58,6 @@ Description:
74
58
  @configuration
75
59
  end
76
60
 
77
- def inherits_from
78
- "Admin::ResourcesController"
79
- end
80
-
81
61
  def resource
82
62
  @resource
83
63
  end
@@ -87,28 +67,13 @@ Description:
87
67
  end
88
68
 
89
69
  def timestamp
90
- Time.zone.now.utc.to_s(:number)
70
+ Time.zone.now.to_s(:number)
91
71
  end
92
72
 
93
73
  private
94
74
 
95
- def templates_path
96
- File.join(Typus.root, "lib", "generators", "templates")
97
- end
98
-
99
- def controllers_path
100
- "app/controllers/admin"
101
- end
102
-
103
- def tests_path
104
- "test/functional/admin"
105
- end
106
-
107
- def views_path
108
- "app/views/admin"
109
- end
110
-
111
75
  def generate_yaml_files
76
+ Typus.reload!
112
77
 
113
78
  configuration = { :base => "", :roles => "" }
114
79
 
@@ -134,23 +99,19 @@ Description:
134
99
  created_at created_on updated_at updated_on deleted_at
135
100
  salt crypted_password
136
101
  password_salt persistence_token single_access_token perishable_token
137
- _type$
102
+ _type$ type
138
103
  _file_size$ )
139
104
 
140
- default_rejections = rejections + %w( password password_confirmation )
141
- form_rejections = rejections + %w( position )
105
+ default_rejections = (rejections + %w( password password_confirmation )).join("|")
106
+ form_rejections = (rejections + %w( position )).join("|")
142
107
 
143
- default = klass.columns.reject do |column|
144
- column.name.match(default_rejections.join("|")) || column.sql_type == "text"
145
- end.map(&:name)
146
-
147
- form = klass.columns.reject do |column|
148
- column.name.match(form_rejections.join("|"))
149
- end.map(&:name)
108
+ fields = klass.columns.map(&:name)
109
+ default = fields.reject { |f| f.match(default_rejections) }
110
+ form = fields.reject { |f| f.match(form_rejections) }
150
111
 
151
112
  # Model defaults.
152
113
  order_by = "position" if default.include?("position")
153
- filters = "created_at" if klass.columns.include?("created_at")
114
+ filters = "created_at" if fields.include?("created_at")
154
115
  search = ( %w(name title) & default ).join(", ")
155
116
 
156
117
  # We want attributes of belongs_to relationships to be shown in our
@@ -179,8 +140,7 @@ Description:
179
140
 
180
141
  end
181
142
 
182
- return configuration
183
-
143
+ configuration
184
144
  end
185
145
 
186
146
  end
@@ -4,7 +4,7 @@ module Typus
4
4
 
5
5
  class ViewsGenerator < Rails::Generators::Base
6
6
 
7
- source_root File.expand_path("../../../../app/views", __FILE__)
7
+ source_root File.expand_path("../../../../app", __FILE__)
8
8
 
9
9
  desc <<-MSG
10
10
  Description:
@@ -13,11 +13,7 @@ Description:
13
13
  MSG
14
14
 
15
15
  def copy_views
16
- directory "admin", "app/views/admin"
17
- end
18
-
19
- def copy_layouts
20
- directory "layouts", "app/views/layouts"
16
+ directory "views", "app/views"
21
17
  end
22
18
 
23
19
  end
@@ -1,5 +1,11 @@
1
1
  class ActiveRecord::Base
2
2
 
3
+ def self.relationship_with(model)
4
+ association = reflect_on_association(model.table_name.to_sym) ||
5
+ reflect_on_association(model.model_name.downcase.to_sym)
6
+ association.macro
7
+ end
8
+
3
9
  #--
4
10
  # >> Post.to_resource
5
11
  # => "posts"
@@ -10,24 +16,6 @@ class ActiveRecord::Base
10
16
  name.underscore.pluralize
11
17
  end
12
18
 
13
- #--
14
- # TODO: This has been copied from Rails 2 because has been removed from
15
- # Rails 3. Once the "build_conditions" has been refactored to use Arel
16
- # this can be removed.
17
- #++
18
- def self.merge_conditions(*conditions)
19
- segments = []
20
-
21
- conditions.each do |condition|
22
- unless condition.blank?
23
- sql = sanitize_sql(condition)
24
- segments << sql unless sql.blank?
25
- end
26
- end
27
-
28
- "(#{segments.join(') AND (')})" unless segments.empty?
29
- end
30
-
31
19
  #--
32
20
  # On a model:
33
21
  #
@@ -49,7 +37,7 @@ class ActiveRecord::Base
49
37
  def mapping(attribute)
50
38
  values = self.class::const_get(attribute.to_s.upcase)
51
39
 
52
- if values.kind_of?(Array)
40
+ if values.is_a?(Array)
53
41
  case values.first
54
42
  when Array
55
43
  array_keys, array_values = values.transpose
@@ -63,7 +51,7 @@ class ActiveRecord::Base
63
51
  end
64
52
 
65
53
  def to_label
66
- respond_to?(:name) ? send(:name) : [ self.class, id ].join("#")
54
+ respond_to?(:name) ? send(:name) : [self.class, id].join("#")
67
55
  end
68
56
 
69
57
  end
@@ -20,6 +20,10 @@ class FakeUser
20
20
  !is_root?
21
21
  end
22
22
 
23
+ def locale
24
+ ::I18n.locale
25
+ end
26
+
23
27
  def resources
24
28
  Typus::Configuration.roles[role].compact
25
29
  end
@@ -36,7 +40,8 @@ class FakeUser
36
40
  Typus.master_role
37
41
  end
38
42
 
39
- def name
43
+ def status
44
+ true
40
45
  end
41
46
 
42
47
  end