yarrow 0.8.7 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTENT.md +228 -0
- data/README.md +8 -8
- data/lib/extensions/mementus.rb +29 -0
- data/lib/yarrow/content/expansion/aggregator.rb +88 -0
- data/lib/yarrow/content/expansion/basename_merge.rb +44 -0
- data/lib/yarrow/content/expansion/directory_map.rb +21 -0
- data/lib/yarrow/content/expansion/directory_merge.rb +31 -0
- data/lib/yarrow/content/expansion/file_list.rb +15 -0
- data/lib/yarrow/content/expansion/filename_map.rb +24 -0
- data/lib/yarrow/content/expansion/strategy.rb +47 -0
- data/lib/yarrow/content/expansion/traversal.rb +67 -0
- data/lib/yarrow/content/expansion/tree.rb +53 -74
- data/lib/yarrow/content/model.rb +3 -4
- data/lib/yarrow/content/policy.rb +77 -21
- data/lib/yarrow/content/source.rb +4 -0
- data/lib/yarrow/format/asciidoc.rb +0 -0
- data/lib/yarrow/format/html.rb +0 -0
- data/lib/yarrow/format/json.rb +0 -0
- data/lib/yarrow/format/markdown.rb +67 -0
- data/lib/yarrow/format/mediawiki.rb +0 -0
- data/lib/yarrow/format/methods/front_matter.rb +58 -0
- data/lib/yarrow/format/methods/metadata.rb +22 -0
- data/lib/yarrow/format/orgmode.rb +0 -0
- data/lib/yarrow/format/text.rb +0 -0
- data/lib/yarrow/format/xml.rb +0 -0
- data/lib/yarrow/format/yaml.rb +19 -0
- data/lib/yarrow/format.rb +71 -0
- data/lib/yarrow/version.rb +1 -1
- data/lib/yarrow/web/manifest.rb +15 -9
- data/lib/yarrow.rb +6 -9
- metadata +22 -3
- data/lib/yarrow/tools/content_utils.rb +0 -74
data/lib/yarrow/web/manifest.rb
CHANGED
@@ -3,6 +3,7 @@ module Yarrow
|
|
3
3
|
class Manifest
|
4
4
|
def self.build(graph)
|
5
5
|
manifest = new
|
6
|
+
manifest.set_graph(graph)
|
6
7
|
|
7
8
|
graph.n(:collection).each do |collection|
|
8
9
|
# TODO: raise error if both content_only and index_only are set
|
@@ -10,12 +11,12 @@ module Yarrow
|
|
10
11
|
|
11
12
|
# If the collection is tagged :index_only then skip adding individual documents
|
12
13
|
unless collection.props[:index_only]
|
13
|
-
collection.out(:
|
14
|
+
collection.out(:entity).each do |entity|
|
14
15
|
#if item[:entity].status.to_sym == :published
|
15
|
-
if
|
16
|
-
index =
|
16
|
+
if entity.props[:resource].name == "index"
|
17
|
+
index = entity
|
17
18
|
else
|
18
|
-
manifest.add_document(
|
19
|
+
manifest.add_document(entity_context(entity))
|
19
20
|
end
|
20
21
|
#end
|
21
22
|
end
|
@@ -34,13 +35,18 @@ module Yarrow
|
|
34
35
|
manifest
|
35
36
|
end
|
36
37
|
|
37
|
-
attr_reader :documents, :assets
|
38
|
+
attr_reader :documents, :assets, :graph
|
38
39
|
|
39
40
|
def initialize
|
40
41
|
@documents = []
|
41
42
|
@assets = []
|
42
43
|
end
|
43
44
|
|
45
|
+
# Used for dot debugging
|
46
|
+
def set_graph(graph)
|
47
|
+
@graph = graph
|
48
|
+
end
|
49
|
+
|
44
50
|
def add_document(document)
|
45
51
|
@documents << document
|
46
52
|
end
|
@@ -53,12 +59,12 @@ module Yarrow
|
|
53
59
|
IndexDocument.new(collection, nil, true)
|
54
60
|
end
|
55
61
|
|
56
|
-
def self.collection_index_context(collection,
|
57
|
-
IndexDocument.new(collection,
|
62
|
+
def self.collection_index_context(collection, entity)
|
63
|
+
IndexDocument.new(collection, entity, false)
|
58
64
|
end
|
59
65
|
|
60
|
-
def self.
|
61
|
-
Document.new(
|
66
|
+
def self.entity_context(entity)
|
67
|
+
Document.new(entity, false)
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
data/lib/yarrow.rb
CHANGED
@@ -15,14 +15,16 @@ require "yarrow/schema/dictionary"
|
|
15
15
|
require "yarrow/schema/entity"
|
16
16
|
require "yarrow/schema/value"
|
17
17
|
require "yarrow/schema/registry"
|
18
|
-
require "yarrow/
|
19
|
-
require "yarrow/tools/content_utils"
|
18
|
+
require "yarrow/format"
|
20
19
|
require "yarrow/content/graph"
|
21
20
|
require "yarrow/content/policy"
|
22
21
|
require "yarrow/content/model"
|
23
22
|
require "yarrow/content/source"
|
24
|
-
require "yarrow/content/expansion/
|
25
|
-
require "yarrow/content/expansion/
|
23
|
+
require "yarrow/content/expansion/aggregator"
|
24
|
+
require "yarrow/content/expansion/basename_merge"
|
25
|
+
require "yarrow/content/expansion/filename_map"
|
26
|
+
require "yarrow/content/expansion/directory_merge"
|
27
|
+
require "yarrow/content/expansion/traversal"
|
26
28
|
require "yarrow/content/resource"
|
27
29
|
require "yarrow/web/manifest"
|
28
30
|
require "yarrow/web/document"
|
@@ -41,9 +43,4 @@ require "yarrow/process/project_manifest"
|
|
41
43
|
require "yarrow/config"
|
42
44
|
require "yarrow/configuration"
|
43
45
|
require "yarrow/console_runner"
|
44
|
-
|
45
46
|
require "yarrow/generator"
|
46
|
-
|
47
|
-
# Dir[File.dirname(__FILE__) + "/yarrow/generators/*.rb"].each do |generator|
|
48
|
-
# require generator
|
49
|
-
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -245,6 +245,7 @@ extra_rdoc_files: []
|
|
245
245
|
files:
|
246
246
|
- ".github/workflows/ruby.yml"
|
247
247
|
- ".gitignore"
|
248
|
+
- CONTENT.md
|
248
249
|
- Gemfile
|
249
250
|
- LICENSE
|
250
251
|
- README.md
|
@@ -260,7 +261,14 @@ files:
|
|
260
261
|
- lib/yarrow/config.rb
|
261
262
|
- lib/yarrow/configuration.rb
|
262
263
|
- lib/yarrow/console_runner.rb
|
264
|
+
- lib/yarrow/content/expansion/aggregator.rb
|
265
|
+
- lib/yarrow/content/expansion/basename_merge.rb
|
266
|
+
- lib/yarrow/content/expansion/directory_map.rb
|
267
|
+
- lib/yarrow/content/expansion/directory_merge.rb
|
268
|
+
- lib/yarrow/content/expansion/file_list.rb
|
269
|
+
- lib/yarrow/content/expansion/filename_map.rb
|
263
270
|
- lib/yarrow/content/expansion/strategy.rb
|
271
|
+
- lib/yarrow/content/expansion/traversal.rb
|
264
272
|
- lib/yarrow/content/expansion/tree.rb
|
265
273
|
- lib/yarrow/content/graph.rb
|
266
274
|
- lib/yarrow/content/model.rb
|
@@ -269,6 +277,18 @@ files:
|
|
269
277
|
- lib/yarrow/content/source.rb
|
270
278
|
- lib/yarrow/content_map.rb
|
271
279
|
- lib/yarrow/defaults.yml
|
280
|
+
- lib/yarrow/format.rb
|
281
|
+
- lib/yarrow/format/asciidoc.rb
|
282
|
+
- lib/yarrow/format/html.rb
|
283
|
+
- lib/yarrow/format/json.rb
|
284
|
+
- lib/yarrow/format/markdown.rb
|
285
|
+
- lib/yarrow/format/mediawiki.rb
|
286
|
+
- lib/yarrow/format/methods/front_matter.rb
|
287
|
+
- lib/yarrow/format/methods/metadata.rb
|
288
|
+
- lib/yarrow/format/orgmode.rb
|
289
|
+
- lib/yarrow/format/text.rb
|
290
|
+
- lib/yarrow/format/xml.rb
|
291
|
+
- lib/yarrow/format/yaml.rb
|
272
292
|
- lib/yarrow/generator.rb
|
273
293
|
- lib/yarrow/help.txt
|
274
294
|
- lib/yarrow/logging.rb
|
@@ -292,7 +312,6 @@ files:
|
|
292
312
|
- lib/yarrow/server/livereload.rb
|
293
313
|
- lib/yarrow/source/graph.rb
|
294
314
|
- lib/yarrow/symbols.rb
|
295
|
-
- lib/yarrow/tools/content_utils.rb
|
296
315
|
- lib/yarrow/tools/front_matter.rb
|
297
316
|
- lib/yarrow/version.rb
|
298
317
|
- lib/yarrow/web/document.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module Yarrow
|
2
|
-
module Tools
|
3
|
-
# Synchronous utility functions for working with filesystem content tasks.
|
4
|
-
module ContentUtils
|
5
|
-
# Pass in a source path and get back a parsed representation of the
|
6
|
-
# content if it is in a known text format. Mostly used as a fallback if
|
7
|
-
# a custom parser or processing chain is not configured for a content
|
8
|
-
# type.
|
9
|
-
#
|
10
|
-
# Supported formats:
|
11
|
-
# - HTML template and document partials
|
12
|
-
# - Markdown documents
|
13
|
-
# - YAML documents
|
14
|
-
# - JSON (untested)
|
15
|
-
#
|
16
|
-
# Works around meta and content source in multiple files or a single
|
17
|
-
# file with front matter.
|
18
|
-
def read_yfm(name)
|
19
|
-
path = if name.is_a?(Pathname)
|
20
|
-
name
|
21
|
-
else
|
22
|
-
Pathname.new(name)
|
23
|
-
end
|
24
|
-
|
25
|
-
text = File.read(path, :encoding => 'utf-8')
|
26
|
-
|
27
|
-
case path.extname
|
28
|
-
when '.htm', '.md', '.txt', '.yfm'
|
29
|
-
extract_yfm(text, symbolize_keys: true)
|
30
|
-
# when '.md'
|
31
|
-
# body, data = read_split_content(path.to_s, symbolize_keys: true)
|
32
|
-
# [Kramdown::Document.new(body).to_html, data]
|
33
|
-
when '.yml'
|
34
|
-
[nil, YAML.load(File.read(path.to_s), symbolize_names: true)]
|
35
|
-
when '.json'
|
36
|
-
[nil, JSON.parse(File.read(path.to_s))]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def extract_yfm(text, options={})
|
41
|
-
pattern = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
42
|
-
if text =~ pattern
|
43
|
-
content = text.sub(pattern, "")
|
44
|
-
|
45
|
-
begin
|
46
|
-
if options.key?(:symbolize_keys)
|
47
|
-
meta = YAML.load($1, symbolize_names: true)
|
48
|
-
else
|
49
|
-
meta = YAML.load($1)
|
50
|
-
end
|
51
|
-
return [content, meta]
|
52
|
-
rescue Psych::SyntaxError => error
|
53
|
-
if defined? ::Logger
|
54
|
-
# todo: application wide logger
|
55
|
-
#logger = ::Logger.new(STDOUT)
|
56
|
-
#logger.error "#{error.message}"
|
57
|
-
end
|
58
|
-
return [content, nil]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
[text, nil]
|
63
|
-
end
|
64
|
-
|
65
|
-
def write_yfm(name, text, meta)
|
66
|
-
# Symbolized keys are better to deal with when manipulating data in
|
67
|
-
# Ruby but are an interop nightmare when serialized so here we do a
|
68
|
-
# round-trip through JSON encoding to ensure all keys are string
|
69
|
-
# encoded before dumping them to the front matter format.
|
70
|
-
File.write(name, [YAML.dump(meta.to_json), "---", text].join("\n"))
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|