Browse Source

Analytics and jquery fallback

development
Godwin 11 years ago
parent
commit
e64eb1f153
  1. 1
      Gemfile
  2. 5
      Gemfile.lock
  3. 4
      app/assets/javascripts/jquery.min.js
  4. 8
      app/assets/stylesheets/sass/_typography.scss
  5. 64
      app/controllers/conferences_controller.rb
  6. 4
      app/views/conferences/_register.html.haml
  7. 14
      app/views/conferences/_register_primary.html.haml
  8. 1
      app/views/conferences/show.html.haml
  9. 1
      app/views/layouts/application.html.haml
  10. 2
      config/initializers/session_store.rb
  11. 3
      config/routes.rb
  12. 5
      db/migrate/20140714012739_add_firstname_to_users.rb
  13. 5
      db/migrate/20140714012811_add_lastname_to_users.rb
  14. 12
      db/migrate/20140714013645_add_sessions_table.rb
  15. 14
      db/schema.rb

1
Gemfile

@ -30,6 +30,7 @@ gem 'font-awesome-rails'
gem 'wysiwyg-rails'
gem 'rails-assets-cdn'
gem 'sitemap_generator'
gem 'activerecord-session_store'
group :development, :test do
gem 'rspec'

5
Gemfile.lock

@ -38,6 +38,10 @@ GEM
activesupport (= 4.0.0)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activerecord-session_store (0.1.0)
actionpack (>= 4.0.0, < 5)
activerecord (>= 4.0.0, < 5)
railties (>= 4.0.0, < 5)
activesupport (4.0.0)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
@ -329,6 +333,7 @@ PLATFORMS
x86-mingw32
DEPENDENCIES
activerecord-session_store
acts_as_list
awesome_print
better_errors

4
app/assets/javascripts/jquery.min.js

File diff suppressed because one or more lines are too long

8
app/assets/stylesheets/sass/_typography.scss

