dimples 6.2.4 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dimples.rb +1 -2
- data/lib/dimples/{frontable.rb → frontmatter.rb} +3 -5
- data/lib/dimples/page.rb +2 -3
- data/lib/dimples/template.rb +3 -3
- data/lib/dimples/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b448da242a2f100c9494e264a5db74cd4776788
|
4
|
+
data.tar.gz: 63d845f81419f62019d05cd982b03ddb51ec58d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42bb20b085f8a65ccc5c0f5d9603d1bdc8d4acea4f668483c7378f9ef4980ce7cb772f80eade7c402999dfd7bc1a4256f8e74bf2435acd2053c95a6fa39676cf
|
7
|
+
data.tar.gz: 2d1cb6681366972afd89b229eaa47f835323a9831fa282cce151ac445d442186193fb41ebf7037745f336f79d8f669a28cc15453ed20623dbd87708429c80510
|
data/lib/dimples.rb
CHANGED
@@ -7,12 +7,11 @@ require 'hashie'
|
|
7
7
|
require 'tilt'
|
8
8
|
require 'yaml'
|
9
9
|
|
10
|
-
require 'dimples/frontable'
|
11
|
-
|
12
10
|
require 'dimples/archive'
|
13
11
|
require 'dimples/category'
|
14
12
|
require 'dimples/configuration'
|
15
13
|
require 'dimples/errors'
|
14
|
+
require 'dimples/frontmatter'
|
16
15
|
require 'dimples/pager'
|
17
16
|
require 'dimples/renderer'
|
18
17
|
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Dimples
|
4
|
-
# Adds the ability to
|
5
|
-
|
4
|
+
# Adds the ability to parse front matter from a file.
|
5
|
+
class FrontMatter
|
6
6
|
FRONT_MATTER_PATTERN = /^(-{3}\n.*?\n?)^(-{3}*$\n?)/m.freeze
|
7
7
|
|
8
|
-
def
|
9
|
-
contents = File.read(path)
|
10
|
-
|
8
|
+
def self.parse(contents)
|
11
9
|
if (matches = contents.match(FRONT_MATTER_PATTERN))
|
12
10
|
metadata = Hashie.symbolize_keys(YAML.safe_load(matches[1]))
|
13
11
|
contents = matches.post_match.strip
|
data/lib/dimples/page.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Dimples
|
4
4
|
# A single page on a site.
|
5
5
|
class Page
|
6
|
-
include Frontable
|
7
|
-
|
8
6
|
attr_accessor :contents
|
9
7
|
attr_accessor :metadata
|
10
8
|
attr_accessor :path
|
@@ -14,7 +12,8 @@ module Dimples
|
|
14
12
|
@path = path
|
15
13
|
|
16
14
|
if @path
|
17
|
-
|
15
|
+
data = File.read(@path)
|
16
|
+
@contents, @metadata = FrontMatter.parse(data)
|
18
17
|
else
|
19
18
|
@contents = ''
|
20
19
|
@metadata = {}
|
data/lib/dimples/template.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Dimples
|
4
4
|
# A single template used when rendering pages, posts and other templates.
|
5
5
|
class Template
|
6
|
-
include Frontable
|
7
|
-
|
8
6
|
attr_accessor :path
|
9
7
|
attr_accessor :contents
|
10
8
|
attr_accessor :metadata
|
@@ -12,7 +10,9 @@ module Dimples
|
|
12
10
|
def initialize(site, path)
|
13
11
|
@site = site
|
14
12
|
@path = path
|
15
|
-
|
13
|
+
|
14
|
+
data = File.read(path)
|
15
|
+
@contents, @metadata = FrontMatter.parse(data)
|
16
16
|
end
|
17
17
|
|
18
18
|
def render(context = {}, body = nil)
|
data/lib/dimples/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bogan
|
@@ -183,7 +183,7 @@ files:
|
|
183
183
|
- lib/dimples/configuration.rb
|
184
184
|
- lib/dimples/errors.rb
|
185
185
|
- lib/dimples/feed.rb
|
186
|
-
- lib/dimples/
|
186
|
+
- lib/dimples/frontmatter.rb
|
187
187
|
- lib/dimples/page.rb
|
188
188
|
- lib/dimples/pager.rb
|
189
189
|
- lib/dimples/post.rb
|