Skip to content

Commit 4722c1d

Browse files
committed
Initial import from ENTP repo. Hopefully no passwords in here ;)
1 parent 5f03c16 commit 4722c1d

File tree

1,113 files changed

+102328
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,113 files changed

+102328
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
log
2+
tmp

Capfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2+
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
3+
load 'config/deploy'

Rakefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5+
6+
require 'rake'
7+
require 'rake/testtask'
8+
require 'rake/rdoctask'
9+
10+
require 'tasks/rails'

app/concerns/latest_extension.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module LatestExtension
2+
def latest
3+
@__latest__ = (first || false) unless @__latest__ == false
4+
end
5+
end

app/controllers/application.rb

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Filters added to this controller apply to all controllers in the application.
2+
# Likewise, all the methods added will be available for all controllers.
3+
class ApplicationController < ActionController::Base
4+
cattr_accessor :host_name, :instance_writer => false
5+
6+
include AuthenticatedSystem
7+
include ExceptionNotifiable
8+
helper :all # include all helpers, all the time
9+
before_filter :set_host
10+
before_filter :adjust_format_for_iphone
11+
before_filter :set_timezone
12+
13+
# See ActionController::RequestForgeryProtection for details
14+
# Uncomment the :secret if you're not using the cookie session store
15+
protect_from_forgery # :secret => 'b26d74a5338fb7435501904f0451dc26'
16+
17+
helper_method :iphone_user_agent?, :browser_timezone
18+
19+
protected
20+
def iphone_user_agent?
21+
@iphone_user_agent ||= (request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/]) || :false
22+
@iphone_user_agent != :false
23+
end
24+
25+
# Set iPhone format if request to iphone.trawlr.com
26+
def adjust_format_for_iphone
27+
request.format = :iphone if iphone_user_agent?
28+
end
29+
30+
# The browsers give the # of minutes that a local time needs to add to
31+
# make it UTC, while TimeZone expects offsets in seconds to add to
32+
# a UTC to make it local.
33+
def browser_timezone
34+
return nil if cookies[:tzoffset].blank?
35+
@browser_timezone ||= begin
36+
min = cookies[:tzoffset].to_i
37+
TimeZone[(min + (-2 * min)).minutes]
38+
end
39+
end
40+
41+
def set_timezone
42+
if logged_in? && browser_timezone && browser_timezone.name != current_user.time_zone
43+
current_user.update_attribute(:time_zone, browser_timezone.name)
44+
end
45+
Time.zone = logged_in? ? current_user.time_zone : browser_timezone
46+
end
47+
48+
def set_host
49+
self.class.host_name = request.host
50+
end
51+
end
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
class ContextsController < ApplicationController
2+
before_filter :login_required, :except => :index
3+
before_filter :find_context, :except => :index
4+
5+
def index
6+
redirect_to root_path
7+
end
8+
9+
def show
10+
@statuses, @date_range = Status.filter(user_status_for(params[:user_id]), params[:filter] ||= :weekly, :context => @context, :date => params[:date], :page => params[:page], :per_page => params[:per]||20)
11+
@daily_hours = Status.filtered_hours(user_status_for(params[:user_id]), :daily, :context => @context, :date => params[:date])
12+
@hours = Status.filtered_hours(user_status_for(params[:user_id]), params[:filter], :context => @context, :date => params[:date])
13+
14+
user_ids = @statuses.map {|s| s.user.permalink }.uniq
15+
@user_hours = []
16+
user_ids.each do |user|
17+
hours = Status.filtered_hours(user_status_for(user), params[:filter], :date => params[:date], :context => @context)
18+
@user_hours << hours unless hours.empty?
19+
end
20+
# reset @user var. hack. omg.
21+
user_status_for(params[:user_id])
22+
23+
@context ||= Context.new :name => "etc"
24+
respond_to do |format|
25+
format.html # show.html.erb
26+
format.iphone
27+
format.xml { render :xml => @context }
28+
format.csv # show.csv.erb
29+
end
30+
end
31+
32+
def update
33+
@context.update_attributes params[:context]
34+
redirect_to context_path(@context)
35+
end
36+
37+
protected
38+
def find_context
39+
@context = current_user.contexts.find_by_permalink(params[:id]) unless params[:id].blank?
40+
end
41+
42+
def user_status_for(status)
43+
@user = status == 'me' ? current_user : User.find_by_permalink(status)
44+
@user ? @user.id : nil
45+
end
46+
end