@ -249,7 +249,7 @@ fieldset {
}
}
&.check-box {
&.check-box-field {
div {
float: left;
font-size: 1.75em;
@ -276,6 +276,12 @@ fieldset {
position: relative;
margin: 0;
display: inline-block;
line-height: 1.6em;
span {
display: inline-block;
vertical-align: text-top;
}
}
}

64
app/controllers/conferences_controller.rb

@ -110,29 +110,53 @@ class ConferencesController < ApplicationController
end
end
def register_submit
#set_conference
next_step = nil
if !session[:registration]
session[:registration] = Hash.new
end
case params['step']
when 'register'
session[:registration][:email] = params[:email]
user = User.find_by(:email => params[:email]) || User.new(:email => params[:email], :role => 'unverified')
registration = ConferenceRegistration.new(:conference_id => @conference.id, :is_attending => 'yes', :is_participant => params[:is_participant], :is_volunteer => params[:is_volunteer])
session[:registration][:user] = user
next_step = 'primary'
when 'primary'
next_step = user.organizations.length > 0 ? 'questions' : 'organizations'
session[:registration][:user].firstname = params[:firstname]
session[:registration][:user].firstname = params[:lastname]
if !session[:registration][:user].role == 'unverified'
session[:registration][:user].username = params[:username]
end
end
next_step
#if next_step
# redirect_to :action => :register, :step => next_step
#else
# do_404
#end
end
def register
set_conference
#@user = User.new
#@sub_action = 'registration_register'
#render :registration
if params['step']
begin
template = "register_#{params['step']}"
if request.xhr?
render :partial => template
else
render template
end
rescue
do_404
end
#template = params['step'] ? "register_#{params['step']}" : 'register'
@register_step = request.post? ? register_submit : 'register'
template = (@register_step == 'register' ? '' : 'register_') + @register_step
if !File.exists?(Rails.root.join("app", "views", params[:controller], "_#{template}.html.haml"))
do_404
return
end
#if params['step'] != true
#session[:last_step] = params['step']
#end
@register_step = template#params['step'] || true
@register_content = render_to_string :partial => template
if request.xhr?
render :json => {status: 200, html: @register_content}
else
if request.xhr?
render :partial => 'register'
else
@register_step = true
render 'show'
end
render 'show'
end
end

4
app/views/conferences/_register.html.haml

@ -0,0 +1,4 @@
= form_tag (@conference.url + '/register/').gsub(/\/\/+/, '/'), :method => :post do
= hidden_field_tag :step, @register_step
= email_field_tag :email
= form_actions :next

14
app/views/conferences/_register_primary.html.haml

@ -0,0 +1,14 @@
= form_tag (@conference.url + '/register/').gsub(/\/\/+/, '/'), :class => 'row', :method => :post do
= hidden_field_tag :step, @register_step
- user = session[:registration][:user]
.columns.medium-6= text_field_tag :firstname, user ? (user.firstname || user.username) : nil, :required => true
.columns.medium-6= text_field_tag :lastname, user ? user.lastname : nil, :required => true
.columns
= text_field_tag :username, user ? user.username : nil, :readonly => (user && user.username)
.columns
%h3
Attending as:
.columns.small-offset-1
= check_box_tag :is_participant
= check_box_tag :is_volunteer
.columns= form_actions :next

1
app/views/conferences/show.html.haml

@ -11,6 +11,7 @@
.columns.large-10
- if @register_step
%h2='Register!'
= @register_content.html_safe
- else
%h2=('About '+@conference.title)
=p @conference, :info

1
app/views/layouts/application.html.haml

@ -48,6 +48,7 @@
.container= render 'shared/footer'
= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'
:javascript
window.jQuery||document.write('<script src="/javascripts/jquery.min.js"><\/script>');(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;e=o.createElement(i);r=o.getElementsByTagName(i)[0];e.src='//www.google-analytics.com/analytics.js';r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));ga('create','UA-42449204-1');ga('send','pageview');
#{yield :scripts}
!function(a,b,c,d){d&&a.addEventListener("DOMContentLoaded",function(){$.ajax({url:$("use").first().attr("xlink:href").replace(/^(.*)\#.*$/,"$1"),dataType:"text",success:function(a){$("body").append('<div class="hide">'+a+"</div>"),$("use").each(function(){$(this).attr("xlink:href",function(a,b){return b.replace(/^.*(#.*)$/,"$1")})})}})})}(document,navigator,{},/Trident\/[567]\b/.test(navigator.userAgent));
$(function(){

2
config/initializers/session_store.rb

@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.
BikeBike::Application.config.session_store :cookie_store, key: '_starterapp_session'
BikeBike::Application.config.session_store :active_record_store

3
config/routes.rb

@ -13,7 +13,8 @@ BikeBike::Application.routes.draw do
#get :registration
#resources :workshops, :param => 'slug'
#get :register, :param => 'step'
##get 'register(/:step)' => 'conferences#register'
#post 'register/next' => 'conferences#register_submit'
# match 'register(/:step)' => 'conferences#register', via: [:get, :post]
#patch 'register/step/:step' => 'conferences#register_step'
#resources :registrations, :path => 'registration' do
# get :form, on: :collection

5
db/migrate/20140714012739_add_firstname_to_users.rb

@ -0,0 +1,5 @@
class AddFirstnameToUsers < ActiveRecord::Migration
def change
add_column :users, :firstname, :string
end
end

5
db/migrate/20140714012811_add_lastname_to_users.rb

@ -0,0 +1,5 @@
class AddLastnameToUsers < ActiveRecord::Migration
def change
add_column :users, :lastname, :string
end
end

12
db/migrate/20140714013645_add_sessions_table.rb

@ -0,0 +1,12 @@
class AddSessionsTable < ActiveRecord::Migration
def change
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id, :unique => true
add_index :sessions, :updated_at
end
end

14
db/schema.rb

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140713213534) do
ActiveRecord::Schema.define(version: 20140714013645) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -184,6 +184,16 @@ ActiveRecord::Schema.define(version: 20140713213534) do
t.datetime "updated_at"
end
create_table "sessions", force: true do |t|
t.string "session_id", null: false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", unique: true, using: :btree
add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
create_table "translations", force: true do |t|
t.string "locale"
t.string "key"
@ -223,6 +233,8 @@ ActiveRecord::Schema.define(version: 20140713213534) do
t.string "avatar"
t.text "about_me"
t.string "role"
t.string "firstname"
t.string "lastname"
end
add_index "users", ["activation_token"], name: "index_users_on_activation_token", using: :btree

Loading…
Cancel
Save