Skip to content
Browse files

Initial version.

  • Loading branch information...
0 parents commit 2747ff62961006ff3c2ce3ec4c3a3358e53f3371 @pwnall committed Mar 11, 2012
Showing with 290 additions and 0 deletions.
  1. +9 −0 .gitignore
  2. +18 −0 .project
  3. +10 −0 Gemfile
  4. +43 −0 Gemfile.lock
  5. +20 −0 LICENSE
  6. +34 −0 README.markdown
  7. +29 −0 app.rb
  8. +3 −0 config.ru
  9. +16 −0 javascripts/shortcuts.coffee
  10. +2 −0 stylesheets/application.scss
  11. +95 −0 stylesheets/generic/_reset.scss
  12. +11 −0 views/welcome.erb
9 .gitignore
@@ -0,0 +1,9 @@
+# SCSS.
+.sass-cache
+
+# Log files.
+.log
+
+# Rubinius
+*.rbc
+.rbx
18 .project
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>playbox</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.aptana.ide.core.unifiedBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.aptana.ruby.core.rubynature</nature>
+ <nature>com.aptana.projects.webnature</nature>
+ </natures>
+</projectDescription>
10 Gemfile
@@ -0,0 +1,10 @@
+source 'http://rubygems.org'
+
+gem 'coffee-script', '>= 2.2.0'
+gem 'json', '>= 1.5.0', :platforms => [:ruby_18]
+gem 'sass', '>= 3.1.12'
+gem 'sinatra', '>= 1.3.2'
+gem 'therubyracer', '>= 0.9.9'
+
+gem 'shotgun', '>= 0.9'
+gem 'unicorn', '>= 4.2.0'
43 Gemfile.lock
@@ -0,0 +1,43 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.2.0)
+ execjs (1.3.0)
+ multi_json (~> 1.0)
+ json (1.6.5)
+ kgio (2.7.2)
+ libv8 (3.3.10.4)
+ multi_json (1.1.0)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ raindrops (0.8.0)
+ sass (3.1.15)
+ shotgun (0.9)
+ rack (>= 1.0)
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ therubyracer (0.9.10)
+ libv8 (~> 3.3.10)
+ tilt (1.3.3)
+ unicorn (4.2.0)
+ kgio (~> 2.6)
+ rack
+ raindrops (~> 0.7)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-script (>= 2.2.0)
+ json (>= 1.5.0)
+ sass (>= 3.1.12)
+ shotgun (>= 0.9)
+ sinatra (>= 1.3.2)
+ therubyracer (>= 0.9.9)
+ unicorn (>= 4.2.0)
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Victor Costan
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 README.markdown
@@ -0,0 +1,34 @@
+# PlayBox
+
+This is a skeleton for Web UI experiments. It uses Sinatra to compile
+CoffeeScript and SCSS on the fly.
+
+
+## Setup
+
+1. Get Ruby, Rubygems, and bundler.
+sudo apt-get install ruby-full
+sudo gem update --system
+sudo gem install bundler
+
+2. Install all the required gems.
+bundle install
+
+3. Start up the web server.
+bundle exec shotgun config.ru
+nohup bundle exec unicorn config.ru > web.log &
+
+4. Go to [http://localhost:9393](http://localhost:9393) and play.
+
+
+## Experiment
+
+CoffeeScript files go in the `javascripts/` directory and are automatically
+merged into one big file, so you don't need to worry about exporting your
+classes.
+
+SCSS files go into the `stylesheets/` directory, and must be `@import`ed in
+`stylesheets/application.scss`. CSS is sensitive to the order of the rules, so
+you're in control of that.
+
+The main page is in `views/welcome.erb`. The server-side code is in `app.rb`.
29 app.rb
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'bundler'
+Bundler.setup
+
+require 'sinatra'
+
+class App < Sinatra::Application
+ # Root HTML.
+ get '/' do
+ erb :welcome
+ end
+
+ # Global JS.
+ get('/application.js') do
+ begin
+ source = Dir.glob('javascripts/**/*.coffee').sort.map { |f| File.read f }.
+ join("\n")
+ coffee source
+ rescue
+ Dir.glob('javascripts/**/*.coffee').sort.map { |f|
+ puts "File: #{f}"
+ CoffeeScript.compile File.read(f)
+ }.join
+ end
+ end
+
+ # Global CSS.
+ get('/application.css') { scss :"../stylesheets/application" }
+end
3 config.ru
@@ -0,0 +1,3 @@
+# This file is used by Rack-based servers to start the application.
+require './app.rb'
+run App
16 javascripts/shortcuts.coffee
@@ -0,0 +1,16 @@
+# Document-scoped select.
+$D = (cssSelector) -> document.querySelector cssSelector
+
+# Element-based select.
+$E = (cssSelector, base) -> base.querySelector cssSelector
+
+# Parse HTML fragment.
+$H = (html) ->
+ range = document.createRange()
+ range.selectNode document.body
+ range.createContextualFragment html
+
+# Extend window, for debugging purposes.
+window['$D'] = $D
+window['$E'] = $E
+window['$H'] = $H
2 stylesheets/application.scss
@@ -0,0 +1,2 @@
+@import 'generic/reset';
+// @import your SCSS files here.
95 stylesheets/generic/_reset.scss
@@ -0,0 +1,95 @@
+html, body, div, span, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+abbr, address, cite, code,
+del, dfn, em, img, ins, kbd, q, samp,
+small, strong, sub, sup, var,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, dialog, figcaption, figure,
+footer, header, hgroup, menu, nav, section, summary,
+time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-size: inherit;
+ line-height: inherit;
+ font: inherit;
+ vertical-align: baseline;
+ background: transparent;
+}
+
+article, aside, details, figcaption, figure, dialog,
+footer, header, hgroup, menu, nav, section {
+ display: block;
+}
+
+dl, ul, ol {
+ list-style: none;
+}
+
+blockquote, q {
+ quotes: none;
+}
+
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+
+a {
+ margin: 0;
+ padding: 0;
+ font-size: inherit;
+ line-height: inherit;
+ vertical-align: baseline;
+ background: transparent;
+}
+a img {
+ border: none;
+}
+
+ins {
+ background-color: #ff9;
+ color: #000;
+ text-decoration: none;
+}
+
+mark {
+ background-color: #ff9;
+ color: #000;
+ font-style: italic;
+ font-weight: bold;
+}
+
+del {
+ text-decoration: line-through;
+}
+
+abbr[title], dfn[title] {
+ border-bottom: 1px dotted;
+ cursor: help;
+}
+
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+th {
+ text-align: left;
+}
+
+hr {
+ display: block;
+ height: 1px;
+ border: 0;
+ border-top: 1px solid #cccccc;
+ margin: 1em 0;
+ padding: 0;
+}
+
+input, select {
+ vertical-align: middle;
+}
11 views/welcome.erb
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Playbox</title>
+ <link rel="stylesheet" href="application.css" type="text/css" />
+ <script src="application.js" type="text/javascript"></script>
+ </head>
+ <body>
+ <h1>This is <code>views/welcome.erb</code></h1>
+ </body>
+</html>

0 comments on commit 2747ff6

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