sitepress-core 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sitepress/asset.rb +5 -2
- data/lib/sitepress/version.rb +1 -1
- metadata +2 -3
- data/lib/sitepress/frontmatter.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12e94c474979815414339a9638d49b53dc95d62a2f9c5ff07b4bdec027adbacd
|
4
|
+
data.tar.gz: 01ad13713950b093bb163a3e5f092386c9ca9b5e37ce16b271cfb58f5ceca91c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 602e0d16c5ea01e1ba567f00ed99f72609b17e536b9815d3d92ff45286f7f37f3f48215867dd8dab7667b4bab9e37a7a84324cb9f13f38ebd7d74fa6495a8df8
|
7
|
+
data.tar.gz: '029d87510096eda957801410bf6c237a072f62dbb35b6552a176c06dfbda10482e6b42d809e28f52031627dd1565235fd419b5ad1a990f588eedff7bf4f4594e'
|
data/lib/sitepress/asset.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "mime/types"
|
2
2
|
require "forwardable"
|
3
|
-
require "pathname"
|
4
3
|
|
5
4
|
module Sitepress
|
6
5
|
# Represents a file on a web server that may be parsed to extract
|
@@ -13,13 +12,17 @@ module Sitepress
|
|
13
12
|
# the resource and figure out what to do with it.
|
14
13
|
DEFAULT_MIME_TYPE = MIME::Types["application/octet-stream"].first
|
15
14
|
|
15
|
+
# Parsers can be swapped out to deal with different types of resources, like Notion
|
16
|
+
# documents, JSON, exif data on images, etc.
|
17
|
+
DEFAULT_PARSER = Parsers::Frontmatter
|
18
|
+
|
16
19
|
attr_reader :path
|
17
20
|
|
18
21
|
extend Forwardable
|
19
22
|
def_delegators :parser, :data, :body
|
20
23
|
def_delegators :path, :handler, :node_name, :format, :exists?
|
21
24
|
|
22
|
-
def initialize(path:, mime_type: nil, parser:
|
25
|
+
def initialize(path:, mime_type: nil, parser: DEFAULT_PARSER)
|
23
26
|
# The MIME::Types gem returns an array when types are looked up.
|
24
27
|
# This grabs the first one, which is likely the intent on these lookups.
|
25
28
|
@mime_type = Array(mime_type).first
|
data/lib/sitepress/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitepress-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- lib/sitepress/extensions/layouts.rb
|
81
81
|
- lib/sitepress/extensions/proc_manipulator.rb
|
82
82
|
- lib/sitepress/formats.rb
|
83
|
-
- lib/sitepress/frontmatter.rb
|
84
83
|
- lib/sitepress/node.rb
|
85
84
|
- lib/sitepress/parsers.rb
|
86
85
|
- lib/sitepress/parsers/base.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
|
3
|
-
module Sitepress
|
4
|
-
# Parses metadata from the header of the page.
|
5
|
-
|
6
|
-
# TODO: Redo this to use File readline and pos to
|
7
|
-
# perform faster
|
8
|
-
class Parsers::Frontmatter
|
9
|
-
DELIMITER = "---".freeze
|
10
|
-
NEWLINE = /\r\n?|\n/.freeze
|
11
|
-
PATTERN = /\A(#{DELIMITER}#{NEWLINE}(.+?)#{NEWLINE}#{DELIMITER}#{NEWLINE}*)?(.+)\Z/m
|
12
|
-
|
13
|
-
attr_reader :body
|
14
|
-
|
15
|
-
def initialize(content)
|
16
|
-
_, @data, @body = content.match(PATTERN).captures
|
17
|
-
end
|
18
|
-
|
19
|
-
def data
|
20
|
-
@data ? YAML.load(@data) : {}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|