app/controllers/feeds_controller.rb

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
class FeedsController < ApplicationController
2+
def index
3+
@feeds = Feed.all
4+
5+
respond_to do |format|
6+
format.html # index.html.erb
7+
format.xml { render :xml => @feeds }
8+
format.json { render :json => @feeds }
9+
end
10+
end
11+
12+
def show
13+
@feed = Feed.find(params[:id])
14+
15+
respond_to do |format|
16+
format.html # show.html.erb
17+
format.xml { render :xml => @feed }
18+
format.json { render :json => @feed }
19+
end
20+
end
21+
22+
def new
23+
@feed = Feed.new
24+
25+
respond_to do |format|
26+
format.html # new.html.erb
27+
format.xml { render :xml => @feed }
28+
format.json { render :json => @feed }
29+
end
30+
end
31+
32+
def create
33+
@feed = Feed.new(params[:feed])
34+
35+
respond_to do |format|
36+
if @feed.save
37+
flash[:notice] = 'Feed was successfully created.'
38+
format.html { redirect_to(@feed) }
39+
format.xml { render :xml => @feed, :status => :created, :location => @feed }
40+
format.json { render :json => @feed, :status => :created, :location => @feed }
41+
else
42+
format.html { render :action => "new" }
43+
format.xml { render :xml => @feed.errors, :status => :unprocessable_entity }
44+
format.json { render :json => @feed.errors, :status => :unprocessable_entity }
45+
end
46+
end
47+
end
48+
49+
def edit
50+
@feed = Feed.find(params[:id])
51+
end
52+
53+
def update
54+
@feed = Feed.find(params[:id])
55+
56+
respond_to do |format|
57+
if @feed.update_attributes(params[:feed])
58+
flash[:notice] = 'Feed was successfully updated.'
59+
format.html { redirect_to(@feed) }
60+
format.xml { head :ok }
61+
format.json { head :ok }
62+
else
63+
format.html { render :action => "edit" }
64+
format.xml { render :xml => @feed.errors, :status => :unprocessable_entity }
65+
format.json { render :json => @feed.errors, :status => :unprocessable_entity }
66+
end
67+
end
68+
end
69+
70+
def destroy
71+
@feed = Feed.find(params[:id])
72+
@feed.destroy
73+
74+
respond_to do |format|
75+
format.html { redirect_to(feeds_url) }
76+
format.xml { head :ok }
77+
format.json { head :ok }
78+
end
79+
end
80+
end

app/controllers/help_controller.rb

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
class HelpController < ApplicationController
2+
def index
3+
@help = Help.all
4+
5+
respond_to do |format|
6+
format.html # index.html.erb
7+
format.xml { render :xml => @help }
8+
format.json { render :json => @help }
9+
end
10+
end
11+
12+
def show
13+
@help = Help.find(params[:id])
14+
15+
respond_to do |format|
16+
format.html # show.html.erb
17+
format.xml { render :xml => @help }
18+
format.json { render :json => @help }
19+
end
20+
end
21+
22+
def new
23+
@help = Help.new
24+
25+
respond_to do |format|
26+
format.html # new.html.erb
27+
format.xml { render :xml => @help }
28+
format.json { render :json => @help }
29+
end
30+
end
31+
32+
def create
33+
@help = Help.new(params[:help])
34+
35+
respond_to do |format|
36+
if @help.save
37+
flash[:notice] = 'Help was successfully created.'
38+
format.html { redirect_to(@help) }
39+
format.xml { render :xml => @help, :status => :created, :location => @help }
40+
format.json { render :json => @help, :status => :created, :location => @help }
41+
else
42+
format.html { render :action => "new" }
43+
format.xml { render :xml => @help.errors, :status => :unprocessable_entity }
44+
format.json { render :json => @help.errors, :status => :unprocessable_entity }
45+
end
46+
end
47+
end
48+
49+
def edit
50+
@help = Help.find(params[:id])
51+
end
52+
53+
def update
54+
@help = Help.find(params[:id])
55+
56+
respond_to do |format|
57+
if @help.update_attributes(params[:help])
58+
flash[:notice] = 'Help was successfully updated.'
59+
format.html { redirect_to(@help) }
60+
format.xml { head :ok }
61+
format.json { head :ok }
62+
else
63+
format.html { render :action => "edit" }
64+
format.xml { render :xml => @help.errors, :status => :unprocessable_entity }
65+
format.json { render :json => @help.errors, :status => :unprocessable_entity }
66+
end
67+
end
68+
end
69+
70+
def destroy
71+
@help = Help.find(params[:id])
72+
@help.destroy
73+
74+
respond_to do |format|
75+
format.html { redirect_to(help_url) }
76+
format.xml { head :ok }
77+
format.json { head :ok }
78+
end
79+
end
80+
end
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class MembershipsController < ApplicationController
2+
before_filter :load_membership_and_project
3+
before_filter :login_required
4+
5+
def create
6+
@membership.save
7+
8+
respond_to do |format|
9+
format.js
10+
end
11+
end
12+
13+
def update
14+
@membership.update_attributes(params[:membership])
15+
respond_to do |format|
16+
format.html { redirect_to project_path(@project)}
17+
end
18+
end
19+
20+
def destroy
21+
@membership.destroy
22+
23+
respond_to do |format|
24+
format.js
25+
end
26+
end
27+
28+
protected
29+
def load_membership_and_project
30+
@membership = params[:id].blank? ? Membership.new(params[:membership]) : Membership.find(params[:id])
31+
@project = @membership.project
32+
end
33+
34+
def authorized?
35+
logged_in? && (admin? || @project.users.include?(current_user))
36+
end
37+
end

0 commit comments

Comments
 (0)