Skip to content

Commit

Permalink
Post Rails 3.0.12 upgrade fixups
Browse files Browse the repository at this point in the history
- Clean up layouts
- Clean up views/{home,projects}
- Clean up helpers
- Clean up views/settings
- Clean up views/{shared,usage,users}
- Collapse Mockr lib into ApplicationController
 - The Mockr module consisted solely of unclaimed?, so I just collapsed it down
   into ApplicationController. Cleaned up references in associated templates and
   controllers.
- Update mock mailers
 - moves mock related mailers into mock_mailer from notifier
 - update the gmail_smtp settings for the new Rails 3.0 configuration settings
 - change default sending email address to use the specified domain name
- Fix jquery javascript_include_tags
- Fix deprecated error_message_on
- Fix library includes
 - Locally, the development server was dealing with `require 'lib/*'`
   gracefully, but Heroku is being complainy. This commit removes the 'lib/'
   prefix.

Change-Id: I0dafcc65fe3d21eb67d4395fa532d098ae05de65
Reviewed-on: https://gerrit.causes.com/5291
Reviewed-by: Adam Derewecki <adam@causes.com>
Tested-by: Adam Derewecki <adam@causes.com>
  • Loading branch information
Adam Derewecki & Lann Martin authored and Adam Derewecki committed Apr 14, 2012
1 parent b902620 commit 19c9d07
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -9,6 +9,6 @@ group :production do
gem 'pg'
end

gem 'aws-s3', :require => 'aws/s3'
gem 'aws-sdk', :require => 'aws/s3'
gem 'tinder'
gem 'paperclip'
18 changes: 12 additions & 6 deletions Gemfile.lock
Expand Up @@ -30,10 +30,11 @@ GEM
activesupport (3.0.12)
addressable (2.2.7)
arel (2.0.10)
aws-s3 (0.6.2)
builder
mime-types
xml-simple
aws-sdk (1.4.0)
httparty (~> 0.7)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
builder (2.1.2)
cocaine (0.2.1)
erubis (2.6.6)
Expand All @@ -47,6 +48,9 @@ GEM
faraday (~> 0.7.3)
hashie (1.2.0)
http_parser.rb (0.5.3)
httparty (0.8.2)
multi_json
multi_xml
i18n (0.5.0)
json (1.6.6)
mail (2.2.19)
Expand All @@ -56,7 +60,9 @@ GEM
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.2.0)
multi_xml (0.4.2)
multipart-post (1.1.5)
nokogiri (1.5.2)
paperclip (2.7.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
Expand Down Expand Up @@ -107,13 +113,13 @@ GEM
http_parser.rb (~> 0.5.1)
simple_oauth (~> 0.1.4)
tzinfo (0.3.33)
xml-simple (1.0.12)
uuidtools (2.1.2)

PLATFORMS
ruby

DEPENDENCIES
aws-s3
aws-sdk
paperclip
pg
rails (= 3.0.12)
Expand Down
9 changes: 0 additions & 9 deletions README

This file was deleted.

52 changes: 52 additions & 0 deletions README.md
@@ -0,0 +1,52 @@
## Introduction
Mockr is a beautiful and fun app for managing mock-ups and images associate with
a project. Mockr supports commenting on selections of the mock to enable a
discussion on the topic.

## Setup - on Heroku
Choose a mockr name -- the app will be at http://$mockrname.heroku.com/
Accounts to set up:

- Facebook (facebook.com/developers)
- Sign up for an app and set your app domain to $mockrname.heroku.comA
- You'll need your app_id and key (same) and secret key
- Amazon Web Services S3 (aws.amazon.com)
- You'll need your access_key and secret_key
- GMail account for notification emails (gmail.com)
- You'll need your username and password (and domain if it's not @gmail.com)

```bash
git clone git@github.com:causes/mockr.git
bundle install
bundle exec rake db:migrate
heroku create $mockrname
heroku rake db:migrate
heroku config:add \
GMAIL_SMTP_USER='username' \
GMAIL_SMTP_PASSWORD='password' \
GMAIL_SMTP_DOMAIN='domain.com' \
INSTANCE_NAME="$mockrname" \
AWS_S3_ACCESS_KEY_ID='access_key' \
AWS_S3_SECRET_ACCESS_KEY='secret_key' \
FB_APP_ID=000000000000000 \
FB_KEY=000000000000000 \
FB_SECRET=00000000000000000000000000000000
git push heroku master
```

## Setup - custom server
Same steps as above except for the commands with heroku in them. To launch a
local web server, you need to set the environment variables:

```bash
GMAIL_SMTP_USER='username' \
GMAIL_SMTP_PASSWORD='password' \
GMAIL_SMTP_DOMAIN='domain.com' \
INSTANCE_NAME="$mockrname" \
AWS_S3_ACCESS_KEY_ID='access_key' \
AWS_S3_SECRET_ACCESS_KEY='secret_key' \
FB_APP_ID=000000000000000 \
FB_KEY=000000000000000 \
FB_SECRET=00000000000000000000000000000000 \
bundle exec rails server
```
8 changes: 7 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base

