Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing up xhtml mobile doctype helper

  • Loading branch information...
commit c8e8d46478b40d7eb0fec56997996054779c662d 1 parent 086ffa4
Brendan G. Lim authored
Showing with 18 additions and 3 deletions.
  1. +18 −3 lib/mobile_fu_helper.rb
View
21 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)
Please sign in to comment.
Something went wrong with that request. Please try again.