added rmagick and ruby number for heroku

This commit is contained in:
Connor Turland 2014-07-07 21:02:43 -04:00
parent e5ba207711
commit 96197130e1
15 changed files with 131 additions and 13 deletions

View file

@ -1,4 +1,5 @@
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.17'
@ -14,6 +15,10 @@ gem 'formtastic'
gem 'json'
gem 'rails3-jquery-autocomplete'
gem 'best_in_place'
gem 'paperclip'
gem 'aws-sdk'
#gem 'therubyracer' #optional
#gem 'rb-readline'
@ -29,6 +34,10 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end
group :production do #this is used on heroku
gem 'rmagick'
end
gem 'jquery-rails', '2.1.2'
# To use ActiveModel has_secure_password

View file

@ -29,6 +29,9 @@ GEM
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
arel (3.0.3)
aws-sdk (1.44.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
bcrypt (3.1.7)
bcrypt (3.1.7-x86-mingw32)
best_in_place (2.1.0)
@ -36,6 +39,10 @@ GEM
rails (~> 3.1)
builder (3.0.4)
cancan (1.6.10)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.4)
climate_control (>= 0.0.3, < 1.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@ -68,8 +75,18 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.6.0)
multi_json (1.10.0)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
nokogiri (1.6.2.1-x86-mingw32)
mini_portile (= 0.6.0)
orm_adapter (0.5.0)
paperclip (4.1.1)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
pg (0.17.1)
pg (0.17.1-x86-mingw32)
polyglot (0.3.4)
@ -129,6 +146,7 @@ PLATFORMS
x86-mingw32
DEPENDENCIES
aws-sdk
best_in_place
cancan
coffee-rails (~> 3.2.1)
@ -138,6 +156,7 @@ DEPENDENCIES
jbuilder (= 0.8.2)
jquery-rails (= 2.1.2)
json
paperclip
pg
rails (= 3.2.17)
rails3-jquery-autocomplete

View file

@ -62,8 +62,8 @@ class MapsController < ApplicationController
# GET maps/:id
def show
@current = current_user
@current = current_user
@map = Map.find(params[:id]).authorize_to_show(@current)
if not @map

View file

@ -69,7 +69,7 @@ class TopicsController < ApplicationController
@topic.permission = 'commons'
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode])
@topic.user = @user
#if being created on a map, set topic by default to whatever permissions the map is
if params[:topic][:map]
@map = Map.find(params[:topic][:map])

View file

@ -16,9 +16,6 @@ class UsersController < ApplicationController
@user = current_user
@user.attributes = params[:user]
#@m = params[:metacodes][:value]
#@user.settings.metacodes=@m.split(',')
@user.save
sign_in(@user, :bypass => true)

View file

@ -11,7 +11,24 @@ has_many :topics2, :through => :synapses1, :source => :topic2
has_many :mappings
has_many :maps, :through => :mappings
# This method associates the attribute ":image" with a file attachment
has_attached_file :image
#, styles: {
# thumb: '100x100>',
# square: '200x200#',
# medium: '300x300>'
#}
# Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
# This method associates the attribute ":image" with a file attachment
has_attached_file :audio
# Validate the attached audio is audio/wav, audio/mp3, etc
validates_attachment_content_type :audio, :content_type => /\Aaudio\/.*\Z/
def synapses
synapses1 + synapses2
end

View file

@ -11,13 +11,32 @@ has_many :mappings
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
attr_accessible :name, :email, :password, :password_confirmation, :code, :joinedwithcode, :remember_me
attr_accessible :name, :email, :image, :password, :password_confirmation, :code, :joinedwithcode, :remember_me
serialize :settings, UserPreference
validates_uniqueness_of :name # done by devise
validates_uniqueness_of :email # done by devise
# This method associates the attribute ":image" with a file attachment
has_attached_file :image, :styles => {
:thumb => ['100x100>', :png],
:square => ['200x200#', :png],
:round => ['200x200#', :png]
}, :convert_options => {:round => Proc.new{self.convert_options}}
# Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
def self.convert_options
trans = ''
trans << ' ( +clone -alpha extract '
trans << '-draw "fill black polygon 0,0 0,100 100,0 fill white circle 100,100 100,0" '
trans << '( +clone -flip ) -compose multiply -composite '
trans << '( +clone -flop ) -compose multiply -composite '
trans << ') -alpha off -compose copy_opacity -composite '
end
if ActiveRecord::Base.connection.table_exists? 'users'
codes = ActiveRecord::Base.connection.execute("SELECT code FROM users").map {|user| user["code"] }
else

View file

@ -116,13 +116,13 @@ if (json.length > 0) {
<% if authenticated? && (@map.permission == "commons" || @map.user == user) %>
// this is for the heroku staging environment
window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
//window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
// this is for metamaps.cc
//window.realtime.socket = io.connect('http://metamaps.cc:5001');
// this is for localhost development
//window.realtime.socket = io.connect('http://localhost:5001');
window.realtime.socket = io.connect('http://localhost:5001');
window.realtime.socket.on('connect', function () {
console.log('socket connected');

View file

@ -8,6 +8,9 @@
<h1 class="index">Your Settings</h1>
<%= formula_form_for @user, url: user_url do |form| %>
<h3>Edit Account</h3>
<label for="user_image">Profile Picture</label>
<% if @user.image %><%= image_tag @user.image.url(:round), :size => "48x48" %><% end %>
<%= form.file_field :image %>
<%= form.input :name, label: "Name", class: "name" %>
<%= form.input :email, label: "Email", class: "email" %>
<%= form.input :password, label: "Password", class: "password", :autocomplete => :off %>

View file

@ -13,7 +13,16 @@ ISSAD::Application.configure do
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# S3 file storage
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'mail.metamaps.cc',

View file

@ -13,6 +13,17 @@ ISSAD::Application.configure do
# Compress JavaScripts and CSS
config.assets.compress = true
# S3 file storage
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {

View file

@ -0,0 +1,2 @@
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'

View file

@ -0,0 +1,11 @@
class AddImageAndAudioToTopics < ActiveRecord::Migration
def self.up
add_attachment :topics, :image
add_attachment :topics, :audio
end
def self.down
remove_attachment :topics, :image
remove_attachment :topics, :audio
end
end

View file

@ -0,0 +1,9 @@
class AddImageToUsers < ActiveRecord::Migration
def self.up
add_attachment :users, :image
end
def self.down
remove_attachment :users, :image
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140517115841) do
ActiveRecord::Schema.define(:version => 20140707161810) do
create_table "in_metacode_sets", :force => true do |t|
t.integer "metacode_id"
@ -83,8 +83,16 @@ ActiveRecord::Schema.define(:version => 20140517115841) do
t.text "permission"
t.integer "user_id"
t.integer "metacode_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "audio_file_name"
t.string "audio_content_type"
t.integer "audio_file_size"
t.datetime "audio_updated_at"
end
create_table "users", :force => true do |t|
@ -110,6 +118,10 @@ ActiveRecord::Schema.define(:version => 20140517115841) do
t.string "current_sign_in_ip"
t.datetime "reset_password_sent_at"
t.boolean "admin"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
end
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true