Permalink
Browse files

Merge pull request #1 from dsci/master

Content type helper
  • Loading branch information...
2 parents 5e9a2a4 + 197d4a9 commit 0a5ab81fcc32b3ae533b9b6a7a565d3c85e943ea @danhigham committed Dec 29, 2011
Showing with 14 additions and 1 deletion.
  1. +13 −0 app/helpers/admin/ace_helper.rb
  2. +1 −1 app/views/admin/page_parts/_page_part.html.haml
@@ -2,6 +2,19 @@ module Admin::AceHelper
include Admin::NodeHelper
include Admin::ReferencesHelper
+ def content_type_for_page(page_part)
+ default_content_type = "text/html"
+ if page_part.page.nil?
+ return default_content_type
+ else
+ if page_part.page.layout.respond_to?(:content_type)
+ return page_part.page.layout.content_type
+ else
+ return default_content_type
+ end
+ end
+ end
+
def init_script(tag_id, text_area_id, content_type, filter)
@javascripts << ["/ace/src/ace.js", "/ace/src/ace-utils.js", "/ace/src/theme-twilight.js", "/ace/src/theme-textmate.js", "/ace/src/mode-html.js", "/ace/src/mode-css.js", "/ace/src/mode-coffee.js", "/ace/src/mode-javascript.js"]
@stylesheets << ["/ace/src/ace-resize.css"]
@@ -1,7 +1,7 @@
-ActionView::Base.send :include, Admin::AceHelper
-filter = page_part.filter
--layout = page_part.page.nil? ? "text/html" : page_part.page.layout.content_type
+-layout = content_type_for_page(page_part)
=init_script("editor_part_#{page_part.name.to_slug}_content", "part_#{page_part.name.to_slug}_content", layout, filter)

0 comments on commit 0a5ab81

Please sign in to comment.