Permalink
Browse files

initial proof-of-concept works locally

  • Loading branch information...
0 parents commit 3a2d4b4942ee58346e6df0ff1796106c9556604c @mahemoff mahemoff committed Jun 26, 2011
6 README
@@ -0,0 +1,6 @@
+This is a proof-of-concept doc/wiki built with SocketStream.
+
+It's not documented for now, but follows standard SocketStream conventions.
+
+I used the following article as a reference:
+http://addyosmani.com/blog/building-real-time-coffeescript-web-applications-with-socketstream/
@@ -0,0 +1,20 @@
+# Client-side Code
+
+# Bind to events
+SS.socket.on 'disconnect', -> $('.conn-error').show()
+SS.socket.on 'connect', -> $('.conn-error').hide()
+
+# This method is called automatically when the websocket connection is established. Do not rename/delete
+exports.init = ->
+
+ # Make a call to the server to retrieve a message
+ SS.server.app.init (response) ->
+ $('#message').text(response)
+ $( () ->
+ $("#doc").keyup ->
+ console.log "doc changed"
+ SS.server.app.updateDoc $("#doc").val()
+ SS.events.on 'docUpdated', (doc) ->
+ console.log(arguments)
+ $("#doc").val(doc.contents)
+ )
@@ -0,0 +1,53 @@
+// Example Stylus file
+// All changes are detected and automatically compiled into CSS
+
+@import 'helpers'
+
+// Main
+
+body, html
+ height 100%
+
+body
+ font normal 1em sans-serif
+ vertical-gradient #eee, #fff
+ text-align center
+
+p
+ margin-bottom 1em
+
+h1,h2
+ font-size 1.5em
+ margin 1.5em
+ color #0057c5
+ text-shadow 1px 1px 2px white
+
+h2
+ font-size 1.2em
+ margin: 1em 0 0.5em
+
+#content
+ padding 50px
+
+#doc
+ display block
+ width 60em
+ height 20em
+ margin 0 auto
+
+.logo
+ width 50px
+ height 50px
+ display block
+ margin 2em 1em
+ float right
+
+.conn-error
+ display none
+ background red
+ color white
+ font-weight bold
+ position absolute
+ top 0
+ right 0
+ padding 1em
@@ -0,0 +1,25 @@
+// Helper functions
+
+vendor(prop, args)
+ -webkit-{prop} args
+ -moz-{prop} args
+ {prop} args
+
+round(n)
+ vendor border-radius, n
+
+round-corner(tb, lr, n)
+ border-{tb}\-{lr}-radius n
+ -moz-border-radius-{tb}{lr} n
+
+box-shadow()
+ vendor box-shadow, arguments
+
+opacity(n)
+ opacity n
+ -moz-opacity n
+
+vertical-gradient(from, to)
+ background-color to
+ background-image -webkit-gradient(linear, left top, left bottom, from(from), to(to))
+ background-image -moz-linear-gradient(top, from, to)
@@ -0,0 +1,8 @@
+# Server-side Code
+
+exports.actions =
+ init: (cb) ->
+ cb "SocketStream version #{SS.version} is up and running. This message was sent over websockets, so everything is working OK."
+ updateDoc: (contents,cb) ->
+ SS.publish.broadcast "docUpdated", {contents: contents}
+ cb true
@@ -0,0 +1,17 @@
+!!! 5
+html(lang="en")
+ head
+ != SocketStream
+ title SocketDoc
+ body
+ #content
+ h1 Edit Something
+ textarea(id="doc",rows=20,cols=80)
+ h2 What is SocketDoc?
+ p This is a demo of the new
+ a(href='https://github.com/socketstream/socketstream') SocketStream
+ | application framework for Node
+ p#message Attempting to connect to the server over websockets or flashsockets...
+ img(class='logo', src='/images/logo.png', alt='SocketStream Logo', width=167, height=159)
+ .conn-error
+ div server is down :(
@@ -0,0 +1,15 @@
+{
+ "http": {
+ "port": 3000,
+ "hostname": "0.0.0.0"
+ },
+ "https": {
+ "enabled": false,
+ "port": 443,
+ "domain": "www.socketstream.org"
+ },
+ "browser_check": {
+ "enabled": false,
+ "strict": true
+ }
+}
@@ -0,0 +1 @@
+# Place your Database config here
@@ -0,0 +1,22 @@
+# HTTP Router Config
+# ------------------
+
+# Version 1.0
+
+# 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()
+
Oops, something went wrong.
Oops, something went wrong.
@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/
+ v2.0 | 20110126
+ License: none (public domain)
+*/
+
+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, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
Oops, something went wrong.
@@ -0,0 +1,49 @@
+/* http://meyerweb.com/eric/tools/css/reset/
+ v2.0 | 20110126
+ License: none (public domain)
+*/
+
+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, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+;
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,9 @@
+body {
+ font: normal 15px 'Lucida Grande', 'Tahoma', sans-serif;
+ text-align: center;
+ margin: 250px 0;
+}
+
+h1 {
+ font-weight: normal;
+}
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <link href="/app.css" media="screen" rel="stylesheet" type="text/css">
+ <title>Incompatible Browser</title>
+</head>
+<body>
+ <h1>Incompatible Browser</h1>
+ <p>
+ We're sorry. This website uses cutting-edge websocket technology which is currently only supported by
+ <a href="http://www.google.com/chrome">Chrome</a> or <a href="http://www.apple.com/safari">Safari</a> (Mac users only).
+ </p>
+ <p>Please download one of the modern browsers above then revisit this site for an amazing real time experience.</p>
+</body>
+</html>

0 comments on commit 3a2d4b4

Please sign in to comment.