utopia-project 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utopia/project/base.rb +18 -10
- data/lib/utopia/project/guide.rb +8 -2
- data/lib/utopia/project/version.rb +1 -1
- data/utopia-project.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a926206a323a14c9bdce2078971b6fbfb594efa217edd10c4667bea84b0d8a1
|
4
|
+
data.tar.gz: 2d19b86b00a9535d4db4b46e0960cdad33f2c7b181d8556dc844d42a8457b551
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19d52ab955df5cd9dc015094828b75f7ec023693c1f207893edefaf962d4bf914a45edc5374f49b352aa1920b2ed3ee4af20c0153b69ef0d15faf808a30e19f6
|
7
|
+
data.tar.gz: 493aa1b337ca8b4406913c4edb4d27b9ea69d33bca1149f2a9e3bc850e40ff3256754ccbd2802af66ecc8fe15a122c34beeaa38035e09d6c163d4a4dd2a5c5c9
|
data/lib/utopia/project/base.rb
CHANGED
@@ -107,29 +107,37 @@ module Utopia
|
|
107
107
|
return nil
|
108
108
|
end
|
109
109
|
|
110
|
-
if language
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
if document = self.document(text, symbol, language: language)
|
111
|
+
return Trenni::MarkupString.raw(
|
112
|
+
document.to_html
|
113
|
+
)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def document(text, symbol = nil, language: symbol&.language)
|
118
|
+
text = text&.gsub(/{(.*?)}/) do |match|
|
119
|
+
linkify($1, symbol, language: language)
|
114
120
|
end
|
115
121
|
|
116
|
-
return
|
117
|
-
Kramdown::Document.new(text, syntax_highlighter: nil).to_html
|
118
|
-
)
|
122
|
+
return Kramdown::Document.new(text, syntax_highlighter: nil)
|
119
123
|
end
|
120
124
|
|
121
125
|
def linkify(text, symbol = nil, language: symbol&.language)
|
122
|
-
reference =
|
126
|
+
reference = @index.languages.parse_reference(text, default_language: language)
|
123
127
|
|
124
128
|
Trenni::Builder.fragment do |builder|
|
125
|
-
if definition = @index.lookup(reference, relative_to: symbol)&.first
|
129
|
+
if reference and definition = @index.lookup(reference, relative_to: symbol)&.first
|
126
130
|
builder.inline('a', href: link_for(definition)) do
|
127
131
|
builder.inline('code', class: "language-#{definition.language.name}") do
|
128
132
|
builder.text definition.short_form
|
129
133
|
end
|
130
134
|
end
|
135
|
+
elsif reference
|
136
|
+
builder.inline('code', class: "language-#{reference.language.name}") do
|
137
|
+
builder.text text
|
138
|
+
end
|
131
139
|
else
|
132
|
-
builder.inline('code'
|
140
|
+
builder.inline('code') do
|
133
141
|
builder.text text
|
134
142
|
end
|
135
143
|
end
|
data/lib/utopia/project/guide.rb
CHANGED
@@ -59,9 +59,15 @@ module Utopia
|
|
59
59
|
File.exist?(readme_path)
|
60
60
|
end
|
61
61
|
|
62
|
+
def readme_document
|
63
|
+
content = File.read(self.readme_path)
|
64
|
+
|
65
|
+
return @base.document(content)
|
66
|
+
end
|
67
|
+
|
62
68
|
def document
|
63
69
|
if self.readme?
|
64
|
-
@document ||=
|
70
|
+
@document ||= self.readme_document.tap do |document|
|
65
71
|
root = document.root
|
66
72
|
if element = root.children.first
|
67
73
|
if element.type == :header
|
@@ -112,7 +118,7 @@ module Utopia
|
|
112
118
|
return to_enum(:sources) unless block_given?
|
113
119
|
|
114
120
|
files.each do |path|
|
115
|
-
if source =
|
121
|
+
if source = @base.index.languages.source_for(path)
|
116
122
|
yield source
|
117
123
|
end
|
118
124
|
end
|
data/utopia-project.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
# spec.add_dependency "utopia-gallery"
|
21
21
|
|
22
22
|
spec.add_dependency "kramdown"
|
23
|
-
spec.add_dependency "decode", "~> 0.
|
23
|
+
spec.add_dependency "decode", "~> 0.13"
|
24
24
|
spec.add_dependency "rackula"
|
25
25
|
spec.add_dependency "falcon"
|
26
26
|
spec.add_dependency "thread-local"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia-project
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: utopia
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.13'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.13'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rackula
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|