brief 1.11.8 → 1.11.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4eb7080fe6495a3998a7ebda464a4f1399b93c1
4
- data.tar.gz: 604c41c7ae50c473b94a2705a2fad554f4d69834
3
+ metadata.gz: 7a8689c2a2ceb352cc525a5739fd3936256664f1
4
+ data.tar.gz: b699ab744e6e570f815304f34d58cbe8207470ba
5
5
  SHA512:
6
- metadata.gz: d45ca5dba5242fa0ee6b90b7cd6fadf1e6d473be899c146ffe3a24c282d9ec5db54bebb32ee942dd2e536c29b9578db7bb0aaf8f22b7a02c590a447dbaa8e439
7
- data.tar.gz: fac37b173292b3a0605111f32e4bb0797cb7a209d74b904dae47838a5053e41042d3646890d6083889f7da9594a4bb036d5672fce8e780d7117c2cfd4a3747f1
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 transform content using special markdown link syntax
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.11.8)
4
+ brief (1.11.9)
5
5
  activesupport (> 3.2)
6
6
  commander (~> 4.3)
7
7
  em-websocket (~> 0.5)
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'
@@ -90,6 +90,10 @@ module Brief
90
90
  }
91
91
  end
92
92
 
93
+ def get_href_for(brief_uri)
94
+ Brief.href_builder.call(brief_uri)
95
+ end
96
+
93
97
  # TODO
94
98
  # The serialization of an entire briefcase at once
95
99
  # is important enough to be its own module
@@ -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 = document.briefcase.find_asset(value)
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 = document.briefcase.document_at(value)
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 = document.briefcase.document_at(value)
69
+ include_doc = briefcase.document_at(value)
63
70
 
64
71
  replacement = nil
65
72
 
data/lib/brief/dsl.rb CHANGED
@@ -13,6 +13,10 @@ module Brief
13
13
  Brief.views[name.to_sym] = block
14
14
  end
15
15
 
16
+ def href_builder(&block)
17
+ Brief.href_builder = block
18
+ end
19
+
16
20
  # Register a new command for this briefcase.
17
21
  #
18
22
  # Pass the name of the command, options, and a block.
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.11.8'
2
+ VERSION = '1.11.9'
3
3
  end
@@ -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.8
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 00:00:00.000000000 Z
11
+ date: 2015-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie