From 350efc24df88dbc203453f217fddad9598f3533e Mon Sep 17 00:00:00 2001 From: zerobearing2 Date: Thu, 2 Sep 2010 18:10:48 -0700 Subject: [PATCH 1/5] Version bump to 0.0.0 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.0 From b1d05f8a7b16250d31ff9ed82e05b992cc0d8130 Mon Sep 17 00:00:00 2001 From: zerobearing2 Date: Thu, 2 Sep 2010 18:11:58 -0700 Subject: [PATCH 2/5] fixed stylesheet path added gemspec --- .gitignore | 1 + Rakefile | 14 +++++++++++ VERSION | 2 +- lib/mobilized_styles.rb | 4 +-- mobile_fu.gemspec | 54 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 mobile_fu.gemspec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..088af20 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pkg/* diff --git a/Rakefile b/Rakefile index de861dd..c057972 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,20 @@ require 'rake' require 'rake/testtask' require 'rake/rdoctask' +begin + require 'jeweler' + Jeweler::Tasks.new do |gemspec| + gemspec.name = "mobile_fu" + gemspec.summary = "Automatically detect mobile devices that access your Rails application" + gemspec.description = "Want to automatically detect mobile devices that access your Rails application? Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry, iPhone, iPad, Nokia, etc. and it will automatically adjust the format of the request from :html to :mobile." + gemspec.email = "brendangl@gmail.com" + gemspec.homepage = "http://github.com/brendanlim/mobile-fu" + gemspec.authors = ["Brendan G. Lim"] + end +rescue LoadError + puts "Jeweler not available. Install it with: gem install jeweler" +end + desc 'Default: run unit tests.' task :default => :test diff --git a/VERSION b/VERSION index 77d6f4c..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.0 +0.3.0 diff --git a/lib/mobilized_styles.rb b/lib/mobilized_styles.rb index 8c16e0b..8c2672b 100644 --- a/lib/mobilized_styles.rb +++ b/lib/mobilized_styles.rb @@ -59,8 +59,8 @@ def stylesheet_link_tag_with_mobilization(*sources) mobilized_sources << source for possible_source in possible_sources - path = File.join(config.stylesheets_dir,"#{possible_source}.css") - sass_path = File.join(config.stylesheets_dir,"sass","#{possible_source}.sass") + path = File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR,"#{possible_source}.css") + sass_path = File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR,"sass","#{possible_source}.sass") mobilized_sources << possible_source if File.exist?(path) || File.exist?(sass_path) end end diff --git a/mobile_fu.gemspec b/mobile_fu.gemspec new file mode 100644 index 0000000..1f2130f --- /dev/null +++ b/mobile_fu.gemspec @@ -0,0 +1,54 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{mobile_fu} + s.version = "0.3.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Brendan G. Lim"] + s.date = %q{2010-09-02} + s.description = %q{Want to automatically detect mobile devices that access your Rails application? Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry, iPhone, iPad, Nokia, etc. and it will automatically adjust the format of the request from :html to :mobile.} + s.email = %q{brendangl@gmail.com} + s.extra_rdoc_files = [ + "README.rdoc" + ] + s.files = [ + "CHANGELOG", + "MIT-LICENSE", + "README.rdoc", + "Rakefile", + "VERSION", + "init.rb", + "install.rb", + "lib/mobile_fu.rb", + "lib/mobile_fu_helper.rb", + "lib/mobilized_styles.rb", + "spec/mobilized_styles_spec.rb", + "spec/spec.opts", + "spec/spec_helper.rb", + "uninstall.rb" + ] + s.homepage = %q{http://github.com/brendanlim/mobile-fu} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.7} + s.summary = %q{Automatically detect mobile devices that access your Rails application} + s.test_files = [ + "spec/mobilized_styles_spec.rb", + "spec/spec_helper.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + else + end + else + end +end + From b2721247eab1dc17557bc7e3aa9b6f3a17397916 Mon Sep 17 00:00:00 2001 From: zerobearing2 Date: Thu, 2 Sep 2010 18:17:07 -0700 Subject: [PATCH 3/5] updated gemspec --- mobile_fu.gemspec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mobile_fu.gemspec b/mobile_fu.gemspec index 1f2130f..a6e0438 100644 --- a/mobile_fu.gemspec +++ b/mobile_fu.gemspec @@ -16,7 +16,8 @@ Gem::Specification.new do |s| "README.rdoc" ] s.files = [ - "CHANGELOG", + ".gitignore", + "CHANGELOG", "MIT-LICENSE", "README.rdoc", "Rakefile", @@ -26,6 +27,7 @@ Gem::Specification.new do |s| "lib/mobile_fu.rb", "lib/mobile_fu_helper.rb", "lib/mobilized_styles.rb", + "mobile_fu.gemspec", "spec/mobilized_styles_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", From 5b8d8748d7635267837182664b3e8f9976d9440c Mon Sep 17 00:00:00 2001 From: zerobearing2 Date: Fri, 3 Sep 2010 10:50:34 -0700 Subject: [PATCH 4/5] fixed gem load/init issues --- init.rb | 12 +++++------- lib/mobile_fu.rb | 10 +++++++++- lib/mobile_fu_helper.rb | 38 +++++++++++++++++++++----------------- lib/mobilized_styles.rb | 3 +-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/init.rb b/init.rb index d34defd..70669af 100644 --- a/init.rb +++ b/init.rb @@ -1,7 +1,5 @@ -require File.dirname(__FILE__) + '/lib/mobile_fu_helper.rb' -require File.dirname(__FILE__) + '/lib/mobilized_styles' -require File.dirname(__FILE__) + '/lib/mobile_fu' - -ActionView::Base.send(:include, MobileFuHelper) -ActionView::Base.send(:include, MobilizedStyles) -ActionView::Base.send(:alias_method_chain, :stylesheet_link_tag, :mobilization) \ No newline at end of file +begin + require File.join(File.dirname(__FILE__), 'lib', 'mobile_fu') # From here +rescue LoadError + require 'mobile_fu' # From gem +end diff --git a/lib/mobile_fu.rb b/lib/mobile_fu.rb index b3aac85..c87e8ea 100644 --- a/lib/mobile_fu.rb +++ b/lib/mobile_fu.rb @@ -1,3 +1,8 @@ +dir = File.dirname(__FILE__) +$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir) +require 'mobile_fu_helper.rb' +require 'mobilized_styles' + module ActionController module MobileFu # These are various strings that can be found in mobile devices. Please feel free @@ -99,4 +104,7 @@ def is_device?(type) end -ActionController::Base.send(:include, ActionController::MobileFu) \ No newline at end of file +ActionController::Base.send(:include, ActionController::MobileFu) +ActionView::Base.send(:include, MobileFuHelper) +ActionView::Base.send(:include, MobilizedStyles) +ActionView::Base.send(:alias_method_chain, :stylesheet_link_tag, :mobilization) diff --git a/lib/mobile_fu_helper.rb b/lib/mobile_fu_helper.rb index 207ba2c..5ba89de 100644 --- a/lib/mobile_fu_helper.rb +++ b/lib/mobile_fu_helper.rb @@ -1,24 +1,28 @@ module MobileFuHelper ACCEPTABLE_TYPES = [:mobile, :basic] + + def self.included(base) + base.extend(ClassMethods) + end - 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?('.') + module ClassMethods + 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 = "\n" - doc_type += "" - when :basic - "\"-//W3C//DTD XHTML Basic #{version}//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic#{version.gsub('.','')}.dtd\">" - end - doc_type - end + doc_type = "\n" + doc_type += "" + 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?('ipod') || is_device?('ipad') || is_device?('mobileexplorer') || is_device?('android') + def js_enabled_mobile_device? + is_device?('iphone') || is_device?('ipod') || is_device?('ipad') || is_device?('mobileexplorer') || is_device?('android') + end end end - -ActionView::Base.send(:include, MobileFuHelper) \ No newline at end of file diff --git a/lib/mobilized_styles.rb b/lib/mobilized_styles.rb index 8c2672b..6879d98 100644 --- a/lib/mobilized_styles.rb +++ b/lib/mobilized_styles.rb @@ -64,7 +64,6 @@ def stylesheet_link_tag_with_mobilization(*sources) mobilized_sources << possible_source if File.exist?(path) || File.exist?(sass_path) end end - stylesheet_link_tag_without_mobilization(*mobilized_sources) end -end \ No newline at end of file +end From aa3a8fa0519392584b6a1dfea8ca1bb6a800d976 Mon Sep 17 00:00:00 2001 From: zerobearing2 Date: Wed, 22 Sep 2010 08:47:03 -0700 Subject: [PATCH 5/5] rolled back stylesheet path -- just realized that master branch is for rails3 and 2.x branch is for rails2 --- lib/mobilized_styles.rb | 4 ++-- mobile_fu.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mobilized_styles.rb b/lib/mobilized_styles.rb index 6879d98..a8116c8 100644 --- a/lib/mobilized_styles.rb +++ b/lib/mobilized_styles.rb @@ -59,8 +59,8 @@ def stylesheet_link_tag_with_mobilization(*sources) mobilized_sources << source for possible_source in possible_sources - path = File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR,"#{possible_source}.css") - sass_path = File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR,"sass","#{possible_source}.sass") + path = File.join(config.stylesheets_dir,"#{possible_source}.css") + sass_path = File.join(config.stylesheets_dir,"sass","#{possible_source}.sass") mobilized_sources << possible_source if File.exist?(path) || File.exist?(sass_path) end end diff --git a/mobile_fu.gemspec b/mobile_fu.gemspec index a6e0438..bb3f364 100644 --- a/mobile_fu.gemspec +++ b/mobile_fu.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Brendan G. Lim"] - s.date = %q{2010-09-02} + s.date = %q{2010-09-22} s.description = %q{Want to automatically detect mobile devices that access your Rails application? Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry, iPhone, iPad, Nokia, etc. and it will automatically adjust the format of the request from :html to :mobile.} s.email = %q{brendangl@gmail.com} s.extra_rdoc_files = [