proton 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,72 +1,8 @@
1
1
  # [Proton](http://sinefunc.com/proton?)
2
2
  #### Proton is a website preprocessor.
3
3
 
4
- http://sinefunc.com/proton/
5
-
6
- - __HAML, Sass, Compass and more:__ Proton will let you write in HAML, SCSS,
7
- Sass, and more by default. It also comes preloaded with
8
- [Compass](http://compass-style.org).
9
-
10
- - __Layouts and Partials:__ Proton lets you define your site's header and footer
11
- layouts in a separate file, and even separate snippets of your site
12
- into reuseable components (partials). Your code will be much cleaner and
13
- DRYer!
14
-
15
- - __Template languages:__ Proton lets you write your site in any template
16
- language you need -- the translation will be taken care of for you.
17
- Proton supports HAML, LessCSS, Markdown, SASS and Textile by default, and
18
- more can be added through extensions.
19
-
20
- - __Extendable:__ Proton is easily customizable with extensions. You can add
21
- new helpers, new commands, support for new languages and many more by
22
- simply adding the extensions to your project folder. Some are even
23
- available as simple Ruby gems!
24
-
25
- - __Design fast:__ Proton comes with a web server that lets you serve up
26
- your site locally. Any changes to your files will be seen on your next
27
- browser refresh!
28
-
29
- - __Build your site as static HTMLs:__ You can export your site as plain
30
- HTML files with one simple command.
31
-
32
- Why use Proton?
33
- ---------------
34
-
35
- It's like building a static site, but better! You can use Proton for:
36
-
37
- - Building HTML prototypes
38
- - Building sites with no dynamic logic
39
- - Creating a blog where the entries are stored in a source repository
40
-
41
- Installation
42
- ------------
43
-
44
- gem install proton
45
-
46
- Usage
47
- -----
48
-
49
- Here's how you can get started:
50
-
51
- proton create <project_name>
52
- cd <project_name>
53
- proton build # <= Build the HTML files, or
54
- proton start # <= Serve via a local web server
55
-
56
-
57
- Testing
58
- -------
59
-
60
- Run tests:
61
-
62
- rake test
63
-
64
- To try it in a different Ruby version, you can use RVM + Bundler to make
65
- things easier. For instance:
66
-
67
- rvm use 1.8.7@proton --create # Create a gemset
68
- bundle install # Install the needed gems on that set
69
- rake test
4
+ * Website: http://sinefunc.com/proton/
5
+ * Documentation: http://sinefunc.com/proton/manual
70
6
 
71
7
  Authors
72
8
  -------
data/Rakefile CHANGED
@@ -2,4 +2,18 @@ task :test do
2
2
  Dir['test/**/*_test.rb'].each { |f| load f }
3
3
  end
4
4
 
5
+ namespace :doc do
6
+ desc "Builds the docs in doc/."
7
+ task :update do
8
+ # gem install proscribe (~> 0.0.2)
9
+ system "proscribe build"
10
+ end
11
+
12
+ desc "Updates the online manual."
13
+ task :deploy => :update do
14
+ # http://github.com/rstacruz/git-update-ghpages
15
+ system "git update-ghpages sinefunc/proton -i doc --prefix manual"
16
+ end
17
+ end
18
+
5
19
  task :default => :test
@@ -1,4 +1,4 @@
1
- !!!
1
+ !!! 5
2
2
  %html
3
3
  %head
4
4
  %title= page.title
@@ -1,4 +1,4 @@
1
1
  source :rubygems
2
2
 
3
- gem "proton", "~> 0.3.2"
3
+ gem "proton", "~> 0.3.4"
4
4
  gem "rack-cache", "~> 1.0.0"
@@ -51,15 +51,16 @@ class Proton
51
51
  # An array of the allowed config filenames.
52
52
  CONFIG_FILES = ['Protonfile', 'proton.conf', '.protonrc', 'hyde.conf', '.hyderc']
53
53
 
54
- autoload :Project, "#{PREFIX}/proton/project"
55
- autoload :Page, "#{PREFIX}/proton/page"
56
- autoload :Meta, "#{PREFIX}/proton/meta"
57
- autoload :Config, "#{PREFIX}/proton/config"
58
- autoload :CLI, "#{PREFIX}/proton/cli"
59
- autoload :Set, "#{PREFIX}/proton/set"
60
- autoload :Layout, "#{PREFIX}/proton/layout"
61
- autoload :Partial, "#{PREFIX}/proton/partial"
62
- autoload :Helpers, "#{PREFIX}/proton/helpers"
54
+ autoload :Project, "#{PREFIX}/proton/project"
55
+ autoload :Page, "#{PREFIX}/proton/page"
56
+ autoload :Meta, "#{PREFIX}/proton/meta"
57
+ autoload :Config, "#{PREFIX}/proton/config"
58
+ autoload :CLI, "#{PREFIX}/proton/cli"
59
+ autoload :Set, "#{PREFIX}/proton/set"
60
+ autoload :Layout, "#{PREFIX}/proton/layout"
61
+ autoload :Partial, "#{PREFIX}/proton/partial"
62
+ autoload :Helpers, "#{PREFIX}/proton/helpers"
63
+ autoload :Cacheable, "#{PREFIX}/proton/cacheable"
63
64
 
64
65
  require "#{PREFIX}/proton/version"
65
66
 
@@ -0,0 +1,47 @@
1
+ class Proton
2
+ # Module: Cache
3
+ module Cacheable
4
+ def self.enable!
5
+ @enabled = true
6
+ end
7
+
8
+ def self.disable!
9
+ @enabled = false
10
+ end
11
+
12
+ def self.enabled?()
13
+ !! @enabled
14
+ end
15
+
16
+ # Enable by default
17
+ enable!
18
+
19
+ def self.cache(*args)
20
+ if enabled?
21
+ @cache ||= Hash.new
22
+ args = args.map { |s| s.to_s }.join('-')
23
+ @cache[args] ||= yield
24
+ else
25
+ yield
26
+ end
27
+ end
28
+
29
+ def cache_method(*methods)
30
+ methods.each do |method|
31
+ alias_method :"real_#{method}", method
32
+
33
+ class_eval do
34
+ define_method(method) { |*args|
35
+ id = nil
36
+ id ||= self.file if respond_to?(:file)
37
+ id ||= self.to_s
38
+
39
+ Cacheable.cache self.class, method, id, args do
40
+ send :"real_#{method}", *args
41
+ end
42
+ }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,4 +1,4 @@
1
- # Class: Proton::CLI (Proton)
1
+ # Class: Proton::CLI
2
2
  # Command line runner.
3
3
 
4
4
  class Proton
@@ -1,4 +1,4 @@
1
- # Module: Proton::Helpers (Proton)
1
+ # Module: Proton::Helpers
2
2
  # Helpers you can use in your pages.
3
3
  #
4
4
  # ## Creating your own helpers
@@ -10,7 +10,7 @@
10
10
  class Proton
11
11
  module Helpers
12
12
 
13
- # Method: partial (Proton::Helpers)
13
+ # Helper: partial (Helpers)
14
14
  # Renders a partial.
15
15
  #
16
16
  # ## Usage
@@ -38,7 +38,7 @@ module Helpers
38
38
  partial.to_html locals.merge(:page => self)
39
39
  end
40
40
 
41
- # Method: rel (Proton::Helpers)
41
+ # Helper: rel (Helpers)
42
42
  # Turns a path into a relative path.
43
43
  #
44
44
  # ## Usage
@@ -76,14 +76,14 @@ module Helpers
76
76
  end
77
77
  end
78
78
 
79
- # Method: content_for (Proton::Helpers)
79
+ # Helper: content_for (Helpers)
80
80
  # Content for.
81
81
  #
82
82
  # ## See also
83
83
  #
84
- # * {Proton::Helpers::has_content?}
85
- # * {Proton::Helpers::content_for}
86
- # * {Proton::Helpers::yield_content}
84
+ # * {Helpers:has_content?}
85
+ # * {Helpers:content_for}
86
+ # * {Helpers:yield_content}
87
87
  #
88
88
  def content_for(key, &blk)
89
89
  content_blocks[key.to_sym] = blk
@@ -94,31 +94,31 @@ module Helpers
94
94
  $content_blocks[page.path] ||= Hash.new
95
95
  end
96
96
 
97
- # Method: has_content? (Proton::Helpers)
97
+ # Helper: has_content? (Helpers)
98
98
  # Checks if there's something defined for a given content block.
99
99
  #
100
100
  # ## Example
101
- # See {Proton::Helpers::content_for} for an example.
101
+ # See {Helpers:content_for} for an example.
102
102
  #
103
103
  # ## See also
104
- # * {Proton::Helpers::has_content?}
105
- # * {Proton::Helpers::content_for}
106
- # * {Proton::Helpers::yield_content}
104
+ # * {Helpers:has_content?}
105
+ # * {Helpers:content_for}
106
+ # * {Helpers:yield_content}
107
107
  #
108
108
  def has_content?(key)
109
109
  content_blocks.member? key.to_sym
110
110
  end
111
111
 
112
- # Method: yield_content (Proton::Helpers)
112
+ # Helper: yield_content (Helpers)
113
113
  # Yield
114
114
  #
115
115
  # ## Example
116
- # See {Proton::Helpers::content_for} for an example.
116
+ # See {Helpers:content_for} for an example.
117
117
  #
118
118
  # ## See also
119
- # * {Proton::Helpers::has_content?}
120
- # * {Proton::Helpers::content_for}
121
- # * {Proton::Helpers::yield_content}
119
+ # * {Helpers:has_content?}
120
+ # * {Helpers:content_for}
121
+ # * {Helpers:yield_content}
122
122
  #
123
123
  def yield_content(key, *args)
124
124
  content = content_blocks[key.to_sym]
@@ -1,112 +1,131 @@
1
1
  class Proton
2
- # A project.
2
+ # Class: Proton::Page
3
+ # A page.
4
+ #
5
+ # ## Common usage
3
6
  #
4
7
  # Getting pages from paths:
5
8
  #
6
- # # Feed it a URL path, not a filename.
7
- # page = Proton::Page['/index.html'] # uses Proton.project
8
- # page = Proton::Page['/index.html', project]
9
+ # # Feed it a URL path, not a filename.
10
+ # page = Proton::Page['/index.html'] # uses Proton.project
11
+ # page = Proton::Page['/index.html', project]
9
12
  #
10
13
  # Getting pages from files:
11
14
  #
12
- # # Feed it a file name, not a URL path.
13
- # # Also, this does no sanity checks.
14
- # page = Proton::Page.new('/home/rsc/index.html', project)
15
+ # # Feed it a file name, not a URL path.
16
+ # # Also, this does no sanity checks.
17
+ # page = Proton::Page.new('/home/rsc/index.html', project)
15
18
  #
16
- # page.exists?
17
- # page.valid?
19
+ # page.exists?
20
+ # page.valid?
18
21
  #
19
22
  # Paths:
20
23
  #
21
- # page.filepath #=> "index.haml" -- path in the filesystem
22
- # page.path #=> "/index.html" -- path as a RUL
24
+ # page.filepath #=> "index.haml" -- path in the filesystem
25
+ # page.path #=> "/index.html" -- path as a RUL
23
26
  #
24
27
  # Meta:
25
28
  #
26
- # page.meta #=> OpenStruct of the metadata
27
- # page.title #=> "Welcome to my site!"
29
+ # page.meta #=> OpenStruct of the metadata
30
+ # page.title #=> "Welcome to my site!"
28
31
  #
29
- # page.layout # Proton::Layout or nil
30
- # page.layout?
32
+ # page.layout # Proton::Layout or nil
33
+ # page.layout?
31
34
  #
32
35
  # Types:
33
36
  #
34
- # page.html?
35
- # page.mime_type #=> "text/html" or nil -- only for tilt? == true
36
- # page.default_ext #=> "html"
37
+ # page.html?
38
+ # page.mime_type #=> "text/html" or nil -- only for tilt? == true
39
+ # page.default_ext #=> "html"
37
40
  #
38
41
  # Contents:
39
42
  #
40
- # page.to_html
41
- # page.to_html(locals={})
42
- # page.content
43
- # page.markup
43
+ # page.to_html
44
+ # page.to_html(locals={})
45
+ # page.content
46
+ # page.markup
44
47
  #
45
48
  # Traversion:
46
49
  #
47
50
  #
48
- # # Pages (a Proton::Page or nil)
49
- # page.parent
50
- # page.next
51
+ # # Pages (a Proton::Page or nil)
52
+ # page.parent
53
+ # page.next
51
54
  #
52
- # # Sets (a Proton::Set)
53
- # page.children
54
- # page.siblings
55
- # page.breadcrumbs
55
+ # # Sets (a Proton::Set)
56
+ # page.children
57
+ # page.siblings
58
+ # page.breadcrumbs
56
59
  #
57
- # # Misc
58
- # page.index? # if it's an index.html
59
- # page.parent?
60
- # page.root? # true if no parents
61
- # page.depth
60
+ # # Misc
61
+ # page.index? # if it's an index.html
62
+ # page.parent?
63
+ # page.root? # true if no parents
64
+ # page.depth
62
65
  #
63
66
  # Tilt:
64
67
  #
65
- # page.tilt? # true, if it's a dynamic file
66
- # page.tilt_engine_name #=> 'RedCloth'
68
+ # page.tilt? # true, if it's a dynamic file
69
+ # page.tilt_engine_name #=> 'RedCloth'
67
70
  #
68
71
  # Building:
69
72
  #
70
- # page.write
71
- # page.write('~/foo.html')
73
+ # page.write
74
+ # page.write('~/foo.html')
72
75
  #
73
76
  class Page
77
+ # Attribute: project (Proton::Page)
78
+ # A reference to the project.
79
+ #
74
80
  attr_reader :project
81
+
82
+ # Attribute: file (Proton::Page)
83
+ # The full path of the source file.
84
+ #
85
+ # ## Example
86
+ # page.filepath #=> "/index.haml"
87
+ # page.file #=> "/home/rsc/project/index.haml"
88
+ #
89
+ # ## See also
90
+ # - {Proton::Page.filepath}
91
+ #
75
92
  attr_reader :file
76
93
 
77
94
  def self.[](id, project=Proton.project)
78
- site_path = root_path(project)
79
- return nil if site_path.nil?
80
-
81
- site = lambda { |*x| File.join site_path, *(x.compact) }
82
- try = lambda { |_id| p = new(_id, project); p if p.exists? }
83
-
84
- # For paths like '/' or '/hello/'
85
- nonfile = File.basename(id).gsub('/','').empty?
86
-
87
- # Account for:
88
- # ~/mysite/site/about/us.html.haml
89
- # about/us.html.haml => ~/mysite/site/about/us.html.haml
90
- # about/us.html => ~/mysite/site/about/us.html.*
91
- # about/us.html => ~/mysite/site/about/us.*
92
- # about/us => ~/mysite/site/about/us/index.*
93
- #
94
- page = try[id]
95
- page ||= try[site[id]]
96
- unless nonfile
97
- page ||= try[Dir[site["#{id}.*"]].first]
98
- page ||= try[Dir[site["#{id.to_s.sub(/\.[^\.]*/,'')}.*"]].first]
99
- end
100
- page ||= try[Dir[site[id, "index.*"]].first]
95
+ Cacheable.cache(:lookup, id, project.root) do
96
+ site_path = root_path(project)
97
+ return nil if site_path.nil?
98
+
99
+ site = lambda { |*x| File.join site_path, *(x.compact) }
100
+ try = lambda { |_id| p = new(_id, project); p if p.exists? }
101
+
102
+ # For paths like '/' or '/hello/'
103
+ nonfile = File.basename(id).gsub('/','').empty?
104
+
105
+ # Account for:
106
+ # ~/mysite/site/about/us.html.haml
107
+ # about/us.html.haml => ~/mysite/site/about/us.html.haml
108
+ # about/us.html => ~/mysite/site/about/us.html.*
109
+ # about/us.html => ~/mysite/site/about/us.*
110
+ # about/us => ~/mysite/site/about/us/index.*
111
+ #
112
+ page = try[id]
113
+ page ||= try[site[id]]
114
+ unless nonfile
115
+ page ||= try[Dir[site["#{id}.*"]].first]
116
+ page ||= try[Dir[site["#{id.to_s.sub(/\.[^\.]*/,'')}.*"]].first]
117
+ end
118
+ page ||= try[Dir[site[id, "index.*"]].first]
101
119
 
102
- # Subclass
103
- if page && page.tilt? && page.meta[:type]
104
- klass = Page.get_type(page.meta[:type])
105
- raise Error, "#{page.filepath}: Class for type '#{page.meta[:type]}' not found" unless klass
106
- page = klass.new(id, project)
107
- end
120
+ # Subclass
121
+ if page && page.tilt? && page.meta[:type]
122
+ klass = Page.get_type(page.meta[:type])
123
+ raise Error, "#{page.filepath}: Class for type '#{page.meta[:type]}' not found" unless klass
124
+ page = klass.new(id, project)
125
+ end
108
126
 
109
- page
127
+ page
128
+ end
110
129
  end
111
130
 
112
131
  def initialize(file, project=Proton.project)
@@ -128,7 +147,16 @@ class Page
128
147
  path
129
148
  end
130
149
 
131
- # Returns a short filepath relative to the project path
150
+ # Attribute: filepath (Proton::Page)
151
+ # Returns a short filepath relative to the project path.
152
+ #
153
+ # ## Description
154
+ # This is different from {Proton::Page.file} as this only returns the
155
+ # path relative to the project's root instead of an absolute path.
156
+ #
157
+ # ## Example
158
+ # See {Proton::Page.file} for an example.
159
+ #
132
160
  def filepath
133
161
  root = project.root
134
162
  fpath = file
@@ -136,6 +164,16 @@ class Page
136
164
  fpath
137
165
  end
138
166
 
167
+ # Attribute: title (Proton::Page)
168
+ # Returns the page title as a string.
169
+ #
170
+ # ## Description
171
+ # This attribute tries to infer the page's title based on metadata. If the
172
+ # `title` key is not in the page's header metadata, then it returns the
173
+ # path name instead.
174
+ #
175
+ # This is also aliased as `to_s`.
176
+ #
139
177
  def title
140
178
  (meta.title if tilt?) || path
141
179
  end
@@ -159,8 +197,8 @@ class Page
159
197
  mime_type == 'text/html'
160
198
  end
161
199
 
162
- # Method: mime_type (Proton::Page)
163
- # Returns a MIME type for the page, based on what template engine was used.
200
+ # Attribute: mime_type (Proton::Page)
201
+ # The MIME type for the page, based on what template engine was used.
164
202
  #
165
203
  # ## Example
166
204
  # Page['/style.css'].mime_type #=> 'text/css'
@@ -186,7 +224,7 @@ class Page
186
224
  end
187
225
  end
188
226
 
189
- # Method: default_ext (Proton::Page)
227
+ # Attribute: default_ext (Proton::Page)
190
228
  # Returns a default extension for the page based on the page's MIME type.
191
229
  #
192
230
  # ## Example
@@ -222,7 +260,7 @@ class Page
222
260
  @file and File.file?(@file||'') and valid?
223
261
  end
224
262
 
225
- # Make sure that it's in the right folder.
263
+ # Ensures that the page is in the right folder.
226
264
  def valid?
227
265
  prefix = File.expand_path(root_path)
228
266
  prefix == File.expand_path(@file)[0...prefix.size]
@@ -233,6 +271,9 @@ class Page
233
271
  tilt(tilt_options).render(dup.extend(Helpers), locals, &blk)
234
272
  end
235
273
 
274
+ # Method: to_html (Proton::Page)
275
+ # Returns the full HTML document for the page.
276
+ #
236
277
  def to_html(locals={}, tilt_options={}, &blk)
237
278
  html = content(locals, tilt_options, &blk)
238
279
  html = layout.to_html(locals, tilt_options) { html } if layout?
@@ -253,11 +294,22 @@ class Page
253
294
  !! layout
254
295
  end
255
296
 
297
+ # Method: meta (Proton::Page)
298
+ # Returns the metadata for the page.
299
+ #
300
+ # ## Description
301
+ # This returns an instance of {Proton::Meta}.
302
+ #
256
303
  def meta
257
304
  @meta ||= Meta.new(parts.first)
258
305
  end
259
306
 
307
+ # Method: write (Proton::Page)
260
308
  # Writes to the given output file.
309
+ #
310
+ # ## Description
311
+ # This is the method used by `proton build`.
312
+ #
261
313
  def write(out=nil)
262
314
  out ||= project.path(:output, path)
263
315
  FileUtils.mkdir_p File.dirname(out)
@@ -269,11 +321,14 @@ class Page
269
321
  end
270
322
  end
271
323
 
324
+ # Method: tilt? (Proton::Page)
272
325
  # Checks if the file is supported by tilt.
326
+ #
273
327
  def tilt?
274
328
  !! tilt_engine
275
329
  end
276
330
 
331
+ # Attribute: tilt_engine (Proton::Page)
277
332
  # Returns the Tilt engine (eg Tilt::HamlEngine).
278
333
  def tilt_engine
279
334
  Tilt[@file]
@@ -283,7 +338,11 @@ class Page
283
338
  tilt_engine.name.match(/:([^:]*)(?:Template?)$/)[1]
284
339
  end
285
340
 
341
+ # Attribute: tilt (Proton::Page)
286
342
  # Returns the tilt layout.
343
+ #
344
+ # This returns an instance of `Tilt`.
345
+ #
287
346
  def tilt(tilt_options={})
288
347
  if tilt?
289
348
  parts
@@ -303,6 +362,16 @@ class Page
303
362
  meta.send(meth)
304
363
  end
305
364
 
365
+ # Attribute: parent (Proton::Page)
366
+ # Returns the page's parent page, or nil.
367
+ #
368
+ # ## Usage
369
+ # page.parent
370
+ #
371
+ # ## Description
372
+ # This will return the page's parent (also a {Proton::Page} instance), or
373
+ # `nil` if it's the page is already the root.
374
+ #
306
375
  def parent
307
376
  parts = path.split('/') # ['', 'about', 'index.html']
308
377
 
@@ -315,6 +384,9 @@ class Page
315
384
  parent ||= try['/'] # Home
316
385
  end
317
386
 
387
+ # Method: children (Proton::Page)
388
+ # Returns a Set of the page's subpages.
389
+ #
318
390
  def children
319
391
  files = if index?
320
392
  # about/index.html => about/*
@@ -331,6 +403,9 @@ class Page
331
403
  compact.sort
332
404
  end
333
405
 
406
+ # Method: siblings (Proton::Page)
407
+ # Returns a Set of pages that share the same parent as the current page.
408
+ #
334
409
  def siblings
335
410
  pages = (p = parent and p.children)
336
411
  return Set.new unless pages
@@ -338,10 +413,22 @@ class Page
338
413
  Set.new(pages)
339
414
  end
340
415
 
416
+ # Attribute: breadcrumbs (Proton::Page)
417
+ # Returns an array of the page's ancestors, including itself.
418
+ #
419
+ # ## Example
420
+ # Proton::Page['/about/company/contact.html'].breadcrumbs
421
+ #
422
+ # May look like:
423
+ # [ Page, Page, Page ]
424
+ #
341
425
  def breadcrumbs
342
426
  Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])
