Skip to content

Commit

Permalink
changes for 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Barnes committed Jun 23, 2011
1 parent 38d3bbd commit 9bc15d7
Show file tree
Hide file tree
Showing 20 changed files with 165 additions and 410 deletions.
2 changes: 1 addition & 1 deletion .socketstream_state
@@ -1 +1 @@
{"version":{"server":"0.0.54","client":"0.0.15"}}
{"version":{"server":"0.1.00","client":"0.0.17"}}
33 changes: 24 additions & 9 deletions app/client/app.coffee
@@ -1,19 +1,34 @@
exports.init = -> if SS.client.browser.isSupported() then loadApp() else SS.client.browser.showIncompatibleMessage()
# Client-side code

loadApp = ->
# This function is called automatically once the websocket is setup
exports.init = ->
$('.message.template').hide()
SS.server.app.init (user) -> if user then $('#main').show() else displaySignInForm()
SS.server.app.init (user) ->
if user then $('#main').show() else displaySignInForm()

# Bind to Submit button
$('form#sendMessage').submit ->
newMessage = $('#newMessage').val()
SS.server.app.sendMessage newMessage, (response) -> if response.error then alert(response.error) else $('#newMessage').val('')
SS.server.app.sendMessage newMessage, (response) ->
if response.error then alert(response.error) else $('#newMessage').val('')
false
SS.events.on 'newMessage', (params) -> renderMessage(params)


# Bind to new incoming message event
SS.events.on 'newMessage', renderMessage


# PRIVATE

displaySignInForm = ->
$('#signIn').show().submit ->
SS.server.app.signIn $('#signIn').find('input').val(), (response) -> $('#signInError').remove() and if response is false then $('#signIn').append("<p id='signInError'>The name you provided was incorrect. Sorry.</p>").find('input').val('') else displayMainScreen()
SS.server.app.signIn $('#signIn').find('input').val(), (response) ->
$('#signInError').remove()
displayMainScreen()
false

displayMainScreen = -> $('#signIn').fadeOut(230) and $('#main').show()
displayMainScreen = ->
$('#signIn').fadeOut(230) and $('#main').show()

renderMessage = (params) -> $('.message').clone().find('.body').html(params.body).parent().find('.user').html(params.cdid).parent().appendTo("#messages").show() and SS.client.scroll.down('#messages', 450)
renderMessage = (params) ->
$('#templates-message').tmpl(params).appendTo('#messages')
SS.client.scroll.down('#messages', 450)
6 changes: 0 additions & 6 deletions app/client/browser.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion app/client/scroll.coffee
Expand Up @@ -7,4 +7,4 @@ exports.down = (id, value) ->
postion[id] = $(id)[0].scrollHeight - value

# Scolling is possible on both windows using the mouse wheel, though we need to make this more apparent
exports.enable = (divId, adjustmentLevel) ->
exports.enable = (divId, adjustmentLevel) ->
188 changes: 10 additions & 178 deletions app/css/app.styl
@@ -1,3 +1,5 @@
// Main Styles

@import 'helpers'
@import 'fonts'

Expand Down Expand Up @@ -114,44 +116,18 @@ a:hover
margin-bottom 2em

.message
float left
width 100%
border solid 1px #ccc
round(5px)
clear both

border 0px solid rgba(0,0,0,0.49)
border-radius 10px

.avatar
clear left
font-size 12pt
padding 10px

.user
font-weight bold
float left
width 30px
height 30px
border solid 1px #ccc
margin 0.5em
cursor pointer

width 100px

.body
float left
margin 0.7em
font-size 12pt
width 680px

.date
float right
opacity 0
-webkit-transition opacity 0.5s linear
text-align right
width 110px
position relative
z-index 1000

.message:hover .date
opacity 1
-webkit-transition opacity 0.5s linear
padding-top 15px


form#sendMessage
position relative
background #444
Expand Down Expand Up @@ -193,149 +169,5 @@ a:hover
input[type='submit']:hover
box-shadow 0 0 10px 4px rgba(123,255,0,0.5)
cursor pointer

#footer
line-height 1.5em
padding 1.5em 0
a
color #444
text-decoration none

#right
float right
width 34em

#peopleContainer
height 35em
border solid 1px #ccc
round(5px)

