dimples 1.3.0 → 1.3.1
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.
- checksums.yaml +4 -4
- data/lib/dimples.rb +4 -1
- data/lib/dimples/page.rb +4 -1
- data/lib/dimples/post.rb +6 -1
- data/lib/dimples/{publishable.rb → renderable.rb} +15 -30
- data/lib/dimples/site.rb +13 -1
- data/lib/dimples/template.rb +1 -1
- data/lib/dimples/version.rb +1 -1
- data/lib/dimples/writeable.rb +20 -0
- metadata +74 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3345e978e2a4e91417d04d9e82188ea9181d129
|
4
|
+
data.tar.gz: ea4f09a5cb4592814a4762c65c69a48082d7eeef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 564ee215d346821935d18797c859da4a733e2dbdf1a0e2b7e62f1279edbe817e160afe518178f971596afa444f6d442a5b11519f5fa5922590ddf297e533828d
|
7
|
+
data.tar.gz: b2a4d12624112e7594c53e31c8d610ccc38fedea9ac3b7b28d4acac52c0bdf91368e15162261df9351c6480fd389d3fc65d61e9b545eda6801a271a8d3f76df1
|
data/lib/dimples.rb
CHANGED
@@ -5,8 +5,11 @@ require 'yaml'
|
|
5
5
|
require 'tilt'
|
6
6
|
|
7
7
|
require 'dimples/errors'
|
8
|
+
|
8
9
|
require 'dimples/frontable'
|
9
|
-
require 'dimples/
|
10
|
+
require 'dimples/writeable'
|
11
|
+
require 'dimples/renderable'
|
12
|
+
|
10
13
|
require 'dimples/configuration'
|
11
14
|
require 'dimples/category'
|
12
15
|
require 'dimples/page'
|
data/lib/dimples/page.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Dimples
|
2
2
|
class Page
|
3
3
|
include Frontable
|
4
|
-
include
|
4
|
+
include Writeable
|
5
|
+
include Renderable
|
5
6
|
|
6
7
|
attr_accessor :path
|
7
8
|
attr_accessor :title
|
@@ -22,7 +23,9 @@ module Dimples
|
|
22
23
|
@filename = File.basename(path, File.extname(path))
|
23
24
|
@contents = read_with_yaml(path)
|
24
25
|
else
|
26
|
+
@path = nil
|
25
27
|
@filename = 'index'
|
28
|
+
@contents = ''
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
data/lib/dimples/post.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Dimples
|
2
2
|
class Post
|
3
3
|
include Frontable
|
4
|
-
include
|
4
|
+
include Writeable
|
5
|
+
include Renderable
|
5
6
|
|
6
7
|
attr_accessor :path
|
7
8
|
attr_accessor :title
|
@@ -17,6 +18,7 @@ module Dimples
|
|
17
18
|
attr_accessor :rendered_contents
|
18
19
|
attr_accessor :previous_post
|
19
20
|
attr_accessor :next_post
|
21
|
+
attr_accessor :draft
|
20
22
|
|
21
23
|
attr_writer :contents
|
22
24
|
|
@@ -35,11 +37,14 @@ module Dimples
|
|
35
37
|
@layout = @site.config['layouts']['post']
|
36
38
|
@categories = {}
|
37
39
|
|
40
|
+
@draft = false
|
41
|
+
|
38
42
|
@year = @date.strftime('%Y')
|
39
43
|
@month = @date.strftime('%m')
|
40
44
|
@day = @date.strftime('%d')
|
41
45
|
|
42
46
|
@contents = read_with_yaml(path)
|
47
|
+
|
43
48
|
end
|
44
49
|
|
45
50
|
def contents
|
@@ -1,22 +1,5 @@
|
|
1
1
|
module Dimples
|
2
|
-
module
|
3
|
-
def write(path, context = {})
|
4
|
-
output = context ? render(context) : contents()
|
5
|
-
|
6
|
-
publish_path = output_file_path(path)
|
7
|
-
parent_path = File.dirname(publish_path)
|
8
|
-
|
9
|
-
begin
|
10
|
-
FileUtils.mkdir_p(parent_path) unless Dir.exist?(parent_path)
|
11
|
-
|
12
|
-
File.open(publish_path, 'w+') do |file|
|
13
|
-
file.write(output)
|
14
|
-
end
|
15
|
-
rescue SystemCallError => e
|
16
|
-
raise Errors::PublishingError.new(publish_path, e.message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
2
|
+
module Renderable
|
20
3
|
def render(context = {}, body = nil, use_layout = true)
|
21
4
|
class_name = self.class.name.split('::').last.downcase.to_sym
|
22
5
|
|
@@ -29,17 +12,6 @@ module Dimples
|
|
29
12
|
scope.instance_variable_set("@#{key}".to_sym, value)
|
30
13
|
end
|
31
14
|
|
32
|
-
proc = Proc.new { |template| contents() }
|
33
|
-
|
34
|
-
renderer = if @path
|
35
|
-
extension = File.extname(@path)[1..-1]
|
36
|
-
options = @site.config['rendering'][extension] || {}
|
37
|
-
|
38
|
-
Tilt.new(@path, options, &proc)
|
39
|
-
else
|
40
|
-
Tilt::StringTemplate.new(&proc)
|
41
|
-
end
|
42
|
-
|
43
15
|
begin
|
44
16
|
output = renderer.render(scope) { body }.strip
|
45
17
|
@rendered_contents = output
|
@@ -53,11 +25,24 @@ module Dimples
|
|
53
25
|
raise Errors::RenderingError.new(problem_file, e.message)
|
54
26
|
end
|
55
27
|
|
56
|
-
if use_layout && @layout && @site.templates[@layout]
|
28
|
+
if use_layout && defined?(@layout) && @site.templates[@layout]
|
57
29
|
output = @site.templates[@layout].render(context, output)
|
58
30
|
end
|
59
31
|
|
60
32
|
output
|
61
33
|
end
|
34
|
+
|
35
|
+
def renderer
|
36
|
+
proc = Proc.new { |template| contents() }
|
37
|
+
|
38
|
+
if @path
|
39
|
+
extension = File.extname(@path)[1..-1]
|
40
|
+
options = @site.config['rendering'][extension] || {}
|
41
|
+
|
42
|
+
Tilt.new(@path, options, &proc)
|
43
|
+
else
|
44
|
+
Tilt::StringTemplate.new(&proc)
|
45
|
+
end
|
46
|
+
end
|
62
47
|
end
|
63
48
|
end
|
data/lib/dimples/site.rb
CHANGED
@@ -28,6 +28,7 @@ module Dimples
|
|
28
28
|
@post_class = Dimples::Post
|
29
29
|
|
30
30
|
@config = Dimples::Configuration.new(config)
|
31
|
+
@generation_options = default_generation_options
|
31
32
|
|
32
33
|
@source_paths[:root] = File.expand_path(@config['source_path'])
|
33
34
|
@output_paths[:site] = File.expand_path(@config['destination_path'])
|
@@ -39,7 +40,9 @@ module Dimples
|
|
39
40
|
@output_paths[:posts] = File.join(@output_paths[:site], @config['paths']['posts'])
|
40
41
|
end
|
41
42
|
|
42
|
-
def generate
|
43
|
+
def generate(options = {})
|
44
|
+
@generation_options.merge!(options)
|
45
|
+
|
43
46
|
prepare_site
|
44
47
|
prepare_categories
|
45
48
|
scan_files
|
@@ -91,6 +94,7 @@ module Dimples
|
|
91
94
|
def scan_posts
|
92
95
|
Dir.glob(File.join(@source_paths[:posts], '*.*')).reverse.each do |path|
|
93
96
|
post = @post_class.new(self, path)
|
97
|
+
next if !@generation_options[:include_drafts] && post.draft
|
94
98
|
|
95
99
|
%w[year month day].each do |date_type|
|
96
100
|
if @config['generation']["#{date_type}_archives"]
|
@@ -232,5 +236,13 @@ module Dimples
|
|
232
236
|
page.write(output_path, {posts: posts.slice((index - 1) * per_page, per_page), pagination: pagination})
|
233
237
|
end
|
234
238
|
end
|
239
|
+
|
240
|
+
private
|
241
|
+
|
242
|
+
def default_generation_options
|
243
|
+
{
|
244
|
+
include_drafts: false
|
245
|
+
}
|
246
|
+
end
|
235
247
|
end
|
236
248
|
end
|
data/lib/dimples/template.rb
CHANGED
data/lib/dimples/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Dimples
|
2
|
+
module Writeable
|
3
|
+
def write(path, context = {})
|
4
|
+
output = context ? render(context) : contents()
|
5
|
+
|
6
|
+
publish_path = output_file_path(path)
|
7
|
+
parent_path = File.dirname(publish_path)
|
8
|
+
|
9
|
+
begin
|
10
|
+
FileUtils.mkdir_p(parent_path) unless Dir.exist?(parent_path)
|
11
|
+
|
12
|
+
File.open(publish_path, 'w+') do |file|
|
13
|
+
file.write(output)
|
14
|
+
end
|
15
|
+
rescue SystemCallError => e
|
16
|
+
raise Errors::PublishingError.new(publish_path, e.message)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
@@ -24,6 +24,76 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: redcarpet
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: erubis
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.4'
|
27
97
|
description: A very, very, very simple gem for building static websites.
|
28
98
|
email:
|
29
99
|
- d+dimples@waferbaby.com
|
@@ -38,10 +108,11 @@ files:
|
|
38
108
|
- lib/dimples/frontable.rb
|
39
109
|
- lib/dimples/page.rb
|
40
110
|
- lib/dimples/post.rb
|
41
|
-
- lib/dimples/
|
111
|
+
- lib/dimples/renderable.rb
|
42
112
|
- lib/dimples/site.rb
|
43
113
|
- lib/dimples/template.rb
|
44
114
|
- lib/dimples/version.rb
|
115
|
+
- lib/dimples/writeable.rb
|
45
116
|
homepage: http://github.com/waferbaby/dimples
|
46
117
|
licenses:
|
47
118
|
- LICENSE
|