small cleanup
This commit is contained in:
parent
7beb2bb7e5
commit
292b1e7465
22 changed files with 9 additions and 698 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
bundler_args: "--without development,production"
|
bundler_args: "--without development production"
|
||||||
|
|
||||||
rvm:
|
rvm:
|
||||||
- 1.8.7
|
- 1.8.7
|
||||||
|
|
|
||||||
1
Gemfile
1
Gemfile
|
|
@ -37,6 +37,7 @@ gem 'faraday-stack'
|
||||||
gem 'haml', '3.1.2'
|
gem 'haml', '3.1.2'
|
||||||
gem 'sass', '3.1.4'
|
gem 'sass', '3.1.4'
|
||||||
gem 'will_paginate', '3.0.pre2'
|
gem 'will_paginate', '3.0.pre2'
|
||||||
|
gem 'mobile-fu'
|
||||||
|
|
||||||
#Localization
|
#Localization
|
||||||
gem 'rails-i18n'
|
gem 'rails-i18n'
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,9 @@ GEM
|
||||||
mixlib-cli (1.2.0)
|
mixlib-cli (1.2.0)
|
||||||
mixlib-config (1.1.2)
|
mixlib-config (1.1.2)
|
||||||
mixlib-log (1.3.0)
|
mixlib-log (1.3.0)
|
||||||
|
mobile-fu (0.2.1)
|
||||||
|
rack-mobile-detect
|
||||||
|
rails
|
||||||
moneta (0.6.0)
|
moneta (0.6.0)
|
||||||
mongrel (1.1.5)
|
mongrel (1.1.5)
|
||||||
cgi_multipart_eof_fix (>= 2.4)
|
cgi_multipart_eof_fix (>= 2.4)
|
||||||
|
|
@ -330,6 +333,8 @@ GEM
|
||||||
polyglot (0.3.2)
|
polyglot (0.3.2)
|
||||||
pyu-ruby-sasl (0.0.3.3)
|
pyu-ruby-sasl (0.0.3.3)
|
||||||
rack (1.2.3)
|
rack (1.2.3)
|
||||||
|
rack-mobile-detect (0.3.0)
|
||||||
|
rack
|
||||||
rack-mount (0.6.14)
|
rack-mount (0.6.14)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-openid (1.3.1)
|
rack-openid (1.3.1)
|
||||||
|
|
@ -501,6 +506,7 @@ DEPENDENCIES
|
||||||
jwt (= 0.1.3)
|
jwt (= 0.1.3)
|
||||||
linecache (= 0.43)
|
linecache (= 0.43)
|
||||||
mini_magick (= 3.2)
|
mini_magick (= 3.2)
|
||||||
|
mobile-fu
|
||||||
mongrel
|
mongrel
|
||||||
mysql2 (= 0.2.6)
|
mysql2 (= 0.2.6)
|
||||||
newrelic_rpm
|
newrelic_rpm
|
||||||
|
|
|
||||||
119
INSTALL_ON_OSX
119
INSTALL_ON_OSX
|
|
@ -1,119 +0,0 @@
|
||||||
#to make this work, run
|
|
||||||
#rake install --rakefile INSTALL_ON_OSX
|
|
||||||
|
|
||||||
require 'rake'
|
|
||||||
|
|
||||||
task :install do
|
|
||||||
puts "this currently is untested, prepare for tragedy"
|
|
||||||
|
|
||||||
puts "****************************************************************************"
|
|
||||||
puts "****************************** HELLO! *************************************"
|
|
||||||
puts "****************************************************************************"
|
|
||||||
puts ""
|
|
||||||
puts "We're going to install a ton of stuff to get Diaspora running on your box."
|
|
||||||
puts "Grab a tasty beverage - this might take a while. Then let's get started!"
|
|
||||||
print "Hit enter once you have a drink! "
|
|
||||||
input = STDIN.gets
|
|
||||||
|
|
||||||
BREW_INSTALLED = installed?('brew')
|
|
||||||
RVM_INSTALLED = installed?('rvm')
|
|
||||||
MYSQL_INSTALLED = installed?('mysql')
|
|
||||||
REDIS_INSTALLED = installed?('redis-server')
|
|
||||||
IMAGEMAGICK_INSTALLED = installed?('mogrify')
|
|
||||||
XCODE_INSTALLED = installed?('gcc')
|
|
||||||
|
|
||||||
unless XCODE_INSTALLED
|
|
||||||
puts "Sadly, you need to install XCode before running this script. :("
|
|
||||||
puts "You can get it from your OSX install DVD, or download it from Apple's developer page."
|
|
||||||
Process.exit
|
|
||||||
end
|
|
||||||
puts "Hooray! You have XCode already!"
|
|
||||||
|
|
||||||
unless BREW_INSTALLED
|
|
||||||
puts "Installing homebrew..."
|
|
||||||
system("ruby -e \"$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)\"")
|
|
||||||
end
|
|
||||||
system("brew update")
|
|
||||||
puts "homebrew is installed. Great job!"
|
|
||||||
|
|
||||||
unless RVM_INSTALLED
|
|
||||||
puts "Installing rvm..."
|
|
||||||
system("curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer ; chmod +x rvm-installer ; ./rvm-installer")
|
|
||||||
system("echo '[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && . \"$HOME/.rvm/scripts/rvm\" # Load RVM function' >> ~/.bash_profile")
|
|
||||||
system("rm rvm-installer")
|
|
||||||
if `. ~/.bash_profile; type rvm | head -1` != "rvm is a function\n"
|
|
||||||
puts "Meh, rvm install failed. Come talk to us in irc, at http://webchat.freenode.net/?channels=diaspora"
|
|
||||||
Process.exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
puts "rvm is installed. Great job!"
|
|
||||||
|
|
||||||
puts "Installing ruby enterprise edition (ree)..."
|
|
||||||
system(". ~/.bash_profile; rvm install ree")
|
|
||||||
$stdout.flush
|
|
||||||
|
|
||||||
puts "Setting up your gemset and .rvmrc..."
|
|
||||||
system(". ~/.bash_profile; rvm use ree; rvm gemset create diaspora")
|
|
||||||
system("echo 'rvm use ree@diaspora' >> .rvmrc")
|
|
||||||
puts "Done installing ree, creating gemset, and setting up .rvmrc!"
|
|
||||||
|
|
||||||
unless IMAGEMAGICK_INSTALLED
|
|
||||||
puts 'Installing imagemagick...'
|
|
||||||
system("brew install imagemagick")
|
|
||||||
end
|
|
||||||
puts 'imagemagick is installed. Great job!'
|
|
||||||
|
|
||||||
unless MYSQL_INSTALLED
|
|
||||||
puts 'Installing mysql...'
|
|
||||||
system("brew install mysql")
|
|
||||||
puts 'Configuring for first time use. Type in your Mac password when it asks.'
|
|
||||||
system("unset TMPDIR")
|
|
||||||
system("sudo mysql_install_db --verbose --user=`whoami` --basedir=\"$(brew --prefix mysql)\" --datadir=/usr/local/var/mysql --tmpdir=/tmp")
|
|
||||||
system("mkdir -p ~/Library/LaunchAgents")
|
|
||||||
plist_file = `brew list mysql | grep plist`.strip
|
|
||||||
system("cp #{plist_file} ~/Library/LaunchAgents/com.mysql.mysqld.plist")
|
|
||||||
system("launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist")
|
|
||||||
end
|
|
||||||
puts 'mysql is installed. Great job!'
|
|
||||||
|
|
||||||
unless REDIS_INSTALLED
|
|
||||||
puts 'Installing redis...'
|
|
||||||
system("brew install redis")
|
|
||||||
end
|
|
||||||
puts 'redis is installed. Great job!'
|
|
||||||
|
|
||||||
puts 'Installing bundler...'
|
|
||||||
system(". ~/.bash_profile; rvm use ree@diaspora; gem install bundler")
|
|
||||||
puts 'bundler is installed. Great Job!'
|
|
||||||
|
|
||||||
puts 'Installing diaspora gems...'
|
|
||||||
system(". ~/.bash_profile; rvm use ree@diaspora; bundle install")
|
|
||||||
|
|
||||||
puts "Creating and migrating your database..."
|
|
||||||
system(". ~/.bash_profile; rvm use ree@diaspora; rake db:create; rake db:migrate")
|
|
||||||
|
|
||||||
puts "Setting up your default app configuration..."
|
|
||||||
system("cp config/app_config.yml.example config/app_config.yml")
|
|
||||||
|
|
||||||
puts "Setting up your default database configuration..."
|
|
||||||
system("cp config/database.yml.example config/database.yml")
|
|
||||||
|
|
||||||
puts "****************************************************************************"
|
|
||||||
puts "***************************** CONGRATS! ***********************************"
|
|
||||||
puts "****************************************************************************"
|
|
||||||
puts ""
|
|
||||||
puts "Everything is installed! How was that beer?"
|
|
||||||
puts "Run the following commands to start up the Diaspora server:"
|
|
||||||
puts ""
|
|
||||||
puts "source ~/.bash_profile"
|
|
||||||
puts "cd .."
|
|
||||||
puts "cd diaspora"
|
|
||||||
puts "script/server"
|
|
||||||
puts ""
|
|
||||||
puts "Next time, all you'll need to do is script/server."
|
|
||||||
puts "Once you've started script/server, visit your local Diaspora in your browser at http://localhost:3000"
|
|
||||||
end
|
|
||||||
|
|
||||||
def installed?(program)
|
|
||||||
`which #{program}`=='' ? false : true
|
|
||||||
end
|
|
||||||
46
Termfile
46
Termfile
|
|
@ -1,46 +0,0 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
# If you do
|
|
||||||
# terminitor start
|
|
||||||
# from the Diaspora root directory, it will open a new terminal window with
|
|
||||||
# 3 tabs: redis, resque, and jasmine.
|
|
||||||
#
|
|
||||||
# You need to install the terminitor gem. It's not in the Gemfile because it
|
|
||||||
# causes problems on some flavors of linux.
|
|
||||||
# gem install terminitor
|
|
||||||
#
|
|
||||||
# You should set REDIS_ROOT before running terminitor start.
|
|
||||||
# You might want to do that in your .bash_profile.
|
|
||||||
# export REDIS_ROOT=/full/path/to/redis/without/the/bin
|
|
||||||
# You can also set DIASPORA_ROOT in a similar way if you don't want it to be
|
|
||||||
# the directory this file is in.
|
|
||||||
#
|
|
||||||
# This will run on OS X and KDE.
|
|
||||||
|
|
||||||
def get_var_for(env_var_name)
|
|
||||||
if ENV[env_var_name].nil? || ENV[env_var_name].strip == ""
|
|
||||||
File.dirname(__FILE__)
|
|
||||||
else
|
|
||||||
ENV[env_var_name]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
before { system "sudo ls" } # this ensures redis can start right away
|
|
||||||
|
|
||||||
window do
|
|
||||||
tab :name => "redis" do
|
|
||||||
run "cd #{get_var_for('REDIS_ROOT')}"
|
|
||||||
run "sudo ./bin/redis-server"
|
|
||||||
end
|
|
||||||
tab :name => "resque" do
|
|
||||||
run "cd #{get_var_for('DIASPORA_ROOT')}"
|
|
||||||
run "QUEUE=* rake resque:work"
|
|
||||||
end
|
|
||||||
tab :name => "jasmine" do
|
|
||||||
run "cd #{get_var_for('DIASPORA_ROOT')}"
|
|
||||||
run "rake jasmine"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
@localserver
|
|
||||||
Feature: Flexible uri deployment
|
|
||||||
To make it possible to use Diaspora on small home servers,
|
|
||||||
which might house also other sw, it should be possible to deploy
|
|
||||||
diaspora on a sub-uri such as http://example.org/diaspora.
|
|
||||||
|
|
||||||
Scenario: Serve webfinger request
|
|
||||||
Given configuration parameter pod_url is http://localhost:3000/diaspora
|
|
||||||
When I retrieve http://localhost:3000/.well-known/host-meta into tmp/host-meta
|
|
||||||
Then I should find 'http://localhost:3000/diaspora/webfinger?q={uri}' in tmp/host-meta
|
|
||||||
|
|
||||||
Scenario: Present application to user
|
|
||||||
Given configuration parameter pod_url is http://localhost:3000/diaspora
|
|
||||||
When I visit url http://localhost:3000/diaspora
|
|
||||||
And I retrieve http://localhost:3000/diaspora into tmp/index.html
|
|
||||||
Then I should see "put something in"
|
|
||||||
And a page-asset should be http://localhost:3000/diaspora/stylesheets/ui.css
|
|
||||||
And I should match 'http://localhost:3000/diaspora/stylesheets/blueprint/print.css.[0-9]+"' in tmp/index.html
|
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ begin
|
||||||
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
||||||
t.fork = true # You may get faster startup if you set this to false
|
t.fork = true # You may get faster startup if you set this to false
|
||||||
t.profile = 'default'
|
t.profile = 'default'
|
||||||
cucumber_opts = "--exclude features/uri-tests/*"
|
cucumber_opts = ""
|
||||||
cucumber_opts << " -f pretty" unless ENV["CI"] || ENV["TRAVIS"]
|
cucumber_opts << " -f pretty" unless ENV["CI"] || ENV["TRAVIS"]
|
||||||
cucumber_opts << " --tags ~@no-ci" if ENV["CI"] || ENV["TRAVIS"]
|
cucumber_opts << " --tags ~@no-ci" if ENV["CI"] || ENV["TRAVIS"]
|
||||||
t.cucumber_opts = cucumber_opts
|
t.cucumber_opts = cucumber_opts
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
system('bundle install --gemfile ./Gemfile && rspec spec')
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
|
||||||
if vendored_cucumber_bin
|
|
||||||
load File.expand_path(vendored_cucumber_bin)
|
|
||||||
else
|
|
||||||
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
|
||||||
require 'cucumber'
|
|
||||||
load Cucumber::BINARY
|
|
||||||
end
|
|
||||||
113
vendor/plugins/mobile-fu/CHANGELOG
vendored
113
vendor/plugins/mobile-fu/CHANGELOG
vendored
|
|
@ -1,113 +0,0 @@
|
||||||
commit a46e0d5ff0a95407bbd8f3437a372ced53d90c9b
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Sat Dec 20 20:59:49 2008 -0500
|
|
||||||
|
|
||||||
Added a helper method to determine if a device is JavaScript enabled and one to output the XHTML Mobile 1.0 doctype
|
|
||||||
|
|
||||||
commit f4b29b2e2c68a79b8904dddb7a91efd4341540ee
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Sun Sep 21 21:39:10 2008 -0400
|
|
||||||
|
|
||||||
Fixes issue with 'in_mobile_view' instead of 'is_mobile_view' helper method
|
|
||||||
|
|
||||||
commit 29e8e8b407dd3dc8d5f3248183223d11c6a78843
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Wed Sep 10 12:51:12 2008 -0400
|
|
||||||
|
|
||||||
Updating CHANGELOG
|
|
||||||
|
|
||||||
commit 0aac5bd7f0d2f71e6af7b144a04a18dad9f5aca5
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Wed Sep 10 12:50:50 2008 -0400
|
|
||||||
|
|
||||||
Styling overrides for iPods
|
|
||||||
|
|
||||||
commit f30c97c794ba74e737856aa9226328469c8395b6
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Mon Sep 8 00:07:27 2008 -0400
|
|
||||||
|
|
||||||
Adding in some comments to the latest changes
|
|
||||||
|
|
||||||
commit 78dae861e46d383356d7e4d6dfdaefbf60072e27
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Mon Sep 8 00:06:16 2008 -0400
|
|
||||||
|
|
||||||
Updating README
|
|
||||||
|
|
||||||
commit 1a66ccd2142e387f6d3138acb688a58df4687fcd
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Mon Sep 8 00:05:48 2008 -0400
|
|
||||||
|
|
||||||
Adding in a helper method to check for a specific mobile device and adding in 'ipod' to the list of mobile user agents
|
|
||||||
|
|
||||||
commit cbb26fff3287e16a757ee2aed2dcc8e98cbfb369
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Aug 22 22:16:19 2008 -0400
|
|
||||||
|
|
||||||
Updating the CHANGELOG
|
|
||||||
|
|
||||||
commit ee49945b593b1c55bf546da1d595a0941d071f94
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Aug 22 22:16:00 2008 -0400
|
|
||||||
|
|
||||||
Updating README
|
|
||||||
|
|
||||||
commit 02c12a8563466f7cef6aba8e53915dc2efec908c
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Mon Aug 18 16:08:51 2008 -0400
|
|
||||||
|
|
||||||
Adding in support for Android
|
|
||||||
|
|
||||||
commit 2dffa5958905c0419288d03a0650127a0734b41a
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Sat Jul 26 14:08:56 2008 -0400
|
|
||||||
|
|
||||||
Adding in other phone user agents, including some Japanese and French manufacturers
|
|
||||||
|
|
||||||
commit e8f9f1a9c2e668d639690f4f1beb4f701f742cfa
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 11:15:52 2008 -0400
|
|
||||||
|
|
||||||
Adding in CHANGELOG
|
|
||||||
|
|
||||||
commit a3122b40c0c722b2942e9cb5341614d0e0d834a5
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 11:14:35 2008 -0400
|
|
||||||
|
|
||||||
Changes to README
|
|
||||||
|
|
||||||
commit 64a24e36b6a770757963eb2d961262fb8a14ec1b
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 11:10:40 2008 -0400
|
|
||||||
|
|
||||||
Quick fix
|
|
||||||
|
|
||||||
commit 116fa5b7c1168471cf56cb9961b98f0b73fc3308
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 10:04:41 2008 -0400
|
|
||||||
|
|
||||||
Fixed issue with mobile view session variable getting set incorrectly, when forcing mobile format
|
|
||||||
|
|
||||||
commit d172665c9d0458801fd672076e269a3c0ee9d80d
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 01:04:19 2008 -0400
|
|
||||||
|
|
||||||
Adding in more MIT license goodness
|
|
||||||
|
|
||||||
commit a6c947d684d2d9abdbe354dc1ea757f23cd5a633
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 01:00:55 2008 -0400
|
|
||||||
|
|
||||||
Change to the README
|
|
||||||
|
|
||||||
commit dad4f4db1f3cb816283069a91c01982c953ff8a5
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 01:00:16 2008 -0400
|
|
||||||
|
|
||||||
Change to the README
|
|
||||||
|
|
||||||
commit c5ec9de6ef19e48a66917d8f6f3a59771295765b
|
|
||||||
Author: Brendan G. Lim <brendan@intridea.com>
|
|
||||||
Date: Fri Jul 18 00:59:36 2008 -0400
|
|
||||||
|
|
||||||
Releasing Mobile Fu to the world
|
|
||||||
20
vendor/plugins/mobile-fu/MIT-LICENSE
vendored
20
vendor/plugins/mobile-fu/MIT-LICENSE
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
99
vendor/plugins/mobile-fu/README.rdoc
vendored
99
vendor/plugins/mobile-fu/README.rdoc
vendored
|
|
@ -1,99 +0,0 @@
|
||||||
= Mobile Fu
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
== Rails 3 Compatibility
|
|
||||||
|
|
||||||
The master branch of this plugin is Rails 3 compatible.
|
|
||||||
|
|
||||||
To use the Rails 3 compatible version of this plugin, please install it like so:
|
|
||||||
|
|
||||||
rails plugin install git://github.com/brendanlim/mobile-fu.git
|
|
||||||
|
|
||||||
== Rails 2 Compatibility
|
|
||||||
|
|
||||||
You will need to install this plugin from the 2.x branch.
|
|
||||||
|
|
||||||
To use the Rails 2 compatible version of this plugin, please install it like so:
|
|
||||||
|
|
||||||
script/plugin install git://github.com/brendanlim/mobile-fu.git -r 2.x
|
|
||||||
|
|
||||||
== Usage
|
|
||||||
|
|
||||||
Add this this one line to the controller.
|
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
|
||||||
has_mobile_fu
|
|
||||||
end
|
|
||||||
|
|
||||||
Once this is in place, any request that comes from a mobile device will be be
|
|
||||||
set as :mobile format. It is up to you to determine how you want to handle
|
|
||||||
these requests. It is also up to you to create the .mobile.erb versions of
|
|
||||||
your views that are to be requested.
|
|
||||||
|
|
||||||
Then add the line below to config/initializers/mime_types.rb
|
|
||||||
|
|
||||||
Mime::Type.register_alias "text/html", :mobile
|
|
||||||
|
|
||||||
I recommend that you setup a before_filter that will redirect to a specific page
|
|
||||||
depending on whether or not it is a mobile request. How can you check this?
|
|
||||||
|
|
||||||
is_mobile_device? # => Returns true or false depending on the device
|
|
||||||
|
|
||||||
You can also determine which format is currently set in by calling the following:
|
|
||||||
|
|
||||||
is_mobile_view? # => Returns true or false depending on current req. format
|
|
||||||
|
|
||||||
Also, if you want the ability to allow a user to switch between 'mobile' and
|
|
||||||
'standard' format (:html), you can just adjust the mobile_view session variable
|
|
||||||
in a custom controller action.
|
|
||||||
|
|
||||||
session[:mobile_view] # => Set to true if request format is :mobile and false
|
|
||||||
if set to :html
|
|
||||||
|
|
||||||
So, different devices need different styling. Don't worry, we've got this
|
|
||||||
baked in to Mobile Fu.
|
|
||||||
|
|
||||||
If you are including a css or sass file via stylesheet_link_tag, all you have
|
|
||||||
to do is add _device to the name of one of your files to override your styling
|
|
||||||
for a certain device. The stylesheet that is loaded is dependant on which device
|
|
||||||
is making the request.
|
|
||||||
|
|
||||||
e.g., Accessing a page from a Blackberry.
|
|
||||||
|
|
||||||
... stylesheet_link_tag 'mobile.css' ...
|
|
||||||
|
|
||||||
This loads mobile.css, and mobile_blackberry.css if the file exists.
|
|
||||||
|
|
||||||
Supported stylesheet override device extensions at the moment are:
|
|
||||||
|
|
||||||
blackberry
|
|
||||||
iphone (iphone,ipod)
|
|
||||||
ipad
|
|
||||||
android
|
|
||||||
mobileexplorer
|
|
||||||
nokia
|
|
||||||
palm
|
|
||||||
|
|
||||||
The stylesheet awesomeness was derived from Michael Bleigh's browserized styles:
|
|
||||||
http://www.intridea.com/2007/12/9/announcing-browserized-styles
|
|
||||||
|
|
||||||
Inspiration for Mobile Fu came from Noel Rappin's rails_iui:
|
|
||||||
http://blogs.pathf.com/agileajax/2008/05/rails-developme.html
|
|
||||||
|
|
||||||
Hopefully this should help you create some awesome mobile applications.
|
|
||||||
|
|
||||||
== Testing Mobile Interface
|
|
||||||
|
|
||||||
If you want to force the mobile interface for testing, you can either use a
|
|
||||||
mobile device emulator, or you can pass 'true' to has_mobile_fu.
|
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
|
||||||
has_mobile_fu(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license
|
|
||||||
22
vendor/plugins/mobile-fu/Rakefile
vendored
22
vendor/plugins/mobile-fu/Rakefile
vendored
|
|
@ -1,22 +0,0 @@
|
||||||
require 'rake'
|
|
||||||
require 'rake/testtask'
|
|
||||||
require 'rake/rdoctask'
|
|
||||||
|
|
||||||
desc 'Default: run unit tests.'
|
|
||||||
task :default => :test
|
|
||||||
|
|
||||||
desc 'Test the sms_fu plugin.'
|
|
||||||
Rake::TestTask.new(:test) do |t|
|
|
||||||
t.libs << 'lib'
|
|
||||||
t.pattern = 'test/**/*_test.rb'
|
|
||||||
t.verbose = true
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Generate documentation for the sms_fu plugin.'
|
|
||||||
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
||||||
rdoc.rdoc_dir = 'rdoc'
|
|
||||||
rdoc.title = 'SmsFu'
|
|
||||||
rdoc.options << '--line-numbers' << '--inline-source'
|
|
||||||
rdoc.rdoc_files.include('README')
|
|
||||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
||||||
end
|
|
||||||
7
vendor/plugins/mobile-fu/init.rb
vendored
7
vendor/plugins/mobile-fu/init.rb
vendored
|
|
@ -1,7 +0,0 @@
|
||||||
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)
|
|
||||||
0
vendor/plugins/mobile-fu/install.rb
vendored
0
vendor/plugins/mobile-fu/install.rb
vendored
105
vendor/plugins/mobile-fu/lib/mobile_fu.rb
vendored
105
vendor/plugins/mobile-fu/lib/mobile_fu.rb
vendored
|
|
@ -1,105 +0,0 @@
|
||||||
module ActionController
|
|
||||||
module MobileFu
|
|
||||||
# These are various strings that can be found in mobile devices. Please feel free
|
|
||||||
# to add on to this list.
|
|
||||||
MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' +
|
|
||||||
'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' +
|
|
||||||
'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' +
|
|
||||||
'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' +
|
|
||||||
'webos|amoi|novarra|cdm|alcatel|pocket|iphone|mobileexplorer|' +
|
|
||||||
'mobile'
|
|
||||||
|
|
||||||
def self.included(base)
|
|
||||||
base.extend(ClassMethods)
|
|
||||||
end
|
|
||||||
|
|
||||||
module ClassMethods
|
|
||||||
|
|
||||||
# Add this to one of your controllers to use MobileFu.
|
|
||||||
#
|
|
||||||
# class ApplicationController < ActionController::Base
|
|
||||||
# has_mobile_fu
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# You can also force mobile mode by passing in 'true'
|
|
||||||
#
|
|
||||||
# class ApplicationController < ActionController::Base
|
|
||||||
# has_mobile_fu(true)
|
|
||||||
# end
|
|
||||||
|
|
||||||
def has_mobile_fu(test_mode = false)
|
|
||||||
include ActionController::MobileFu::InstanceMethods
|
|
||||||
|
|
||||||
if test_mode
|
|
||||||
before_filter :force_mobile_format
|
|
||||||
else
|
|
||||||
before_filter :set_mobile_format
|
|
||||||
end
|
|
||||||
|
|
||||||
helper_method :is_mobile_device?
|
|
||||||
helper_method :in_mobile_view?
|
|
||||||
helper_method :is_device?
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_mobile_device?
|
|
||||||
@@is_mobile_device
|
|
||||||
end
|
|
||||||
|
|
||||||
def in_mobile_view?
|
|
||||||
@@in_mobile_view
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_device?(type)
|
|
||||||
@@is_device
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module InstanceMethods
|
|
||||||
|
|
||||||
# Forces the request format to be :mobile
|
|
||||||
|
|
||||||
def force_mobile_format
|
|
||||||
request.format = :mobile
|
|
||||||
session[:mobile_view] = true if session[:mobile_view].nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
# Determines the request format based on whether the device is mobile or if
|
|
||||||
# the user has opted to use either the 'Standard' view or 'Mobile' view.
|
|
||||||
|
|
||||||
def set_mobile_format
|
|
||||||
if is_mobile_device? && ['/','text/html'].include?(request.format)
|
|
||||||
request.format = session[:mobile_view] == false ? :html : :mobile
|
|
||||||
session[:mobile_view] = true if session[:mobile_view].nil?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns either true or false depending on whether or not the format of the
|
|
||||||
# request is either :mobile or not.
|
|
||||||
|
|
||||||
def in_mobile_view?
|
|
||||||
request.format.to_sym == :mobile
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns either true or false depending on whether or not the user agent of
|
|
||||||
# the device making the request is matched to a device in our regex.
|
|
||||||
|
|
||||||
def is_mobile_device?
|
|
||||||
# hack for ipad
|
|
||||||
req = request.user_agent.to_s.downcase
|
|
||||||
req =~ Regexp.new(ActionController::MobileFu::MOBILE_USER_AGENTS) && !req.match('ipad')
|
|
||||||
end
|
|
||||||
|
|
||||||
# Can check for a specific user agent
|
|
||||||
# e.g., is_device?('iphone') or is_device?('mobileexplorer')
|
|
||||||
|
|
||||||
def is_device?(type)
|
|
||||||
request.user_agent.to_s.downcase.include?(type.to_s.downcase)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
ActionController::Base.send(:include, ActionController::MobileFu)
|
|
||||||
|
|
||||||
24
vendor/plugins/mobile-fu/lib/mobile_fu_helper.rb
vendored
24
vendor/plugins/mobile-fu/lib/mobile_fu_helper.rb
vendored
|
|
@ -1,24 +0,0 @@
|
||||||
module MobileFuHelper
|
|
||||||
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?('ipod') || is_device?('ipad') || is_device?('mobileexplorer') || is_device?('android')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ActionView::Base.send(:include, MobileFuHelper)
|
|
||||||
70
vendor/plugins/mobile-fu/lib/mobilized_styles.rb
vendored
70
vendor/plugins/mobile-fu/lib/mobilized_styles.rb
vendored
|
|
@ -1,70 +0,0 @@
|
||||||
# Copyright (c) 2008 Brendan G. Lim (brendan@intridea.com)
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
# a copy of this software and associated documentation files (the
|
|
||||||
# "Software"), to deal in the Software without restriction, including
|
|
||||||
# without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
# permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
# the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be
|
|
||||||
# included in all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
module MobilizedStyles
|
|
||||||
|
|
||||||
# This logic was taken from Michael Bleigh's browserized styles
|
|
||||||
# with modification to work for mobile browsers.
|
|
||||||
|
|
||||||
def user_agent_device_name
|
|
||||||
@user_agent_device_name ||= begin
|
|
||||||
|
|
||||||
ua = request.user_agent
|
|
||||||
return nil if ua.nil?
|
|
||||||
ua.downcase!
|
|
||||||
|
|
||||||
if ua.index('mobileexplorer') || ua.index('windows ce')
|
|
||||||
'mobileexplorer'
|
|
||||||
elsif ua.index('blackberry')
|
|
||||||
'blackberry'
|
|
||||||
elsif ua.index('iphone') || ua.index('ipod')
|
|
||||||
'iphone'
|
|
||||||
elsif ua.index('ipad')
|
|
||||||
'ipad'
|
|
||||||
elsif ua.index('android')
|
|
||||||
'android'
|
|
||||||
elsif ua.index('nokia')
|
|
||||||
'nokia'
|
|
||||||
elsif ua.index('palm')
|
|
||||||
'palm'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stylesheet_link_tag_with_mobilization(*sources)
|
|
||||||
mobilized_sources = Array.new
|
|
||||||
sources.each do |source|
|
|
||||||
subbed_source = source.to_s.gsub(".css","")
|
|
||||||
|
|
||||||
possible_sources = ["#{subbed_source.to_s}_#{user_agent_device_name}"]
|
|
||||||
|
|
||||||
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")
|
|
||||||
mobilized_sources << possible_source if File.exist?(path) || File.exist?(sass_path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
stylesheet_link_tag_without_mobilization(*mobilized_sources)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/spec_helper'
|
|
||||||
|
|
||||||
module ActionView
|
|
||||||
module Helpers
|
|
||||||
module AssetTagHelper
|
|
||||||
STYLESHEETS_DIR = "stylesheets"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe MobilizedStyles do
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
@view = mock(:ActionView)
|
|
||||||
@request = mock(:ActionRequest)
|
|
||||||
@view.extend(MobilizedStyles)
|
|
||||||
@view.stub!(:request).and_return(@request)
|
|
||||||
@request.stub!(:user_agent)
|
|
||||||
end
|
|
||||||
|
|
||||||
def ua(str)
|
|
||||||
@request.stub!(:user_agent).and_return(str)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "will include a mobilized css file if it recognizes a string in the user agent" do
|
|
||||||
ua "iphone"
|
|
||||||
File.should_receive(:exist?).with("stylesheets/style_iphone.css").and_return(true)
|
|
||||||
@view.should_receive(:stylesheet_link_tag_without_mobilization).with("style", "style_iphone")
|
|
||||||
@view.stylesheet_link_tag_with_mobilization("style")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "includes mobiziled css files whether or not the original call to stylesheet_link_tag used a file extension" do
|
|
||||||
ua "blackberry"
|
|
||||||
File.should_receive(:exist?).with("stylesheets/style_blackberry.css").and_return(true)
|
|
||||||
@view.should_receive(:stylesheet_link_tag_without_mobilization).with("style.css", "style_blackberry")
|
|
||||||
@view.stylesheet_link_tag_with_mobilization("style.css")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
0
vendor/plugins/mobile-fu/spec/spec.opts
vendored
0
vendor/plugins/mobile-fu/spec/spec.opts
vendored
1
vendor/plugins/mobile-fu/spec/spec_helper.rb
vendored
1
vendor/plugins/mobile-fu/spec/spec_helper.rb
vendored
|
|
@ -1 +0,0 @@
|
||||||
require File.dirname(__FILE__) + "/../lib/mobilized_styles"
|
|
||||||
0
vendor/plugins/mobile-fu/uninstall.rb
vendored
0
vendor/plugins/mobile-fu/uninstall.rb
vendored
Loading…
Reference in a new issue