mobile_version 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/README.rdoc +33 -0
- data/Rakefile +10 -0
- data/lib/mobile_version.rb +30 -0
- data/lib/mobile_version/.DS_Store +0 -0
- data/lib/mobile_version/controller.rb +24 -0
- data/lib/mobile_version/filters.rb +13 -0
- data/lib/mobile_version/missing_template_resolver.rb +16 -0
- data/lib/mobile_version/railtie.rb +10 -0
- data/lib/mobile_version/request.rb +13 -0
- data/lib/mobile_version/version.rb +3 -0
- data/mobile_version.gemspec +25 -0
- data/test/.DS_Store +0 -0
- data/test/dummy/.DS_Store +0 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +4 -0
- data/test/dummy/app/controllers/home_controller.rb +12 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/home/action_one.html.erb +1 -0
- data/test/dummy/app/views/home/action_one.mobilehtml.erb +1 -0
- data/test/dummy/app/views/home/action_two.html.erb +1 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/.DS_Store +0 -0
- data/test/dummy/config/application.rb +41 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +7 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/log/test.log +390 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/mobile_version_test.rb +31 -0
- data/test/test_helper.rb +11 -0
- metadata +230 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
= Mobile Version -- Render mobile browser versions of your views in Rails with zero-configuration.
|
2
|
+
|
3
|
+
With Mobile Version you can have an alternate layout in your rails application for
|
4
|
+
mobile browsers with zero-configuration.
|
5
|
+
|
6
|
+
== Download and installation
|
7
|
+
|
8
|
+
The latest version of Mobile Version can be installed with Rubygems:
|
9
|
+
% [sudo] gem install mobile_version
|
10
|
+
|
11
|
+
Include the gem in your Gemfile:
|
12
|
+
gem 'mobile_version'
|
13
|
+
|
14
|
+
Source code can be downloaded from Github:
|
15
|
+
|
16
|
+
* http://github.com/dunkelbraun/mobile_version
|
17
|
+
|
18
|
+
== Usage
|
19
|
+
|
20
|
+
Whenever you want to render an alternate view for mobile browsers, create a template with the extension "mobilehtml".
|
21
|
+
|
22
|
+
For example: the mobile version template of the index action is
|
23
|
+
index.mobilehtml.erb
|
24
|
+
|
25
|
+
Rails will render the mobile view for all the incoming mobile browser HTML requests and
|
26
|
+
it will fallback to the default HTML view if it does not find the a mobile version for the
|
27
|
+
requested action.
|
28
|
+
|
29
|
+
|
30
|
+
== License
|
31
|
+
|
32
|
+
Mobile Version is released under the MIT license.
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'browser'
|
2
|
+
|
3
|
+
require "mobile_version/version"
|
4
|
+
require "mobile_version/filters"
|
5
|
+
require "mobile_version/request"
|
6
|
+
require "mobile_version/missing_template_resolver"
|
7
|
+
require "mobile_version/controller"
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
module MobileVersion
|
12
|
+
|
13
|
+
def self.included(mod)
|
14
|
+
mod.class_eval do
|
15
|
+
include MobileVersion::Filters
|
16
|
+
include MobileVersion::Request
|
17
|
+
include MobileVersion::Controller
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class ActionController::Base
|
24
|
+
include MobileVersion
|
25
|
+
end
|
26
|
+
|
27
|
+
Mime::Type.register_alias "text/html", :mobilehtml
|
28
|
+
|
29
|
+
require 'mobile_version/railtie'
|
30
|
+
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MobileVersion
|
2
|
+
|
3
|
+
module Controller
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def has_mobile_html_version
|
10
|
+
append_view_path(MobileVersion::MissingTemplateResolver.new(Rails.root.join('app/views')))
|
11
|
+
before_filter(:set_mobile_html_version)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.included(mod)
|
17
|
+
mod.extend ClassMethods
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MobileVersion
|
2
|
+
|
3
|
+
class MissingTemplateResolver < ::ActionView::FileSystemResolver
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
super(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_templates(name, prefix, partial, details)
|
10
|
+
self.instance_variable_set(:@pattern, ':prefix/:action{.:locale,}.html{.:handlers,}') if details[:formats] == [:mobilehtml]
|
11
|
+
super(name, prefix, partial, details)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "mobile_version/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "mobile_version"
|
7
|
+
s.version = MobileVersion::VERSION
|
8
|
+
s.authors = ["Marc Essindi"]
|
9
|
+
s.email = ["marc.essindi@dunkelbraun.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = "Test"
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_development_dependency "rails", ">= 3.0.3"
|
19
|
+
s.add_development_dependency "sqlite3"
|
20
|
+
s.add_development_dependency "mocha"
|
21
|
+
|
22
|
+
s.add_dependency "rails", ">= 3.0.3"
|
23
|
+
s.add_dependency "browser", ">= 0.1.3"
|
24
|
+
|
25
|
+
end
|
data/test/.DS_Store
ADDED
Binary file
|
Binary file
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
ACTION ONE HTML
|
@@ -0,0 +1 @@
|
|
1
|
+
ACTION ONE MOBILEHTML
|
@@ -0,0 +1 @@
|
|
1
|
+
ACTION TWO HTML
|
Binary file
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
module Dummy
|
6
|
+
class Application < Rails::Application
|
7
|
+
# Settings in config/environments/* take precedence over those specified here.
|
8
|
+
# Application configuration should go into files in config/initializers
|
9
|
+
# -- all .rb files in that directory are automatically loaded.
|
10
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
11
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
12
|
+
|
13
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
14
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
15
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
16
|
+
|
17
|
+
# Activate observers that should always be running.
|
18
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
19
|
+
|
20
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
21
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
22
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
23
|
+
|
24
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
25
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
26
|
+
# config.i18n.default_locale = :de
|
27
|
+
|
28
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
29
|
+
config.encoding = "utf-8"
|
30
|
+
|
31
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
32
|
+
config.filter_parameters += [:password]
|
33
|
+
|
34
|
+
# Enable the asset pipeline
|
35
|
+
config.assets.enabled = true
|
36
|
+
|
37
|
+
# Version of your assets, change this if you want to expire all your assets
|
38
|
+
config.assets.version = '1.0'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
33
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
34
|
+
# like if you have constraints or database-specific column types
|
35
|
+
# config.active_record.schema_format = :sql
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
41
|
+
config.assets.allow_debugging = true
|
42
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|