brief 1.9.12 → 1.9.13

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: 316633c274b953b641bfba353bd834ba968a22a7
4
- data.tar.gz: db0f92002cd2c63c2e44dfb89972fec21f1ea9e7
3
+ metadata.gz: ffd7a1f8f048a0d051ae83e1365775048bc7961e
4
+ data.tar.gz: 7c3a9ea58040102998143f4e20ef5a289c92bdf1
5
5
  SHA512:
6
- metadata.gz: 716128ec26d9525c7eddca5c448ff4486a95ac0aff751ba2fd33e38c99981067015e13223cf4d93a07d332a9f7ae627c9a176748117033020c634c967b639a68
7
- data.tar.gz: f72905da6879984d8b52b5252024cb1e876781f2fef27c5fb43c3c732332a942ba62337c28ff530ba5e55a114b910f8dd203a3bf27fd4d92e32191cc201da061
6
+ metadata.gz: ee496381895b9ee3243f8d1e719b02aaef678670609672f52e3c542ada03005e7c4f10985b00f5b642d74bae3493707e3ade50bc48ab22115f0993ac9d8b7c59
7
+ data.tar.gz: 9e93004ee76ba3fc42b3cf99bcc9c09a4a3ae1e0312895283588cc8f55556a2b73d629faecddc314bf9ef89ae9e24e40dc53ab5ceada036e45b23f7f8df56583
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.9.12)
4
+ brief (1.9.13)
5
5
  activesupport (~> 4.0)
6
6
  commander (~> 4.3)
7
7
  em-websocket (= 0.5.1)
@@ -14,10 +14,20 @@ module Brief
14
14
 
15
15
  def inline_svg_content
16
16
  inline_svg_images.each do |img|
17
- _, value = img['src'].to_s.split("=")
17
+ src = img['src'].to_s
18
18
 
19
- if asset = document.briefcase.find_asset(value)
20
- img.replace("<div class='svg-wrapper'>#{ asset.read }</div>")
19
+ if src.match(/=/)
20
+ _, value = img['src'].to_s.split("=")
21
+ else
22
+ value = src
23
+ end
24
+
25
+ begin
26
+ if asset = document.briefcase.find_asset(value)
27
+ img.replace("<div class='svg-wrapper'>#{ asset.read }</div>")
28
+ end
29
+ rescue
30
+ nil
21
31
  end
22
32
  end
23
33
  end
@@ -30,9 +40,14 @@ module Brief
30
40
  if instruction == "link" && attribute == "path"
31
41
  begin
32
42
  link_to_doc = document.briefcase.document_at(value)
33
- text = link_to_doc.send(strategy)
34
- node.inner_html = text
35
- node['href'] = "brief://#{ link_to_doc.path }"
43
+
44
+ if link_to_doc.exist?
45
+ text = link_to_doc.send(strategy)
46
+ node.inner_html = text
47
+ node['href'] = "brief://#{ link_to_doc.path }"
48
+ else
49
+ node['href'] = "brief://document-not-found"
50
+ end
36
51
  rescue
37
52
  nil
38
53
  end
@@ -57,6 +72,8 @@ module Brief
57
72
  node.replace(replacement) if replacement
58
73
  end
59
74
  end
75
+ rescue
76
+ nil
60
77
  end
61
78
 
62
79
  private
@@ -31,6 +31,10 @@ module Brief
31
31
  self
32
32
  end
33
33
 
34
+ def title
35
+ (data && data.title) || css('h1:first-of-type').text || path.to_s.split("/").last.gsub(/\..*/,'')
36
+ end
37
+
34
38
  def to_s
35
39
  "#{ model_class }.at_path(#{relative_path})"
36
40
  end
@@ -10,10 +10,6 @@ module Brief::Model::Serializers
10
10
  doc_path = path.realpath.relative_path_from(briefcase_docs_path).to_s
11
11
  end
12
12
 
13
- # TEMP
14
- title = data.try(:[], :title) || extracted_content_data.try(:title) || (send(:title) rescue nil) || path.basename.to_s.gsub(/\.html.md/,'')
15
- title = title.to_s.gsub(/\.md/,'')
16
-
17
13
  {
18
14
  data: data,
19
15
  extracted: extracted_content_data,
data/lib/brief/model.rb CHANGED
@@ -29,6 +29,10 @@ module Brief
29
29
  end
30
30
 
31
31
  module AccessorMethods
32
+ def title
33
+ document_title
34
+ end
35
+
32
36
  def document_title
33
37
  data.try(:[], :title) ||
34
38
  extracted_content_data.try(:title) ||
@@ -265,7 +269,7 @@ module Brief
265
269
  definition.send(:section_mappings, *args)
266
270
  end
267
271
 
268
- def generate_template_content_from(object, include_frontmatter = true)
272
+ def generate_template_content_from(object={}, include_frontmatter = true)
269
273
  @erb ||= ERB.new(template_body)
270
274
  content = @erb.result(binding)
271
275
  frontmatter = object.slice(*attribute_names)
@@ -65,6 +65,9 @@ module Brief
65
65
  InvalidPath = Class.new(Exception)
66
66
 
67
67
  def normalize_path(p)
68
+ p = p.to_s
69
+ p = p + '.md' unless p.match(/\.\w+$/)
70
+
68
71
  docs_path.join(p).tap do |normalized|
69
72
  if normalized.to_s.split("/").length < docs_path.realpath.to_s.split("/").length
70
73
  raise InvalidPath
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.9.12'
2
+ VERSION = '1.9.13'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brief
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.12
4
+ version: 1.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder