diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f27cb8f4..dafc7661 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -30,7 +30,10 @@ h2 {display:block; text-align:center; font-family: "vinyl",sans-serif; backgroun a {color:#2d6a5d; text-decoration:none;} .clearfloat {clear:both;} -.new_session, .new_user, .new_item, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map { display: block; width: 350px; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; } +.new_session, .new_user, .new_item, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map, .invite { display: block; width: 350px; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; } + +.invite p { margin:10px 0; } +.invite strong { text-align:center; display:block; color:#67AF9F; } .anypage .new_item, .anypage .new_synapse { display: none; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; border:2px solid #000; } #closenewtopic, #closenewsynapse { position:absolute; top: 3px; right:3px; } diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index a333b8f3..fd44c546 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,6 +1,8 @@ class MainController < ApplicationController include ItemsHelper + before_filter :require_user, only: [:invite] + respond_to :html, :js, :json #homepage pick a random map and show it @@ -38,5 +40,13 @@ class MainController < ApplicationController end end + def invite + @user = current_user + + respond_to do |format| + format.html { respond_with(@user) } + end + end + end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 883babe2..821e3643 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -34,9 +34,15 @@ class UsersController < ApplicationController @user = User.create(params[:user]) + #generate a random 8 letter/digit code that they can use to invite people + @user.code = rand(36**8).to_s(36) @user.save + + # direct them straight to the metamaps manual map. + @connor = User.find(555629996) + @map = Map.find(5) - respond_with(@user, location: root_url) do |format| + respond_with(@user, location: user_map_url(@connor,@map)) do |format| end end diff --git a/app/models/user.rb b/app/models/user.rb index efa5088b..1aaa3c3a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,10 +16,16 @@ has_many :mappings end validates :password, :presence => true, - :length => {:within => 6..20}, + :length => { + :maximum => 20, + :too_long => "is too long (maximum is %{count} characters)" }, :on => :create - validates :password, :length => {:within => 6..20}, - :allow_blank => true, + validates :password, :allow_blank => true, + :length => { + :maximum => 20, + :too_long => "is too long (maximum is %{count} characters)"}, :on => :update + + validates :joinedwithcode, :presence => true, :inclusion => { :in => User.all.map(&:code), :message => "%{value} is not a valid code" }, :on => :create end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3b71e812..50667f80 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -51,12 +51,16 @@
You can invite others to the Metamaps platform. Just send them the link to
http://metamaps.cc/users/new
and give them the access code shown below.
+We invite you to be conscious as to who you invite to this platform, because much of the collaborative editing is based on trust. We want to cultivate a community here that is fun, wise, creative, and flourishing. Can you help us build a community like that?
+