diff --git a/Gemfile b/Gemfile index 65988ca4..f5358f47 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 3346fa26..e4bbb146 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index a5ef3c6b..40107e72 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -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 diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index d16a8f80..d824b72b 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -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]) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ac97d22e..bfbc1ffc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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) diff --git a/app/models/topic.rb b/app/models/topic.rb index 149321c9..668c94fe 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index ae03c659..1be8144a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index 474a6c1a..8a325a73 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -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'); diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 732b0f03..1bb64d46 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -8,6 +8,9 @@