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 @@

<%= link_to "metamaps", root_url %>

 beta <% unless authenticated? %> - diff --git a/app/views/main/invite.html.erb b/app/views/main/invite.html.erb new file mode 100644 index 00000000..404d12c5 --- /dev/null +++ b/app/views/main/invite.html.erb @@ -0,0 +1,6 @@ +
+

Invite Others

+

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.

+
<%= @user.code %>
+

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?

+
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index e7c273a7..e118909d 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -3,7 +3,8 @@ <%= form.input :name, label: "Name", class: "name" %> <%= form.input :email, label: "Email", class: "email" %> <%= form.input :password, label: "Password", class: "password" %> - <%= form.submit "Login", class: "add" %> + <%= form.input :joinedwithcode, label: "Access Code", class: "joinedwithcode" %> + <%= form.submit "Create Account", class: "add" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index dcf1019b..8d465aeb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,8 @@ ISSAD::Application.routes.draw do match 'metamap', to: 'main#metamap', via: :get, as: :metamap match 'maps', to: 'main#allmaps', via: :get, as: :allmaps + match 'invite', to: 'main#invite', via: :get, as: :invite + resource :session resources :users do diff --git a/db/migrate/20120920013446_create_users.rb b/db/migrate/20120920013446_create_users.rb index 82d303a3..aa0cea24 100644 --- a/db/migrate/20120920013446_create_users.rb +++ b/db/migrate/20120920013446_create_users.rb @@ -3,6 +3,8 @@ class CreateUsers < ActiveRecord::Migration create_table :users do |t| t.string :name t.string :email + t.string :code, :limit => 8 + t.string :joinedwithcode, :limit => 8 t.string :crypted_password t.string :password_salt t.string :persistence_token diff --git a/db/schema.rb b/db/schema.rb index 56cf4c79..4edb697d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121026103129) do +ActiveRecord::Schema.define(:version => 20121029164735) do create_table "item_categories", :force => true do |t| t.text "name" @@ -71,8 +71,10 @@ ActiveRecord::Schema.define(:version => 20121026103129) do t.string "password_salt" t.string "persistence_token" t.string "perishable_token" - 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 "code", :limit => 8 + t.string "joinedwithcode", :limit => 8 end end