README.markdown in divining_rod-0.2.0 vs README.markdown in divining_rod-0.3.0

- old
+ new

@@ -1,50 +1,64 @@ # Divining Rod -A tool to help format your sites mobile pages. The goal is to have the ability to do things in your -views like this +A tool to help format your sites mobile pages. - <%- if request.dv_profile.youtube_capable? %> - <%= link_to "YouTube Video", @link.youtube_url %> - <%- else %> - Sorry, you have a shitty phone. - <% end %> - ## Installation gem install divining_rod ## Usage - require 'divining_rod' +_initializers/divining\_rod.rb_ DiviningRod::Matchers.define do |map| + # map.ua /user_agent_regex/, :format, :tags => [] map.ua /iPhone/, :webkit, :tags => [:iphone, :youtube_capable] - map.ua /Android/, :webkit, :tags => [:youtube_capable, :google_gears] - map.default :unknown + map.ua /Android/, :webkit, :tags => [:android, :youtube_capable, :google_gears] + map.subdomain /wap/, :wap, :tags => [:crappy_old_phone] + + # Enable this to forces a default format if unmatched + # otherwise it will return the request.format + # map.default :html end + +_initializers/mime\_types.rb_ - profile = DiviningRod::Profile(request) #profile and incoming iphone request - profile.format #=> :webkit - profile.iphone? #=> true + Mime::Type.register_alias "text/html", :webkit +_app/controllers/mobile\_controller.rb_ + + class MobileController < ApplicationController + before_filter :detect_mobile_type + + .... + + private + + def detect_mobile_type + # If the profile isn't matched it defaults to request.format + @profile = DiviningRod::Profile.new(request).format + end + + end + +_app/views/mobile/show.webkit.html_ + + <%- if @profile.iphone? %> + <%= link_to "Install our iPhone App in the AppStore", @iPhone_appstore_url %> + <%- elsif @profile.android? %> + <%= link_to "Direct download", @android_app_url %> + <% end %> + + ## Note on the development -This is still very much in beta, but we are using in extensively in production. We plan -to keep the API the same. +This is still very much in beta, but we are using it in production. As such we plan +to do our best to keep the API the same. The user agent definitions will be updated here later this week. - -### Note on Patches/Pull Requests - -* Fork the project. -* Make your feature addition or bug fix. -* Add tests for it. This is important so I don't break it in a - future version unintentionally. -* Commit, do not mess with rakefile, version, or history. - (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) -* Send me a pull request. Bonus points for topic branches. +## Todo ### Copyright Copyright (c) 2010 Mark Percival. See LICENSE for details.