border 0px solid rgba(0,0,0,0.49)
border-radius 10px
background-image -moz-linear-gradient(top, #fcfcfc, #f7f7f7 3%, #f2f2f2 12%, #d9d9d9 90%, #bfbfbf)
background-image -webkit-gradient(linear, center top, center bottom, from(#fcfcfc), to(#bfbfbf), color-stop(3%, #f7f7f7), color-stop(12%, #f2f2f2), color-stop(90%, #d9d9d9))
box-shadow inset 0px 3px 14px 1px rgba(0,0,0,0.25)

#people
overflow hidden
height 34em
padding 1em 2em 0em

.person:first
margin-top 3em

.person:last
margin-bottom 2em

.person
float left
clear both
margin 0.5em

.avatar
float left
margin-right 10px
border solid 1px #ccc
width 20px
height 20px
cursor pointer

.commonName
float left
padding-top 3px
font-size 10pt

#peepsOnline
padding-top 0.5em
clear right
text-align center
margin-bottom 1em
font-size 12pt
outline none

.userInfo
background rgba(0,0,0,0.85)
text-shadow 1px 1px 1px #333
padding 1em
width 30em
round 7px
outline none
color white
box-shadow 0px 3px 14px 5px rgba(0,0,0,0.35)
z-index 2

.mugshot
width 60px
height 60px
float left
margin 0px 15px 10px 0px
border solid 5px white
border-bottom solid 18px white
box-shadow 1px 3px 5px 1px rgba(0,0,0,0.35)

.nameTag
float left
width 21em

.name a, .name a:visited
float left
font-size 14pt
padding-bottom 5px
color white
text-decoration none

.name a:hover
color #ccc

.title
float left
clear left
font-size 10pt
color #aaa
padding-bottom 5px

.contactInfo
float left
padding-top 5px
width 21em

.emailInfo, .aimInfo
padding-bottom 5px
color #ccc
clear left
float left
font-size 10pt
outline none

a
float left
color #ccc
text-decoration none

a:hover
color #888
outline none



// BROWSER NOT SUPPORTED ERROR MESSAGE

#browserNotSupported
position absolute
top 0px
left 0px
right 0px
bottom 0px
width 100%
height 100%
z-index 2
background white
text-align center

h1
font-size 18pt
margin 6em 0em 2em

p
font-size 12pt
padding 0.5em 0em
4 changes: 3 additions & 1 deletion app/css/fonts.styl
@@ -1,3 +1,5 @@
// Font-face experiments

@font-face
font-family 'Lato'
font-style normal
Expand Down Expand Up @@ -32,4 +34,4 @@
font-family 'Lato'
font-style italic
font-weight 400
src local('Lato Italic'), local('Lato-Italic'), url('/fonts/lato/Lato-Italic.ttf') format('truetype')
src local('Lato Italic'), local('Lato-Italic'), url('/fonts/lato/Lato-Italic.ttf') format('truetype')
17 changes: 10 additions & 7 deletions app/server/app.coffee
@@ -1,16 +1,19 @@
# Server-side code

exports.actions =

init: (cb) ->
if @session.user_id
R.get "user:#{@session.user_id}", (err, data) => if data then cb data else cb false
R.get "user:#{@session.user_id}", (err, data) =>
if data then cb data else cb false
else
cb false

sendMessage: (message, cb) ->
if message
SS.publish.broadcast 'newMessage', {cdid: @session.user_id, body: message}
cb true
else
cb false
# TODO: Check messages for malformed content, HTML tags, etc
SS.publish.broadcast 'newMessage', {user: @session.user_id, body: message}
cb true

signIn: (cdid, cb) -> R.get "user:#{cdid}", (err, cached_user_data) => R.set "user:#{cdid}", "user:#{cdid}", (err, data) => cb "user:#{cdid}"
signIn: (user, cb) ->
@session.setUserId(user)
cb user
2 changes: 0 additions & 2 deletions app/shared/viewHelpers.coffee

This file was deleted.

10 changes: 0 additions & 10 deletions app/views/app.jade
Expand Up @@ -16,9 +16,6 @@ html(lang:"en")
#content
#messageContainer
#messages
.message.template
.user
.body
form#sendMessage
input(id='newMessage', type='text', name='message', autocomplete='off')
Expand All @@ -30,10 +27,3 @@ html(lang:"en")
h1 Please enter a username to begin:
input(type='text')
#browserNotSupported.hidden
#loveLetterToIE.views.hidden
h1 Sorry, IE is not supported as yet.
#sorryFirefoxOperaPeeps.views.hidden
h1 Your browser is not supported. Please use either Google Chrome or Apple Safari.
5 changes: 4 additions & 1 deletion app/views/templates/message.jade
@@ -1,2 +1,5 @@
.message.template
.message
.user
{{= user}}
.body
{{= body}}
Empty file removed app/views/templates/userInfo.jade
Empty file.
16 changes: 15 additions & 1 deletion config/app.json
@@ -1 +1,15 @@
{"limiter":{"enable":true,"websockets":{"rps":10}},"redis":{"db_index":1}}
{
"http": {
"port": 3000,
"hostname": "0.0.0.0"
},
"https": {
"enabled": false,
"port": 443,
"domain": "www.socketstream.org"
},
"browser_check": {
"enabled": true,
"strict": true
}
}
1 change: 0 additions & 1 deletion config/environments/staging.json

This file was deleted.

20 changes: 20 additions & 0 deletions config/http.coffee
@@ -0,0 +1,20 @@
# HTTP Router Config
# ------------------

# This file defines how incoming HTTP requests are handled
# Note: The default configuration will probably change a lot in the future. Be warned!

exports.call = (request, response, next) ->

# Custom Middleware
# -----------------

# Hook-in your own custom HTTP middleware to modify or respond to requests before they're passed to the SocketStream HTTP stack
# See README for more details and example middleware code

# require('my_middleware').call request, response, next


# Unless you're passing the callback to custom middleware, you'll need to call next() here
next()

0 comments on commit 9bc15d7

Please sign in to comment.