piano 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +26 -8
- data/bin/piano +4 -2
- data/lib/piano.rb +5 -9
- data/lib/piano/version.rb +1 -1
- metadata +10 -10
data/README.rdoc
CHANGED
@@ -22,6 +22,26 @@ Haml (http://haml-lang.com) <tt>.haml</tt> files and Sass (http://sass-lang.com)
|
|
22
22
|
|
23
23
|
Other files (images, plain text files, etc) will be loaded from the <tt>server/folder/public</tt> as is default behavior in Sinatra.
|
24
24
|
|
25
|
+
== Extending functionality
|
26
|
+
|
27
|
+
Piano will try to load a file named <tt>server/folder/.piano</tt>. There you can add functionality, like custom helpers.
|
28
|
+
|
29
|
+
==== Sample <tt>.piano</tt> file
|
30
|
+
|
31
|
+
This file, for example, will bring back the email masking functionality that was deprecated in version 0.7.6
|
32
|
+
|
33
|
+
class Piano
|
34
|
+
helpers do
|
35
|
+
def unicode_entities(string)
|
36
|
+
encodings = ""
|
37
|
+
string.codepoints do |c|
|
38
|
+
encodings += "&##{c};"
|
39
|
+
end
|
40
|
+
encodings
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
25
45
|
== YAML Data
|
26
46
|
|
27
47
|
When receiving a request for <tt>"/users"</tt>, Piano will look up for a YAML file <tt>server/folder/data/users.haml</tt>. If it is there, the YAML file will be loaded and available for the correspondent Haml template in the <tt>@data</tt> variable.
|
@@ -84,7 +104,6 @@ Note: you can also add a <tt>server/folder/data/404.yaml</tt> file to keep layer
|
|
84
104
|
* Port number: Any number passed as an argument to the <tt>piano</tt> command will be used as the port number.
|
85
105
|
* Environment: Any string that does not matches any other argument will be setted as the environment.
|
86
106
|
* <tt>noetags</tt>: Adding <tt>noetags</tt> to the shell command will cause Piano to run without etags.
|
87
|
-
* <tt>nocoffee</tt>: Adding <tt>nocoffee</tt> to the shell command will cause Piano to Not load the CoffeeScript library. Useful when no JavaScript environment is available.
|
88
107
|
|
89
108
|
== Library Usage
|
90
109
|
|
@@ -155,12 +174,6 @@ You can use them in your haml templates like this:
|
|
155
174
|
Another helper you may find useful is <tt>extract("source_text/html", word_count = 80)</tt>. Returns an extract of the first <tt>word_count</tt> words (default is 80), html tags stripped, and closed by <tt>"..."</tt> . It does nothing is the text is less than <tt>word_count</tt> words in length.
|
156
175
|
|
157
176
|
%p= extract content, 25
|
158
|
-
|
159
|
-
==== <tt>unicode_entities</tt>
|
160
|
-
|
161
|
-
Useful for hashing email addresses (and hiding them from crawlers. Returns the htmlentities in unicode for each letter of the argument string. For example:
|
162
|
-
|
163
|
-
%p= unicode_entities "sample@address.com"
|
164
177
|
|
165
178
|
Code is poetry.
|
166
179
|
|
@@ -176,6 +189,7 @@ Etags cause client side caching. This should not be a problem since the hash cha
|
|
176
189
|
* haml (http://haml-lang.com)
|
177
190
|
* sass (http://sass-lang.com)
|
178
191
|
* coffee-script (http://github.com/josh/ruby-coffee-script)
|
192
|
+
* therubyracer (http://rubygems.org/gems/therubyracer)
|
179
193
|
|
180
194
|
== Desired (future) features
|
181
195
|
|
@@ -186,7 +200,6 @@ Etags cause client side caching. This should not be a problem since the hash cha
|
|
186
200
|
* Deploy of sample with command line <tt>--sample</tt> argument.
|
187
201
|
* Online source files edition.
|
188
202
|
* Test <tt>use Piano</tt> within a <tt>Sinatra::Base</tt> class.
|
189
|
-
* If CoffeeScript can't run, inform of the <tt>nocoffee</tt> command line option.
|
190
203
|
|
191
204
|
* Now it would be nice to give Piano personalized templates not only to 404 but for all error pages, specially 500
|
192
205
|
* Custom error when there's no data
|
@@ -195,6 +208,7 @@ Etags cause client side caching. This should not be a problem since the hash cha
|
|
195
208
|
|
196
209
|
* Setup to production enviroment option (why not?!)
|
197
210
|
* Etag on/off (currently etags are hardcoded on)
|
211
|
+
* CoffeeScript appears to ve working everywhere once <tt>therubyracer</tt> was added as a dependency, so the nocoffee option was deleted.
|
198
212
|
|
199
213
|
== Tips
|
200
214
|
|
@@ -204,6 +218,10 @@ Piano is in intensive development, you might want to keep track of small updates
|
|
204
218
|
|
205
219
|
gem "piano", :git => "git://github.com/xaviervia/piano.git"
|
206
220
|
|
221
|
+
== Deprecated functions
|
222
|
+
|
223
|
+
From version 0.7.6 on, <tt>unicode_entities</tt> has been deprecated for better Ruby version backwards compatibility.
|
224
|
+
|
207
225
|
= License
|
208
226
|
|
209
227
|
(The MIT License)
|
data/bin/piano
CHANGED
@@ -9,8 +9,6 @@ unless ARGV.empty?
|
|
9
9
|
args[:port] = arg
|
10
10
|
elsif arg =~ /^noetags$/
|
11
11
|
args[:etags] = :off
|
12
|
-
elsif arg =~ /^nocoffee/
|
13
|
-
$notcoffeescript = true
|
14
12
|
elsif arg =~ /^sample$/
|
15
13
|
puts "Warning: the sample site folder files will be created in the current directory."
|
16
14
|
puts "Any files with the same name will be overwritten."
|
@@ -53,4 +51,8 @@ def make_sample
|
|
53
51
|
FileUtils.cp_r "#{source_dir}/sample", this_dir
|
54
52
|
end
|
55
53
|
|
54
|
+
if File.exists?(File.expand_path(Dir.pwd) + "/.piano")
|
55
|
+
load File.expand_path(Dir.pwd) + "/.piano"
|
56
|
+
end
|
57
|
+
|
56
58
|
Piano.run!
|
data/lib/piano.rb
CHANGED
@@ -3,8 +3,12 @@ require "haml"
|
|
3
3
|
require "sass"
|
4
4
|
require "yaml"
|
5
5
|
|
6
|
-
|
6
|
+
begin
|
7
7
|
require "coffee-script"
|
8
|
+
rescue Exception => error
|
9
|
+
puts "No JavaScript environment was found. Please install therubyracer gem"
|
10
|
+
puts " gem install therubyracer"
|
11
|
+
Process.exit!
|
8
12
|
end
|
9
13
|
|
10
14
|
class Piano < Sinatra::Base
|
@@ -120,14 +124,6 @@ class Piano < Sinatra::Base
|
|
120
124
|
return text if words.length <= length
|
121
125
|
words[0..(length-1)].join(" ") + "..."
|
122
126
|
end
|
123
|
-
|
124
|
-
def unicode_entities(string)
|
125
|
-
encodings = ""
|
126
|
-
string.codepoints do |c|
|
127
|
-
encodings += "&##{c};"
|
128
|
-
end
|
129
|
-
encodings
|
130
|
-
end
|
131
127
|
end
|
132
128
|
|
133
129
|
def self.play!
|
data/lib/piano/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-25 00:00:00.000000000 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
17
|
-
requirement: &
|
17
|
+
requirement: &20217504 !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: *
|
25
|
+
version_requirements: *20217504
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: haml
|
28
|
-
requirement: &
|
28
|
+
requirement: &20217204 !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: *
|
36
|
+
version_requirements: *20217204
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: sass
|
39
|
-
requirement: &
|
39
|
+
requirement: &20216928 !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: *
|
47
|
+
version_requirements: *20216928
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: coffee-script
|
50
|
-
requirement: &
|
50
|
+
requirement: &20216652 !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: *
|
58
|
+
version_requirements: *20216652
|
59
59
|
description: Out-of-the-box sinatra server for web site sketching using haml + sass
|
60
60
|
+ coffee-script
|
61
61
|
email:
|