sitepress-core 3.0.1 → 3.1.3
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/sitepress/asset.rb +5 -2
- data/lib/sitepress/version.rb +1 -1
- metadata +3 -4
- 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: d3a21318c9c7097a4655b82a0d5d49dd2328c911cc36227dcd39d9dbfc2ce2c5
|
4
|
+
data.tar.gz: fa94fc43352dd36fc1851e99bcc467d41cba18cb77dffc4d966b58186fd67dc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 882cd6fc9bf67c641a1f3d1b33980149f17e6411511b41688d5d12149f89d8ebbcc40bb6d3b5d0402edf095480c983ddd66844fc1965c5eabcf2866ff8acd2a5
|
7
|
+
data.tar.gz: 7fad5f1a0253f618b037d8618ce293b80ef7c0b6f20739c9af67a74a5e571876aeca8c9da72cbf10176e6e7ae651a2402999d7d706ed572d23e3530afeafc521
|
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.
|
4
|
+
version: 3.1.3
|
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-
|
11
|
+
date: 2022-09-12 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
|
@@ -112,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
111
|
- !ruby/object:Gem::Version
|
113
112
|
version: '0'
|
114
113
|
requirements: []
|
115
|
-
rubygems_version: 3.3.
|
114
|
+
rubygems_version: 3.3.20
|
116
115
|
signing_key:
|
117
116
|
specification_version: 4
|
118
117
|
summary: An embeddable file-backed content management system.
|
@@ -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
|