jekyll-theme-modootoday 1.6.0 → 1.7.0
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/CHANGELOG.md +65 -1
- data/README.ja.md +150 -0
- data/README.ko.md +17 -16
- data/README.md +16 -15
- data/RULES.md +5 -1
- data/_includes/modootoday/assets/build.html +6 -0
- data/_includes/modootoday/assets/registry.html +14 -6
- data/_includes/modootoday/assets/scripts.html +2 -0
- data/_includes/modootoday/assets/sheets.html +6 -3
- data/_includes/modootoday/blog/subscribe.html +5 -0
- data/_includes/modootoday/brand/icon.html +2 -1
- data/_includes/modootoday/chrome/banner-text.html +16 -0
- data/_includes/modootoday/chrome/banner.html +5 -0
- data/_includes/modootoday/config.html +2 -1
- data/_includes/modootoday/detail/cta.html +1 -1
- data/_includes/modootoday/detail/facts.html +1 -0
- data/_includes/modootoday/detail/jsonld.html +6 -1
- data/_includes/modootoday/detail/page.html +1 -0
- data/_includes/modootoday/detail/tickets.html +6 -0
- data/_includes/modootoday/docs-extra/feed-entries.html +24 -0
- data/_includes/modootoday/docs-extra/head.html +7 -1
- data/_includes/modootoday/head-meta.html +17 -9
- data/_includes/modootoday/i18n/ar.html +1 -1
- data/_includes/modootoday/i18n/de.html +1 -1
- data/_includes/modootoday/i18n/el.html +1 -1
- data/_includes/modootoday/i18n/es.html +1 -1
- data/_includes/modootoday/i18n/fa.html +1 -1
- data/_includes/modootoday/i18n/fr.html +1 -1
- data/_includes/modootoday/i18n/id.html +1 -1
- data/_includes/modootoday/i18n/it.html +1 -1
- data/_includes/modootoday/i18n/ja.html +1 -1
- data/_includes/modootoday/i18n/ko.html +1 -1
- data/_includes/modootoday/i18n/ml.html +1 -1
- data/_includes/modootoday/i18n/pl.html +1 -1
- data/_includes/modootoday/i18n/pt-BR.html +1 -1
- data/_includes/modootoday/i18n/ro.html +1 -1
- data/_includes/modootoday/i18n/ru.html +1 -1
- data/_includes/modootoday/i18n/th.html +1 -1
- data/_includes/modootoday/i18n/tr.html +1 -1
- data/_includes/modootoday/i18n/uk.html +1 -1
- data/_includes/modootoday/i18n/ur-Latn.html +1 -1
- data/_includes/modootoday/i18n/vi.html +1 -1
- data/_includes/modootoday/i18n/zh-CN.html +1 -1
- data/_includes/modootoday/i18n/zh-TW.html +1 -1
- data/_includes/modootoday/i18n.html +176 -152
- data/_includes/modootoday/jsonld/graph.html +1 -1
- data/_includes/modootoday/markdown/anchors.html +26 -0
- data/_includes/modootoday/markdown/c/install.html +6 -0
- data/_includes/modootoday/markdown/figures/diagrams.html +3 -2
- data/_includes/modootoday/markdown/sections.html +9 -3
- data/_includes/modootoday/meta/feed-url.html +13 -0
- data/_includes/modootoday/meta/feedback.html +14 -0
- data/_includes/modootoday/meta/feeds.html +14 -0
- data/_includes/modootoday/meta/github.html +15 -0
- data/_includes/modootoday/meta/og-image.html +15 -0
- data/_includes/modootoday/meta/releases-feed.html +5 -0
- data/_includes/modootoday/page-meta.html +22 -4
- data/_includes/modootoday/pwa/head.html +7 -0
- data/_includes/modootoday/pwa/manifest.json +54 -0
- data/_includes/modootoday/pwa/offline-assets.html +10 -0
- data/_includes/modootoday/pwa/precache.html +21 -0
- data/_includes/modootoday/pwa/sw.js +36 -0
- data/_includes/modootoday/site/dir.html +5 -0
- data/_includes/modootoday/stylesheets.html +5 -1
- data/_includes/modootoday/t.html +1 -1
- data/_includes/modootoday/theme-color.html +1 -0
- data/_includes/modootoday/version.html +1 -1
- data/_layouts/archive.html +2 -1
- data/_layouts/author.html +1 -0
- data/_layouts/blog.html +1 -0
- data/_layouts/default.html +8 -8
- data/_layouts/doc.html +1 -0
- data/_layouts/feed.html +14 -5
- data/_layouts/pages/offline.html +14 -0
- data/_layouts/redirect.html +1 -2
- data/_sass/modootoday/components/content/_anchor.scss +9 -0
- data/_sass/modootoday/components/doc/_sidebar.scss +3 -1
- data/_sass/modootoday/components/doc/_toc.scss +4 -0
- data/_sass/modootoday/components/media/_diagram.scss +3 -1
- data/_sass/modootoday/components/section/showcase/_install.scss +14 -0
- data/_sass/modootoday/layout/_page-meta.scss +5 -1
- data/_sass/modootoday/print/_sheet.scss +17 -0
- data/_sass/modootoday/pwa/_toast.scss +16 -0
- data/_sass/modootoday.scss +1 -0
- data/assets/css/modootoday/chrome/print.scss +5 -0
- data/assets/css/modootoday/chrome/toast.scss +8 -0
- data/assets/css/modootoday/content/anchor.scss +7 -0
- data/assets/css/modootoday/showcase/install.scss +7 -0
- data/assets/js/modootoday/pwa/install.js +60 -0
- data/assets/js/modootoday/pwa/offline.js +33 -0
- data/assets/js/modootoday/pwa/register.js +79 -0
- data/assets/js/modootoday/pwa/update-toast.js +75 -0
- data/assets/js/modootoday/pwa/worker.js +150 -0
- data/assets/js/modootoday/structure/toc-spy.js +121 -0
- data/assets/modootoday/icon-192.png +0 -0
- data/assets/modootoday/icon-512.png +0 -0
- data/assets/modootoday/icon-maskable-512.png +0 -0
- data/i18n/ar.yml +19 -2
- data/i18n/de.yml +19 -2
- data/i18n/el.yml +19 -2
- data/i18n/en.yml +19 -2
- data/i18n/es.yml +19 -2
- data/i18n/fa.yml +19 -2
- data/i18n/fr.yml +19 -2
- data/i18n/glossary.yml +21 -3
- data/i18n/id.yml +19 -2
- data/i18n/it.yml +19 -2
- data/i18n/ja.yml +19 -2
- data/i18n/ko.yml +19 -2
- data/i18n/ml.yml +19 -2
- data/i18n/pl.yml +19 -2
- data/i18n/pt-BR.yml +19 -2
- data/i18n/ro.yml +19 -2
- data/i18n/ru.yml +19 -2
- data/i18n/th.yml +19 -2
- data/i18n/tr.yml +19 -2
- data/i18n/uk.yml +19 -2
- data/i18n/ur-Latn.yml +19 -2
- data/i18n/vi.yml +19 -2
- data/i18n/zh-CN.yml +19 -2
- data/i18n/zh-TW.yml +19 -2
- data/lib/modootoday/check/build/feeds.rb +63 -0
- data/lib/modootoday/check/build/links.rb +74 -0
- data/lib/modootoday/check/build/pwa/manifest.rb +61 -0
- data/lib/modootoday/check/build/pwa/precache.rb +38 -0
- data/lib/modootoday/check/build/pwa/worker.rb +55 -0
- data/lib/modootoday/check/build/pwa.rb +55 -0
- data/lib/modootoday/check/build/{aliases.rb → stubs/aliases.rb} +1 -1
- data/lib/modootoday/check/build/{records.rb → stubs/records.rb} +1 -1
- data/lib/modootoday/check/build/{twins.rb → stubs/twins.rb} +1 -1
- data/lib/modootoday/check/cli.rb +4 -3
- data/lib/modootoday/check/config/keys/appearance/brand.rb +28 -0
- data/lib/modootoday/check/config/keys/appearance/chrome.rb +11 -1
- data/lib/modootoday/check/config/keys/appearance/switches.rb +11 -1
- data/lib/modootoday/check/config/keys/figures/renderers.rb +10 -0
- data/lib/modootoday/check/config/keys/pages/blog.rb +11 -0
- data/lib/modootoday/check/config/keys/pages/content.rb +11 -0
- data/lib/modootoday/check/config/keys/pages/edit_url.rb +17 -2
- data/lib/modootoday/check/config/keys/pages/feedback.rb +24 -0
- data/lib/modootoday/check/config/keys/pages/languages.rb +2 -0
- data/lib/modootoday/check/config/keys/serving/pwa.rb +118 -0
- data/lib/modootoday/check/config/keys.rb +5 -0
- data/lib/modootoday/check/config/site_config.rb +2 -1
- data/lib/modootoday/check/config/validate.rb +4 -1
- data/lib/modootoday/check/layouts/detail.rb +24 -6
- data/lib/modootoday/check/layouts/directory.rb +1 -1
- data/lib/modootoday/check/page/a11y/new_window.rb +2 -1
- data/lib/modootoday/check/page/component_rules.rb +5 -1
- data/lib/modootoday/check/page/figures/diagrams.rb +10 -2
- data/lib/modootoday/check.rb +6 -3
- data/lib/modootoday/markdown.rb +3 -0
- data/lib/modootoday/stubs/cli.rb +5 -4
- data/lib/modootoday/stubs/pwa.rb +57 -0
- data/lib/modootoday/stubs.rb +3 -2
- metadata +56 -5
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rexml/document"
|
|
4
|
+
|
|
5
|
+
module Modootoday
|
|
6
|
+
module Check
|
|
7
|
+
# Front matter feed: on a page names its Atom feed (meta/feed-url.html): false, or a site path to an .xml page that
|
|
8
|
+
# exists in the build. The theme drops a feed it cannot find, so a wrong path would lose the link without a word.
|
|
9
|
+
# A feed page's feed_source: is "data" or a built page; every built Atom feed must be well-formed XML.
|
|
10
|
+
module Feeds
|
|
11
|
+
SKIP = %r{(?:\A|/)(?:_site|node_modules|vendor|\.[^/]+)/}
|
|
12
|
+
|
|
13
|
+
module_function
|
|
14
|
+
|
|
15
|
+
def call(ctx)
|
|
16
|
+
ctx.mds.each do |f|
|
|
17
|
+
fm = (Markdown.fm(File.read(f)) rescue nil)
|
|
18
|
+
next unless fm.is_a?(Hash) && fm.key?("feed")
|
|
19
|
+
problem = check(ctx.site, fm["feed"])
|
|
20
|
+
ctx.errs << "#{ctx.rel(f)}: feed: #{problem}" if problem
|
|
21
|
+
end
|
|
22
|
+
sources(ctx)
|
|
23
|
+
built(ctx)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def check(site, feed)
|
|
27
|
+
return if feed == false
|
|
28
|
+
return "must be false or a site path to the page's Atom feed, such as /blog/feed.xml (got #{feed.inspect})" unless feed.is_a?(String) && feed.start_with?("/") && feed.end_with?(".xml")
|
|
29
|
+
return if File.file?(File.join(site, feed))
|
|
30
|
+
"#{feed} is not in the build: add a page with layout: feed at that permalink, or fix the path"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# feed_source: on .xml pages with front matter (layout: feed).
|
|
34
|
+
def sources(ctx)
|
|
35
|
+
Dir.glob(File.join(ctx.src, "**", "*.xml")).sort.each do |f|
|
|
36
|
+
next if ctx.rel(f).match?(SKIP)
|
|
37
|
+
fm = (Markdown.fm(File.read(f)) rescue nil)
|
|
38
|
+
next unless fm.is_a?(Hash) && fm.key?("feed_source")
|
|
39
|
+
source = fm["feed_source"]
|
|
40
|
+
next if source == "data"
|
|
41
|
+
unless source.is_a?(String) && source.start_with?("/")
|
|
42
|
+
ctx.errs << "#{ctx.rel(f)}: feed_source: must be data or the URL of a layout: changelog page, such as /changelog/ (got #{source.inspect})"
|
|
43
|
+
next
|
|
44
|
+
end
|
|
45
|
+
page = File.join(ctx.site, source, source.end_with?("/") ? "index.html" : "")
|
|
46
|
+
ctx.errs << "#{ctx.rel(f)}: feed_source: #{source} is not in the build" unless File.file?(page) || File.file?("#{page}.html")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def built(ctx)
|
|
51
|
+
Dir.glob(File.join(ctx.site, "**", "*.xml")).sort.each do |f|
|
|
52
|
+
text = File.read(f)
|
|
53
|
+
next unless text.include?("<feed")
|
|
54
|
+
begin
|
|
55
|
+
REXML::Document.new(text)
|
|
56
|
+
rescue REXML::ParseException => e
|
|
57
|
+
ctx.errs << "#{ctx.rel(f)}: the Atom feed is not well-formed XML: #{e.message.lines.first.to_s.strip}"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
module Modootoday
|
|
6
|
+
module Check
|
|
7
|
+
# --links: every same-site a href, link href, img src, script src and source srcset in the built site points
|
|
8
|
+
# at a file that exists, and a #fragment matches an id or a[name] on its target page. External URLs are not
|
|
9
|
+
# fetched. Warnings, which --strict turns into failures (adr:modootoday/20261111231457). Needs Nokogiri.
|
|
10
|
+
module Links
|
|
11
|
+
TARGETS = "a[href], link[href], img[src], script[src], source[srcset]"
|
|
12
|
+
EXTERNAL = %r{\A[a-z][a-z0-9+.-]*:|\A//}i
|
|
13
|
+
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
def call(ctx)
|
|
17
|
+
return unless ctx.option?("--links")
|
|
18
|
+
return ctx.warns << "--links needs the nokogiri gem; links were not checked" unless nokogiri?
|
|
19
|
+
found = scan(ctx.site, baseurl(ctx))
|
|
20
|
+
found[:problems].each { |p| ctx.warns << p }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def nokogiri?
|
|
24
|
+
require "nokogiri"
|
|
25
|
+
true
|
|
26
|
+
rescue LoadError
|
|
27
|
+
false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def baseurl(ctx) = ctx.site_cfg["baseurl"].to_s.chomp("/")
|
|
31
|
+
|
|
32
|
+
# One pass over SITE; returns the problems and the external URLs it skipped.
|
|
33
|
+
def scan(site, baseurl, &each_page)
|
|
34
|
+
ids = Hash.new { |h, f| h[f] = Nokogiri::HTML(File.read(f)).css("[id],a[name]").map { |n| n["id"] || n["name"] } }
|
|
35
|
+
problems, external = [], []
|
|
36
|
+
Dir.glob(File.join(site, "**/*.html")).sort.each do |file|
|
|
37
|
+
rel = file.delete_prefix(site)
|
|
38
|
+
doc = Nokogiri::HTML(File.read(file))
|
|
39
|
+
each_page&.call(rel, doc)
|
|
40
|
+
doc.css(TARGETS).each do |n|
|
|
41
|
+
url = (n["href"] || n["src"] || n["srcset"].to_s.split(/\s+/).first).to_s.strip
|
|
42
|
+
next if url.empty?
|
|
43
|
+
next external << url if url.match?(EXTERNAL)
|
|
44
|
+
problem = link(site, baseurl, file, rel, url, ids)
|
|
45
|
+
problems << problem if problem
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
{ problems: problems, external: external.uniq.sort }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def link(site, baseurl, file, rel, url, ids)
|
|
52
|
+
upath, frag = url.split("#", 2)
|
|
53
|
+
upath = upath.to_s.split("?", 2).first.to_s
|
|
54
|
+
target = file
|
|
55
|
+
unless upath.empty?
|
|
56
|
+
path = upath.start_with?("/") ? upath : File.expand_path(upath, File.dirname("#{baseurl}#{rel}"))
|
|
57
|
+
path += "/" if upath.end_with?("/") && !path.end_with?("/")
|
|
58
|
+
return "#{rel}: #{url} is outside baseurl #{baseurl}" unless baseurl.empty? || path == baseurl || path.start_with?("#{baseurl}/")
|
|
59
|
+
target = resolve(site, path.delete_prefix(baseurl))
|
|
60
|
+
return "#{rel}: broken link #{url}" unless target
|
|
61
|
+
end
|
|
62
|
+
return if frag.nil? || frag.empty? || !target.end_with?(".html")
|
|
63
|
+
"#{rel}: missing anchor #{url}" unless ids[target].include?(CGI.unescape(frag))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def resolve(site, path)
|
|
67
|
+
full = File.join(site, CGI.unescape(path))
|
|
68
|
+
return full if File.file?(full)
|
|
69
|
+
return File.join(full, "index.html") if File.file?(File.join(full, "index.html"))
|
|
70
|
+
"#{full}.html" if File.file?("#{full}.html")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Modootoday
|
|
6
|
+
module Check
|
|
7
|
+
module Pwa
|
|
8
|
+
# The built manifest.webmanifest: a JSON object with the fields browsers need to install the site, start_url and id
|
|
9
|
+
# inside the scope, and icons and screenshots that are PNG files in SITE of the size they state (read from the IHDR
|
|
10
|
+
# chunk); a shortcut opens a page of the build.
|
|
11
|
+
module Manifest
|
|
12
|
+
REQUIRED = %w[id name short_name start_url scope display icons].freeze
|
|
13
|
+
PNG = "\x89PNG\r\n\x1a\n".b
|
|
14
|
+
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def call(ctx)
|
|
18
|
+
f = File.join(ctx.site, Stubs::Pwa::MANIFEST)
|
|
19
|
+
return ctx.errs << "#{f}: missing (#{HINT}, then build)" unless File.file?(f)
|
|
20
|
+
m = JSON.parse(File.read(f))
|
|
21
|
+
return ctx.errs << "#{f}: must be a JSON object" unless m.is_a?(Hash)
|
|
22
|
+
missing = REQUIRED - m.keys
|
|
23
|
+
return ctx.errs << "#{f}: missing #{missing.join(', ')}" unless missing.empty?
|
|
24
|
+
scope = m["scope"].to_s
|
|
25
|
+
%w[start_url id].each { |k| ctx.errs << "#{f}: #{k} #{m[k].inspect} is outside the scope #{scope}" unless m[k].to_s.start_with?(scope) }
|
|
26
|
+
icons(ctx, f, m["icons"], scope.chomp("/"))
|
|
27
|
+
Array(m["screenshots"]).each { |i| image(ctx, f, "screenshot", i, scope.chomp("/")) }
|
|
28
|
+
Array(m["shortcuts"]).each { |s| shortcut(ctx, f, s.is_a?(Hash) ? s["url"].to_s : "", scope) }
|
|
29
|
+
rescue JSON::ParserError => e
|
|
30
|
+
ctx.errs << "#{f}: not JSON (#{e.message.lines.first.strip})"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Icon URLs carry the baseurl, which the built SITE folder does not.
|
|
34
|
+
def icons(ctx, f, icons, base)
|
|
35
|
+
return ctx.errs << "#{f}: icons must be a list" unless icons.is_a?(Array) && !icons.empty?
|
|
36
|
+
icons.each { |i| image(ctx, f, "icon", i, base) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def image(ctx, f, kind, i, base)
|
|
40
|
+
src = i.is_a?(Hash) ? i["src"].to_s : ""
|
|
41
|
+
file = File.join(ctx.site, src.delete_prefix(base).split("?").first.to_s)
|
|
42
|
+
return ctx.errs << "#{f}: #{kind} #{src.inspect} is not in the build" unless src.start_with?("#{base}/") && File.file?(file)
|
|
43
|
+
size = png_size(file)
|
|
44
|
+
return ctx.errs << "#{f}: #{kind} #{src} is not a PNG file" unless size
|
|
45
|
+
ctx.errs << "#{f}: #{kind} #{src} is #{size.join('x')}, not #{i['sizes']}" unless i["sizes"] == size.join("x")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def shortcut(ctx, f, url, scope)
|
|
49
|
+
return ctx.errs << "#{f}: shortcut #{url.inspect} is outside the scope #{scope}" unless url.start_with?(scope)
|
|
50
|
+
ctx.errs << "#{f}: shortcut #{url} is not in the build" unless File.file?(Worker.file(ctx, scope.chomp("/"), url))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def png_size(file)
|
|
54
|
+
head = File.binread(file, 24)
|
|
55
|
+
return unless head && head.size == 24 && head.start_with?(PNG) && head[12, 4] == "IHDR"
|
|
56
|
+
head[16, 8].unpack("NN")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Modootoday
|
|
4
|
+
module Check
|
|
5
|
+
module Pwa
|
|
6
|
+
# What the worker precaches: every URL is in the build (the worker skips a missing one, so offline reading silently
|
|
7
|
+
# lacks it), and the total stays small for a first visit. Front matter pwa: takes only precache.
|
|
8
|
+
module Precache
|
|
9
|
+
LIMIT = 1024 * 1024
|
|
10
|
+
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
def call(ctx)
|
|
14
|
+
c = Worker.settings(ctx)
|
|
15
|
+
return unless c
|
|
16
|
+
f = File.join(ctx.site, Stubs::Pwa::WORKER)
|
|
17
|
+
base = c["scope"].to_s.chomp("/")
|
|
18
|
+
offline = c["offline"].to_h.values
|
|
19
|
+
total = Array(c["precache"]).sum do |url|
|
|
20
|
+
file = Worker.file(ctx, base, url)
|
|
21
|
+
next File.size(file) if File.file?(file)
|
|
22
|
+
ctx.errs << "#{f}: precache URL #{url} is not in the build" unless offline.include?(url)
|
|
23
|
+
0
|
|
24
|
+
end
|
|
25
|
+
ctx.warns << "#{f}: the precache list is #{total} bytes; every first visit downloads it, so keep it under 1 MiB" if total > LIMIT
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def front_matter(ctx)
|
|
29
|
+
ctx.mds.each do |f|
|
|
30
|
+
fm = begin Markdown.fm(File.read(f)) rescue nil end
|
|
31
|
+
next unless fm.is_a?(Hash) && fm.key?("pwa") && fm["pwa"] != "precache"
|
|
32
|
+
ctx.errs << "#{ctx.rel(f)}: pwa: takes only precache (the worker keeps the page for offline reading)"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Modootoday
|
|
6
|
+
module Check
|
|
7
|
+
module Pwa
|
|
8
|
+
# The built sw.js: rendered by the theme include at the baseurl root, the constants form with enabled: true and the
|
|
9
|
+
# self-removing form with kill, with an offline page for each language prefix it names. A disabled site that keeps
|
|
10
|
+
# the stub serves the self-removing worker, which is right for a while and then only clutter.
|
|
11
|
+
module Worker
|
|
12
|
+
CONSTANTS = /^self\.MT_PWA = (\{.*\});$/
|
|
13
|
+
KILL = "self.registration.unregister()"
|
|
14
|
+
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def call(ctx, mode)
|
|
18
|
+
f = File.join(ctx.site, Stubs::Pwa::WORKER)
|
|
19
|
+
return ctx.errs << "#{f}: missing (#{HINT}, then build)" unless File.file?(f)
|
|
20
|
+
if mode == "kill"
|
|
21
|
+
ctx.errs << "#{f}: not the theme's self-removing worker; keep the stub as modootoday-stubs writes it" unless File.read(f).include?(KILL)
|
|
22
|
+
return
|
|
23
|
+
end
|
|
24
|
+
c = settings(ctx)
|
|
25
|
+
return ctx.errs << "#{f}: not the theme's worker (no self.MT_PWA); keep the stub as modootoday-stubs writes it" unless c
|
|
26
|
+
base = c["scope"].to_s.chomp("/")
|
|
27
|
+
c["offline"].to_h.each_value do |url|
|
|
28
|
+
ctx.errs << "#{f}: the offline page #{url} is not in the build (#{HINT}, then build)" unless File.file?(file(ctx, base, url))
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# The worker's constants, or nil when sw.js is missing or not the theme's.
|
|
33
|
+
def settings(ctx)
|
|
34
|
+
f = File.join(ctx.site, Stubs::Pwa::WORKER)
|
|
35
|
+
m = File.file?(f) && File.read(f)[CONSTANTS, 1]
|
|
36
|
+
m && JSON.parse(m)
|
|
37
|
+
rescue JSON::ParserError
|
|
38
|
+
nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The built file a site URL (with the baseurl, maybe a query) is served from.
|
|
42
|
+
def file(ctx, base, url)
|
|
43
|
+
path = url.to_s.split("?").first.to_s.delete_prefix(base)
|
|
44
|
+
File.join(ctx.site, path.end_with?("/") ? "#{path}index.html" : path)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def leftover(ctx)
|
|
48
|
+
f = File.join(*[ctx.src, Pwa.dir(ctx), Stubs::Pwa::WORKER].compact)
|
|
49
|
+
return unless File.file?(f) && Stubs::Pwa.ours?(File.read(f))
|
|
50
|
+
ctx.warns << "#{ctx.rel(f)}: modootoday.pwa is off, so it serves a self-removing worker; delete the PWA stubs a week after the last enabled deploy"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../stubs"
|
|
4
|
+
require_relative "pwa/manifest"
|
|
5
|
+
require_relative "pwa/worker"
|
|
6
|
+
require_relative "pwa/precache"
|
|
7
|
+
|
|
8
|
+
module Modootoday
|
|
9
|
+
module Check
|
|
10
|
+
# modootoday.pwa: with true or kill the stubs are in place and current (the plan of modootoday-stubs --pwa --check, so
|
|
11
|
+
# the two never disagree) and sw.js is built (pwa/worker.rb); with true also the manifest, the link on every theme
|
|
12
|
+
# page and the precache list. Off with the worker stub left: a warning.
|
|
13
|
+
module Pwa
|
|
14
|
+
HINT = "run modootoday-stubs SRC --pwa --write"
|
|
15
|
+
THEME_PAGE = /<html\b[^>]*\sdata-mt-copy=/
|
|
16
|
+
LINK = /<link rel="manifest" href=/
|
|
17
|
+
GENERATED = "generated"
|
|
18
|
+
|
|
19
|
+
module_function
|
|
20
|
+
|
|
21
|
+
def call(ctx)
|
|
22
|
+
cfg = ctx.mtc.is_a?(Hash) ? ctx.mtc["pwa"] : nil
|
|
23
|
+
mode = cfg.is_a?(Hash) ? cfg["enabled"] : nil
|
|
24
|
+
Precache.front_matter(ctx)
|
|
25
|
+
return Worker.leftover(ctx) unless Stubs::Pwa::ENABLED.include?(mode)
|
|
26
|
+
stubs(ctx)
|
|
27
|
+
Worker.call(ctx, mode)
|
|
28
|
+
return unless mode == true
|
|
29
|
+
Manifest.call(ctx)
|
|
30
|
+
links(ctx)
|
|
31
|
+
Precache.call(ctx)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Beside the pages, or under generated/ (the docs site, as for twin stubs).
|
|
35
|
+
def dir(ctx) = File.file?(File.join(ctx.src, GENERATED, Stubs::Pwa::WORKER)) ? GENERATED : nil
|
|
36
|
+
|
|
37
|
+
def stubs(ctx)
|
|
38
|
+
Stubs::Plan.new(Stubs::Source.new(ctx.src), [:pwa], prune: false, args: { pwa: { dir: dir(ctx) } }).changes.each do |c|
|
|
39
|
+
ctx.errs << "#{c.path}: #{c.reason == 'missing' ? 'missing' : 'out of date'}: #{HINT}"
|
|
40
|
+
end
|
|
41
|
+
rescue Stubs::ConfigError, Stubs::DataError => e
|
|
42
|
+
ctx.errs << "modootoday.pwa: #{e.message}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# MDN: every page of a multi-page app links the manifest. A site layout or head-meta.html override can drop it.
|
|
46
|
+
def links(ctx)
|
|
47
|
+
Dir.glob("#{ctx.site}/**/*.html").sort.each do |f|
|
|
48
|
+
html = File.read(f)
|
|
49
|
+
next unless html.match?(THEME_PAGE) && !html.match?(LINK)
|
|
50
|
+
ctx.errs << "#{f}: no <link rel=\"manifest\">; a site override of the head drops modootoday/pwa/head.html"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/modootoday/check/cli.rb
CHANGED
|
@@ -4,11 +4,12 @@ module Modootoday
|
|
|
4
4
|
module Check
|
|
5
5
|
# Command line: usage, --help/--version, running the rule groups in order, reporting.
|
|
6
6
|
module CLI
|
|
7
|
-
USAGE = "usage: modootoday-check SRC SITE [--twins] [--aliases] [--byte-exact=DIR,...] [--github-pages[=VERSION]] [--gh] [--strict] [--schema-recommended] [--i18n] [--i18n-pages] [--i18n-init=LANG,...]\n modootoday-check SRC --diagrams\n modootoday-check SRC --math"
|
|
7
|
+
USAGE = "usage: modootoday-check SRC SITE [--twins] [--aliases] [--links] [--byte-exact=DIR,...] [--github-pages[=VERSION]] [--gh] [--strict] [--schema-recommended] [--i18n] [--i18n-pages] [--i18n-init=LANG,...]\n modootoday-check SRC --diagrams\n modootoday-check SRC --math"
|
|
8
8
|
# Single source for --help and the README "Commands" table (script/readme-commands, test/project/readme_test.rb).
|
|
9
9
|
OPTIONS = [
|
|
10
|
-
["SRC SITE", "always: front matter, forbidden syntax, alerts, fence info strings, `status:`/`tag:`/`kbd:` values (`since:` is rejected), `sections:` count, `_data/i18n/<lang>.yml` keys against the default language and translated pages against default-language pages, `_data/components.yml` (keys, slot contract counts per section, `parts` against `api.md` and the built HTML), Sass/CSS rules, the token hook `_sass/modootoday/_site.scss` (only the three override maps, known token names), `site_css`, `preload` and `scripts` files present in the build, `script:` and `poster:` on hero and section items (a registered script, a sized poster that exists), `filter:` on section items and pages (a list or table to filter, a `facet` column the table has), `chart:` lines and `c: chart` sections (a type and options, a table or a `_data/charts` file, number cells), `widget:` lines, `widget_props` and `c: widget` sections (an element a `modootoday.scripts` entry defines, plain prop values, a lead paragraph), `diagrams:` (an entry per Mermaid fence, `alt`, the SVG files, an SVG drawn from another fence), static math (an entry per math block in `_data/math`, entries rendered from other TeX, no inline math),`modootoday.search` keys and collections, `modootoday.showcase` (also in `_config.demo.yml`) and, while it is enabled, the robots `noindex` on every built page (warning), `search.json` over 1.5 MB (warning), unconverted markers in the build, schema.org JSON-LD in the build (valid JSON, vocabulary, required properties per type, absolute URLs, ISO 8601 dates, one graph per page, agreement with Open Graph, a `DefinedTerm` page's `term_set` glossary), `modootoday.schema.faq`, `modootoday.records` (a page per record and a record per page, as `modootoday-stubs --records --check` judges)"],
|
|
10
|
+
["SRC SITE", "always: front matter, forbidden syntax, alerts, fence info strings, `status:`/`tag:`/`kbd:` values (`since:` is rejected), `sections:` count, `feed:` (false, or a site path to an Atom feed page in the build), `_data/i18n/<lang>.yml` keys against the default language and translated pages against default-language pages, `_data/components.yml` (keys, slot contract counts per section, `parts` against `api.md` and the built HTML), Sass/CSS rules, the token hook `_sass/modootoday/_site.scss` (only the three override maps, known token names), `site_css`, `preload` and `scripts` files present in the build, `script:` and `poster:` on hero and section items (a registered script, a sized poster that exists), `filter:` on section items and pages (a list or table to filter, a `facet` column the table has), `chart:` lines and `c: chart` sections (a type and options, a table or a `_data/charts` file, number cells), `widget:` lines, `widget_props` and `c: widget` sections (an element a `modootoday.scripts` entry defines, plain prop values, a lead paragraph), `diagrams:` (an entry per Mermaid fence, `alt`, the SVG files, an SVG drawn from another fence), static math (an entry per math block in `_data/math`, entries rendered from other TeX, no inline math),`modootoday.search` keys and collections, `modootoday.showcase` (also in `_config.demo.yml`) and, while it is enabled, the robots `noindex` on every built page (warning), `search.json` over 1.5 MB (warning), unconverted markers in the build, schema.org JSON-LD in the build (valid JSON, vocabulary, required properties per type, absolute URLs, ISO 8601 dates, one graph per page, agreement with Open Graph, a `DefinedTerm` page's `term_set` glossary), `modootoday.schema.faq`, `modootoday.records` (a page per record and a record per page, as `modootoday-stubs --records --check` judges), `modootoday.pwa` (its keys and icons, the stub `modootoday-stubs --pwa` writes, the built manifest's fields, icon files and their PNG sizes, the manifest link on every page)"],
|
|
11
11
|
["--twins", "every page has a byte-identical Markdown twin, per-language `llms.txt` and `llms-full.txt`"],
|
|
12
|
+
["--links", "same-site links in the built HTML (`a`, `link`, `img`, `script`, `source srcset`) point at files that exist and `#` fragments match an `id` or `a[name]` on the target page; external URLs are not fetched. Warnings, failures with `--strict`; needs the nokogiri gem"],
|
|
12
13
|
["--aliases", "the URL aliases `modootoday.aliases` declares: `/<page>.md` byte-identical to the twin (`md`), `/<page>.html` redirecting to the page with the page URL as canonical (`html`); two pages with one alias, or an alias over another source file, fail"],
|
|
13
14
|
["--byte-exact=DIR,...", "files under these source folders (an API, downloads) are in the build with the same sha256; a folder under `_` or `.` or excluded, a file with front matter, or one Jekyll converts (Markdown, Sass) fails"],
|
|
14
15
|
["--github-pages[=VERSION]", "`Gemfile.lock` pins `github-pages` VERSION (default 232)"],
|
|
@@ -25,7 +26,7 @@ module Modootoday
|
|
|
25
26
|
].freeze
|
|
26
27
|
# Rule groups in report order.
|
|
27
28
|
RULES = [Registry, SiteConfig.method(:source_mode), Pages, Layouts, Native::Layouts, Native::Collections, I18n, Registry.method(:i18n_keys), BuiltParts,
|
|
28
|
-
BuildOutput.method(:residue), NewWindow.method(:built), Illustration, StructuredData, TermSets, Stylesheets, SiteHook, BuildOutput.method(:css), BuildOutput.method(:search_index), SiteConfig, ShowcaseBuild, SiteAssets, Renderers, Blog, GithubPages, Twins, Aliases, Records, ByteExact, GhRender].freeze
|
|
29
|
+
BuildOutput.method(:residue), NewWindow.method(:built), Illustration, StructuredData, TermSets, Stylesheets, SiteHook, BuildOutput.method(:css), BuildOutput.method(:search_index), SiteConfig, ShowcaseBuild, SiteAssets, Renderers, Blog, GithubPages, Twins, Aliases, Records, Links, Feeds, Pwa, ByteExact, GhRender].freeze
|
|
29
30
|
|
|
30
31
|
module_function
|
|
31
32
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Modootoday
|
|
4
|
+
module Check
|
|
5
|
+
module Config
|
|
6
|
+
Schema.register(Key.new(name: "logo", type: :text, message: "must be brand or the path of an image"))
|
|
7
|
+
Schema.register(Key.new(name: "favicon", type: :text, message: "must be brand or the path of an icon"))
|
|
8
|
+
# A path, or {path, alt, width, height}: the map adds og:image:alt and the size crawlers use before they fetch.
|
|
9
|
+
og_image = lambda do |ctx, path, v|
|
|
10
|
+
next if v.is_a?(String) && !v.strip.empty?
|
|
11
|
+
unless v.is_a?(Hash) && v["path"].is_a?(String) && (v.keys - %w[path alt width height]).empty?
|
|
12
|
+
next ctx.errs << "_config.yml: #{path} must be the path or URL of an image, or a map {path, alt, width, height}"
|
|
13
|
+
end
|
|
14
|
+
%w[width height].each { |k| ctx.errs << "_config.yml: #{path}.#{k} must be a whole number of pixels" if v.key?(k) && !(v[k].is_a?(Integer) && v[k].positive?) }
|
|
15
|
+
ctx.warns << "_config.yml: #{path} has no alt: a shared link shows the image without a text alternative" if v["alt"].to_s.strip.empty?
|
|
16
|
+
end
|
|
17
|
+
Schema.register(Key.new(name: "og_image", type: :any, check: og_image))
|
|
18
|
+
|
|
19
|
+
hex = /\A#(\h{3}|\h{4}|\h{6}|\h{8})\z/
|
|
20
|
+
scheme_colors = lambda do |ctx, path, v|
|
|
21
|
+
ok = v == false || v.to_s.match?(hex) ||
|
|
22
|
+
(v.is_a?(Hash) && !v.empty? && (v.keys - %w[light dark]).empty? && v.values.all? { |c| c.to_s.match?(hex) })
|
|
23
|
+
ctx.errs << "_config.yml: #{path} must be a \"#hex\" color, {light: \"#hex\", dark: \"#hex\"} or false (got #{v.inspect})" unless ok
|
|
24
|
+
end
|
|
25
|
+
Schema.register(Key.new(name: "theme_color", type: :any, check: scheme_colors))
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
module Modootoday
|
|
4
4
|
module Check
|
|
5
5
|
module Config
|
|
6
|
-
|
|
6
|
+
# text: shows as written; without it release: latest (site.github) or {version, url} fills the release line.
|
|
7
|
+
banner = lambda do |ctx, path, v|
|
|
8
|
+
release = v["release"]
|
|
9
|
+
next ctx.errs << "_config.yml: #{path} needs text: or release: (latest, or {version, url})" if v["text"].nil? && release.nil?
|
|
10
|
+
next if release.nil?
|
|
11
|
+
ok = release == "latest" || (release.is_a?(Hash) && release["version"].is_a?(String) && (release.keys - %w[version url]).empty?)
|
|
12
|
+
next ctx.errs << "_config.yml: #{path}.release must be latest or a map {version, url} (got #{release.inspect})" unless ok
|
|
13
|
+
GITHUB_SOURCE.call(ctx, "#{path}.release", release)
|
|
14
|
+
end
|
|
15
|
+
Schema.register(Key.new(name: "banner", type: :map, check: banner, message: "must be a map with text: (and optional url:, link:) or release:"))
|
|
7
16
|
Schema.register(Key.new(name: "header", type: :map, keys: %w[compact_title], values: :bool,
|
|
8
17
|
message: "must be a map with compact_title: set to true or false"))
|
|
9
18
|
Schema.register(Key.new(name: "nav", type: :off_or_name, message: "must be the name of a _data/nav file, or false (no list of titled pages)"))
|
|
10
19
|
Schema.register(Key.new(name: "sidebar", type: :enum, enum: [true, false, "auto"], message: "must be auto, true or false"))
|
|
20
|
+
Schema.register(Key.new(name: "viewport_fit", type: :enum, enum: %w[cover auto], message: "must be cover or auto (got %{got})"))
|
|
11
21
|
end
|
|
12
22
|
end
|
|
13
23
|
end
|
|
@@ -3,9 +3,19 @@
|
|
|
3
3
|
module Modootoday
|
|
4
4
|
module Check
|
|
5
5
|
module Config
|
|
6
|
+
# A layout: feed page at /feed.xml writes the feed in Liquid, so feed: true then needs no plugin.
|
|
7
|
+
feed_page = lambda do |ctx|
|
|
8
|
+
Dir.glob(File.join(ctx.src, "**", "*.xml")).any? do |f|
|
|
9
|
+
rel = ctx.rel(f)
|
|
10
|
+
next false if rel.match?(Feeds::SKIP) || ctx.skipped?(f)
|
|
11
|
+
fm = (Markdown.fm(File.read(f)) rescue nil)
|
|
12
|
+
fm.is_a?(Hash) && fm["layout"] == "feed" && (fm["permalink"] || "/#{rel}") == "/feed.xml"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
6
15
|
feed_plugin = lambda do |ctx, path, v|
|
|
7
16
|
next unless v == true && !Array(ctx.site_cfg["plugins"]).map(&:to_s).include?("jekyll-feed")
|
|
8
|
-
|
|
17
|
+
next if feed_page.call(ctx)
|
|
18
|
+
ctx.warns << "_config.yml: #{path}: true links /feed.xml; add a feed.xml page with layout: feed, or jekyll-feed to plugins"
|
|
9
19
|
end
|
|
10
20
|
%w[css_layers badges seo hreflang feed page_actions back_to_top loading].each do |name|
|
|
11
21
|
Schema.register(Key.new(name: name, type: :bool, check: name == "feed" ? feed_plugin : nil))
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Modootoday
|
|
4
|
+
module Check
|
|
5
|
+
module Config
|
|
6
|
+
# Registered so every key has one entry; check/config/renderers.rb judges their settings and URLs.
|
|
7
|
+
%w[mermaid math].each { |name| Schema.register(Key.new(name: name, type: :any)) }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Modootoday
|
|
4
|
+
module Check
|
|
5
|
+
module Config
|
|
6
|
+
Schema.register(Key.new(name: "authors", type: :bool, message: "must be true or false (false hides post bylines)"))
|
|
7
|
+
# Registered so every key has one entry; their shapes are judged by the blog layouts and section checks.
|
|
8
|
+
%w[blog news subscribe].each { |name| Schema.register(Key.new(name: name, type: :any)) }
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -5,6 +5,17 @@ module Modootoday
|
|
|
5
5
|
module Config
|
|
6
6
|
Schema.register(Key.new(name: "lists", type: :map, keys: %w[link_chips titled_items], values: :bool,
|
|
7
7
|
message: "must be a map of link_chips and titled_items set to true or false"))
|
|
8
|
+
Schema.register(Key.new(name: "external_links", type: :map, keys: %w[new_window icon], values: :bool,
|
|
9
|
+
message: "must be a map of new_window and icon set to true or false"))
|
|
10
|
+
anchor_on = lambda do |ctx, path, v|
|
|
11
|
+
list = ctx.mtc["components"]
|
|
12
|
+
next unless v == true && list.is_a?(Array) && !list.map(&:to_s).include?("anchor")
|
|
13
|
+
ctx.warns << "_config.yml: #{path}: true has no effect while modootoday.components leaves out anchor"
|
|
14
|
+
end
|
|
15
|
+
# print: true links the print sheet (chrome/print.css) with media="print".
|
|
16
|
+
Schema.register(Key.new(name: "print", type: :bool))
|
|
17
|
+
Schema.register(Key.new(name: "heading_anchors", type: :bool, check: anchor_on,
|
|
18
|
+
message: "must be true or false (true links each ## and ### heading to itself)"))
|
|
8
19
|
|
|
9
20
|
site_paths = lambda do |ctx, path, map|
|
|
10
21
|
map.each do |k, v|
|
|
@@ -3,8 +3,23 @@
|
|
|
3
3
|
module Modootoday
|
|
4
4
|
module Check
|
|
5
5
|
module Config
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
EDIT_URL = %r{\Ahttps?://\S+/\z}
|
|
7
|
+
# auto, build_link, feedback.issues: auto and banner.release: latest read site.github, which GitHub Pages (or the jekyll-github-metadata
|
|
8
|
+
# plugin) provides; a github: map in _config.yml stands in for it elsewhere. Without either the link is left out.
|
|
9
|
+
GITHUB_SOURCE = lambda do |ctx, path, v|
|
|
10
|
+
next unless v == "auto" || v == true || v == "latest"
|
|
11
|
+
cfg = ctx.site_cfg
|
|
12
|
+
next if ctx.option?("--github-pages") || cfg["github"].is_a?(Hash) || Array(cfg["plugins"]).include?("jekyll-github-metadata")
|
|
13
|
+
ctx.warns << "_config.yml: #{path}: #{v.inspect} reads site.github, which this build may not have: build on GitHub Pages, " \
|
|
14
|
+
"add the jekyll-github-metadata plugin, or set a github: map (repository_url, source: {branch, path}, " \
|
|
15
|
+
"build_revision); without it the link is left out"
|
|
16
|
+
end
|
|
17
|
+
edit_url = lambda do |ctx, path, v|
|
|
18
|
+
next ctx.errs << "_config.yml: #{path} must be auto or an http(s) URL ending in / (page.path is appended)" unless v == "auto" || v.to_s.match?(EDIT_URL)
|
|
19
|
+
GITHUB_SOURCE.call(ctx, path, v)
|
|
20
|
+
end
|
|
21
|
+
Schema.register(Key.new(name: "edit_url", type: :any, check: edit_url))
|
|
22
|
+
Schema.register(Key.new(name: "build_link", type: :bool, check: GITHUB_SOURCE))
|
|
8
23
|
end
|
|
9
24
|
end
|
|
10
25
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Modootoday
|
|
4
|
+
module Check
|
|
5
|
+
module Config
|
|
6
|
+
ISSUES_URL = %r{\Ahttps?://\S+/issues\z}
|
|
7
|
+
# modootoday.feedback (meta/feedback.html): prefilled issue links and a discussion link, no script.
|
|
8
|
+
feedback = lambda do |ctx, path, v|
|
|
9
|
+
issues = v["issues"]
|
|
10
|
+
unless issues.nil? || issues == false || issues == "auto" || issues.to_s.match?(ISSUES_URL)
|
|
11
|
+
ctx.errs << "_config.yml: #{path}.issues must be auto, false or a repository's issues URL such as https://github.com/OWNER/REPO/issues (got #{issues.inspect})"
|
|
12
|
+
end
|
|
13
|
+
GITHUB_SOURCE.call(ctx, "#{path}.issues", issues)
|
|
14
|
+
ctx.errs << "_config.yml: #{path}.helpful must be true or false" unless [nil, true, false].include?(v["helpful"])
|
|
15
|
+
ctx.warns << "_config.yml: #{path}.helpful: true needs issues:, since both answers are prefilled issue links" if v["helpful"] == true && [nil, false].include?(issues)
|
|
16
|
+
ctx.errs << "_config.yml: #{path}.discuss must be an http(s) URL (got #{v["discuss"].inspect})" unless v["discuss"].nil? || v["discuss"].to_s.match?(Validate::URL)
|
|
17
|
+
labels = v["labels"]
|
|
18
|
+
ctx.errs << "_config.yml: #{path}.labels must be a list of label names" unless labels.nil? || (labels.is_a?(Array) && labels.all? { |l| l.is_a?(String) && !l.strip.empty? })
|
|
19
|
+
end
|
|
20
|
+
Schema.register(Key.new(name: "feedback", type: :map, keys: %w[issues helpful discuss labels], check: feedback,
|
|
21
|
+
message: "must be a map of issues, helpful, discuss and labels (got %{got})"))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -12,6 +12,8 @@ module Modootoday
|
|
|
12
12
|
(list.map(&:to_s) - langs).each { |l| ctx.errs << "_config.yml: #{path}: '#{l}' is not in modootoday.languages" }
|
|
13
13
|
end
|
|
14
14
|
Schema.register(Key.new(name: "full_languages", type: :list, message: "must be a list of codes from modootoday.languages", check: in_languages))
|
|
15
|
+
Schema.register(Key.new(name: "language_switcher", type: :enum, enum: ["header", "footer", false],
|
|
16
|
+
message: "must be header, footer or false (got %{got})"))
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
end
|