Commit 292b1e74 authored by Jonne Hass's avatar Jonne Hass
Browse files

small cleanup

parent 7beb2bb7
bundler_args: "--without development,production"
bundler_args: "--without development production"
rvm:
- 1.8.7
......
......@@ -37,6 +37,7 @@ gem 'faraday-stack'
gem 'haml', '3.1.2'
gem 'sass', '3.1.4'
gem 'will_paginate', '3.0.pre2'
gem 'mobile-fu'
#Localization
gem 'rails-i18n'
......
......@@ -257,6 +257,9 @@ GEM
mixlib-cli (1.2.0)
mixlib-config (1.1.2)
mixlib-log (1.3.0)
mobile-fu (0.2.1)
rack-mobile-detect
rails
moneta (0.6.0)
mongrel (1.1.5)
cgi_multipart_eof_fix (>= 2.4)
......@@ -330,6 +333,8 @@ GEM
polyglot (0.3.2)
pyu-ruby-sasl (0.0.3.3)
rack (1.2.3)
rack-mobile-detect (0.3.0)
rack
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-openid (1.3.1)
......@@ -501,6 +506,7 @@ DEPENDENCIES
jwt (= 0.1.3)
linecache (= 0.43)
mini_magick (= 3.2)
mobile-fu
mongrel
mysql2 (= 0.2.6)
newrelic_rpm
......
#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
# 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
@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.fork = true # You may get faster startup if you set this to false
t.profile = 'default'
cucumber_opts = "--exclude features/uri-tests/*"
cucumber_opts = ""
cucumber_opts << " -f pretty" unless ENV["CI"] || ENV["TRAVIS"]
cucumber_opts << " --tags ~@no-ci" if ENV["CI"] || ENV["TRAVIS"]
t.cucumber_opts = cucumber_opts
......
#!/usr/bin/env ruby
system('bundle install --gemfile ./Gemfile && rspec spec')
#!/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
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
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.
= 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
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
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
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)