343
427
  end
344
428
 
429
+ # Method: index? (Proton::Page)
430
+ # Returns true if the page is and index page.
431
+ #
345
432
  def index?
346
433
  File.basename(path, '.*') == 'index'
347
434
  end
@@ -349,7 +436,8 @@ class Page
349
436
  # Method: parent? (Proton::Page)
350
437
  # Returns true if the page has a parent.
351
438
  #
352
- # This is the opposite of {Proton::Page::root?}.
439
+ # ## Description
440
+ # This is the opposite of {Proton::Page::root?}.
353
441
  #
354
442
  # ## See also
355
443
  # - {Proton::Page::root?}
@@ -361,7 +449,8 @@ class Page
361
449
  # Method: root? (Proton::Page)
362
450
  # Returns true if the page is the home page.
363
451
  #
364
- # This is the opposite of {Proton::Page::parent?}.
452
+ # ## Description
453
+ # This is the opposite of {Proton::Page::parent?}.
365
454
  #
366
455
  # ## See also
367
456
  # - {Proton::Page::parent?}
@@ -370,6 +459,18 @@ class Page
370
459
  parent.nil?
371
460
  end
372
461
 
462
+ # Attribute: depth (Proton::Page)
463
+ # Returns how deep the page is in the heirarchy.
464
+ #
465
+ # ## Description
466
+ # This counts the number of pages from the root page. This means:
467
+ #
468
+ # * The root page (eg, `/index.html`) has a depth of `1`
469
+ # * A child page of the root (eg, `/about.html`) has a depth of `2`
470
+ # * A child of that (eg, `/about/company.html`) has a depth of `3`
471
+ # * ...and so on
472
+ #
473
+ #
373
474
  def depth
