piano 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -9
- data/lib/piano.rb +6 -0
- data/lib/piano/version.rb +1 -1
- data/sample/data/index.yaml +3 -1
- metadata +10 -10
data/README.rdoc
CHANGED
@@ -24,13 +24,13 @@ Other files (images, plain text files, etc) will be loaded from the <tt>server/f
|
|
24
24
|
|
25
25
|
== YAML Data
|
26
26
|
|
27
|
-
When receiving a request for <tt>"/users"</tt>, Piano will look up for a YAML file <tt>server/folder
|
27
|
+
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.
|
28
28
|
|
29
29
|
== 5 minutes site!
|
30
30
|
|
31
31
|
...all working with stylesheet, scripts and YAML data sources.
|
32
32
|
|
33
|
-
|
33
|
+
==== folder/index.haml
|
34
34
|
|
35
35
|
!!! 5
|
36
36
|
%head
|
@@ -44,7 +44,7 @@ When receiving a request for <tt>"/users"</tt>, Piano will look up for a YAML fi
|
|
44
44
|
- @data['list'].each do |item|
|
45
45
|
%li= item
|
46
46
|
|
47
|
-
|
47
|
+
==== folder/style.sass
|
48
48
|
|
49
49
|
body
|
50
50
|
width: 960px
|
@@ -53,11 +53,11 @@ When receiving a request for <tt>"/users"</tt>, Piano will look up for a YAML fi
|
|
53
53
|
family: sans-serif
|
54
54
|
size: 15px
|
55
55
|
|
56
|
-
|
56
|
+
==== folder/app.coffee
|
57
57
|
|
58
58
|
alert "This is too simple to be true"
|
59
59
|
|
60
|
-
|
60
|
+
==== folder/data/index.yaml
|
61
61
|
|
62
62
|
title: 5 minutes site!
|
63
63
|
description: Is amazing how simple it gets
|
@@ -66,7 +66,7 @@ When receiving a request for <tt>"/users"</tt>, Piano will look up for a YAML fi
|
|
66
66
|
- a list
|
67
67
|
- also.
|
68
68
|
|
69
|
-
Note: You can find this sample in the repository within the sample folder.
|
69
|
+
Note: You can find this sample in the repository within the <tt>/sample</tt> folder.
|
70
70
|
|
71
71
|
== Library Usage
|
72
72
|
|
@@ -76,7 +76,7 @@ If you want, you can include Piano as a library in your own server. Kind of defe
|
|
76
76
|
|
77
77
|
Piano.play! # .play! added 4 the lulz; Piano.run! will do the trick aswell
|
78
78
|
|
79
|
-
Piano inherits Sinatra::Base
|
79
|
+
<tt>Piano</tt> inherits <tt>Sinatra::Base</tt>, so all of <tt>Sinatra::Base</tt> own methods are available.
|
80
80
|
|
81
81
|
Of course, you can also do this:
|
82
82
|
|
@@ -108,6 +108,10 @@ You can use them in your haml templates like this:
|
|
108
108
|
= style "style.css"
|
109
109
|
= script "app.js"
|
110
110
|
|
111
|
+
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.
|
112
|
+
|
113
|
+
%p= extract content, 25
|
114
|
+
|
111
115
|
Code is poetry.
|
112
116
|
|
113
117
|
=== Etags
|
@@ -126,12 +130,21 @@ Etags cause client side caching. This should not be a problem since the hash cha
|
|
126
130
|
== Desired (future) features
|
127
131
|
|
128
132
|
* Etag on/off (currently etags are hardcoded on)
|
129
|
-
*
|
133
|
+
* Folder paths and sinatra default arguments configurable.
|
134
|
+
* Condition for disabling default Piano routes
|
135
|
+
* Further documentation of Piano helpers
|
136
|
+
* More helpers for semantic data handling.
|
137
|
+
* Deploy of sample with command line <tt>--sample</tt> argument.
|
138
|
+
* Setup to production enviroment option (why not?!)
|
130
139
|
* Online source files edition.
|
131
140
|
|
132
141
|
== Tips
|
133
142
|
|
134
|
-
|
143
|
+
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.
|
144
|
+
|
145
|
+
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
|
146
|
+
|
147
|
+
gem "piano", :git => "git://github.com/xaviervia/piano.git"
|
135
148
|
|
136
149
|
= License
|
137
150
|
|
data/lib/piano.rb
CHANGED
@@ -79,6 +79,12 @@ class Piano < Sinatra::Base
|
|
79
79
|
def hash_for(name, type)
|
80
80
|
"#{name}.#{type} - " + File.mtime("#{pwd}/#{name}.#{type}").to_s
|
81
81
|
end
|
82
|
+
|
83
|
+
def extract(text, length = 80)
|
84
|
+
words = text.gsub(/<.+?>/, "").split
|
85
|
+
return text if words.length <= length
|
86
|
+
words[0..(length-1)].join(" ") + "..."
|
87
|
+
end
|
82
88
|
end
|
83
89
|
|
84
90
|
def self.play!
|
data/lib/piano/version.rb
CHANGED
data/sample/data/index.yaml
CHANGED
@@ -3,4 +3,6 @@ description: Is amazing how simple it gets
|
|
3
3
|
list:
|
4
4
|
- and I can have
|
5
5
|
- a list
|
6
|
-
- also.
|
6
|
+
- also.
|
7
|
+
content: |
|
8
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a tortor vel sapien facilisis faucibus at eget dolor. Sed rhoncus est sit amet ipsum cursus eu porttitor dui eleifend. Maecenas accumsan egestas dolor eu imperdiet. Maecenas molestie urna quis sapien volutpat eu pretium risus rutrum. Pellentesque commodo urna eu tortor euismod venenatis. Pellentesque luctus dui ullamcorper eros feugiat sit amet suscipit lectus iaculis. Aliquam dolor massa, pulvinar id feugiat sed, commodo non dolor. Mauris fringilla purus ut nunc dapibus ac posuere velit adipiscing. Etiam id vestibulum eros. Aenean id dolor lorem. Donec sed lacus vel sem congue congue eu nec tellus.
|
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.1
|
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-10 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: &21661932 !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: *21661932
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: haml
|
28
|
-
requirement: &
|
28
|
+
requirement: &21661632 !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: *21661632
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: sass
|
39
|
-
requirement: &
|
39
|
+
requirement: &21661356 !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: *21661356
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: coffee-script
|
50
|
-
requirement: &
|
50
|
+
requirement: &21661080 !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: *21661080
|
59
59
|
description: Out-of-the-box sinatra server for web site sketching using haml + sass
|
60
60
|
+ coffee-script
|
61
61
|
email:
|