jekyll-rpg 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/collection_document.rb +20 -12
- data/lib/graph.rb +2 -2
- data/lib/jekyll-rpg.rb +16 -1
- data/lib/markdown_link.rb +23 -0
- data/lib/reference_table.rb +1 -1
- data/lib/references.rb +22 -3
- metadata +23 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c75f941d938f99bcb95405f25776adc34ceba10009d7183eec136145f3eba72b
|
4
|
+
data.tar.gz: 0050b660cb0c708f39e1cc723f65456d6c4e7010b1e0950503aab8ed95250496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0a31e5458c3744523ca3ddfa188f703b64c056539abecff50bb0971a4c0f1e7e9f42a78822229138d715f58bae51bbe4338841e6712387842628533f996f3c
|
7
|
+
data.tar.gz: b8777aa50b266366be65540da516a90043feeaabda8321e5d4bd751e2550ec3ca2a623bc7343222d76006c8b7f12c51b64782181240db3444f7c70d617f4cc18
|
data/lib/collection_document.rb
CHANGED
@@ -1,36 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module JekyllRPG
|
4
|
-
# Represents a document that may be in a Jekyll collection
|
4
|
+
# Represents a document that may be in a Jekyll collection,
|
5
|
+
# extracted from either a document itself, or a markdown
|
6
|
+
# link.
|
5
7
|
class CollectionDocument
|
6
|
-
attr_accessor :name, :collection, :slug, :
|
8
|
+
attr_accessor :name, :collection, :slug, :viewable
|
7
9
|
|
8
10
|
def extract_doc(doc)
|
9
11
|
@name = doc.data['name']
|
10
12
|
@collection = doc.collection.label
|
11
13
|
@slug = doc.data['slug']
|
12
|
-
@
|
14
|
+
@viewable = true
|
13
15
|
self
|
14
16
|
end
|
15
17
|
|
16
18
|
# extracts link text, collection and slug
|
17
|
-
# [@name](/@collection/@slug)
|
18
19
|
def extract_markdown(site, link)
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
20
|
+
@site = site
|
21
|
+
@collection = link.collection
|
22
|
+
@slug = link.slug
|
23
|
+
@viewable = viewable
|
24
|
+
@name = @viewable ? find_document.data['name'] : link.name
|
23
25
|
self
|
24
26
|
end
|
25
27
|
|
26
28
|
# Checks whether document exists in a site
|
27
|
-
def document_exists
|
28
|
-
|
29
|
+
def document_exists
|
30
|
+
!@site.collections[@collection].nil? && !find_document.nil?
|
29
31
|
end
|
30
32
|
|
31
33
|
# Find a document based on its collection and slug
|
32
|
-
def find_document
|
33
|
-
site.collections[@collection].docs.find { |doc| doc.data['slug'] == @slug }
|
34
|
+
def find_document
|
35
|
+
@site.collections[@collection].docs.find { |doc| doc.data['slug'] == @slug }
|
36
|
+
end
|
37
|
+
|
38
|
+
def viewable
|
39
|
+
return unless document_exists
|
40
|
+
|
41
|
+
@site.config['dm_mode'] || !find_document.data['dm']
|
34
42
|
end
|
35
43
|
|
36
44
|
def markdown_link
|
data/lib/graph.rb
CHANGED
data/lib/jekyll-rpg.rb
CHANGED
@@ -10,7 +10,22 @@ module JekyllRPG
|
|
10
10
|
ref = References.new(site)
|
11
11
|
|
12
12
|
site.data['graph'] = ref.graph.hash
|
13
|
-
|
14
13
|
site.data['broken_links'] = ref.broken_links
|
15
14
|
end
|
15
|
+
|
16
|
+
# DM tag to hide content
|
17
|
+
class RenderDMContent < Liquid::Block
|
18
|
+
def render(context)
|
19
|
+
text = ''
|
20
|
+
if context.registers[:site].config['dm_mode']
|
21
|
+
text += "> # DM Note: \n"
|
22
|
+
super.each_line do |line|
|
23
|
+
text += '>> ' + line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
text
|
27
|
+
end
|
28
|
+
end
|
16
29
|
end
|
30
|
+
|
31
|
+
Liquid::Template.register_tag('dm', JekyllRPG::RenderDMContent)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllRPG
|
4
|
+
# A markdown link with components extracted from text
|
5
|
+
# [name](/collection/slug)
|
6
|
+
class MarkdownLink
|
7
|
+
def initialize(link)
|
8
|
+
@link = link
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
@link[/(?<=\[).*?(?=\])/]
|
13
|
+
end
|
14
|
+
|
15
|
+
def slug
|
16
|
+
@link[%r{(?<=/)(?:(?!/).)*?(?=\))}]
|
17
|
+
end
|
18
|
+
|
19
|
+
def collection
|
20
|
+
@link[%r{(?<=/).*(?=/)}]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/reference_table.rb
CHANGED
data/lib/references.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'collection_document'
|
4
4
|
require 'edge'
|
5
5
|
require 'graph'
|
6
|
+
require 'markdown_link'
|
6
7
|
require 'reference_table'
|
7
8
|
|
8
9
|
module JekyllRPG
|
@@ -12,6 +13,7 @@ module JekyllRPG
|
|
12
13
|
|
13
14
|
def initialize(site)
|
14
15
|
@site = site
|
16
|
+
@dm_mode = @site.config['dm_mode']
|
15
17
|
@graph = Graph.new
|
16
18
|
@broken_links = []
|
17
19
|
@collection_keys = @site.collections.keys - ['posts']
|
@@ -20,7 +22,7 @@ module JekyllRPG
|
|
20
22
|
referent_pass
|
21
23
|
|
22
24
|
# Create list of broken links
|
23
|
-
@graph.
|
25
|
+
@graph.unviewable.each do |edge|
|
24
26
|
@broken_links.push(edge.hash)
|
25
27
|
end
|
26
28
|
end
|
@@ -31,14 +33,31 @@ module JekyllRPG
|
|
31
33
|
collection_documents.each do |doc|
|
32
34
|
# Do not publish or reference a page if the site is not in DM Mode
|
33
35
|
# And the page is marked as for dms
|
34
|
-
|
36
|
+
doc_dm = doc.data['dm']
|
37
|
+
if doc_dm && !@dm_mode
|
35
38
|
doc.data['published'] = false
|
36
39
|
else
|
40
|
+
unviewable_links = []
|
41
|
+
# Extract details of the referent from the document
|
37
42
|
referent = CollectionDocument.new.extract_doc(doc)
|
43
|
+
|
44
|
+
# make a reference from each link on the page
|
38
45
|
markdown_links(doc).each do |link|
|
39
|
-
|
46
|
+
md_link = MarkdownLink.new(link)
|
47
|
+
reference = CollectionDocument.new.extract_markdown(@site, md_link)
|
48
|
+
|
49
|
+
# if the reference isn't viewable in the current configuration
|
50
|
+
# append that link to the array of links to strikethrough
|
51
|
+
unviewable_links << reference.markdown_link unless reference.viewable
|
52
|
+
|
53
|
+
# Make a new edge on the graph
|
40
54
|
@graph.edges.push(Edge.new(referent, reference))
|
41
55
|
end
|
56
|
+
|
57
|
+
# Unviewable links are struck through
|
58
|
+
unviewable_links.uniq.each do |link|
|
59
|
+
doc.content = doc.content.sub! link, "~~#{link}~~"
|
60
|
+
end
|
42
61
|
end
|
43
62
|
end
|
44
63
|
end
|
metadata
CHANGED
@@ -1,71 +1,77 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-rpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lockwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.8.6
|
17
20
|
- - "~>"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 4.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.8.6
|
24
30
|
- - "~>"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 4.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: factory_bot
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 5.0.2
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 5.0.2
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: pry
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: 0.12.2
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 0.12.2
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rspec
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
67
|
+
version: 3.8.0
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
74
|
+
version: 3.8.0
|
69
75
|
description: ''
|
70
76
|
email: tom@lockwood.dev
|
71
77
|
executables: []
|
@@ -76,6 +82,7 @@ files:
|
|
76
82
|
- lib/edge.rb
|
77
83
|
- lib/graph.rb
|
78
84
|
- lib/jekyll-rpg.rb
|
85
|
+
- lib/markdown_link.rb
|
79
86
|
- lib/reference_table.rb
|
80
87
|
- lib/references.rb
|
81
88
|
homepage: https://github.com/tomlockwood/jekyll-rpg
|