374
475
  breadcrumbs.size
375
476
  end
@@ -420,6 +521,9 @@ protected
420
521
  end
421
522
  end
422
523
 
524
+ extend Cacheable
525
+ cache_method :children, :siblings, :parent, :next, :breadcrumbs, :path, :tilt
526
+
423
527
  def self.root_path(project, *a)
424
528
  project.path(:site, *a)
425
529
  end
@@ -2,6 +2,11 @@ require 'cuba'
2
2
  require 'rack'
3
3
  require 'proton'
4
4
 
5
+ # The only time this file gets loaded is if you require it explicity, ie,
6
+ # in a config.ru. Disable caching for when it's ran as a development-time
7
+ # server.
8
+ Proton::Cacheable.disable!
9
+
5
10
  # Module: Proton::Server
6
11
  # The Proton server rack application.
7
12
 
@@ -1,5 +1,5 @@
1
1
  class Proton
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
 
4
4
  # Attribute: version (Proton)
5
5
  # Returns the version.
@@ -1 +1 @@
1
- dir{color:#332211}
1
+ dir{color:#321}
metadata CHANGED
@@ -1,150 +1,149 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: proton
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.4
4
5
  prerelease:
5
- version: 0.3.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Rico Sta. Cruz
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-15 00:00:00 +08:00
12
+ date: 2011-08-01 00:00:00.000000000 +08:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: shake
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2156733040 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
19
+ requirements:
22
20
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "0.1"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.1'
25
23
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: tilt
29
24
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2156733040
26
+ - !ruby/object:Gem::Dependency
27
+ name: tilt
28
+ requirement: &2156732540 !ruby/object:Gem::Requirement
31
29
  none: false
32
- requirements:
30
+ requirements:
33
31
  - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 1.2.2
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.2
36
34
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: cuba
40
35
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2156732540
37
+ - !ruby/object:Gem::Dependency
38
+ name: cuba
39
+ requirement: &2156732080 !ruby/object:Gem::Requirement
42
40
  none: false
43
- requirements:
41
+ requirements:
44
42
  - - ~>
45
- - !ruby/object:Gem::Version
43
+ - !ruby/object:Gem::Version
46
44
  version: 2.0.0
47
45
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: hashie
51
46
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2156732080
48
+ - !ruby/object:Gem::Dependency
49
+ name: hashie
50
+ requirement: &2156731620 !ruby/object:Gem::Requirement
53
51
  none: false
54
- requirements:
52
+ requirements:
55
53
  - - ~>
56
- - !ruby/object:Gem::Version
54
+ - !ruby/object:Gem::Version
57
55
  version: 1.0.0
58
56
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: haml
62
57
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *2156731620
59
+ - !ruby/object:Gem::Dependency
60
+ name: haml
61
+ requirement: &2156731160 !ruby/object:Gem::Requirement
64
62
  none: false
65
- requirements:
63
+ requirements:
66
64
  - - ~>
67
- - !ruby/object:Gem::Version
65
+ - !ruby/object:Gem::Version
68
66
  version: 3.1.1
69
67
  type: :runtime
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: sass
73
68
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *2156731160
70
+ - !ruby/object:Gem::Dependency
71
+ name: sass
72
+ requirement: &2156730700 !ruby/object:Gem::Requirement
75
73
  none: false
76
- requirements:
74
+ requirements:
77
75
  - - ~>
78
- - !ruby/object:Gem::Version
76
+ - !ruby/object:Gem::Version
79
77
  version: 3.1.1
80
78
  type: :runtime
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: compass
84
79
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
80
+ version_requirements: *2156730700
81
+ - !ruby/object:Gem::Dependency
82
+ name: compass
83
+ requirement: &2156730240 !ruby/object:Gem::Requirement
86
84
  none: false
87
- requirements:
85
+ requirements:
88
86
  - - ~>
89
- - !ruby/object:Gem::Version
87
+ - !ruby/object:Gem::Version
90
88
  version: 0.11.1
91
89
  type: :runtime
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: RedCloth
95
90
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
91
+ version_requirements: *2156730240
92
+ - !ruby/object:Gem::Dependency
93
+ name: RedCloth
94
+ requirement: &2156729780 !ruby/object:Gem::Requirement
97
95
  none: false
98
- requirements:
96
+ requirements:
99
97
  - - ~>
100
- - !ruby/object:Gem::Version
98
+ - !ruby/object:Gem::Version
101
99
  version: 4.2.3
102
100
  type: :runtime
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: maruku
106
101
  prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
102
+ version_requirements: *2156729780
103
+ - !ruby/object:Gem::Dependency
104
+ name: maruku
105
+ requirement: &2156729320 !ruby/object:Gem::Requirement
108
106
  none: false
109
- requirements:
107
+ requirements:
110
108
  - - ~>
111
- - !ruby/object:Gem::Version
109
+ - !ruby/object:Gem::Version
112
110
  version: 0.6.0
113
111
  type: :runtime
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: less
117
112
  prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
113
+ version_requirements: *2156729320
114
+ - !ruby/object:Gem::Dependency
115
+ name: less
116
+ requirement: &2156728940 !ruby/object:Gem::Requirement
119
117
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
124
122
  type: :development
125
- version_requirements: *id010
126
- - !ruby/object:Gem::Dependency
127
- name: maruku
128
123
  prerelease: false
129
- requirement: &id011 !ruby/object:Gem::Requirement
124
+ version_requirements: *2156728940
125
+ - !ruby/object:Gem::Dependency
126
+ name: maruku
127
+ requirement: &2156728480 !ruby/object:Gem::Requirement
130
128
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
135
133
  type: :development
136
- version_requirements: *id011
137
- description: Proton lets you create static websites from a bunch of files written in HAML, Textile, Sass, or any other templating language.
138
- email:
134
+ prerelease: false
135
+ version_requirements: *2156728480
136
+ description: Proton lets you create static websites from a bunch of files written
137
+ in HAML, Textile, Sass, or any other templating language.
138
+ email:
139
139
  - rico@sinefunc.com
140
- executables:
140
+ executables:
141
141
  - proton
142
142
  extensions: []
143
-
144
143
  extra_rdoc_files: []
145
-
146
- files:
144
+ files:
147
145
  - bin/proton
146
+ - lib/proton/cacheable.rb
148
147
  - lib/proton/cli/helpers.rb
149
148
  - lib/proton/cli.rb
150
149
  - lib/proton/compass_support.rb
@@ -264,7 +263,6 @@ files:
264
263
  - data/new_site/README.md
265
264
  - data/rack/config.ru
266
265
  - data/rack/Gemfile
267
- - data/rack/Gemfile.lock
268
266
  - HISTORY.md
269
267
  - README.md
270
268
  - TODO.md
@@ -273,30 +271,26 @@ files:
273
271
  has_rdoc: true
274
272
  homepage: http://github.com/sinefunc/proton
275
273
  licenses: []
276
-
277
274
  post_install_message:
278
275
  rdoc_options: []
279
-
280
- require_paths:
276
+ require_paths:
281
277
  - lib
282
- required_ruby_version: !ruby/object:Gem::Requirement
278
+ required_ruby_version: !ruby/object:Gem::Requirement
283
279
  none: false
284
- requirements:
285
- - - ">="
286
- - !ruby/object:Gem::Version
287
- version: "0"
288
- required_rubygems_version: !ruby/object:Gem::Requirement
280
+ requirements:
281
+ - - ! '>='
282
+ - !ruby/object:Gem::Version
283
+ version: '0'
284
+ required_rubygems_version: !ruby/object:Gem::Requirement
289
285
  none: false
290
- requirements:
291
- - - ">="
292
- - !ruby/object:Gem::Version
293
- version: "0"
286
+ requirements:
287
+ - - ! '>='
288
+ - !ruby/object:Gem::Version
289
+ version: '0'
294
290
  requirements: []
295
-
296
291
  rubyforge_project:
297
292
  rubygems_version: 1.6.2
298
293
  signing_key:
299
294
  specification_version: 3
300
295
  summary: Prototyping tool / static site generator.
301
296
  test_files: []
302
-
@@ -1,40 +0,0 @@
1
- GEM
2
- specs:
3
- RedCloth (4.2.3)
4
- chunky_png (1.2.0)
5
- compass (0.11.3)
6
- chunky_png (~> 1.2)
7
- fssm (>= 0.2.7)
8
- sass (~> 3.1)
9
- cuba (2.0.0)
10
- rack (~> 1.2)
11
- tilt (~> 1.2)
12
- fssm (0.2.7)
13
- haml (3.1.1)
14
- hashie (1.0.0)
15
- maruku (0.6.0)
16
- syntax (>= 1.0.0)
17
- proton (0.3.2)
18
- RedCloth (~> 4.2.3)
19
- compass (~> 0.11.1)
20
- cuba (~> 2.0.0)
21
- haml (~> 3.1.1)
22
- hashie (~> 1.0.0)
23
- maruku (~> 0.6.0)
24
- sass (~> 3.1.1)
25
- shake (~> 0.1)
26
- tilt (~> 1.2.2)
27
- rack (1.3.0)
28
- rack-cache (1.0.2)
29
- rack (>= 0.4)
30
- sass (3.1.1)
31
- shake (0.1.2)
32
- syntax (1.0.0)
33
- tilt (1.2.2)
34
-
35
- PLATFORMS
36
- ruby
37
-
38
- DEPENDENCIES
39
- proton (~> 0.3.2)
40
- rack-cache (~> 1.0.0)