protect_from_forgery

require 'lib/authentication'
require 'authentication'
include Authentication
helper_method :viewer

Expand All @@ -25,4 +25,10 @@ def require_authorization
redirect_to new_session_path(:next_url => request.path)
end
end

helper_method :unclaimed?
def unclaimed?
User.count == 0
end

end
5 changes: 2 additions & 3 deletions app/controllers/claim_controller.rb
@@ -1,10 +1,8 @@

class ClaimController < ApplicationController

skip_before_filter :require_authorization

def index
if Mockr.unclaimed? && viewer.authenticated?
if unclaimed? && viewer.authenticated?
graph_data = ActiveSupport::JSON.decode(Net::HTTP.get(
'graph.facebook.com', "/#{viewer.facebook_uid}"))
owner = User.create(:facebook_uid => viewer.facebook_uid,
Expand All @@ -18,4 +16,5 @@ def index
redirect_to new_session_path
end
end

end
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
@@ -1,12 +1,12 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def format_text(text)
text = nl2br(text)
auto_link(text, :all, :target => "_blank")
text = nl2br(h text)
auto_link(text, :all, :target => "_blank").html_safe
end

def nl2br(text)
text.gsub(/\r\n?/, "\n").gsub(/\n/, '<br />')
text.gsub(/\r\n?/, "\n").gsub(/\n/, '<br />').html_safe
end

def fbml_plain_name(user, options={})
Expand All @@ -21,11 +21,11 @@ def fbml_plain_name(user, options={})
options = default_options.merge(options)
attributes = options.map{|pair| pair.join('=')}.join(' ')

"<fb:name #{attributes}></fb:name>"
"<fb:name #{attributes}></fb:name>".html_safe
end

def login_button
"<fb:login-button size='large'>Login with Facebook</fb:login-button>"
"<fb:login-button size='large'>Login with Facebook</fb:login-button>".html_safe
end

def logout_link(text)
Expand Down
18 changes: 6 additions & 12 deletions app/models/notifier.rb → app/mailers/mock_mailer.rb
@@ -1,24 +1,18 @@
class Notifier < ActionMailer::Base
helper ApplicationHelper

# TODO: fix this
REPLY_TO = "do-not-reply@causes.com"
class MockMailer < ActionMailer::Base
default :from => "no-reply@#{ActionMailer::Base.smtp_settings[:domain]}"

def new_comment(comment)
from REPLY_TO
reply_to REPLY_TO
subject comment.mock.default_subject
recipients comment.recipient_emails
content_type "text/html"
body :comment => comment
end

@comment = comment
body
end

def new_mock(mock, recipients = nil)
host = self.class.default_url_options[:host]

from REPLY_TO
recipients ||= Setting[:notification_email]
reply_to REPLY_TO
subject mock.default_subject
recipients recipients
attachment :body => mock.attachment_body,
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Expand Up @@ -6,8 +6,8 @@
<link rel="shortcut icon" href="/images/feelings/happy.gif" />
<%= stylesheet_link_tag "base", "shared/buttons", "shared/progress",
"layouts/application" %>
<%= javascript_include_tag
"//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" %>
<%= javascript_include_tag(
"//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js") %>
<%= javascript_include_tag "user",
"scrollto",
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/mocks/show.html.erb
Expand Up @@ -5,8 +5,8 @@
<link rel="shortcut icon" href="/images/feelings/happy.gif" />
<%= stylesheet_link_tag "base", "shared/progress", "layouts/application" %>
<%= javascript_include_tag
"//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" %>
<%= javascript_include_tag(
"//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js") %>
<%= javascript_include_tag "user",
"scrollto",
"plugins/jquery.form",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/views/mocks/_add_feedback_form.html.erb
Expand Up @@ -18,7 +18,7 @@
:collection => Comment.basic_feelings,
:locals => {:f => f} %>
<% if viewer.awards.any? %>
<li><%= link_to_function "More&hellip;",
<li><%= link_to_function raw("More&hellip;"),
"$('#advanced_feelings').slideToggle();", :tabindex => -1 %></li>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mocks/_child_comment.html.erb
Expand Up @@ -3,7 +3,7 @@
<%= format_text(child.text) %>
</div>
<div class="meta">
<%=h child.author.first_name %>,
<%= child.author.first_name %>,
<span
title="<%=
child.created_at.strftime("%b %e, %l:%M%p").squish %>"><%=
Expand Down
6 changes: 5 additions & 1 deletion app/views/projects/new.html.erb
Expand Up @@ -7,7 +7,11 @@
<div class="field_row">
<%= f.label :title, "Name" %><br />
<%= f.text_field :title %><br />
<%= f.error_message_on :title, "The project name " %>
<% if errors = @project.try(:errors) %>
<div class="formError">
<%= "Title #{errors[:title]}" if errors[:title] %>
</div>
<% end %>
<%= f.submit "Create Project" %> or <%= link_to "Cancel", home_url %>
</div>
<%- end -%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/new.html.erb
Expand Up @@ -16,7 +16,7 @@
<%= image_tag("intro.png") %><br />
<% if viewer.authenticated? %>
<% if Mockr.unclaimed? %>
<% if unclaimed? %>
Hi <%= fbml_plain_name(viewer, :firstnameonly => false) %>.
<%= button_to("Claim this!", claim_path) %>
<% else %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/settings/campfire.html.erb
Expand Up @@ -13,25 +13,25 @@
} %>

