piano 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +1 -4
  2. data/lib/piano.rb +7 -101
  3. data/lib/piano/version.rb +1 -1
  4. metadata +13 -13
data/README.rdoc CHANGED
@@ -194,6 +194,7 @@ Etags cause client side caching. This should not be a problem since the hash cha
194
194
  == Desired (future) features
195
195
 
196
196
  * Folder paths configurable.
197
+ * <tt>style</tt> and <tt>script</tt> helpers working with symbols.
197
198
  * Further documentation of Piano helpers
198
199
  * More helpers for semantic data handling.
199
200
  * Deploy of sample with command line <tt>--sample</tt> argument.
@@ -214,10 +215,6 @@ Etags cause client side caching. This should not be a problem since the hash cha
214
215
 
215
216
  As for v0.7.3, Piano has now the ability to go <tt>:production</tt> mode both in command line and library modes.
216
217
 
217
- 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
218
-
219
- gem "piano", :git => "git://github.com/xaviervia/piano.git"
220
-
221
218
  == Deprecated functions
222
219
 
223
220
  From version 0.7.6 on, <tt>unicode_entities</tt> has been deprecated for better Ruby version backwards compatibility.
data/lib/piano.rb CHANGED
@@ -14,107 +14,6 @@ end
14
14
 
15
15
  module Sinatra
16
16
  module Piano
17
- module Helpers
18
- def try_haml(template)
19
- file_name = "#{pwd}/#{template}.haml"
20
- bad_luck file_name unless File.exists? file_name
21
-
22
- if etags?
23
- hash = hash_for template, :haml
24
- hash += hash_for "data/#{template}", :yaml if File.exists? "#{pwd}/data/#{template}.yaml"
25
- etag hash
26
- end
27
- haml template.to_sym
28
- end
29
-
30
- def sass(template)
31
- file_name = "#{pwd}/#{template}.sass"
32
- bad_luck file_name unless File.exists? file_name
33
-
34
- etag hash_for(template, :sass) if etags?
35
- Sass.compile File.read(file_name), :syntax => :sass
36
- end
37
-
38
- def coffee(template)
39
- file_name = "#{pwd}/#{template}.coffee"
40
- bad_luck file_name unless File.exists? file_name
41
-
42
- etag hash_for(template, :coffee) if etags?
43
- CoffeeScript.compile(File.read(file_name))
44
- end
45
-
46
- def data_for(template)
47
- file_name = "#{pwd}/data/#{template}.yaml"
48
- YAML.load_file(file_name) if File.exists?(file_name)
49
- end
50
-
51
- def style(path)
52
- "<link rel='stylesheet' type='text/css' href='#{path}' />"
53
- end
54
-
55
- def script(path)
56
- "<script type='text/javascript' src='#{path}'></script>"
57
- end
58
-
59
- def pwd
60
- settings.views
61
- end
62
-
63
- def bad_luck(path)
64
- content_type :html
65
- if settings.environment == :production
66
- if File.exists? "#{pwd}/404.haml"
67
- @data = data_for "404"
68
- halt 404, haml(:"404")
69
- else
70
- halt 404, "<h1>404 - Not Found</h1><p>Piano has found nothing in this address</p>"
71
- end
72
- else
73
- halt 404, "<h1>You have still to put something here.</h1><p>This is <em>#{path}</em></p><blockquote>Good luck!</blockquote>"
74
- end
75
- end
76
-
77
- def hash_for(name, type)
78
- "#{name}.#{type} - " + File.mtime("#{pwd}/#{name}.#{type}").to_s
79
- end
80
-
81
- def extract(text, length = 80)
82
- words = text.gsub(/<.+?>/, "").split
83
- return text if words.length <= length
84
- words[0..(length-1)].join(" ") + "..."
85
- end
86
-
87
- def link(text, length = 5)
88
- words = text
89
- .gsub(/<.+?>/, "")
90
- .gsub(" ", "-")
91
- .downcase
92
- .gsub(/[^a-z0-9\-]/, "")
93
- .split("-")
94
- words[0..(length-1)].join("-")
95
- end
96
-
97
- def etags?
98
- if settings.respond_to? :etags
99
- settings.etags == :on
100
- else
101
- true
102
- end
103
- end
104
-
105
- def t(key)
106
- I18n.translate key
107
- end
108
- end
109
- end
110
-
111
- helpers Piano::Helpers
112
- end
113
-
114
-
115
-
116
- class Piano < Sinatra::Base
117
- helpers do
118
17
  def try_haml(template)
119
18
  file_name = "#{pwd}/#{template}.haml"
120
19
  bad_luck file_name unless File.exists? file_name
@@ -206,7 +105,14 @@ class Piano < Sinatra::Base
206
105
  I18n.translate key
207
106
  end
208
107
  end
108
+
109
+ register Piano
110
+ end
111
+
209
112
 
113
+
114
+ class Piano < Sinatra::Base
115
+ register Sinatra::Piano
210
116
 
211
117
  set :root, File.expand_path(Dir.pwd)
212
118
  set :views, File.expand_path(Dir.pwd)
data/lib/piano/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Piano
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
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.8.4
4
+ version: 0.8.5
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: &22118244 !ruby/object:Gem::Requirement
17
+ requirement: &23082864 !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: *22118244
25
+ version_requirements: *23082864
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: haml
28
- requirement: &22117824 !ruby/object:Gem::Requirement
28
+ requirement: &23082444 !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: *22117824
36
+ version_requirements: *23082444
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sass
39
- requirement: &22117368 !ruby/object:Gem::Requirement
39
+ requirement: &23081964 !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: *22117368
47
+ version_requirements: *23081964
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: coffee-script
50
- requirement: &22116924 !ruby/object:Gem::Requirement
50
+ requirement: &23081544 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.2.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *22116924
58
+ version_requirements: *23081544
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: i18n
61
- requirement: &22116528 !ruby/object:Gem::Requirement
61
+ requirement: &23081148 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.6.0
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *22116528
69
+ version_requirements: *23081148
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: metafun
72
- requirement: &22116264 !ruby/object:Gem::Requirement
72
+ requirement: &23080884 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *22116264
80
+ version_requirements: *23080884
81
81
  description: Out-of-the-box sinatra server for web site sketching using haml + sass
82
82
  + coffee-script
83
83
  email: