brief 1.11.8 → 1.11.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/lib/brief.rb +10 -1
- data/lib/brief/briefcase.rb +4 -0
- data/lib/brief/document/transformer.rb +12 -5
- data/lib/brief/dsl.rb +4 -0
- data/lib/brief/version.rb +1 -1
- data/spec/lib/brief/content_transformation_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a8689c2a2ceb352cc525a5739fd3936256664f1
|
4
|
+
data.tar.gz: b699ab744e6e570f815304f34d58cbe8207470ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1857df21a19cb17bdcb58f11fd85711f81ea2776274329eb1fb83253f424009c79c09f95be02e0f425a1704be12d51e33c2d58757b9c7c1f11be3c7ebfc51dd1
|
7
|
+
data.tar.gz: da9cbc07f175690ff3a49022e7c63678d8547a80447d2eb3fc4b334147d04265ae4d32b7fd5ef6687200617f02f19f6043a45dd289e7d94b7996c34947e4d62d
|
data/CHANGELOG.md
CHANGED
@@ -142,9 +142,13 @@ attributes.
|
|
142
142
|
- Added a websocket server for easy on the fly parsing / querying
|
143
143
|
|
144
144
|
### 1.9.12
|
145
|
-
- Included ability to
|
145
|
+
- Included ability to embed content using special markdown link syntax
|
146
146
|
- Included ability to inline svg assets
|
147
147
|
|
148
148
|
### 1.11.7
|
149
149
|
- Added ability to define briefcase commands and dispatch these
|
150
150
|
commands from the CLI
|
151
|
+
|
152
|
+
### 1.11.9
|
153
|
+
- By Setting `Brief.href_builder` to a Proc, you can control the URI
|
154
|
+
that are generated through the brief markdown link syntax
|
data/Gemfile.lock
CHANGED
data/lib/brief.rb
CHANGED
@@ -45,7 +45,6 @@ module Brief
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
48
|
def self.views
|
50
49
|
@views ||= {}
|
51
50
|
end
|
@@ -112,6 +111,16 @@ module Brief
|
|
112
111
|
raise "Invalid adapter: #{ identifier }" unless adapter
|
113
112
|
end
|
114
113
|
end
|
114
|
+
|
115
|
+
# This can be overridden so that you can generate uri values
|
116
|
+
# in the renderings that fit within the medium (e.g. website, electron app)
|
117
|
+
def self.href_builder
|
118
|
+
@href_builder || ->(o){o}
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.href_builder= value
|
122
|
+
@href_builder = value
|
123
|
+
end
|
115
124
|
end
|
116
125
|
|
117
126
|
require 'brief/core_ext'
|
data/lib/brief/briefcase.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# The Document Transformer allows for special usage of markdown
|
2
|
+
# link and image embedding syntax. This lets us piggy back on these syntax
|
3
|
+
# and use them as include directives to embed other documents, or SVG diagrams.
|
1
4
|
module Brief
|
2
5
|
class Document::Transformer
|
3
6
|
attr_reader :document, :fragment
|
@@ -12,6 +15,10 @@ module Brief
|
|
12
15
|
inline_svg_content
|
13
16
|
end
|
14
17
|
|
18
|
+
def briefcase
|
19
|
+
@briefcase ||= document.briefcase
|
20
|
+
end
|
21
|
+
|
15
22
|
def inline_svg_content
|
16
23
|
inline_svg_images.each do |img|
|
17
24
|
src = img['src'].to_s
|
@@ -23,7 +30,7 @@ module Brief
|
|
23
30
|
end
|
24
31
|
|
25
32
|
begin
|
26
|
-
if asset =
|
33
|
+
if asset = briefcase.find_asset(value)
|
27
34
|
img.replace("<div class='svg-wrapper'>#{ asset.read }</div>")
|
28
35
|
end
|
29
36
|
rescue
|
@@ -39,14 +46,14 @@ module Brief
|
|
39
46
|
|
40
47
|
if instruction == "link" && attribute == "path"
|
41
48
|
begin
|
42
|
-
link_to_doc =
|
49
|
+
link_to_doc = briefcase.document_at(value)
|
43
50
|
|
44
51
|
if link_to_doc.exist?
|
45
52
|
text = link_to_doc.send(strategy)
|
46
53
|
node.inner_html = text
|
47
|
-
node['href'] = "brief://#{ link_to_doc.path }"
|
54
|
+
node['href'] = briefcase.get_href_for("brief://#{ link_to_doc.path }")
|
48
55
|
else
|
49
|
-
node['href'] = "brief://document-not-found"
|
56
|
+
node['href'] = briefcase.get_href_for("brief://document-not-found")
|
50
57
|
end
|
51
58
|
rescue
|
52
59
|
nil
|
@@ -59,7 +66,7 @@ module Brief
|
|
59
66
|
instruction, strategy = node.text.to_s.split(':')
|
60
67
|
|
61
68
|
if instruction == "include" && attribute == "path"
|
62
|
-
include_doc =
|
69
|
+
include_doc = briefcase.document_at(value)
|
63
70
|
|
64
71
|
replacement = nil
|
65
72
|
|
data/lib/brief/dsl.rb
CHANGED
data/lib/brief/version.rb
CHANGED
@@ -15,4 +15,12 @@ describe "Content Transformation" do
|
|
15
15
|
expect(html).to include("svg-wrapper")
|
16
16
|
expect(html).to include("svg version")
|
17
17
|
end
|
18
|
+
|
19
|
+
describe "HREF Generation" do
|
20
|
+
it "does nothing by default" do
|
21
|
+
expect(Brief.testcase.get_href_for("brief://me")).to eq("brief://me")
|
22
|
+
end
|
23
|
+
end
|
18
24
|
end
|
25
|
+
|
26
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brief
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Soeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|