Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
== Welcome to Rails

Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.
Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.

This pattern splits the view (also called the presentation) into "dumb" templates
that are primarily responsible for inserting pre-built data in between HTML tags.
Expand Down Expand Up @@ -57,14 +57,14 @@ Options +FollowSymLinks +ExecCGI

# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
#
# Example:
# RewriteCond %{REQUEST_URI} ^/notrails.*
# RewriteRule .* - [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
Expand All @@ -85,7 +85,7 @@ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
#
# Example:
# ErrorDocument 500 /500.html

Expand Down Expand Up @@ -132,7 +132,7 @@ and also on programming in general.

Debugger support is available through the debugger command when you start your Mongrel or
Webrick server with --debugger. This means that you can break out of execution at any point
in the code, investigate and change the model, AND then resume execution!
in the code, investigate and change the model, AND then resume execution!
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Example:

Expand Down
64 changes: 32 additions & 32 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ class ApplicationController < ActionController::Base


include AuthenticatedSystem

# Scrub sensitive parameters from your log
filter_parameter_logging :password, :confirm_password

before_filter :host_check if ENV["RAILS_ENV"] == 'production'
before_filter :session_user_agent_check
before_filter :set_locale
#before_filter :adjust_format_for_iphone

#move this to different class?
def make_map(type='detail',satellite=false,world=false)
# Create a new map object, also defining the div ("map")
# Create a new map object, also defining the div ("map")
# where the map will be rendered in the view
@map_type = type.to_sym
case @map_type
Expand Down Expand Up @@ -47,7 +47,7 @@ def make_map(type='detail',satellite=false,world=false)
:height => 200
}
end


@map = {};
# ym4r/gm plugin api: http://ym4r.rubyforge.org/ym4r_gm-doc/
Expand All @@ -56,44 +56,44 @@ def make_map(type='detail',satellite=false,world=false)
@map['zoom'] = 4
else
@map['zoom'] = 18

end
@map['zoom'] = 11 if world


if !@water_point.blank? && !@water_point.lat.blank? && !@water_point.lng.blank?
@map['lat'] = @water_point.lat
@map['lng'] = @water_point.lng
@map['zoom'] = 18

if (@map_type == :detail) or (@map_type == :search)
# @map.global_init(@map.enable_google_bar())
#note = @water_point.note.to_s.mb_chars.length > 160 ? @water_point.note.to_s.mb_chars[0,160].to_s+'...</a>' : @water_point.note;
note = @water_point.note

if @map_type == :detail
@map['marker_info'] = "<b>#{@water_point.title}</b><br/>#{note}"
else
#special case
photo = @template.photo_for(@water_point, :large)
@map['marker_info'] = "<div style='overflow:hidden'><b><a href='/#{@locale}/water_points/#{@water_point.id}'>#{@water_point.title}</a></b><br/>#{photo}<br/>"+t('thanks_to')+" <a href='/#{@locale}/users/#{@water_point.posted_by.id}'>#{@water_point.posted_by.login}</a></div>"
end


@map['marker_title'] = @water_point.title
### Bug in GM library? The following line should work, but instead generates an error:
#@map.icon_global_init(GIcon.new(:image => "/images/markers/lightblue.png"), "detail_icon")
### instead need to specify these other attribs as well, even though gmaps api doesn't require them!

### instead need to specify these other attribs as well, even though gmaps api doesn't require them!




#@map.icon_global_init(GIcon.new(:image => "/images/markers/lightblue.png", :icon_size => GSize.new(16,16),:icon_anchor => GPoint.new(8.0,8.0),:info_window_anchor => GPoint.new(8.0,8.0),:shadow => "/images/markers/shadow.png", :shadowSize => GSize.new(25.0,16.0)),"detail_icon")
#detail_icon = Variable.new("detail_icon")
#marker = GMarker.new([@water_point.lat,@water_point.lng],
#marker = GMarker.new([@water_point.lat,@water_point.lng],
# :title=> @water_point.title,
# :icon=> detail_icon
# )
#@map.declare_init(marker, "marker") #THANK YOU to this post: http://blog.odeley.com/?p=40
#@map.declare_init(marker, "marker") #THANK YOU to this post: http://blog.odeley.com/?p=40
#@map.overlay_init(marker)

###@map.record_init 'window.alert("foo "+detail_icon.image+" typeof "+typeof detail_icon+" mic "+marker.getIcon().image);'
Expand All @@ -104,7 +104,7 @@ def make_map(type='detail',satellite=false,world=false)
end
else
# Default center location. no auto open marker.
#@map.center_zoom_init([41.898,12.518],zoom)
#@map.center_zoom_init([41.898,12.518],zoom)
@map['lat'] = 41.898
@map['lng'] = 12.518
end
Expand All @@ -114,11 +114,11 @@ def make_map(type='detail',satellite=false,world=false)
#@map.record_init "window.WH_mgr = new MarkerManager(map);"#,:managed_markers => [managed_markers1,managed_markers2,managed_markers3])

# @map.declare_init(mm,"mgr")

@map['skip_id'] = @water_point.blank? ? '' : @water_point.id

#@map.record_init "WH_LoadMarkerFeed(map,window.WH_mgr,'all'"+skip_id+");"

# Thank you: http://www.daftlogic.com/sandbox-google-maps-centre-crosshairs.htm
crosshair_js = <<CROSSHAIR_JS_BLOCK
//var crosshairsSize=19;
Expand All @@ -145,14 +145,14 @@ def make_map(type='detail',satellite=false,world=false)
};

