piano 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +17 -4
  2. data/bin/piano +10 -2
  3. data/lib/piano.rb +10 -1
  4. data/lib/piano/version.rb +1 -1
  5. metadata +9 -9
@@ -10,9 +10,9 @@ The magic triplet, one command away!
10
10
 
11
11
  == Standalone Usage
12
12
 
13
- server/folder$ piano [<port-number>]
13
+ server/folder$ piano [<port-number> <environment>]
14
14
 
15
- Piano will start a Sinatra server based in the same folder where you run the command, in the port given. If no port is given, piano will start in the default Sinatra port, 4567.
15
+ Piano will start a Sinatra server based in the same folder where you run the command, in the port and environment given. If no port is given, Piano will start in the default Sinatra port <tt>4567</tt> and the default environment <tt>:development</tt>.
16
16
 
17
17
  Haml (http://haml-lang.com) <tt>.haml</tt> files and Sass (http://sass-lang.com) <tt>.sass</tt> and CoffeeScript (http://github.com/josh/ruby-coffee-script) <tt>.coffee</tt> files in the base folder will automatically be mapped to urls.
18
18
 
@@ -68,6 +68,17 @@ When receiving a request for <tt>"/users"</tt>, Piano will look up for a YAML fi
68
68
 
69
69
  Note: You can find this sample in the repository within the <tt>/sample</tt> folder.
70
70
 
71
+ == Going :production!
72
+
73
+ Piano goes production in command line just adding <tt>production</tt> to its arguments. When it goes, it goes this way:
74
+
75
+ * Now any unmatched route will give a zero-information-disclosure nice old 404 error page
76
+ * And the default behaviour for 500 errors in Sinatra.
77
+
78
+ For nicety sake, you can personalize 404 pages simply by creating a <tt>server/folder/404.haml</tt> template. Beware when you do: out there be dragons.
79
+
80
+ Note: you can also add a <tt>server/folder/data/404.yaml</tt> file to keep layer separation even in your error pages.
81
+
71
82
  == Library Usage
72
83
 
73
84
  If you want, you can include Piano as a library in your own server. Kind of defeats the point of using Piano, but useful if you want to extend its functionality.
@@ -146,12 +157,14 @@ Etags cause client side caching. This should not be a problem since the hash cha
146
157
  * Custom error when there's no data
147
158
  * More helpers for semantic data handling.
148
159
  * Deploy of sample with command line <tt>--sample</tt> argument.
149
- * Setup to production enviroment option (why not?!)
150
160
  * Online source files edition.
151
161
 
162
+ DONE &gt; Setup to production enviroment option (why not?!)
163
+ * Now it would be nice to give Piano personalized templates not only to 404 but for all error pages, specially 500
164
+
152
165
  == Tips
153
166
 
154
- As for v0.7, not really suitable for production use, since any empty URL will return a full path disclosure of the file that Piano intended to load.
167
+ As for v0.7.3, Piano has now the ability to go <tt>:production</tt> mode both in command line and library modes.
155
168
 
156
169
  Piano is in intensive development, you might want to keep track of small updates with Bundler pointing to the github repository. Here is the line to put in your Gemfile
157
170
 
data/bin/piano CHANGED
@@ -2,8 +2,16 @@
2
2
 
3
3
  require "piano"
4
4
 
5
- if port = ARGV.shift
6
- Piano.port = port
5
+ unless ARGV.empty?
6
+
7
+ ARGV.each do |arg|
8
+ if arg =~ /^\d+$/
9
+ Piano.port = arg
10
+ elsif arg =~ /^[a-z]+$/
11
+ Piano.environment = arg.to_sym
12
+ end
13
+ end
14
+
7
15
  end
8
16
 
9
17
  Piano.run!
@@ -73,7 +73,16 @@ class Piano < Sinatra::Base
73
73
  end
74
74
 
75
75
  def bad_luck(path)
76
- halt 404, "<h1>You have still to put something here.</h1><p>This is <em>#{path}</em></p><blockquote>Good luck!</blockquote>"
76
+ if settings.environment == :production
77
+ if File.exists? "#{pwd}/404.haml"
78
+ @data = data_for "404"
79
+ halt 404, haml(:"404")
80
+ else
81
+ halt 404, "<h1>404 - Not Found</h1><p>Piano has found nothing in this address</p>"
82
+ end
83
+ else
84
+ halt 404, "<h1>You have still to put something here.</h1><p>This is <em>#{path}</em></p><blockquote>Good luck!</blockquote>"
85
+ end
77
86
  end
78
87
 
79
88
  def hash_for(name, type)
@@ -1,3 +1,3 @@
1
1
  module Piano
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra
17
- requirement: &20782944 !ruby/object:Gem::Requirement
17
+ requirement: &21772596 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.2.6
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *20782944
25
+ version_requirements: *21772596
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: haml
28
- requirement: &20782644 !ruby/object:Gem::Requirement
28
+ requirement: &21772296 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 3.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *20782644
36
+ version_requirements: *21772296
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sass
39
- requirement: &20782368 !ruby/object:Gem::Requirement
39
+ requirement: &21772020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 3.1.1
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *20782368
47
+ version_requirements: *21772020
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: coffee-script
50
- requirement: &20782092 !ruby/object:Gem::Requirement
50
+ requirement: &21771744 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: 2.2.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *20782092
58
+ version_requirements: *21771744
59
59
  description: Out-of-the-box sinatra server for web site sketching using haml + sass
60
60
  + coffee-script
61
61
  email: