refinerycms-core 0.9.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. data/app/controllers/admin/base_controller.rb +10 -0
  2. data/app/controllers/admin/dialogs_controller.rb +26 -0
  3. data/app/controllers/admin/refinery_core_controller.rb +12 -0
  4. data/app/controllers/application_controller.rb +6 -0
  5. data/app/controllers/refinery/fast_controller.rb +9 -0
  6. data/app/controllers/sitemap_controller.rb +14 -0
  7. data/app/helpers/application_helper.rb +5 -0
  8. data/app/views/admin/_head.html.erb +43 -0
  9. data/app/views/admin/_javascripts.html.erb +32 -0
  10. data/app/views/admin/_menu.html.erb +17 -0
  11. data/app/views/admin/dialogs/show.html.erb +19 -0
  12. data/app/views/layouts/admin.html.erb +24 -0
  13. data/app/views/layouts/admin_dialog.html.erb +14 -0
  14. data/app/views/layouts/application.html.erb +21 -0
  15. data/app/views/shared/_content_page.html.erb +63 -0
  16. data/app/views/shared/_draft_page_message.html.erb +3 -0
  17. data/app/views/shared/_footer.html.erb +4 -0
  18. data/app/views/shared/_google_analytics.html.erb +8 -0
  19. data/app/views/shared/_head.html.erb +42 -0
  20. data/app/views/shared/_header.html.erb +8 -0
  21. data/app/views/shared/_html_tag.html.erb +6 -0
  22. data/app/views/shared/_ie6check.html.erb +63 -0
  23. data/app/views/shared/_javascripts.html.erb +10 -0
  24. data/app/views/shared/_menu.html.erb +30 -0
  25. data/app/views/shared/_menu_branch.html.erb +26 -0
  26. data/app/views/shared/_message.html.erb +10 -0
  27. data/app/views/shared/_no_script.html.erb +9 -0
  28. data/app/views/shared/_site_bar.html.erb +25 -0
  29. data/app/views/shared/admin/_continue_editing.html.erb +3 -0
  30. data/app/views/shared/admin/_error_messages.html.erb +16 -0
  31. data/app/views/shared/admin/_form_actions.html.erb +75 -0
  32. data/app/views/shared/admin/_image_picker.html.erb +60 -0
  33. data/app/views/shared/admin/_make_sortable.html.erb +13 -0
  34. data/app/views/shared/admin/_resource_picker.html.erb +66 -0
  35. data/app/views/shared/admin/_search.html.erb +6 -0
  36. data/app/views/shared/admin/_sortable_list.html.erb +7 -0
  37. data/app/views/shared/admin/_tabbed_fields.html.erb +42 -0
  38. data/app/views/welcome.html.erb +17 -0
  39. data/app/views/wymiframe.html.erb +15 -0
  40. data/config/locales/cs.yml +77 -0
  41. data/config/locales/da.yml +75 -0
  42. data/config/locales/de.yml +75 -0
  43. data/config/locales/el.yml +75 -0
  44. data/config/locales/en.yml +75 -0
  45. data/config/locales/es.yml +68 -0
  46. data/config/locales/fr.yml +72 -0
  47. data/config/locales/it.yml +96 -0
  48. data/config/locales/lolcat.yml +68 -0
  49. data/config/locales/lt.yml +75 -0
  50. data/config/locales/lv.yml +72 -0
  51. data/config/locales/nb.yml +75 -0
  52. data/config/locales/nl.yml +75 -0
  53. data/config/locales/pl.yml +75 -0
  54. data/config/locales/pt-BR.yml +72 -0
  55. data/config/locales/rs.yml +76 -0
  56. data/config/locales/ru.yml +71 -0
  57. data/config/locales/sl.yml +72 -0
  58. data/config/locales/sv.yml +75 -0
  59. data/config/locales/vi.yml +75 -0
  60. data/config/locales/zh-CN.yml +75 -0
  61. data/config/locales/zh-TW.yml +75 -0
  62. data/config/routes.rb +19 -0
  63. data/crud.md +197 -0
  64. data/doc/included-jquery-ui-packages.jpg +0 -0
  65. data/engines.md +179 -0
  66. data/features/search.feature +55 -0
  67. data/features/site_bar.feature +24 -0
  68. data/features/step_definitions/core_steps.rb +61 -0
  69. data/features/support/paths.rb +14 -0
  70. data/features/uploads/beach.jpeg +0 -0
  71. data/features/uploads/refinery_is_awesome.txt +1 -0
  72. data/lib/gemspec.rb +43 -0
  73. data/lib/generators/refinerycms_generator.rb +110 -0
  74. data/lib/generators/templates/.gitignore +83 -0
  75. data/lib/generators/templates/app/views/sitemap/index.xml.builder +22 -0
  76. data/lib/generators/templates/autotest/autotest.rb +17 -0
  77. data/lib/generators/templates/autotest/discover.rb +2 -0
  78. data/lib/generators/templates/config/database.yml.mysql +20 -0
  79. data/lib/generators/templates/config/database.yml.postgresql +57 -0
  80. data/lib/generators/templates/config/database.yml.sqlite3 +26 -0
  81. data/lib/generators/templates/config/i18n-js.yml +6 -0
  82. data/lib/generators/templates/config/initializers/devise.rb +142 -0
  83. data/lib/generators/templates/config/settings.rb +2 -0
  84. data/lib/generators/templates/db/seeds.rb +5 -0
  85. data/lib/refinery/activity.rb +45 -0
  86. data/lib/refinery/admin/base_controller.rb +111 -0
  87. data/lib/refinery/admin_base_controller.rb +5 -0
  88. data/lib/refinery/application.rb +48 -0
  89. data/lib/refinery/application_controller.rb +120 -0
  90. data/lib/refinery/application_helper.rb +19 -0
  91. data/lib/refinery/base_presenter.rb +27 -0
  92. data/lib/refinery/catch_all_routes.rb +11 -0
  93. data/lib/refinery/crud.rb +295 -0
  94. data/lib/refinery/helpers/form_helper.rb +66 -0
  95. data/lib/refinery/helpers/head_helper.rb +17 -0
  96. data/lib/refinery/helpers/html_truncation_helper.rb +25 -0
  97. data/lib/refinery/helpers/image_helper.rb +49 -0
  98. data/lib/refinery/helpers/menu_helper.rb +68 -0
  99. data/lib/refinery/helpers/meta_helper.rb +67 -0
  100. data/lib/refinery/helpers/pagination_helper.rb +16 -0
  101. data/lib/refinery/helpers/script_helper.rb +36 -0
  102. data/lib/refinery/helpers/site_bar_helper.rb +24 -0
  103. data/lib/refinery/helpers/tag_helper.rb +21 -0
  104. data/lib/refinery/helpers/translation_helper.rb +17 -0
  105. data/lib/refinery/link_renderer.rb +55 -0
  106. data/lib/refinery/plugin.rb +106 -0
  107. data/lib/refinery/plugins.rb +75 -0
  108. data/lib/refinerycms-core.rb +156 -0
  109. data/lib/tasks/doc.rake +29 -0
  110. data/lib/tasks/refinery.rake +231 -0
  111. data/lib/tasks/yard.rake +30 -0
  112. data/license.md +21 -0
  113. data/public/404.html +26 -0
  114. data/public/422.html +26 -0
  115. data/public/500.html +26 -0
  116. data/public/favicon.ico +0 -0
  117. data/public/images/refinery/add.png +0 -0
  118. data/public/images/refinery/admin_bg.png +0 -0
  119. data/public/images/refinery/ajax-loader.gif +0 -0
  120. data/public/images/refinery/branch-end.gif +0 -0
  121. data/public/images/refinery/branch-start.gif +0 -0
  122. data/public/images/refinery/branch.gif +0 -0
  123. data/public/images/refinery/carousel-left.png +0 -0
  124. data/public/images/refinery/carousel-right.png +0 -0
  125. data/public/images/refinery/cross.png +0 -0
  126. data/public/images/refinery/dialogLoadingAnimation.gif +0 -0
  127. data/public/images/refinery/header_background.png +0 -0
  128. data/public/images/refinery/hover-gradient.jpg +0 -0
  129. data/public/images/refinery/icons/accept.png +0 -0
  130. data/public/images/refinery/icons/add.png +0 -0
  131. data/public/images/refinery/icons/ajax-loader.gif +0 -0
  132. data/public/images/refinery/icons/application_edit.png +0 -0
  133. data/public/images/refinery/icons/application_go.png +0 -0
  134. data/public/images/refinery/icons/arrow_left.png +0 -0
  135. data/public/images/refinery/icons/arrow_switch.png +0 -0
  136. data/public/images/refinery/icons/arrow_up.png +0 -0
  137. data/public/images/refinery/icons/bin.png +0 -0
  138. data/public/images/refinery/icons/bin_closed.png +0 -0
  139. data/public/images/refinery/icons/cancel.png +0 -0
  140. data/public/images/refinery/icons/cog_add.png +0 -0
  141. data/public/images/refinery/icons/cog_edit.png +0 -0
  142. data/public/images/refinery/icons/cross.png +0 -0
  143. data/public/images/refinery/icons/delete.png +0 -0
  144. data/public/images/refinery/icons/doc.png +0 -0
  145. data/public/images/refinery/icons/down.gif +0 -0
  146. data/public/images/refinery/icons/edit.png +0 -0
  147. data/public/images/refinery/icons/email.png +0 -0
  148. data/public/images/refinery/icons/email_edit.png +0 -0
  149. data/public/images/refinery/icons/email_go.png +0 -0
  150. data/public/images/refinery/icons/email_open.png +0 -0
  151. data/public/images/refinery/icons/eye.png +0 -0
  152. data/public/images/refinery/icons/folder_page_white.png +0 -0
  153. data/public/images/refinery/icons/image_add.png +0 -0
  154. data/public/images/refinery/icons/image_edit.png +0 -0
  155. data/public/images/refinery/icons/img.png +0 -0
  156. data/public/images/refinery/icons/information.png +0 -0
  157. data/public/images/refinery/icons/layout_add.png +0 -0
  158. data/public/images/refinery/icons/layout_edit.png +0 -0
  159. data/public/images/refinery/icons/music.png +0 -0
  160. data/public/images/refinery/icons/page_add.png +0 -0
  161. data/public/images/refinery/icons/page_edit.png +0 -0
  162. data/public/images/refinery/icons/page_white_edit.png +0 -0
  163. data/public/images/refinery/icons/page_white_gear.png +0 -0
  164. data/public/images/refinery/icons/page_white_put.png +0 -0
  165. data/public/images/refinery/icons/pdf.png +0 -0
  166. data/public/images/refinery/icons/ppt.png +0 -0
  167. data/public/images/refinery/icons/star.png +0 -0
  168. data/public/images/refinery/icons/tick.png +0 -0
  169. data/public/images/refinery/icons/up.gif +0 -0
  170. data/public/images/refinery/icons/user_add.png +0 -0
  171. data/public/images/refinery/icons/user_comment.png +0 -0
  172. data/public/images/refinery/icons/user_edit.png +0 -0
  173. data/public/images/refinery/icons/xls.png +0 -0
  174. data/public/images/refinery/icons/zip.png +0 -0
  175. data/public/images/refinery/icons/zoom.png +0 -0
  176. data/public/images/refinery/logo-large.png +0 -0
  177. data/public/images/refinery/logo-medium.png +0 -0
  178. data/public/images/refinery/logo-site-bar.png +0 -0
  179. data/public/images/refinery/logo-small-medium.png +0 -0
  180. data/public/images/refinery/logo-small.png +0 -0
  181. data/public/images/refinery/logo-tiny.png +0 -0
  182. data/public/images/refinery/logo.png +0 -0
  183. data/public/images/refinery/nav-3-background.gif +0 -0
  184. data/public/images/refinery/nav_inactive_background.png +0 -0
  185. data/public/images/refinery/orange_button.png +0 -0
  186. data/public/images/refinery/page_bg.png +0 -0
  187. data/public/images/refinery/resolve_digital_footer_logo.png +0 -0
  188. data/public/images/refinery/text_field_background.png +0 -0
  189. data/public/images/refinery/tooltip-nib.gif +0 -0
  190. data/public/images/refinery/tooltip-nib.png +0 -0
  191. data/public/images/wymeditor/skins/refinery/arrow_redo.png +0 -0
  192. data/public/images/wymeditor/skins/refinery/arrow_undo.png +0 -0
  193. data/public/images/wymeditor/skins/refinery/eye.png +0 -0
  194. data/public/images/wymeditor/skins/refinery/iframe/lbl-blockquote.png +0 -0
  195. data/public/images/wymeditor/skins/refinery/iframe/lbl-h1.png +0 -0
  196. data/public/images/wymeditor/skins/refinery/iframe/lbl-h2.png +0 -0
  197. data/public/images/wymeditor/skins/refinery/iframe/lbl-h3.png +0 -0
  198. data/public/images/wymeditor/skins/refinery/iframe/lbl-h4.png +0 -0
  199. data/public/images/wymeditor/skins/refinery/iframe/lbl-h5.png +0 -0
  200. data/public/images/wymeditor/skins/refinery/iframe/lbl-h6.png +0 -0
  201. data/public/images/wymeditor/skins/refinery/iframe/lbl-p.png +0 -0
  202. data/public/images/wymeditor/skins/refinery/iframe/lbl-pre.png +0 -0
  203. data/public/images/wymeditor/skins/refinery/link_add.png +0 -0
  204. data/public/images/wymeditor/skins/refinery/link_break.png +0 -0
  205. data/public/images/wymeditor/skins/refinery/page_code.png +0 -0
  206. data/public/images/wymeditor/skins/refinery/page_paste.png +0 -0
  207. data/public/images/wymeditor/skins/refinery/photo_add.png +0 -0
  208. data/public/images/wymeditor/skins/refinery/right.png +0 -0
  209. data/public/images/wymeditor/skins/refinery/style.png +0 -0
  210. data/public/images/wymeditor/skins/refinery/table_add.png +0 -0
  211. data/public/images/wymeditor/skins/refinery/text_align_center.png +0 -0
  212. data/public/images/wymeditor/skins/refinery/text_align_justify.png +0 -0
  213. data/public/images/wymeditor/skins/refinery/text_align_left.png +0 -0
  214. data/public/images/wymeditor/skins/refinery/text_align_right.png +0 -0
  215. data/public/images/wymeditor/skins/refinery/text_bold.png +0 -0
  216. data/public/images/wymeditor/skins/refinery/text_heading_1.png +0 -0
  217. data/public/images/wymeditor/skins/refinery/text_heading_2.png +0 -0
  218. data/public/images/wymeditor/skins/refinery/text_heading_3.png +0 -0
  219. data/public/images/wymeditor/skins/refinery/text_heading_4.png +0 -0
  220. data/public/images/wymeditor/skins/refinery/text_heading_5.png +0 -0
  221. data/public/images/wymeditor/skins/refinery/text_heading_6.png +0 -0
  222. data/public/images/wymeditor/skins/refinery/text_indent.png +0 -0
  223. data/public/images/wymeditor/skins/refinery/text_indent_remove.png +0 -0
  224. data/public/images/wymeditor/skins/refinery/text_italic.png +0 -0
  225. data/public/images/wymeditor/skins/refinery/text_list_bullets.png +0 -0
  226. data/public/images/wymeditor/skins/refinery/text_list_numbers.png +0 -0
  227. data/public/images/wymeditor/skins/refinery/text_paragraph.png +0 -0
  228. data/public/images/wymeditor/skins/refinery/text_strikethrough.png +0 -0
  229. data/public/images/wymeditor/skins/refinery/text_subscript.png +0 -0
  230. data/public/images/wymeditor/skins/refinery/text_superscript.png +0 -0
  231. data/public/images/wymeditor/skins/refinery/text_underline.png +0 -0
  232. data/public/images/wymeditor/skins/wymeditor_icon.png +0 -0
  233. data/public/javascripts/admin.js +7 -0
  234. data/public/javascripts/application.js +1 -0
  235. data/public/javascripts/dd_belatedpng.js +13 -0
  236. data/public/javascripts/i18n-messages.js +2 -0
  237. data/public/javascripts/jquery-min.js +16 -0
  238. data/public/javascripts/jquery-ui-custom-min.js +251 -0
  239. data/public/javascripts/jquery.js +8176 -0
  240. data/public/javascripts/jquery/GPL-LICENSE.txt +278 -0
  241. data/public/javascripts/jquery/MIT-LICENSE.txt +20 -0
  242. data/public/javascripts/jquery/jquery.corner.js +345 -0
  243. data/public/javascripts/jquery/jquery.html5-placeholder-shim.js +88 -0
  244. data/public/javascripts/jquery/jquery.jcarousel.js +900 -0
  245. data/public/javascripts/jquery/jquery.textTruncate.js +174 -0
  246. data/public/javascripts/jquery/jquery.timers.js +138 -0
  247. data/public/javascripts/modernizr-min.js +30 -0
  248. data/public/javascripts/rails.js +175 -0
  249. data/public/javascripts/refinery/admin.js +1114 -0
  250. data/public/javascripts/refinery/boot_wym.js +285 -0
  251. data/public/javascripts/refinery/core.js +18 -0
  252. data/public/javascripts/refinery/i18n.js +340 -0
  253. data/public/javascripts/refinery/nestedsortables.js +164 -0
  254. data/public/javascripts/refinery/serializelist.js +66 -0
  255. data/public/javascripts/refinery/site_bar.js +16 -0
  256. data/public/javascripts/refinery/submenu.js +49 -0
  257. data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +5156 -0
  258. data/public/javascripts/wymeditor/lang/ca.js +45 -0
  259. data/public/javascripts/wymeditor/lang/cs.js +45 -0
  260. data/public/javascripts/wymeditor/lang/da.js +48 -0
  261. data/public/javascripts/wymeditor/lang/de.js +45 -0
  262. data/public/javascripts/wymeditor/lang/en.js +47 -0
  263. data/public/javascripts/wymeditor/lang/es.js +48 -0
  264. data/public/javascripts/wymeditor/lang/fa.js +46 -0
  265. data/public/javascripts/wymeditor/lang/fr.js +45 -0
  266. data/public/javascripts/wymeditor/lang/he.js +45 -0
  267. data/public/javascripts/wymeditor/lang/hu.js +45 -0
  268. data/public/javascripts/wymeditor/lang/it.js +48 -0
  269. data/public/javascripts/wymeditor/lang/lv.js +47 -0
  270. data/public/javascripts/wymeditor/lang/nb.js +48 -0
  271. data/public/javascripts/wymeditor/lang/nl.js +47 -0
  272. data/public/javascripts/wymeditor/lang/nn.js +45 -0
  273. data/public/javascripts/wymeditor/lang/pl.js +45 -0
  274. data/public/javascripts/wymeditor/lang/pt-BR.js +47 -0
  275. data/public/javascripts/wymeditor/lang/pt.js +45 -0
  276. data/public/javascripts/wymeditor/lang/rs.js +47 -0
  277. data/public/javascripts/wymeditor/lang/ru.js +45 -0
  278. data/public/javascripts/wymeditor/lang/sl.js +47 -0
  279. data/public/javascripts/wymeditor/lang/sv.js +45 -0
  280. data/public/javascripts/wymeditor/lang/tr.js +45 -0
  281. data/public/javascripts/wymeditor/lang/vi.js +47 -0
  282. data/public/javascripts/wymeditor/lang/zh_cn.js +47 -0
  283. data/public/javascripts/wymeditor/skins/refinery/skin.js +48 -0
  284. data/public/robots.txt +3 -0
  285. data/public/stylesheets/application.css +4 -0
  286. data/public/stylesheets/formatting.css +4 -0
  287. data/public/stylesheets/home.css +4 -0
  288. data/public/stylesheets/refinery/application.css +72 -0
  289. data/public/stylesheets/refinery/formatting.css +57 -0
  290. data/public/stylesheets/refinery/home.css +0 -0
  291. data/public/stylesheets/refinery/refinery.css +1579 -0
  292. data/public/stylesheets/refinery/site_bar.css +87 -0
  293. data/public/stylesheets/refinery/submenu.css +22 -0
  294. data/public/stylesheets/refinery/theme.css +36 -0
  295. data/public/stylesheets/refinery/tooltips.css +34 -0
  296. data/public/stylesheets/refinery/ui.css +107 -0
  297. data/public/stylesheets/theme.css +4 -0
  298. data/public/stylesheets/wymeditor/skins/refinery/skin.css +528 -0
  299. data/public/stylesheets/wymeditor/skins/refinery/wymiframe.css +96 -0
  300. data/public/wymeditor/GPL-license.txt +278 -0
  301. data/public/wymeditor/MIT-license.txt +20 -0
  302. data/public/wymeditor/README +35 -0
  303. data/refinerycms-core.gemspec +391 -0
  304. data/spec/lib/refinery/plugins_spec.rb +90 -0
  305. metadata +482 -0
