hullapp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/bin/hull +15 -0
- data/hullapp.gemspec +27 -0
- data/lib/hull.rb +6 -0
- data/lib/hull/cli.rb +124 -0
- data/lib/hull/version.rb +3 -0
- data/templates/.DS_Store +0 -0
- data/templates/hullenv.tt +4 -0
- data/templates/ruby/.gitignore +7 -0
- data/templates/ruby/.powenv +8 -0
- data/templates/ruby/.powrc +5 -0
- data/templates/ruby/.rvmrc.tt +1 -0
- data/templates/ruby/Gemfile +50 -0
- data/templates/ruby/Guardfile +8 -0
- data/templates/ruby/Procfile +4 -0
- data/templates/ruby/README.md +198 -0
- data/templates/ruby/Rakefile +40 -0
- data/templates/ruby/application/assets.rb +7 -0
- data/templates/ruby/application/assets/images/icons/facebook.png +0 -0
- data/templates/ruby/application/assets/images/icons/twitter.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/app-store.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/dribbble.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/facebook.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/flickr.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/forrst.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/foursquare.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/github.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/google-plus.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/google.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/instagram.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/linkedin.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/skype.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/social-email.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/social-rss.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/spotify.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/tumblr.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/twitter-2.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/twitter.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/vimeo.png +0 -0
- data/templates/ruby/application/assets/images/socialmedia/youtube.png +0 -0
- data/templates/ruby/application/assets/javascripts/app.js +11 -0
- data/templates/ruby/application/assets/javascripts/main.coffee +17 -0
- data/templates/ruby/application/assets/javascripts/template.js.erb +1 -0
- data/templates/ruby/application/assets/stylesheets/partials/_base.scss +17 -0
- data/templates/ruby/application/assets/stylesheets/partials/_boilerplate.scss +291 -0
- data/templates/ruby/application/assets/stylesheets/partials/_colors.scss +0 -0
- data/templates/ruby/application/assets/stylesheets/partials/_fonts.scss +1 -0
- data/templates/ruby/application/assets/stylesheets/partials/_h5bp.scss +298 -0
- data/templates/ruby/application/assets/stylesheets/partials/_layout.scss +12 -0
- data/templates/ruby/application/assets/stylesheets/partials/_normalize.scss +504 -0
- data/templates/ruby/application/assets/stylesheets/partials/_variables.scss +28 -0
- data/templates/ruby/application/assets/stylesheets/style.scss +16 -0
- data/templates/ruby/application/assets/templates/hello.hbs +1 -0
- data/templates/ruby/application/compass.rb +27 -0
- data/templates/ruby/application/core.rb +15 -0
- data/templates/ruby/application/core_extensions/blank.rb +111 -0
- data/templates/ruby/application/core_extensions/hash.rb +34 -0
- data/templates/ruby/application/core_extensions/sprockets.rb +74 -0
- data/templates/ruby/application/core_extensions/try.rb +57 -0
- data/templates/ruby/application/helpers.rb +121 -0
- data/templates/ruby/application/helpers/form_tag_helpers.rb +127 -0
- data/templates/ruby/application/helpers/notification_helpers.rb +20 -0
- data/templates/ruby/application/helpers/run_later.rb +111 -0
- data/templates/ruby/application/settings.rb +8 -0
- data/templates/ruby/application/views/demo.erb +27 -0
- data/templates/ruby/application/views/index.erb +9 -0
- data/templates/ruby/application/views/layout.erb +45 -0
- data/templates/ruby/application/workers.rb +0 -0
- data/templates/ruby/config.ru +84 -0
- data/templates/ruby/config/settings.yml +53 -0
- data/templates/ruby/config/sidekiq.yml +11 -0
- data/templates/ruby/config/unicorn.rb +91 -0
- data/templates/ruby/public/.htaccess +538 -0
- data/templates/ruby/public/404.html +157 -0
- data/templates/ruby/public/apple-touch-icon-114x114-precomposed.png +0 -0
- data/templates/ruby/public/apple-touch-icon-144x144-precomposed.png +0 -0
- data/templates/ruby/public/apple-touch-icon-57x57-precomposed.png +0 -0
- data/templates/ruby/public/apple-touch-icon-72x72-precomposed.png +0 -0
- data/templates/ruby/public/apple-touch-icon-precomposed.png +0 -0
- data/templates/ruby/public/apple-touch-icon.png +0 -0
- data/templates/ruby/public/crossdomain.xml +15 -0
- data/templates/ruby/public/favicon.ico +0 -0
- data/templates/ruby/public/humans.txt +15 -0
- data/templates/ruby/public/robots.txt +5 -0
- data/templates/ruby/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/templates/ruby/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/templates/ruby/vendor/assets/javascripts/backbone.js +1431 -0
- data/templates/ruby/vendor/assets/javascripts/bootstrap.js +2027 -0
- data/templates/ruby/vendor/assets/javascripts/index.js +0 -0
- data/templates/ruby/vendor/assets/javascripts/jquery.js +9227 -0
- data/templates/ruby/vendor/assets/javascripts/modernizr.js +11 -0
- data/templates/ruby/vendor/assets/javascripts/underscore.js +1059 -0
- data/templates/ruby/vendor/assets/javascripts/vendor.js +2 -0
- data/templates/ruby/vendor/assets/stylesheets/bootstrap-responsive.css +1040 -0
- data/templates/ruby/vendor/assets/stylesheets/bootstrap.css +5624 -0
- data/templates/ruby/vendor/assets/stylesheets/vendor.scss +2 -0
- metadata +243 -0
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Romain Dardour
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Hull
|
2
|
+
|
3
|
+
hull is a command line helper that will setup a complete application scaffold, so you can begin working straight away.
|
4
|
+
It will ask you a few questions, such as your client Id, application Id, and application Secret, and will configure the app to use them.
|
5
|
+
|
6
|
+
For now, only a sinatra template is included.
|
7
|
+
It has several nice features :
|
8
|
+
|
9
|
+
* Coffeescript, Compass and Sprockets integration
|
10
|
+
* a `rake assets:precompile` task to precompile your assets
|
11
|
+
* a Settings file (config/settings.yml) containing sensible defaults
|
12
|
+
* Guard and LiveReload for quick iteration
|
13
|
+
* It is set up to work out of the box with Pow and Heroku.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Install it with :
|
18
|
+
|
19
|
+
$ gem install hullapp
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Usage:
|
24
|
+
|
25
|
+
hull new APP_NAME
|
26
|
+
|
27
|
+
Options:
|
28
|
+
|
29
|
+
-t, [--template=TEMPLATE] # Choose the template to use
|
30
|
+
-f, [--force] # Don't ask for confirmation
|
31
|
+
[--client-id=CLIENT_ID] # Configure client_id
|
32
|
+
[--app-id=APP_ID] # Configure app_id
|
33
|
+
[--app-secret=APP_SECRET] # Configure app_secret
|
34
|
+
|
35
|
+
The app will ask you if you want to integrate with Pow and install the gems. If you do, your app will be ready to work.
|
36
|
+
|
37
|
+
#### RVM users :
|
38
|
+
Due to security restrictions, you will need to enter the directory, accept the `.rvmrc`, and launch `bundle install` manually
|
39
|
+
|
40
|
+
## Working with hull
|
41
|
+
Launch guard with :
|
42
|
+
|
43
|
+
guard start
|
44
|
+
|
45
|
+
in your newly created application's directory. Livereload will be activated and will refresh your browser for you.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
54
|
+
|
55
|
+
|
56
|
+
# License
|
57
|
+
(The MIT License)
|
58
|
+
|
59
|
+
Copyright © 2012 hull
|
60
|
+
hull.io
|
61
|
+
|
62
|
+
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:
|
63
|
+
|
64
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
65
|
+
|
66
|
+
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.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/hull
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'hull'
|
5
|
+
Bundler.require if File.exists?('Gemfile')
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'hull/cli'
|
9
|
+
Hull::CLI.start
|
10
|
+
rescue Interrupt => e
|
11
|
+
puts "\nBye bye..."
|
12
|
+
exit 1
|
13
|
+
rescue SystemExit => e
|
14
|
+
exit e.status
|
15
|
+
end
|
data/hullapp.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hull/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "hullapp"
|
8
|
+
gem.version = Hull::VERSION
|
9
|
+
gem.authors = ["Romain Dardour"]
|
10
|
+
gem.email = ["romain@hull.io"]
|
11
|
+
gem.description = %q{A command line tool to easily scaffold hull projects}
|
12
|
+
gem.summary = %q{a new way to build social applications}
|
13
|
+
gem.homepage = "http://hull.io"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'thor', '~> 0.16.0'
|
21
|
+
gem.add_dependency 'rack', '~> 1.4.1'
|
22
|
+
gem.add_dependency 'artii'
|
23
|
+
gem.add_dependency 'foreman'
|
24
|
+
gem.add_dependency 'unicorn'
|
25
|
+
gem.add_dependency 'listen'
|
26
|
+
|
27
|
+
end
|
data/lib/hull.rb
ADDED
data/lib/hull/cli.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'listen'
|
4
|
+
require 'rack'
|
5
|
+
require 'thor'
|
6
|
+
require 'artii'
|
7
|
+
|
8
|
+
|
9
|
+
ALLOWED_TEMPLATES = %w{ruby php}
|
10
|
+
ENVIRONMENT_VARIABLES = %w{client_id app_id app_secret}
|
11
|
+
|
12
|
+
# Very much inspired by the nice tool 'catapult' by maccman :
|
13
|
+
# https://github.com/maccman/catapult
|
14
|
+
module Hull
|
15
|
+
class CLI < Thor
|
16
|
+
include Thor::Actions
|
17
|
+
|
18
|
+
no_tasks do
|
19
|
+
|
20
|
+
def artii
|
21
|
+
@artii ||= Artii::Base.new :font=> 'doom'
|
22
|
+
end
|
23
|
+
|
24
|
+
def ruby_postinstall
|
25
|
+
inside @name do
|
26
|
+
run "source .rvmrc && bundle install"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.source_root
|
33
|
+
File.expand_path('../../..', __FILE__)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
desc "server", "start a local development server"
|
38
|
+
def server
|
39
|
+
run 'foreman start -e .powenv -p 5000'
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "livereload", "Launch Guard to automatically reload page on change"
|
43
|
+
def livereload
|
44
|
+
run 'guard start'
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
desc 'configure', 'add hull environment variables'
|
53
|
+
def configure
|
54
|
+
@env ||= {}
|
55
|
+
ENVIRONMENT_VARIABLES.each do |e|
|
56
|
+
if @env[e].nil?
|
57
|
+
a = ask "Enter your #{e} : "
|
58
|
+
@env[e] = a
|
59
|
+
end
|
60
|
+
end
|
61
|
+
template("templates/hullenv.tt", "#{@name}/.hullenv")
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
desc 'symlink', 'symlink to pow directory'
|
66
|
+
def symlink
|
67
|
+
inside @name do
|
68
|
+
run "ln -s #{File.expand_path('.')} ~/.pow/#{@name}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'new', 'Create a new project'
|
73
|
+
method_option :template, :aliases => "-t", :desc => "Choose the template to use", :type => :string
|
74
|
+
method_option :force, :aliases => "-f", :desc => "Don't ask for confirmation", :type => :boolean, :lazy_default => true
|
75
|
+
ENVIRONMENT_VARIABLES.each { |e| method_option e.to_sym, :desc => "Configure #{e}" }
|
76
|
+
|
77
|
+
def new(name)
|
78
|
+
|
79
|
+
unless name
|
80
|
+
say "Sorry, but you need to specify a directory."
|
81
|
+
return false
|
82
|
+
end
|
83
|
+
@name = name
|
84
|
+
|
85
|
+
|
86
|
+
say artii.asciify("hullo, #{name}!\n"), :blue, true
|
87
|
+
|
88
|
+
# template = options[:template]
|
89
|
+
# unless ALLOWED_TEMPLATES.include? template
|
90
|
+
# say "Sorry mate, We don't have a #{template} template - pick again !" unless template
|
91
|
+
# template = ask "Which template should I use ?", :limited_to => ALLOWED_TEMPLATES
|
92
|
+
# end
|
93
|
+
template = 'ruby'
|
94
|
+
|
95
|
+
@env = {}
|
96
|
+
ENVIRONMENT_VARIABLES.each { |e|
|
97
|
+
if options[e.to_sym]
|
98
|
+
@env[e] = options[e.to_sym]
|
99
|
+
end
|
100
|
+
}
|
101
|
+
|
102
|
+
directory "templates/#{template}", @name
|
103
|
+
empty_directory "#{@name}/tmp"
|
104
|
+
|
105
|
+
if @env.empty?
|
106
|
+
config = yes? "Configure hull now ? [yN]"
|
107
|
+
configure if config
|
108
|
+
else
|
109
|
+
configure
|
110
|
+
end
|
111
|
+
|
112
|
+
if template == 'ruby'
|
113
|
+
post = yes? "Install bundles for this app ? [yN]"
|
114
|
+
# export rvm_trust_rvmrcs_flag=1
|
115
|
+
ruby_postinstall if post
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
link = yes? "Symlink this app to pow, so it's available as http://#{@name}.dev ? [yN]"
|
120
|
+
symlink if link
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/lib/hull/version.rb
ADDED
data/templates/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@<%=@name%> --create
|
@@ -0,0 +1,50 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
# session store
|
4
|
+
gem 'dalli', :require => 'rack/session/dalli'
|
5
|
+
gem 'kgio'
|
6
|
+
|
7
|
+
gem 'settingslogic'
|
8
|
+
|
9
|
+
gem 'rake'
|
10
|
+
|
11
|
+
gem 'hullapp', :path => '/Users/romain/Sites/hullapp'
|
12
|
+
|
13
|
+
# rack
|
14
|
+
gem 'rack'
|
15
|
+
gem 'rack-contrib', :require => 'rack/contrib'
|
16
|
+
gem 'rack-protection', :require => 'rack/protection'
|
17
|
+
|
18
|
+
# sinatra
|
19
|
+
gem 'sinatra'
|
20
|
+
gem 'sinatra-flash', :require => 'sinatra/flash' # enables flash[:notice] && flash[:error]
|
21
|
+
|
22
|
+
# faster better stronger
|
23
|
+
gem 'erubis'
|
24
|
+
|
25
|
+
# email
|
26
|
+
gem 'pony'
|
27
|
+
|
28
|
+
|
29
|
+
# workers, disabled for now.
|
30
|
+
gem 'sidekiq'
|
31
|
+
|
32
|
+
gem 'growl'
|
33
|
+
gem 'rb-fsevent'
|
34
|
+
gem 'rack-livereload'
|
35
|
+
|
36
|
+
gem 'guard' , '~> 1.3.1'
|
37
|
+
gem 'guard-livereload'
|
38
|
+
|
39
|
+
|
40
|
+
gem 'compass'
|
41
|
+
gem 'uglifier'
|
42
|
+
gem 'oily_png'
|
43
|
+
gem 'handlebars_assets'
|
44
|
+
gem 'coffee-script'
|
45
|
+
|
46
|
+
# sprockets galore
|
47
|
+
gem 'sprockets'
|
48
|
+
gem 'sprockets-sass'
|
49
|
+
gem 'sprockets-helpers'
|
50
|
+
gem 'compass'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
guard 'livereload' do
|
2
|
+
watch(%r{application/views/.+\.(erb|haml|slim)})
|
3
|
+
watch(%r{application/helpers/.+\.rb})
|
4
|
+
watch(%r{public/.+\.(css|js|html)})
|
5
|
+
watch(%r{config/locales/.+\.yml})
|
6
|
+
# Rails Assets Pipeline
|
7
|
+
watch(%r{(application|vendor)/assets/\w+/(.+\.(scss|css|coffee|js|hbs)).*}) { |m| "/assets/#{m[2]}" }
|
8
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# Foreword : Sixdegrees's Additions
|
2
|
+
|
3
|
+
* Migrated many things to Settings, using [Settingslogic](https://github.com/binarylogic/settingslogic)
|
4
|
+
* Memcached made optional (using settings.yml)
|
5
|
+
* Made sprockets configuration a bit more flexible (using settings.yml)
|
6
|
+
* Added `lib` and `vendor` search paths for Sprockets. Add your extensions & libs, and reference them in vendor.css & vendor.js
|
7
|
+
* Vendored [bootstrap](http://twitter.github.com/bootstrap/)
|
8
|
+
* Added crossdomain.xml & 404 static file
|
9
|
+
* Migrated email notification sender & receiver in settings.yml
|
10
|
+
* Examples for compass spriting, and webfonts inclusion
|
11
|
+
* Ready for Pow…
|
12
|
+
|
13
|
+
|
14
|
+
# Sinatra Boilerplate
|
15
|
+
|
16
|
+
A great place to start with [Sinatra](http://www.sinatrarb.com/), [HTML5 Boilerplate](http://html5boilerplate.com/), [Compass](http://compass-style.org/), [CoffeeScript](http://coffeescript.org/) and [Sprockets (aka the asset pipeline)](https://github.com/sstephenson/sprockets) all cooked together.
|
17
|
+
|
18
|
+
## TL;DR: Get me up and running
|
19
|
+
|
20
|
+
1. Grab the code and `bundle` the gems.
|
21
|
+
2. Make sure you have [memcached](http://www.memcached.org/) installed.
|
22
|
+
3. Run `rake s` to start the development server.
|
23
|
+
|
24
|
+
# What's in the Box
|
25
|
+
|
26
|
+
## HTML5 Boilerplate
|
27
|
+
|
28
|
+
sinatra-boilerplate uses *some* of the utter uber-hawtness that is the [HTML5 Boilerplate](http://html5boilerplate.com/) but *not all*. I opted not to use the build script stuff because I feel like it adds an extra layer of trouble when working with Sinatra.
|
29
|
+
|
30
|
+
The base layout file is pretty compliant with what the Boilerplate puts out except for a few minor tweaks. Most of the comments have been left in place as well.
|
31
|
+
|
32
|
+
Direct implementations from HTML5BP:
|
33
|
+
|
34
|
+
* `html` scoping by class.
|
35
|
+
* Viewport settings for mobile browsers.
|
36
|
+
* Better analytics script.
|
37
|
+
* More awesome CSS base.
|
38
|
+
* ... probably more that I've forgotten :)
|
39
|
+
|
40
|
+
## Modernizr
|
41
|
+
|
42
|
+
[Modernizr](http://www.modernizr.com/) is fantastic and I threw it in because... well, it's fantastic!
|
43
|
+
|
44
|
+
## Modernizr.load
|
45
|
+
|
46
|
+
*There's an [outstanding bug in Yepnope](https://github.com/SlexAxton/yepnope.js/issues/100) that's made `Modernizr.load` a lot less useful so I've decided to stop including it here.* Feel free to use it in your own build but I won't include it here again until that issue gets fixed.
|
47
|
+
|
48
|
+
## Compass
|
49
|
+
|
50
|
+
Because CSS sucks and SASS + Compass doesn't.
|
51
|
+
|
52
|
+
Compass + SASS gives you all kinds of great mixins and nesting stuff that would surely make anyone who's done a lot of CSS quiver in schoolgirl-like delight. Take, for example, some CSS:
|
53
|
+
|
54
|
+
```css
|
55
|
+
#content { border: 1px solid red; }
|
56
|
+
#content p { font-size: 34em; }
|
57
|
+
#content p.small { font-size: 12em; }
|
58
|
+
#content em { color: white; }
|
59
|
+
```
|
60
|
+
|
61
|
+
Not so great. You have to write `#content` each time you want to address that element. How about with Compass?
|
62
|
+
|
63
|
+
```scss
|
64
|
+
#content {
|
65
|
+
border: 1px solid red;
|
66
|
+
|
67
|
+
p {
|
68
|
+
font-size: 34em;
|
69
|
+
|
70
|
+
&.small {
|
71
|
+
font-size: 12em;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
em {
|
75
|
+
color: white;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
Wait, **what**? Yeah, you can nest it all. If you do any CSS at all in your life ever then you should be using Compass.
|
81
|
+
|
82
|
+
[Scope the docs and get crackin'.](http://compass-style.org/)
|
83
|
+
|
84
|
+
|
85
|
+
## Sinatra Addons
|
86
|
+
|
87
|
+
### Run Later
|
88
|
+
|
89
|
+
After filters are great and all, but they block the rendering of the page and that sucks. I want to be able to, mid-render, tell Ruby to go off and do some stuff that I know will take a long time without it stopping the current page. Think of it as an asynchronous (ya know, like AJAX) Ruby request!
|
90
|
+
|
91
|
+
This is a plain insert of my [Sinatra run_later module](https://github.com/l3ck/sinatra_run_later), which I based off of [this run_later module](https://github.com/pmamediagroup/sinatra_run_later) which is based off of [THIS run_later module](https://github.com/mattmatt/run_later). Use it like so:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
require 'rubygems'
|
95
|
+
require 'sinatra'
|
96
|
+
require 'run_later'
|
97
|
+
|
98
|
+
get '/' do
|
99
|
+
run_later do
|
100
|
+
# some task that you don't want to block.
|
101
|
+
sleep 20
|
102
|
+
end
|
103
|
+
|
104
|
+
"Hello World"
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
### Form Tag Helpers
|
116
|
+
|
117
|
+
The thing I missed most in Sinatra was the glorious `input_for` kind of stuff you get with Rails, so I made some!
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
# input_for
|
121
|
+
input_for :first_name # => <input type='text' name='first_name' id='first_name' value=''>
|
122
|
+
|
123
|
+
# input_for with options
|
124
|
+
input_for :email, :type => 'email', :required => nil # => <input type='email' name='email' id='email' required value=''>
|
125
|
+
|
126
|
+
# select_for
|
127
|
+
select_for 'days', { :monday => 'Monday', :myday => 'MY DAY!' }
|
128
|
+
|
129
|
+
# yields
|
130
|
+
# <select name='days' id='days' size='1'>
|
131
|
+
# <option value='monday'>Monday</option>
|
132
|
+
# <option value='myday'>MY DAY!</option>
|
133
|
+
# </select>
|
134
|
+
```
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
## Extra Hawt Sauce
|
143
|
+
|
144
|
+
I've added a bunch of modules and helper functions that I use all the time to this to (hopefully) make your life easier when you're getting your app first setup. Some of the helpers methods I've added include:
|
145
|
+
|
146
|
+
* **SPROCKETS**
|
147
|
+
* holy crap that's nice!!
|
148
|
+
* **core extensions**
|
149
|
+
* extended Hash class with some useful methods for the web
|
150
|
+
* **Sinatra extensions**
|
151
|
+
* a better `erb` method so you don't have to do crap like `erb :"folder/file"` anymore
|
152
|
+
|
153
|
+
|
154
|
+
## How to Use It
|
155
|
+
|
156
|
+
You like it? **Awesome!** Here's how to use it:
|
157
|
+
|
158
|
+
1. Download the sauce (either through git or the download button).
|
159
|
+
2. `bundle`
|
160
|
+
3. Make sure you have [memcached](http://www.memcached.org/) installed.
|
161
|
+
4. Run `rake s` from the directory of the sauce.
|
162
|
+
5. Profit!
|
163
|
+
|
164
|
+
If you have suggestions or think I goofed please let me know or send a pull request.
|
165
|
+
|
166
|
+
## Acknowledgements
|
167
|
+
|
168
|
+
All the stuff used here is either open source or donation ware and totally the work of the people who made it, not me. I just put the pieces together and bundled it up all pretty-like. This little starter package wouldn't be possible without the awesome work these guys have done and their generosity in sharing their code with the rest of us.
|
169
|
+
|
170
|
+
Oh, and...
|
171
|
+
|
172
|
+
<pre>
|
173
|
+
# . . . . . . . . . . . . . . . . _,,,--~~~~~~~~--,_
|
174
|
+
# . . . . . . . . . . . . . . ,-' : : : :::: :::: :: : : : : :º '-, ITS A TRAP!
|
175
|
+
# . . . . . . . . . . . . .,-' :: : : :::: :::: :::: :::: : : :o : '-,
|
176
|
+
# . . . . . . . . . . . ,-' :: ::: :: : : :: :::: :::: :: : : : : :O '-,
|
177
|
+
# . . . . . . . . . .,-' : :: :: :: :: :: : : : : : , : : :º :::: :::: ::';
|
178
|
+
# . . . . . . . . .,-' / / : :: :: :: :: : : :::: :::-, ;; ;; ;; ;; ;; ;; ;\
|
179
|
+
# . . . . . . . . /,-',' :: : : : : : : : : :: :: :: : '-, ;; ;; ;; ;; ;; ;;|
|
180
|
+
# . . . . . . . /,',-' :: :: :: :: :: :: :: : ::_,-~~,_'-, ;; ;; ;; ;; |
|
181
|
+
# . . . . . _/ :,' :/ :: :: :: : : :: :: _,-'/ : ,-';'-'''''~-, ;; ;; ;;,'
|
182
|
+
# . . . ,-' / : : : : : : ,-''' : : :,--'' :|| /,-'-'--'''__,''' \ ;; ;,-'/
|
183
|
+
# . . . \ :/,, : : : _,-' --,,_ : : \ :\ ||/ /,-'-'x### ::\ \ ;;/
|
184
|
+
# . . . . \/ /---'''' : \ #\ : :\ : : \ :\ \| | : (O##º : :/ /-''
|
185
|
+
# . . . . /,'____ : :\ '-#\ : \, : :\ :\ \ \ : '-,___,-',-`-,,
|
186
|
+
# . . . . ' ) : : : :''''--,,--,,,,,,¯ \ \ :: ::--,,_''-,,'''¯ :'- :'-,
|
187
|
+
# . . . . .) : : : : : : ,, : ''''~~~~' \ :: :: :: :'''''¯ :: ,-' :,/\
|
188
|
+
# . . . . .\,/ /|\\| | :/ / : : : : : : : ,'-, :: :: :: :: ::,--'' :,-' \ \
|
189
|
+
# . . . . .\\'|\\ \|/ '/ / :: :_--,, : , | )'; :: :: :: :,-'' : ,-' : : :\ \,
|
190
|
+
# . . . ./¯ :| \ |\ : |/\ :: ::----, :\/ :|/ :: :: ,-'' : :,-' : : : : : : ''-,,
|
191
|
+
# . . ..| : : :/ ''-(, :: :: :: '''''~,,,,,'' :: ,-'' : :,-' : : : : : : : : :,-'''\\
|
192
|
+
# . ,-' : : : | : : '') : : :¯''''~-,: : ,--''' : :,-'' : : : : : : : : : ,-' :¯'''''-,_ .
|
193
|
+
# ./ : : : : :'-, :: | :: :: :: _,,-''''¯ : ,--'' : : : : : : : : : : : / : : : : : : :''-,
|
194
|
+
# / : : : : : -, :¯'''''''''''¯ : : _,,-~'' : : : : : : : : : : : : : :| : : : : : : : : :
|
195
|
+
# : : : : : : : :¯''~~~~~~''' : : : : : : : : : : : : : : : : : : | : : : : : : : : :
|
196
|
+
</pre>
|
197
|
+
|
198
|
+
So, ya know, watch out...
|