map.addCrosshairs();

//Extra stuff
google.maps.event.addListener(map,'bounds_changed',function() {
var center = map.getCenter();
$('water_point_lat').value = center.lat();
$('water_point_lng').value = center.lng();
});

//move this to server-side...
//populate w current center val if empty...
if (!($('water_point_lat').value && $('water_point_lng').value)) {
Expand All @@ -165,7 +165,7 @@ def make_map(type='detail',satellite=false,world=false)
end


protected
protected
def set_locale
if params[:locale].blank?
redirect_to :locale => 'en'
Expand All @@ -174,11 +174,11 @@ def set_locale
WillPaginate::ViewHelpers.pagination_options[:previous_label] = I18n.translate('previous')
WillPaginate::ViewHelpers.pagination_options[:next_label] = I18n.translate('next')
end

def is_megatron?
request.user_agent =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)\b/i
end
end

def session_user_agent_check
##################################################
#If user agent matches bot pattern
Expand Down Expand Up @@ -214,22 +214,22 @@ def admin_required
def adjust_format_for_iphone
# iPhone sub-comain request
# request.format = :iphone if iphone_subdomain?

# Detect from iPhone user-agent
# html and js (or whatever gets generated via xhr by iui OK. json no.)
request.format = :iphone if iphone_user_agent? and (request.format != :json)
end

def iphone_user_agent?
request.env["HTTP_USER_AGENT"] &&
request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/] &&
!request.env["HTTP_USER_AGENT"][/Ipad/]
end

def choose_layout
'main'
end

def choose_layout_OLD
if request.format == 'iphone'
#debugger
Expand All @@ -244,8 +244,8 @@ def choose_layout_OLD
'minimal'
end
else
'main'
end
'main'
end
end

end
8 changes: 4 additions & 4 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class CommentsController < ApplicationController

layout :choose_layout
before_filter :login_required, :except => [ :index, :show, ]

before_filter :login_required, :except => [ :index, :show, ]

# GET /comments
# GET /comments.xml
def index
Expand Down Expand Up @@ -55,7 +55,7 @@ def create
if @comment.save
flash[:notice] = 'Comment was successfully created.' unless request.xhr?
#format.html { redirect_to(@comment) }
format.any(:html,:iphone) { if request.xhr?
format.any(:html,:iphone) { if request.xhr?
render :partial => 'shared/comment', :locals => {:comment => @comment}
else
#remove this?
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/feedback_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class FeedbackController < ApplicationController
layout :choose_layout

def report
if params[:ref].blank?
params[:ref] = request.referrer
end
end

def deliver
comment = params[:comment]
email = params[:email]
Expand All @@ -26,9 +26,9 @@ def deliver
end
end
end

def thanks

end

end
10 changes: 5 additions & 5 deletions app/controllers/followers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class FollowersController < ApplicationController


before_filter :login_required, :except => [ :index, :show, ]
before_filter :login_required, :except => [ :index, :show, ]

def toggle

#Check whether already subscribed
params[:follower][:user_id] = @current_user.id
@follower = Follower.find_by_user_id_and_water_point_id(@current_user.id, params[:follower][:water_point_id])
Expand All @@ -25,14 +25,14 @@ def toggle
if save_attempt
format.any(:html,:iphone) { redirect_to('/') } #where to send?
format.xml { head :ok }
format.js { head :ok }
format.js { head :ok }
else
format.any(:html,:iphone) { redirect_to('/') } #where to send?
format.xml { render :xml => @follower.errors, :status => :unprocessable_entity }
format.js if request.xhr? { head :unprocessable_entity }
format.js if request.xhr? { head :unprocessable_entity }
end
end

end

end
10 changes: 5 additions & 5 deletions app/controllers/group_members_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class GroupMembersController < ApplicationController

before_filter :login_required, :except => [ :index, :show ]
before_filter :login_required, :except => [ :index, :show ]

def toggle

#Check whether already subscribed
params[:group_member][:user_id] = @current_user.id
@member = GroupMember.find_by_user_id_and_group_id(@current_user.id, params[:group_member][:group_id])
Expand All @@ -29,13 +29,13 @@ def toggle
format.js {
#get list of members. rjs template needs them.
@group = Group.find(params[:group_member][:group_id])
}#{ head :ok }
}#{ head :ok }
else
format.any(:html,:iphone) { redirect_to('/') } # error msg?
format.xml { render :xml => @member.errors, :status => :unprocessable_entity }
format.js if request.xhr? { head :unprocessable_entity }
format.js if request.xhr? { head :unprocessable_entity }
end
end

end
end
16 changes: 8 additions & 8 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class GroupsController < ApplicationController

layout :choose_layout

before_filter :login_required, :except => [ :index, :show ]
before_filter :admin_required, :only => [ :destroy ]
# GET /groups
Expand Down Expand Up @@ -50,7 +50,7 @@ def create




def message
@group = Group.find(params[:id])
# send message to all members.
Expand All @@ -72,8 +72,8 @@ def message
format.js #groups/message.rjs.js
end
end



##############The following methods are currently NOT USED. moved them to private so
##############that they cannot be accessed by accident. Once final page flow is confirmed,
Expand Down Expand Up @@ -108,12 +108,12 @@ def update
format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
end
end
end
end


# GET /groups/1/edit
def edit
@group = Group.find(params[:id])
end

end
Loading