Skip to content
Browse files

Skeleton stuff.

  • Loading branch information...
1 parent eb7980f commit 53b4d22952999ae0a7b3d7a900f464e00429ef5d Virgil Dimaguila committed Aug 19, 2012
View
4 Gemfile
@@ -14,6 +14,10 @@ gem 'redis'
gem 'resque'
gem 'mobylette'
+gem 'eventmachine'
+gem 'em-websocket'
+gem 'em-http-request'
+
# Gems used only for assets and not required
# in production environments by default.
group :assets do
View
12 Gemfile.lock
@@ -28,6 +28,7 @@ GEM
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.3.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
@@ -53,7 +54,15 @@ GEM
debugger-linecache (1.1.2)
debugger-ruby_core_source (>= 1.1.1)
debugger-ruby_core_source (1.1.3)
+ em-http-request (0.3.0)
+ addressable (>= 2.0.0)
+ escape_utils
+ eventmachine (>= 0.12.9)
+ em-websocket (0.3.8)
+ addressable (>= 2.1.1)
+ eventmachine (>= 0.12.9)
erubis (2.7.0)
+ escape_utils (0.2.4)
eventmachine (0.12.10)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -166,6 +175,9 @@ DEPENDENCIES
capistrano
coffee-rails (~> 3.2.1)
debugger
+ em-http-request
+ em-websocket
+ eventmachine
haml (= 3.1.4)
jquery-rails
memcached
View
2 app/assets/stylesheets/application.css
@@ -9,5 +9,5 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
- *= require_tree .
+ *= require main
*/
View
65 app/assets/stylesheets/main.sass
@@ -0,0 +1,65 @@
+$dark-color: #00B4FF
+$page-width: 900px
+$text-color: #fff
+
+@mixin clearfix
+ display: inline-block
+ &:after
+ content: "."
+ display: block
+ height: 0
+ clear: both
+ visibility: hidden
+ * html &
+ height: 1px
+
+@mixin border-radius($radius: 5px)
+ border-radius: $radius
+
+@mixin box-shadow($left: 0px, $top: 1px, $blur: 2px, $color: #000, $inset:"")
+ -webkit-box-shadow: $left $top $blur $color #{$inset}
+ -moz-box-shadow: $left $top $blur $color #{$inset}
+ box-shadow: $left $top $blur $color #{$inset}
+
+body
+ font-family: HelveticaNeue, Helvetica, Sans-Serif
+ font-size: 12px
+ background-color: $dark-color
+ color: $text-color
+
+
+.login_page
+ $width: 500px
+ $height: 200px
+ width: $width
+ height: $height
+ +border-radius(10px)
+ position: absolute
+ top: 50%
+ left: 50%
+ margin: (-$height / 2) 0px 0px (-$width / 2)
+ background-color: lighten($dark-color, 5%)
+ padding: 20px
+ color: #fff
+
+ .title
+ font-size: 48px
+ font-weight: bold
+ text-align: center
+
+ form
+ padding-left: 130px
+ padding-top: 20px
+
+ label
+ width: 300px
+ font-size: 20px
+
+.nav
+ li
+ list-style-type: none
+ a
+ text-decoration: none
+ color: $text-color
+ font-size: 24px
+ font-weight: bold
View
42 app/assets/stylesheets/reset.sass
@@ -0,0 +1,42 @@
+// http://meyerweb.com/eric/tools/css/reset/
+// v2.0 | 20110126
+// License: none (public domain)
+
+=meyer-reset
+ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
+ margin: 0
+ padding: 0
+ border: 0
+ font-size: 100%
+ font: inherit
+ vertical-align: baseline
+
+ // HTML5 display-role reset for older browsers
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section
+ display: block
+
+ body
+ line-height: 1
+
+ ol, ul
+ list-style: none
+
+ blockquote, q
+ quotes: none
+
+ blockquote
+ &:before, &:after
+ content: ''
+ content: none
+
+ q
+ &:before, &:after
+ content: ''
+ content: none
+
+ table
+ border-collapse: collapse
+ border-spacing: 0
+
++meyer-reset
+
View
4 app/assets/stylesheets/sass/main.sass
@@ -1,4 +0,0 @@
-body
- font-family: Helvetica
- font-size: 12px
-
View
13 app/controllers/application_controller.rb
@@ -3,7 +3,18 @@ class ApplicationController < ActionController::Base
protect_from_forgery
def current_user
-
+ return @current_user unless @current_user.nil?
+
+ user_id = session[:current_user_id]
+ if user_id
+ @current_user = User.find_by_id(user_id)
+ end
+ end
+
+ def require_user
+ if session[:current_user_id].blank?
+ redirect_to login_url
+ end
end
end
View
21 app/controllers/users_controller.rb
@@ -1,10 +1,29 @@
class UsersController < ApplicationController
+ before_filter :require_user, :except => [:login]
def dashboard
-
end
def login
+ if current_user
+ return redirect_to root_url
+ end
+
+ if request.get?
+ return render
+ end
+
+ @current_user = User.find_by_username(params[:username])
+ if @current_user
+ session[:current_user_id] = @current_user.id
+ redirect_to :dashboard
+ end
+ end
+
+ def logout
+ @current_user = session[:current_user_id] = nil
+ session.clear
+ redirect_to :login
end
def index
View
12 app/helpers/application_helper.rb
@@ -1,2 +1,14 @@
module ApplicationHelper
+
+ def body_classes
+ classes = []
+ if is_mobile_request?
+ classes << "mobile"
+ else
+ classes << "desktop"
+ end
+
+ classes.join(' ')
+ end
+
end
View
8 app/views/layouts/application.html.haml
@@ -1,11 +1,13 @@
!!! 5
-%html
+%html{ :lang => "en" }
%head
+ %meta{ :charset => "utf-8" }
%title Little One
= stylesheet_link_tag "application", :media => "all"
- = javascript_include_tag "application"
= csrf_meta_tags
- %body
+ %body{ :class => body_classes }
= yield
+ = javascript_include_tag "application"
+
View
10 app/views/users/dashboard.html.haml
@@ -1 +1,9 @@
-%h1 Dashboard
+%ul.nav
+ %li
+ = link_to "Dashboard"
+ %li
+ = link_to "Profile"
+ %li
+ = link_to "Timeline"
+ %li
+ = link_to "Sign out", logout_url
View
12 app/views/users/login.html.haml
@@ -0,0 +1,12 @@
+.login_page
+ .title Sign in
+
+ = form_tag(login_url, :method => "post") do
+ .line
+ %label Username:
+ = text_field_tag :username
+ .line
+ %label Password:
+ = password_field_tag :password
+ .line
+ = submit_tag "Login"
View
2 config/initializers/session_store.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
-Littleone::Application.config.session_store :cookie_store, key: '_littleone_session'
+Littleone::Application.config.session_store :cookie_store, key: 'l1'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
View
4 config/routes.rb
@@ -1,5 +1,9 @@
Littleone::Application.routes.draw do
+ match 'login' => "users#login", :via => [:post, :get]
+ match 'logout' => "users#logout", :via => [:post, :get]
+ match 'dashboard' => "users#dashboard", :via => :get
+
root :to => "users#dashboard"
# The priority is based upon order of creation:

0 comments on commit 53b4d22

Please sign in to comment.
Something went wrong with that request. Please try again.