yarrow 0.4.3 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +23 -0
- data/.gitignore +8 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +59 -0
- data/Rakefile +18 -0
- data/SERVER.md +41 -0
- data/lib/yarrow.rb +18 -5
- data/lib/yarrow/config.rb +59 -0
- data/lib/yarrow/configuration.rb +35 -63
- data/lib/yarrow/content/collection_expander.rb +218 -0
- data/lib/yarrow/content/content_type.rb +42 -0
- data/lib/yarrow/content/graph.rb +33 -0
- data/lib/yarrow/content/source.rb +11 -0
- data/lib/yarrow/content/source_collector.rb +55 -0
- data/lib/yarrow/extensions.rb +1 -0
- data/lib/yarrow/extensions/mementus.rb +24 -0
- data/lib/yarrow/output/context.rb +0 -6
- data/lib/yarrow/output/generator.rb +2 -2
- data/lib/yarrow/output/web/indexed_file.rb +39 -0
- data/lib/yarrow/process/expand_content.rb +12 -0
- data/lib/yarrow/process/extract_source.rb +12 -0
- data/lib/yarrow/process/project_manifest.rb +20 -0
- data/lib/yarrow/process/step_processor.rb +43 -0
- data/lib/yarrow/process/workflow.rb +36 -0
- data/lib/yarrow/schema.rb +132 -0
- data/lib/yarrow/schema/validations/array.rb +0 -0
- data/lib/yarrow/schema/validations/object.rb +0 -0
- data/lib/yarrow/schema/validations/string.rb +0 -0
- data/lib/yarrow/server.rb +8 -5
- data/lib/yarrow/source/graph.rb +6 -0
- data/lib/yarrow/symbols.rb +19 -0
- data/lib/yarrow/tools/content_utils.rb +66 -0
- data/lib/yarrow/tools/front_matter.rb +4 -2
- data/lib/yarrow/version.rb +3 -2
- data/lib/yarrow/web/html_document.rb +9 -0
- data/lib/yarrow/web/manifest.rb +9 -0
- data/lib/yarrow/web/static_asset.rb +9 -0
- data/lib/yarrow/web/template.rb +9 -0
- data/yarrow.gemspec +30 -0
- metadata +61 -47
- data/lib/yarrow/html.rb +0 -1
- data/lib/yarrow/html/asset_tags.rb +0 -59
- data/lib/yarrow/html/content_tags.rb +0 -7
- data/lib/yarrow/tools/output_file.rb +0 -40
data/lib/yarrow/html.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative 'html/asset_tags'
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Yarrow
|
2
|
-
module HTML
|
3
|
-
module AssetTags
|
4
|
-
include Yarrow::Configurable
|
5
|
-
|
6
|
-
# TODO: make sprockets manifest optional/pluggable
|
7
|
-
def manifest
|
8
|
-
Yarrow::Assets::Manifest.new(config)
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
# Computes the base URL path to assets in the public web directory.
|
13
|
-
def base_url_path
|
14
|
-
if config.assets.nil? || config.output_dir.nil?
|
15
|
-
raise Yarrow::ConfigurationError
|
16
|
-
end
|
17
|
-
|
18
|
-
# TODO: prepend configurable CDN URL for host path
|
19
|
-
# TODO: dev/production mode switch
|
20
|
-
|
21
|
-
config.assets.output_dir.gsub(config.output_dir, '')
|
22
|
-
end
|
23
|
-
|
24
|
-
def script_tags
|
25
|
-
manifest.js_logical_paths.map { |path| script_tag(asset: path) }.join("\n")
|
26
|
-
end
|
27
|
-
|
28
|
-
def script_tag(options)
|
29
|
-
src_path = if asset_in_manifest?(options)
|
30
|
-
digest_path(options[:asset])
|
31
|
-
else
|
32
|
-
options[:src]
|
33
|
-
end
|
34
|
-
|
35
|
-
"<script src=\"#{src_path}\"></script>"
|
36
|
-
end
|
37
|
-
|
38
|
-
def link_tag(options)
|
39
|
-
href_path = if asset_in_manifest?(options)
|
40
|
-
digest_path(options[:asset])
|
41
|
-
else
|
42
|
-
options[:href]
|
43
|
-
end
|
44
|
-
|
45
|
-
"<link href=\"#{href_path}\" rel=\"stylesheet\" type=\"text/css\">"
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def asset_in_manifest?(options)
|
51
|
-
options.has_key?(:asset) and manifest.exists?(options[:asset])
|
52
|
-
end
|
53
|
-
|
54
|
-
def digest_path(path)
|
55
|
-
"#{base_url_path}/#{manifest.digest_path(path)}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Yarrow
|
2
|
-
module Tools
|
3
|
-
# TODO: consider renaming this to OutputDocument.
|
4
|
-
class OutputFile
|
5
|
-
include Yarrow::Configurable
|
6
|
-
|
7
|
-
WRITE_MODE = 'w+:UTF-8'.freeze
|
8
|
-
|
9
|
-
# @return [String] Basename reflecting the server convention (usually: index.html)
|
10
|
-
def index_name
|
11
|
-
@index_name ||= config.index_name || 'index.html'
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [String] Docroot of the output target
|
15
|
-
def docroot
|
16
|
-
@docroot ||= config.output_dir || 'public'
|
17
|
-
end
|
18
|
-
|
19
|
-
# Write an output file to the specified path under the docroot.
|
20
|
-
#
|
21
|
-
# @param path [String]
|
22
|
-
# @param content [String]
|
23
|
-
def write(path, content)
|
24
|
-
# If the target path is a directory,
|
25
|
-
# generate a default index filename.
|
26
|
-
if path[path.length-1] == '/'
|
27
|
-
path = "#{path}#{index_name}"
|
28
|
-
end
|
29
|
-
|
30
|
-
target_path = Pathname.new("#{docroot}#{path}")
|
31
|
-
|
32
|
-
FileUtils.mkdir_p(target_path.dirname)
|
33
|
-
|
34
|
-
File.open(target_path.to_s, WRITE_MODE) do |file|
|
35
|
-
file.puts(content)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|