<div id="tabbed_content">
<% form_tag update_campfire_settings_path, :method => :put,
<%= form_tag update_campfire_settings_path, :method => :put,
:id => "campfire_form" do %>
<div class="field_row">
<%= label_tag "campfire_subdomain", "Subdomain:" %><br />
<%= text_field_tag "campfire_subdomain",
@campfire_settings["campfire_subdomain"] %>.campfirenow.com
</div>

<div class="field_row">
<%= label_tag "campfire_token", "Token:" %><br />
<%= text_field_tag "campfire_token", @campfire_settings["campfire_token"]
%>
</div>

<div class="field_row">
<%= label_tag "campfire_room", "Room Name:" %><br />
<%= text_field_tag "campfire_room", @campfire_settings["campfire_room"] %>
</div>

<div class="field_row">
<%= submit_tag %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/settings/email.html.erb
Expand Up @@ -13,7 +13,7 @@
} %>

<div id="tabbed_content">
<% form_for :setting, @setting, :url => setting_path(@setting),
<%= form_for :setting, @setting, :url => setting_path(@setting),
:html => {:method => :put} do |f| %>
<%= f.hidden_field :key %>
<%= f.label :value, "Deliver group email notifications to:" %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_flash.html.erb
@@ -1,6 +1,6 @@
<% if !flash[:notice].blank? %>
<% if flash[:notice].present? %>
<div id="notice">
<%= link_to "x", "#", :class => "hide_link" %>
<%= flash[:notice] %>
<%= raw(flash[:notice]) %>
</div>
<% end %>
5 changes: 2 additions & 3 deletions app/views/shared/_new_mock_form.html.erb
@@ -1,9 +1,8 @@
<% form_for :mock, :url => mocks_path, :html => {:multipart => true,
<%= form_for :mock, :url => mocks_path, :html => {:multipart => true,
:id => "mock_creation_form", :class => "fullscreen"} do |f| %>
<%= f.hidden_field :path, :value => "" %>
<%= f.hidden_field :author_id, :value => viewer.id %>
<input type="file" name="images[]" id='file' multiple
style="display: none" />
<input type="file" name="images[]" id='file' multiple style="display: none" />
<% if @project %>
<%= hidden_field_tag :project_id, @project.id %>
<% end %>
Expand Down
8 changes: 3 additions & 5 deletions app/views/shared/_subnav.html.erb
Expand Up @@ -3,11 +3,9 @@
<% if local_assigns[:links] %>
<ul class="clearfix">
<% links.each do |name, url| %>
<% if current_page?(url) %>
<li><%= link_to name, url, :class => "current" %></li>
<% else %>
<li><%= link_to name, url %></li>
<% end %>
<li>
<%= link_to name, url, :class => ("current" if current_page?(url)) %>
</li>
<% end %>
</ul>
<% end %>
Expand Down
12 changes: 6 additions & 6 deletions app/views/usage/index.html.erb
Expand Up @@ -6,14 +6,14 @@
</tr>
<% @users.each do |user| %>
<tr>
<td><%=h user.name %></td>
<td><%=h user.mocks.count %></td>
<td><%=h user.comments.count %></td>
<td><%= user.name %></td>
<td><%= user.mocks.count %></td>
<td><%= user.comments.count %></td>
</tr>
<% end %>
<tr>
<td><%=h User.count %></td>
<td><%=h Mock.count %></td>
<td><%=h Comment.count %></td>
<td><%= User.count %></td>
<td><%= Mock.count %></td>
<td><%= Comment.count %></td>
</tr>
</table>
4 changes: 2 additions & 2 deletions app/views/users/index.html.erb
Expand Up @@ -21,10 +21,10 @@
<% @users.each do |user| %>
<tr>
<td>
<%=h user.name %>
<%= user.name %>
</td>
<td>
<%=h user.facebook_uid %>
<%= user.facebook_uid %>
</td>
<td>
<%= user.email %>
Expand Down

0 comments on commit 19c9d07

Please sign in to comment.