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,66 @@
1
+ require 'action_view'
2
+ require 'action_view/helpers'
3
+
4
+ ActionView::Helpers::FormHelper.module_eval do
5
+
6
+ def required_label(object_name, method, text = nil, options = {})
7
+ options = {:class => "required"}.merge!(options)
8
+
9
+ label(object_name, method, "#{label_humanize_text(object_name, method, text, options)} *", options)
10
+ end
11
+
12
+
13
+ def label_humanize_text object_name, method, text = nil, options = {}
14
+ if text.blank?
15
+ text = object_name.classify.constantize.respond_to?(:human_attribute_name) ? object_name.classify.constantize.human_attribute_name(method) : method.to_s
16
+ else
17
+ text = text.to_s
18
+ end
19
+ text.humanize
20
+ end
21
+
22
+ end
23
+
24
+ ActionView::Helpers::FormBuilder.module_eval do
25
+
26
+ def required_label(method, text = nil, options = {})
27
+ @template.required_label(@object_name, method, text, objectify_options(options))
28
+ end
29
+
30
+ end
31
+
32
+ ActionView::Helpers::FormTagHelper.module_eval do
33
+
34
+ def required_label_tag(name, text = nil, options = {})
35
+ options = {:class => "required"}.merge!(options)
36
+ text ||= "#{name.to_s.humanize} *"
37
+
38
+ label_tag(name, text, options)
39
+ end
40
+
41
+ end
42
+
43
+
44
+ # I18n labels automatically
45
+ module ActionView
46
+ module Helpers
47
+ class InstanceTag
48
+ def to_label_tag(text = nil, options = {})
49
+ options = options.stringify_keys
50
+ name_and_id = options.dup
51
+ add_default_name_and_id(name_and_id)
52
+ options.delete("index")
53
+ options["for"] ||= name_and_id["id"]
54
+ if text.blank?
55
+ content = method_name.humanize
56
+ if object.class.respond_to?(:human_attribute_name)
57
+ content = object.class.human_attribute_name(method_name)
58
+ end
59
+ else
60
+ content = text.to_s
61
+ end
62
+ label_tag(name_and_id["id"], content, options)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,17 @@
1
+ module Refinery
2
+ module Helpers
3
+ module HeadHelper
4
+
5
+ def stylesheets_for_head(stylesheets, theme = false)
6
+ # you can disable the use of the built-in refinery stylesheets by disabling the setting.
7
+ stylesheets.map! {|ss| ["refinery/#{ss}", ss] }.flatten! if RefinerySetting.find_or_set(:frontend_refinery_stylesheets_enabled, true)
8
+
9
+ # if theme is set, use themed stylesheet links.
10
+ stylesheets.map! {|ss| ss =~ /^refinery\// ? ss : "/theme/stylesheets/#{ss}" } if theme
11
+
12
+ stylesheets
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ require 'truncate_html'
2
+
3
+ module Refinery
4
+ module Helpers
5
+ module HtmlTruncationHelper
6
+
7
+ # Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and words.
8
+ # <script> tags pass through and are not counted in the total.
9
+ # the omission specified _does_ count toward the total length count.
10
+ # use :link => link_to('more', post_path), or something to that effect
11
+ def truncate(text, options = {})
12
+ return unless text.present?
13
+ return super unless options.delete(:preserve_html_tags) == true # ensure preserve_html_tags doesn't pass through
14
+
15
+ max_length = options[:length] || 30
16
+ omission = options[:omission] || "..."
17
+
18
+ return truncate_html(text,
19
+ :length => max_length,
20
+ :word_boundary => true,
21
+ :omission => omission)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module Refinery
2
+ module Helpers
3
+ module ImageHelper
4
+
5
+ # replace all system images with a thumbnail version of them (handy for all images inside a page part)
6
+ # for example, <%= content_fu(@page[:body], '96x96#c') %> converts all /system/images to a 96x96 cropped thumbnail
7
+ def content_fu(content, thumbnail)
8
+ content.gsub(%r{<img.+?src=['"](/system/images/.+?)/.+?/>}) do |image_match|
9
+ begin
10
+ uid = Dragonfly::Job.from_path(
11
+ "#{image_match.match(%r{(/system/images/.+?)/})[1]}", Dragonfly[:images]
12
+ ).uid
13
+
14
+ image_fu Image.where(:image_uid => uid).first, thumbnail
15
+ rescue
16
+ # FAIL, don't care why but return what we found initially.
17
+ image_match
18
+ end
19
+ end
20
+ end
21
+
22
+ # image_fu is a helper for inserting an image that has been uploaded into a template.
23
+ # Say for example that we had a @model.image (@model having a belongs_to :image relationship)
24
+ # and we wanted to display a thumbnail cropped to 200x200 then we can use image_fu like this:
25
+ # <%= image_fu @model.image, '200x200' %> or with no thumbnail: <%= image_fu @model.image %>
26
+ def image_fu(image, geometry = nil, options={})
27
+ if image.present?
28
+ # call rails' image tag function with default alt tag.
29
+ # if any other options were supplied these are merged in and can replace the defaults.
30
+ # if the geomtry is nil, then we know the image height and width already.
31
+ # detect nil geometry or cropping presence which is where we can guess the dimensions
32
+ unless geometry.nil? or !(split_geometry = geometry.to_s.split('#')).many? or !(split_geometry = split_geometry.first.split('x')).many?
33
+ image_width, image_height = split_geometry
34
+ else
35
+ image_with = nil
36
+ image_height = nil
37
+ end
38
+
39
+ image_tag(image.thumbnail(geometry).url, {
40
+ :alt => image.respond_to?(:title) ? image.title : image.image_name,
41
+ :width => image_width,
42
+ :height => image_height
43
+ }.merge(options))
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,68 @@
1
+ module Refinery
2
+ module Helpers
3
+ module MenuHelper
4
+
5
+ # Adds conditional caching
6
+ def cache_if(condition, name = {}, &block)
7
+ if condition
8
+ cache(name, &block)
9
+ else
10
+ yield
11
+ end
12
+
13
+ # for <%= style helpers vs <% style
14
+ nil
15
+ end
16
+
17
+ # This was extracted from app/views/shared/_menu_branch.html.erb
18
+ # to remove the complexity of that template by reducing logic in the view.
19
+ def css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count = nil, collection = [], selected_item = nil)
20
+ css = []
21
+ css << "selected" if selected_page_or_descendant_page_selected?(menu_branch, collection, selected_item)
22
+ css << "first" if menu_branch_counter == 0
23
+ css << "last" if menu_branch_counter == (sibling_count ||= menu_branch.shown_siblings.size)
24
+ css
25
+ end
26
+
27
+ # Determines whether any page underneath the supplied page is the current page according to rails.
28
+ # Just calls selected_page? for each descendant of the supplied page.
29
+ # if you pass a collection it won't check its own descendants but use the collection supplied.
30
+ def descendant_page_selected?(page, collection = [], selected_item = nil)
31
+ return false unless page.has_descendants? or (selected_item && !selected_item.in_menu?)
32
+
33
+ descendants = if collection.present? and (!selected_item or (selected_item && selected_item.in_menu?))
34
+ collection.select{ |item| item.parent_id == page.id }
35
+ else
36
+ page.descendants
37
+ end
38
+
39
+ descendants.any? do |descendant|
40
+ selected_item ? selected_item == descendant : selected_page?(descendant)
41
+ end
42
+ end
43
+
44
+ def selected_page_or_descendant_page_selected?(page, collection = [], selected_item = nil)
45
+ selected = false
46
+ selected = selected_item ? selected_item === page : selected_page?(page)
47
+ selected = descendant_page_selected?(page, collection, selected_item) unless selected
48
+ selected
49
+ end
50
+
51
+ # Determine whether the supplied page is the currently open page according to Refinery.
52
+ # Also checks whether Rails thinks it is selected after that using current_page?
53
+ def selected_page?(page)
54
+ # ensure we match the path without the locale.
55
+ path = request.path
56
+ if defined?(::Refinery::I18n) and ::Refinery::I18n.enabled?
57
+ path = path.split("/#{::I18n.locale}").last
58
+ end
59
+
60
+ (path =~ Regexp.new(page.menu_match) if page.menu_match.present?) or
61
+ (path == page.link_url) or
62
+ (path == page.nested_path) or
63
+ current_page?(page)
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,67 @@
1
+ module Refinery
2
+ module Helpers
3
+ module MetaHelper
4
+
5
+ # This is used to display the title of the current object (normally a page) in the browser's titlebar.
6
+ #
7
+ def browser_title(yield_title=nil)
8
+ [
9
+ (yield_title if yield_title.present?),
10
+ @meta.browser_title.present? ? @meta.browser_title : @meta.path,
11
+ RefinerySetting.find_or_set(:site_name, "Company Name")
12
+ ].compact.join(" - ")
13
+ end
14
+
15
+ # you can override the object used for the title by supplying options[:object]
16
+ # this object must support custom_title_type if you want custom titles.
17
+ def page_title(options = {})
18
+ object = options.fetch(:object, @meta)
19
+ options.delete(:object)
20
+ options = RefinerySetting.find_or_set(:page_title, {
21
+ :chain_page_title => false,
22
+ :ancestors => {
23
+ :separator => " | ",
24
+ :class => 'ancestors',
25
+ :tag => 'span'
26
+ },
27
+ :page_title => {
28
+ :class => nil,
29
+ :tag => nil,
30
+ :wrap_if_not_chained => false
31
+ }
32
+ }).merge(options)
33
+
34
+ title = []
35
+ objects = (options[:chain_page_title] and object.respond_to?(:ancestors)) ? [object.ancestors, object] : [object]
36
+
37
+ objects.flatten.compact.each do |obj|
38
+ if obj.respond_to?(:custom_title_type)
39
+ title << case obj.custom_title_type
40
+ when "text"
41
+ obj.custom_title
42
+ when "image"
43
+ image_fu(obj.custom_title_image, nil, {:alt => obj.title}) rescue obj.title
44
+ else
45
+ obj.title
46
+ end
47
+ else
48
+ title << obj.title
49
+ end
50
+ end
51
+
52
+ final_title = title.pop
53
+ if (options[:page_title][:wrap_if_not_chained] and title.empty?) and options[:page_title][:tag].present?
54
+ css = " class='#{options[:page_title][:class]}'" if options[:page_title][:class].present?
55
+ final_title = "<#{options[:page_title][:tag]}#{css}>#{final_title}</#{options[:page_title][:tag]}>"
56
+ end
57
+
58
+ if title.empty?
59
+ return final_title.to_s.html_safe
60
+ else
61
+ return "<#{options[:ancestors][:tag]} class='#{options[:ancestors][:class]}'>#{title.join options[:ancestors][:separator]}#{options[:ancestors][:separator]}</#{options[:ancestors][:tag]}>#{final_title}".html_safe
62
+ end
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,16 @@
1
+ module Refinery
2
+ module Helpers
3
+ module PaginationHelper
4
+
5
+ # Figures out the CSS classname to apply to your pagination list for animations.
6
+ def pagination_css_class
7
+ if request.xhr? and params[:from_page].present? and params[:page].present?
8
+ "frame_#{params[:from_page].to_s > params[:page].to_s ? 'left' : 'right'}"
9
+ else
10
+ "frame_center"
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,36 @@
1
+ module Refinery
2
+ module Helpers
3
+ module ScriptHelper
4
+
5
+ # This function helps when including both the jquery and jqueryui libraries.
6
+ # If you use this function then whenever we update or relocate the version of jquery or jquery ui in use
7
+ # we will update the reference here and your existing application starts to use it.
8
+ # Use <%= jquery_include_tags %> to include it in your <head> section.
9
+ def jquery_include_tags(options={})
10
+ # Merge in options
11
+ options = {
12
+ :caching => (Rails.root.writable? and RefinerySetting.find_or_set(:use_resource_caching, true)),
13
+ :google => RefinerySetting.find_or_set(:use_google_ajax_libraries, false),
14
+ :jquery_ui => true
15
+ }.merge(options)
16
+
17
+ # render the tags normally unless
18
+ unless options[:google] and !local_request?
19
+ if options[:jquery_ui]
20
+ javascript_include_tag "jquery#{"-min" if Rails.env.production?}", "jquery-ui-custom-min",
21
+ :cache => ("cache/jquery" if options[:caching])
22
+ else
23
+ javascript_include_tag "jquery#{"-min" if Rails.env.production?}"
24
+ end
25
+ else
26
+ "#{javascript_include_tag("http://www.google.com/jsapi").gsub(".js", "")}
27
+ <script>
28
+ google.load('jquery', '1.5.0');
29
+ #{"google.load('jqueryui', '1.8.9');" if options[:jquery_ui]}
30
+ </script>".html_safe
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ module Refinery
2
+ module Helpers
3
+ module SiteBarHelper
4
+
5
+ # Generates the link to determine where the site bar switch button returns to.
6
+ def site_bar_switch_link
7
+ link_to_if(admin?, t('.switch_to_your_website'),
8
+ (if session.keys.include?(:website_return_to) and session[:website_return_to].present?
9
+ session[:website_return_to]
10
+ else
11
+ root_path
12
+ end)) do
13
+ link_to t('.switch_to_your_website_editor'),
14
+ (if session.keys.include?(:refinery_return_to) and session[:refinery_return_to].present?
15
+ session[:refinery_return_to]
16
+ else
17
+ admin_root_path
18
+ end rescue admin_root_path)
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ module Refinery
2
+ module Helpers
3
+ module TagHelper
4
+
5
+ # Returns <span class='help' title='Your Input'>(help)</span>
6
+ # Remember to wrap your block with <span class='label_with_help'></span> if you're using a label next to the help tag.
7
+ def refinery_help_tag(title='')
8
+ title = h(title) unless title.html_safe?
9
+
10
+ "<span class=\"help\" title=\"#{title}\">(#{t('help', :scope => 'shared.admin')})</span>".html_safe
11
+ end
12
+
13
+ # This is just a quick wrapper to render an image tag that lives inside refinery/icons.
14
+ # They are all 16x16 so this is the default but is able to be overriden with supplied options.
15
+ def refinery_icon_tag(filename, options = {})
16
+ image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge(options)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module Refinery
2
+ module Helpers
3
+ module TranslationHelper
4
+
5
+ # Overrides Rails' core I18n.t() function to produce a more helpful error message.
6
+ # The default one wreaks havoc with CSS and makes it hard to understand the problem.
7
+ def t(key, options = {})
8
+ if (val = super) =~ /class.+?translation_missing/
9
+ val = val.to_s.gsub(/<span[^>]*>/, 'i18n: ').gsub('</span>', '').gsub(', ', '.')
10
+ end
11
+
12
+ val
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ class Refinery::LinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
2
+
3
+ # TODO: Rewrite for WillPaginate 3 API
4
+
5
+ =begin
6
+
7
+ attr_accessor :url
8
+
9
+ def url_for(page)
10
+ # extract any url parameter and store it for subsequent requests but delete it
11
+ # this is so that we don't end up with it being an attribute of the resulting HTML.
12
+ @url ||= @options.delete(:url) || {}
13
+ page_one = page == 1
14
+ @url_params = {}
15
+ # page links should preserve GET parameters
16
+ stringified_merge @url_params, @template.params if @template.request.get?
17
+ stringified_merge @url_params, @options[:params] if @options[:params]
18
+
19
+ if complex = param_name.index(/[^\w-]/)
20
+ page_param = parse_query_parameters("#{param_name}=#{page}")
21
+
22
+ stringified_merge @url_params, page_param
23
+ else
24
+ @url_params[param_name] = page_one ? 1 : 2
25
+ end
26
+
27
+ url = @template.url_for(@url_params.merge!(@url).to_options)
28
+ return url if page_one
29
+
30
+ if complex
31
+ @url_string = url.sub(%r!((?:\?|&amp;)#{CGI.escape param_name}=)#{page}!, '\1@')
32
+ return url
33
+ else
34
+ @url_string = url
35
+ @url_params[param_name] = 3
36
+ @template.url_for(@url_params).split(//).each_with_index do |char, i|
37
+ if char == '3' and url[i, 1] == '2'
38
+ @url_string[i] = '@'
39
+ break
40
+ end
41
+ end
42
+ end
43
+ # finally!
44
+ @url_string.sub '@', page.to_s
45
+ end
46
+
47
+ private
48
+
49
+ def param_name
50
+ @options[:param_name].to_s
51
+ end
52
+
53
+ =end
54
+
55
+ end