plate 0.7.0.pre3 → 0.7.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/plate/builder.rb CHANGED
@@ -216,10 +216,28 @@ module Plate
216
216
 
217
217
  page.reload!
218
218
 
219
- # If this page was a draft, and now is published. Reload the entire site
220
- # and publish it.
221
- if Draft === page and page.publish?
222
- rebuild! and return
219
+ case page
220
+ when Asset
221
+ when Draft
222
+ # If this page was a draft, and now is published. Reload the entire site
223
+ # and publish it.
224
+ if page.publish?
225
+ FileUtils.rm_rf(File.join(site.destination, page.file_path))
226
+ self.rebuild! and return
227
+ end
228
+ when StaticPage
229
+ # If this page was static and needs to be upgraded to a regular page, reload the
230
+ # entire site.
231
+ if page.upgrade?
232
+ FileUtils.rm_rf(File.join(site.destination, page.file_path))
233
+ self.rebuild! and return
234
+ end
235
+ else
236
+ # If a page is downgraded from Page to StaticPage, reload site
237
+ if page.downgrade?
238
+ FileUtils.rm_rf(File.dirname(File.join(site.destination, page.file_path)))
239
+ self.rebuild! and return
240
+ end
223
241
  end
224
242
 
225
243
  page.write!
@@ -4,13 +4,14 @@ module Plate
4
4
  # Pass in a hash object to use this class as a proxy for its keys.
5
5
  def initialize(source = {})
6
6
  @source = source
7
+ @source ||= {}
7
8
  end
8
-
9
+
9
10
  # Pass through for getting the hash's value at the given key.
10
11
  def [](key)
11
12
  @source[key]
12
13
  end
13
-
14
+
14
15
  # Handle method missing calls and proxy methods to hash values.
15
16
  #
16
17
  # Allows for checking to see if a key exists and returning a key value.
data/lib/plate/page.rb CHANGED
@@ -6,6 +6,9 @@ module Plate
6
6
 
7
7
  attr_accessor :body, :content, :file, :meta, :site, :layout
8
8
 
9
+ # The raw source of this page, before any manipulation.
10
+ attr_reader :raw
11
+
9
12
  # If set, will return an array of partial names used within this page.
10
13
  #
11
14
  # In watch mode, this allows the current page to be reloaded when any
@@ -58,6 +61,11 @@ module Plate
58
61
  end
59
62
  end
60
63
 
64
+ # Check a static page to see if it should be converted into a Page
65
+ def downgrade?
66
+ !raw.start_with?('---')
67
+ end
68
+
61
69
  def engines
62
70
  @engines ||= self.extensions.reverse.collect { |e| self.site.registered_page_engines[e.gsub(/\./, '').to_sym] }.reject { |e| !e }
63
71
  end
@@ -289,7 +297,8 @@ module Plate
289
297
 
290
298
  # Read the file and store it in @content
291
299
  def read_file!
292
- self.content = file? ? File.read(self.file) : nil
300
+ @raw = file? ? File.read(self.file) : nil
301
+ self.content = @raw
293
302
  end
294
303
 
295
304
  # Reads all content from a page's meta data
data/lib/plate/site.rb CHANGED
@@ -91,8 +91,6 @@ module Plate
91
91
  self.posts = PostCollection.new
92
92
  self.partials = []
93
93
  self.drafts = []
94
-
95
- @metadata = {}
96
94
  end
97
95
 
98
96
  # The default blog post category
@@ -5,29 +5,34 @@ module Plate
5
5
  def file_path
6
6
  base = Pathname.new(File.join(self.site.source, 'content'))
7
7
  current = Pathname.new(self.file)
8
-
8
+
9
9
  dirs = current.relative_path_from(base)
10
-
10
+
11
11
  "/#{dirs}"
12
12
  end
13
-
13
+
14
14
  def layout
15
15
  nil
16
16
  end
17
-
18
- # If we need for some reason, read this file's contents
17
+
18
+ # If we need for some reason, read this file's contents
19
19
  def rendered_content
20
20
  @rendered_content ||= File.read(self.file)
21
21
  end
22
-
22
+
23
+ # Check a static page to see if it should be converted into a Page
24
+ def upgrade?
25
+ rendered_content.start_with?('---')
26
+ end
27
+
23
28
  # Write this page to the destination. For static files this just results
24
29
  # in copying the file over to the destination
25
- def write!
30
+ def write!
26
31
  path = File.join(site.build_destination, file_path)
27
32
  FileUtils.mkdir_p(File.dirname(path))
28
33
  FileUtils.cp(self.file, path)
29
34
  end
30
-
35
+
31
36
  protected
32
37
  # Don't read any meta data for static files, leave them as-is.
33
38
  def read_metadata!
data/lib/plate/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plate
2
- VERSION = "0.7.0.pre3" unless defined?(::Plate::VERSION)
2
+ VERSION = "0.7.0.pre4" unless defined?(::Plate::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.pre3
4
+ version: 0.7.0.pre4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000Z
12
+ date: 2012-08-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70194904166220 !ruby/object:Gem::Requirement
16
+ requirement: &70103958579000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70194904166220
24
+ version_requirements: *70103958579000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: directory_watcher
27
- requirement: &70194904165760 !ruby/object:Gem::Requirement
27
+ requirement: &70103958578560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70194904165760
35
+ version_requirements: *70103958578560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: i18n
38
- requirement: &70194904165160 !ruby/object:Gem::Requirement
38
+ requirement: &70103958577980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.6'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70194904165160
46
+ version_requirements: *70103958577980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70194904164700 !ruby/object:Gem::Requirement
49
+ requirement: &70103958577500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70194904164700
57
+ version_requirements: *70103958577500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: redcarpet
60
- requirement: &70194904164080 !ruby/object:Gem::Requirement
60
+ requirement: &70103958576880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '2'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70194904164080
68
+ version_requirements: *70103958576880
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tilt
71
- requirement: &70194904163520 !ruby/object:Gem::Requirement
71
+ requirement: &70103958576340 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '1.3'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70194904163520
79
+ version_requirements: *70103958576340
80
80
  description: Plate is a simple, static site generator and blog engine.
81
81
  email:
82
82
  - john@johntornow.com