@@ -0,0 +1,106 @@
1
+ module Refinery
2
+ module Engines; end;
3
+
4
+ class Plugin
5
+
6
+ def self.register(&block)
7
+ plugin = self.new
8
+
9
+ yield plugin
10
+
11
+ raise "A plugin MUST have a name!: #{plugin.inspect}" if plugin.name.blank?
12
+
13
+ # Set the root as Rails::Engine.called_from will always be
14
+ # vendor/engines/refinery/lib/refinery
15
+ new_called_from = begin
16
+ # Remove the line number from backtraces making sure we don't leave anything behind
17
+ call_stack = caller.map { |p| p.split(':')[0..-2].join(':') }
18
+ File.dirname(call_stack.detect { |p| p !~ %r[railties[\w\-\.]*/lib/rails|rack[\w\-\.]*/lib/rack] })
19
+ end
20
+
21
+ klass = Class.new(Rails::Engine)
22
+ klass.class_eval <<-RUBY
23
+ def self.called_from; "#{new_called_from}"; end
24
+ RUBY
25
+ Object.const_set(plugin.class_name.to_sym, klass)
26
+ end
27
+
28
+ attr_accessor :name, :class_name, :controller, :directory, :url,
29
+ :version, :dashboard, :always_allow_access,
30
+ :menu_match, :hide_from_menu,
31
+ :pathname, :plugin_activity
32
+ attr_reader :description
33
+
34
+ # Returns the class name of the plugin
35
+ def class_name
36
+ @class_name ||= name.camelize
37
+ end
38
+
39
+ # Returns the internationalized version of the title
40
+ def title
41
+ ::I18n.translate(['plugins', name, 'title'].join('.'))
42
+ end
43
+
44
+ # Returns the internationalized version of the description
45
+ def description
46
+ ::I18n.translate(['plugins', name, 'description'].join('.'))
47
+ end
48
+
49
+ # Retrieve information about how to access the latest activities of this plugin.
50
+ def activity
51
+ self.plugin_activity ||= []
52
+ end
53
+
54
+ # Stores information that can be used to retrieve the latest activities of this plugin
55
+ def activity=(activities)
56
+ [activities].flatten.each { |activity| add_activity(activity) }
57
+ end
58
+
59
+ # Returns true, if the user doesn't require plugin access
60
+ def always_allow_access?
61
+ @always_allow_access ||= false
62
+ end
63
+
64
+ # Special property to indicate that this plugin is the dashboard plugin.
65
+ def dashboard?
66
+ @dashboard ||= false
67
+ end
68
+
69
+ # Used to highlight the current tab in the admin interface
70
+ def highlighted?(params)
71
+ (params[:controller] =~ self.menu_match) or (self.dashboard? and params[:action] == 'error_404')
72
+ end
73
+
74
+ # Returns a RegExp that matches, if the current page is part of the plugin.
75
+ def menu_match
76
+ @menu_match ||= /(admin|refinery)\/#{self.name}$/
77
+ end
78
+
79
+ # Returns a hash that can be used to create a url that points to the administration part of the plugin.
80
+ def url
81
+ return @url if defined?(@url)
82
+
83
+ if self.controller.present?
84
+ @url = {:controller => "/admin/#{self.controller}"}
85
+ elsif self.directory.present?
86
+ @url = {:controller => "/admin/#{self.directory.split('/').pop}"}
87
+ else
88
+ @url = {:controller => "/admin/#{self.name}"}
89
+ end
90
+ end
91
+
92
+ # Make this protected, so that only Plugin.register can use it.
93
+ protected
94
+
95
+ def add_activity(options)
96
+ (self.plugin_activity ||= []) << Activity::new(options)
97
+ end
98
+
99
+ def initialize
100
+ # save the pathname to where this plugin is using its lib directory which is standard now.
101
+ depth = RUBY_VERSION >= "1.9.2" ? 4 : 3
102
+ self.pathname = Pathname.new(caller(depth).first.match("(.*)#{File::SEPARATOR}lib")[1])
103
+ Refinery::Plugins.registered << self # add me to the collection of registered plugins
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,75 @@
1
+ module Refinery
2
+ class Plugins < Array
3
+
4
+ def initialize
5
+ @plugins = []
6
+ end
7
+
8
+ def find_activity_by_model(model)
9
+ unless (plugin = find_by_model(model)).nil?
10
+ plugin.activity.detect {|activity| activity.class == model}
11
+ end
12
+ end
13
+
14
+ def find_by_model(model)
15
+ model = model.constantize if model.is_a? String
16
+ self.detect { |plugin| plugin.activity.any? {|activity| activity.class == model } }
17
+ end
18
+
19
+ def find_by_name(name)
20
+ self.detect { |plugin| plugin.name == name }
21
+ end
22
+ alias :[] :find_by_name
23
+
24
+ def find_by_title(title)
25
+ self.detect { |plugin| plugin.title == title }
26
+ end
27
+
28
+ def in_menu
29
+ self.reject{ |p| p.hide_from_menu }
30
+ end
31
+
32
+ def names
33
+ self.collect { |p| p.name }
34
+ end
35
+
36
+ def pathnames
37
+ self.collect { |p| p.pathname }.compact.uniq
38
+ end
39
+
40
+ def titles
41
+ self.collect { |p| p.title }
42
+ end
43
+
44
+ class << self
45
+ def active
46
+ @active_plugins ||= self.new
47
+ end
48
+
49
+ def always_allowed
50
+ registered.reject { |p| !p.always_allow_access? }
51
+ end
52
+
53
+ def registered
54
+ @registered_plugins ||= self.new
55
+ end
56
+
57
+ def activate(name)
58
+ active << registered[name] if registered[name] && !active[name]
59
+ end
60
+
61
+ def deactivate(name)
62
+ active.delete_if {|p| p.name == name}
63
+ end
64
+
65
+ def set_active(names)
66
+ @active_plugins = self.new
67
+
68
+ names.each do |name|
69
+ activate(name)
70
+ end
71
+ end
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,156 @@
1
+ require 'acts_as_indexed'
2
+ require 'awesome_nested_set'
3
+ require 'friendly_id'
4
+ require 'truncate_html'
5
+ require 'will_paginate'
6
+
7
+ module Refinery
8
+ autoload :Activity, File.expand_path('../refinery/activity', __FILE__)
9
+ autoload :Application, File.expand_path('../refinery/application', __FILE__)
10
+ autoload :ApplicationController, File.expand_path('../refinery/application_controller', __FILE__)
11
+ autoload :ApplicationHelper, File.expand_path('../refinery/application_helper', __FILE__)
12
+ autoload :Plugin, File.expand_path('../refinery/plugin', __FILE__)
13
+ autoload :Plugins, File.expand_path('../refinery/plugins', __FILE__)
14
+ end
15
+
16
+ # These have to be specified after the autoload to correct load issues on some systems.
17
+ # As per commit 12af0e3e83a147a87c97bf7b29f343254c5fcb3c
18
+ require 'refinerycms-base'
19
+ require 'refinerycms-generators'
20
+ require 'refinerycms-settings'
21
+ require 'rails/generators'
22
+ require 'rails/generators/migration'
23
+
24
+ module Refinery
25
+
26
+ module Core
27
+ class << self
28
+ def attach_to_application!
29
+ ::Rails::Application.subclasses.each do |subclass|
30
+ begin
31
+ subclass.send :include, ::Refinery::Application
32
+ rescue
33
+ $stdout.puts "Refinery CMS couldn't attach to #{subclass.name}."
34
+ $stdout.puts "Error was: #{$!.message}"
35
+ $stdout.puts $!.backtrace
36
+ end
37
+ end
38
+ end
39
+
40
+ attr_accessor :root
41
+ def root
42
+ @root ||= Pathname.new(File.expand_path('../../', __FILE__))
43
+ end
44
+ end
45
+
46
+ class Engine < ::Rails::Engine
47
+
48
+ config.autoload_paths += %W( #{config.root}/lib )
49
+
50
+ # Attach ourselves to the Rails application.
51
+ config.before_configuration do
52
+ ::Refinery::Core.attach_to_application!
53
+ end
54
+
55
+ # Wrap errors in spans and cache vendored assets.
56
+ config.to_prepare do
57
+ # This wraps errors in span not div
58
+ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
59
+ "<span class=\"fieldWithErrors\">#{html_tag}</span>".html_safe
60
+ end
61
+
62
+ # TODO: Is there a better way to cache assets in engines?
63
+ ::ActionView::Helpers::AssetTagHelper.module_eval do
64
+ def asset_file_path(path)
65
+ unless File.exist?(return_path = File.join(config.assets_dir, path.split('?').first))
66
+ ::Refinery::Plugins.registered.collect{|p| p.pathname}.compact.each do |pathname|
67
+ if File.exist?(plugin_asset_path = File.join(pathname.to_s, 'public', path.split('?').first))
68
+ return_path = plugin_asset_path.to_s
69
+ end
70
+ end
71
+ end
72
+
73
+ return_path
74
+ end
75
+ end
76
+ end
77
+
78
+ # Register the plugin
79
+ config.after_initialize do
80
+ ::Refinery::Plugin.register do |plugin|
81
+ plugin.name ="refinery_core"
82
+ plugin.class_name ="RefineryEngine"
83
+ plugin.version = ::Refinery.version
84
+ plugin.hide_from_menu = true
85
+ plugin.always_allow_access = true
86
+ plugin.menu_match = /(refinery|admin)\/(refinery_core)$/
87
+ end
88
+
89
+ # Register the dialogs plugin
90
+ ::Refinery::Plugin.register do |plugin|
91
+ plugin.name = "refinery_dialogs"
92
+ plugin.version = ::Refinery.version
93
+ plugin.hide_from_menu = true
94
+ plugin.always_allow_access = true
95
+ plugin.menu_match = /(refinery|admin)\/(refinery_)?dialogs/
96
+ end
97
+ end
98
+
99
+ # Run other initializer code that used to be in config/initializers/
100
+ initializer "serve static assets" do |app|
101
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
102
+ end
103
+
104
+ initializer 'add catch all routes' do |app|
105
+ app.routes_reloader.paths << File.expand_path('../refinery/catch_all_routes.rb', __FILE__)
106
+ end
107
+
108
+ initializer 'add presenters' do |app|
109
+ app.config.autoload_paths += [
110
+ Rails.root.join("app", "presenters"),
111
+ Rails.root.join("vendor", "**", "**", "app", "presenters"),
112
+ Refinery.roots.map{|r| r.join("**", "app", "presenters")}
113
+ ].flatten
114
+ end
115
+
116
+ initializer "configure acts_as_indexed" do |app|
117
+ ActsAsIndexed.configure do |config|
118
+ config.index_file = Rails.root.join('tmp', 'index')
119
+ config.index_file_depth = 3
120
+ config.min_word_size = 3
121
+ end
122
+ end
123
+
124
+ initializer "fix rack <= 1.2.1" do |app|
125
+ ::Rack::Utils.module_eval do
126
+ def escape(s)
127
+ regexp = case
128
+ when RUBY_VERSION >= "1.9" && s.encoding === Encoding.find('UTF-8')
129
+ /([^ a-zA-Z0-9_.-]+)/u
130
+ else
131
+ /([^ a-zA-Z0-9_.-]+)/n
132
+ end
133
+ s.to_s.gsub(regexp) {
134
+ '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
135
+ }.tr(' ', '+')
136
+ end
137
+ end if ::Rack.version <= "1.2.1"
138
+ end
139
+
140
+ initializer 'set will_paginate link labels' do |app|
141
+ WillPaginate::ViewHelpers.pagination_options[:previous_label] = "&laquo;".html_safe
142
+ WillPaginate::ViewHelpers.pagination_options[:next_label] = "&raquo;".html_safe
143
+ end
144
+
145
+ initializer 'ensure devise is initialised' do |app|
146
+ unless Rails.root.join('config', 'initializers', 'devise.rb').file?
147
+ load Refinery.roots('core').join(*%w(lib generators templates config initializers devise.rb))
148
+ end
149
+ end
150
+
151
+ end
152
+ end
153
+
154
+ end
155
+
156
+ ::Refinery.engines << 'core'
@@ -0,0 +1,29 @@
1
+ namespace :doc do
2
+
3
+ task :app => [:refinery]
4
+
5
+ desc "Generate documentation for the application"
6
+ Rake::RDocTask.new(:refinery) { |rdoc|
7
+ rdoc.title = "Refinery CMS Documentation"
8
+ rdoc.main = "readme.md"
9
+ rdoc.options = ['--inline-source']
10
+ rdoc.rdoc_files.include('lib/**/*.rb',
11
+ 'lib/*',
12
+ 'app/**/*.rb',
13
+ 'db/seeds.rb',
14
+ 'config/preinitializer.rb',
15
+ 'vendor/engines/images/**/*.rb',
16
+ 'vendor/engines/authentication/**/*.rb',
17
+ 'vendor/engines/dashboard/**/*.rb',
18
+ 'vendor/engines/inquiries/**/*.rb',
19
+ 'vendor/engines/news/**/*.rb',
20
+ 'vendor/engines/pages/**/*.rb',
21
+ 'vendor/engines/refinery/**/*.rb',
22
+ 'vendor/engines/refinery_dialogs/**/*.rb',
23
+ 'vendor/engines/refinery_settings/**/*.rb',
24
+ 'vendor/engines/resources/**/*.rb',
25
+ 'vendor/engines/themes/**/*.rb',
26
+ 'readme.md', 'license.md', 'vendor/engines/themes/readme.md')
27
+ }
28
+
29
+ end
@@ -0,0 +1,231 @@
1
+ namespace :refinery do
2
+
3
+ desc "Override files for use in an application"
4
+ task :override => :environment do
5
+ require 'fileutils'
6
+
7
+ if (view = ENV["view"]).present?
8
+ pattern = "#{view.split("/").join(File::SEPARATOR)}*.{erb,builder}"
9
+ looking_for = Refinery::Plugins.registered.pathnames.map{|p| p.join("app", "views", pattern).to_s}
10
+
11
+ # copy in the matches
12
+ matches = looking_for.collect{|d| Dir[d]}.flatten.compact.uniq
13
+ if matches.any?
14
+ matches.each do |match|
15
+ dir = match.split("/app/views/").last.split('/')
16
+ file = dir.pop # get rid of the file.
17
+ dir = dir.join(File::SEPARATOR) # join directory back together
18
+
19
+ unless (theme = ENV["theme"]).present?
20
+ destination_dir = Rails.root.join("app", "views", dir)
21
+ else
22
+ destination_dir = Rails.root.join("themes", theme, "views", dir)
23
+ end
24
+ FileUtils.mkdir_p(destination_dir)
25
+ FileUtils.cp match, (destination = File.join(destination_dir, file))
26
+
27
+ puts "Copied view template file to #{destination.gsub("#{Rails.root.to_s}#{File::SEPARATOR}", '')}"
28
+ end
29
+ else
30
+ puts "Couldn't match any view template files in any engines like #{view}"
31
+ end
32
+ elsif (controller = ENV["controller"]).present?
33
+ pattern = "#{controller.split("/").join(File::SEPARATOR)}*.rb"
34
+ looking_for = Refinery::Plugins.registered.pathnames.map{|p| p.join("app", "controllers", pattern).to_s}
35
+
36
+ # copy in the matches
37
+ matches = looking_for.collect{|d| Dir[d]}.flatten.compact.uniq
38
+ if matches.any?
39
+ matches.each do |match|
40
+ dir = match.split("/app/controllers/").last.split('/')
41
+ file = dir.pop # get rid of the file.
42
+ dir = dir.join(File::SEPARATOR) # join directory back together
43
+
44
+ destination_dir = Rails.root.join("app", "controllers", dir)
45
+ FileUtils.mkdir_p(destination_dir)
46
+ FileUtils.cp match, (destination = File.join(destination_dir, file))
47
+
48
+ puts "Copied controller file to #{destination.gsub("#{Rails.root.to_s}#{File::SEPARATOR}", '')}"
49
+ end
50
+ else
51
+ puts "Couldn't match any controller files in any engines like #{controller}"
52
+ end
53
+ elsif (model = ENV["model"]).present?
54
+ pattern = "#{model.split("/").join(File::SEPARATOR)}*.rb"
55
+ looking_for = Refinery::Plugins.registered.pathnames.map{|p| p.join("app", "models", pattern).to_s}
56
+
57
+ # copy in the matches
58
+ matches = looking_for.collect{|d| Dir[d]}.flatten.compact.uniq
59
+ if matches.any?
60
+ matches.each do |match|
61
+ dir = match.split("/app/models/").last.split('/')
62
+ file = dir.pop # get rid of the file.
63
+ dir = dir.join(File::SEPARATOR) # join directory back together
64
+
65
+ destination_dir = Rails.root.join("app", "models", dir)
66
+ FileUtils.mkdir_p(destination_dir)
67
+ FileUtils.cp match, (destination = File.join(destination_dir, file))
68
+
69
+ puts "Copied model file to #{destination.gsub("#{Rails.root.to_s}#{File::SEPARATOR}", '')}"
70
+ end
71
+ else
72
+ puts "Couldn't match any model files in any engines like #{model}"
73
+ end
74
+ elsif (javascripts = ENV["javascript"]).present?
75
+ pattern = "#{javascripts.split("/").join(File::SEPARATOR)}*.js"
76
+ looking_for = Refinery::Plugins.registered.pathnames.map{|p| p.join("public", "javascripts", pattern).to_s}
77
+
78
+ # copy in the matches
79
+ matches = looking_for.collect{|d| Dir[d]}.flatten.compact.uniq
80
+ if matches.any?
81
+ matches.each do |match|
82
+ dir = match.split("/public/javascripts/").last.split('/')
83
+ file = dir.pop # get rid of the file.
84
+ dir = dir.join(File::SEPARATOR) # join directory back together
85
+
86
+ destination_dir = Rails.root.join("public", "javascripts", dir)
87
+ FileUtils.mkdir_p(destination_dir)
88
+ FileUtils.cp match, (destination = File.join(destination_dir, file))
89
+
90
+ puts "Copied javascript file to #{destination.gsub("#{Rails.root.to_s}#{File::SEPARATOR}", '')}"
91
+ end
92
+ else
93
+ puts "Couldn't match any javascript files in any engines like #{javascript}"
94
+ end
95
+ elsif (stylesheets = ENV["stylesheet"]).present?
96
+ pattern = "#{stylesheets.split("/").join(File::SEPARATOR)}*.css"
97
+ looking_for = Refinery::Plugins.registered.pathnames.map{|p| p.join("public", "stylesheets", pattern).to_s}
98
+
99
+ # copy in the matches
100
+ matches = looking_for.collect{|d| Dir[d]}.flatten.compact.uniq
101
+ if matches.any?
102
+ matches.each do |match|
103
+ dir = match.split("/public/stylesheets/").last.split('/')
104
+ file = dir.pop # get rid of the file.
105
+ dir = dir.join(File::SEPARATOR) # join directory back together
106
+
107
+ destination_dir = Rails.root.join("public", "stylesheets", dir)
108
+ FileUtils.mkdir_p(destination_dir)
109
+ FileUtils.cp match, (destination = File.join(destination_dir, file))
110
+
111
+ puts "Copied stylesheet file to #{destination.gsub("#{Rails.root.to_s}#{File::SEPARATOR}", '')}"
112
+ end
113
+ else
114
+ puts "Couldn't match any stylesheet files in any engines like #{stylesheets}"
115
+ end
116
+ else
117
+ puts "You didn't specify anything to override. Here's some examples:"
118
+ {
119
+ :view => ['pages/home', 'pages/home theme=demolicious', '**/*menu', 'shared/_menu_branch'],
120
+ :javascript => %w(jquery),
121
+ :stylesheet => %w(refinery/site_bar),
122
+ :controller => %w(pages),
123
+ :model => %w(page)
124
+ }.each do |type, examples|
125
+ examples.each do |example|
126
+ puts "rake refinery:override #{type}=#{example}"
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ desc "Un-crudify a method on a controller that uses crudify"
133
+ task :uncrudify => :environment do
134
+ if (model_name = ENV["model"]).present? and (action = ENV["action"]).present?
135
+ singular_name = model_name.to_s
136
+ class_name = singular_name.camelize
137
+ plural_name = singular_name.pluralize
138
+
139
+ crud_lines = Refinery.roots('core').join('lib', 'refinery', 'crud.rb').read
140
+ if (matches = crud_lines.scan(/(\ +)(def #{action}.+?protected)/m).first).present? and
141
+ (method_lines = "#{matches.last.split(%r{^#{matches.first}end}).first.strip}\nend".split("\n")).many?
142
+ indent = method_lines.second.index(%r{[^ ]})
143
+ crud_method = method_lines.join("\n").gsub(/^#{" " * indent}/, " ")
144
+
145
+ default_crud_options = ::Refinery::Crud.default_options(model_name)
146
+ crud_method.gsub!('#{options[:redirect_to_url]}', default_crud_options[:redirect_to_url])
147
+ crud_method.gsub!('#{options[:conditions].inspect}', default_crud_options[:conditions].inspect)
148
+ crud_method.gsub!('#{options[:title_attribute]}', default_crud_options[:title_attribute])
149
+ crud_method.gsub!('#{singular_name}', singular_name)
150
+ crud_method.gsub!('#{class_name}', class_name)
151
+ crud_method.gsub!('#{plural_name}', plural_name)
152
+ crud_method.gsub!('\\#{', '#{')
153
+
154
+ puts crud_method
155
+ end
156
+ else
157
+ puts "You didn't specify anything to uncrudify. Here's some examples:"
158
+ puts "rake refinery:uncrudify model=page action=create"
159
+ puts "rake refinery:uncrudify model=product action=new"
160
+ end
161
+ end
162
+
163
+ desc "Update the core files with the gem"
164
+ task :update => :environment do
165
+ verbose = ENV["verbose"] || false
166
+ require 'fileutils'
167
+
168
+ # Clean up mistakes
169
+ if (bad_migration = Rails.root.join('db', 'migrate', '20100913234704_add_cached_slug_to_pages.rb')).file?
170
+ FileUtils::rm bad_migration
171
+ end
172
+
173
+ unless (devise_config = Rails.root.join('config', 'initializers', 'devise.rb')).file?
174
+ devise_config.parent.mkpath
175
+ FileUtils::cp Refinery.roots('core').join(*%w(lib generators templates config initializers devise.rb)),
176
+ devise_config,
177
+ :verbose => verbose
178
+ end
179
+
180
+ (contents = Rails.root.join('Gemfile').read).gsub!("group :test do", "group :development, :test do")
181
+ Rails.root.join('Gemfile').open("w") do |f|
182
+ f.puts contents
183
+ end
184
+
185
+ # copy in any new migrations, except for ones that create schemas (this is an update!)
186
+ # or ones that exist already.
187
+ Rails.root.join("db", "migrate").mkpath
188
+ migrations = Pathname.glob(Refinery.roots.map{|r| r.join("db", "migrate", "*.rb")}).reject{|m|
189
+ m.to_s =~ %r{\d+_create_refinerycms_.+?_schema\.rb} or
190
+ Dir[Rails.root.join('db', 'migrate', "*#{m.split.last.to_s.split(/\d+_/).last}")].any?
191
+ }
192
+ FileUtils::cp migrations,
193
+ Rails.root.join('db', 'migrate').cleanpath.to_s,
194
+ :verbose => verbose
195
+
196
+ Rails.root.join("db", "seeds").mkpath
197
+ Pathname.glob(Refinery.roots.map{|r| r.join('db', 'seeds', '*.rb')}).each do |seed|
198
+ unless (destination = Rails.root.join('db', 'seeds', seed.split.last)).exist?
199
+ FileUtils::cp seed, destination.to_s, :verbose => verbose
200
+ end
201
+ end
202
+
203
+ puts "\n" if verbose
204
+
205
+ unless (ENV["from_installer"] || 'false').to_s == 'true'
206
+ puts "\n=== ACTION REQUIRED ==="
207
+ puts "Please run rake db:migrate to ensure your database is at the correct version.\n"
208
+ end
209
+ end
210
+
211
+ namespace :cache do
212
+ desc "Eliminate existing cache files for javascript and stylesheet resources in default directories"
213
+ task :clear => :environment do
214
+ FileUtils.rm(Dir[Rails.root.join("public", "javascripts", "cache", "[^.]*").cleanpath.to_s])
215
+ FileUtils.rm(Dir[Rails.root.join("public", "stylesheets", "cache", "[^.]*").cleanpath.to_s])
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ desc 'Removes trailing whitespace across the entire application.'
222
+ task :whitespace do
223
+ require 'rbconfig'
224
+ if Config::CONFIG['host_os'] =~ /linux/
225
+ sh %{find . -name '*.*rb' -exec sed -i 's/\t/ /g' {} \\; -exec sed -i 's/ *$//g' {} \\; }
226
+ elsif Config::CONFIG['host_os'] =~ /darwin/
227
+ sh %{find . -name '*.*rb' -exec sed -i '' 's/\t/ /g' {} \\; -exec sed -i '' 's/ *$//g' {} \\; }
228
+ else
229
+ puts "This doesn't work on systems other than OSX or Linux. Please use a custom whitespace tool for your platform '#{Config::CONFIG["host_os"]}'."
230
+ end
231
+ end