Skip to content

Commit

Permalink
fixing up xhtml mobile doctype helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan G. Lim committed Apr 3, 2009
1 parent 086ffa4 commit c8e8d46
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/mobile_fu_helper.rb
@@ -1,9 +1,24 @@
module MobileFuHelper
def mobile_xhtml_doctype
"<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">"
ACCEPTABLE_TYPES = [:mobile, :basic]

def mobile_xhtml_doctype(type = :mobile, version = '1.0')
raise Exception.new("MobileFu: XHTML DOCTYPE type must either be ':mobile' or ':basic'") unless ACCEPTABLE_TYPES.include?(type)
raise Exception.new("MobileFu: XHTML DOCTYPE version must be in the format of '1.0' or '1.1', etc.") unless version.include?('.')

doc_type = "<?xml version=\"1.0\" charset=\"UTF-8\" ?>\n"
doc_type += "<!DOCTYPE html PUBLIC "
doc_type += case type
when :mobile
"\"-//WAPFORUM//DTD XHTML Mobile #{version}//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile#{version.gsub('.','')}.dtd\">"
when :basic
"\"-//W3C//DTD XHTML Basic #{version}//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic#{version.gsub('.','')}.dtd\">"
end
doc_type
end

def js_enabled_mobile_device?
is_device?('iphone') || is_device?('mobileexplorer') || is_device?('android')
end
end
end

ActionView::Base.send(:include, MobileFuHelper)

0 comments on commit c8e8d46

Please sign in to comment.