brief 1.8.4 → 1.8.5

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: a5def0728ed54389129584f946fb33161b8ab138
4
- data.tar.gz: 1792a378fa94f8475ebd3f88dd0d5ec9963c5b34
3
+ metadata.gz: 4ad789d0f35fc2864273df7ee4dfe3f05b8cdfaf
4
+ data.tar.gz: 60b434c6ddea2a564862e4cd4888b18645bbe1aa
5
5
  SHA512:
6
- metadata.gz: df431f1e995f94e3841ed9a6473df7a2e254eb7f0801006f07a123411270bc44a26c14f52eee78777696c66b7bc81e679035ade1f76d2914392566fa489e9d63
7
- data.tar.gz: 3c522d5ad2aecbe1dd8dff0a84100cad1dff2190ef69a1e4bd1f79ca5873d597978783335fa6dd1a36e17ea3fcc290fda1d8909ae3ceb2f0187e4a4469e861d9
6
+ metadata.gz: 1de7b03ff13fec0ba55696438e93766e58302b36c4b44f2728eb02f8d9a97b7f4dc2d39c82ca2bb87f3ea485e18445f692a870dca31b77705b2f5b09cd5bc1d8
7
+ data.tar.gz: 03e4f1e437db09249703ea0cd6ff4588a423eefe6a799bc5844ce6d5903a1322d6f9dc66651f3e58d478c073d3e837c7792683ef0070136353b96d563996d899
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.8.3)
4
+ brief (1.8.5)
5
5
  activemodel
6
6
  activesupport (>= 4.0)
7
7
  commander (>= 4.2.1)
@@ -0,0 +1,11 @@
1
+ class Brief::Apps::Blueprint::Outline
2
+ include Brief::Model
3
+
4
+ meta do
5
+ type
6
+ end
7
+
8
+ content do
9
+ settings "code.yaml:first-of-type", :serialize => :yaml, :hide => true
10
+ end
11
+ end
@@ -20,10 +20,6 @@ module Brief
20
20
  Brief.cases[root.basename.to_s] ||= self
21
21
  end
22
22
 
23
- def render_paths paths
24
-
25
- end
26
-
27
23
  def present(style="default", params={})
28
24
  if respond_to?("as_#{style}")
29
25
  send("as_#{style}", params)
@@ -37,6 +33,14 @@ module Brief
37
33
  "#{slug}:#{repository.cache_key}"
38
34
  end
39
35
 
36
+ def table_of_contents
37
+ table_of_contents_document.to_model
38
+ end
39
+
40
+ def table_of_contents_document
41
+ Brief::Document.new(docs_path.join("index.md"), document_type: "outline")
42
+ end
43
+
40
44
  def slug
41
45
  options.fetch(:slug) { root.basename.to_s.parameterize }
42
46
  end
@@ -0,0 +1,48 @@
1
+ command 'render' do |c|
2
+ c.syntax = 'brief render PATH [OPTIONS]'
3
+ c.description = 'render the briefcase path'
4
+
5
+ c.option '--root PATH', String, 'The briefcase root'
6
+ c.option '--output PATH', String, 'Save the output to the specified path'
7
+ c.option '--app APP', String, 'Use the specified app to get our models etc'
8
+ c.option '--config PATH', String, 'Use the specified config file'
9
+ c.option '--include-raw', nil, 'Whether or not to include the raw content'
10
+
11
+ c.action do |args, options|
12
+ options.default(root: Pathname(Dir.pwd))
13
+
14
+ o = {
15
+ root: options.root
16
+ }
17
+
18
+ o[:app] = options.app if options.app
19
+ o[:config_path] = options.config if options.config
20
+
21
+ briefcase = Brief::Briefcase.new(o)
22
+
23
+ index = 0
24
+
25
+ rendered = if args.empty?
26
+ briefcase.all_models.map do |model|
27
+ model.document.to_html(script: true, content: !!(options.include_raw), skip_preamble: (index += 1) > 1)
28
+ end
29
+ else
30
+ args.map do |a|
31
+ Dir[briefcase.root.join(a)].map do |f|
32
+ doc = Brief::Document.new(f).in_briefcase(briefcase)
33
+ doc.to_html(script: true, content: !!(options.include_raw), skip_preamble: (index += 1) > 1)
34
+ end
35
+ end.flatten
36
+ end
37
+
38
+ html = rendered.join("\n")
39
+ html = "<html><head></head><body class='brief-export #{options[:app]}'>#{html}</body></html>"
40
+ if options.output
41
+ Pathname(options.output).open("w+") do |fh|
42
+ fh.write(html)
43
+ end
44
+ else
45
+ puts html
46
+ end
47
+ end
48
+ end
@@ -4,7 +4,7 @@ module Brief
4
4
  include Brief::Document::FrontMatter
5
5
  include Brief::Document::Templating
6
6
 
7
- attr_accessor :path, :content, :frontmatter, :raw_content
7
+ attr_accessor :path, :content, :frontmatter, :raw_content, :options
8
8
 
9
9
  def document
10
10
  self
@@ -214,6 +214,10 @@ module Brief
214
214
  end
215
215
 
216
216
  def document_type
217
+ options.fetch(:type) { document_type! }
218
+ end
219
+
220
+ def document_type!
217
221
  existing = data && data.type
218
222
  return existing if existing
219
223
  parent_folder_name.try(:singularize)
@@ -25,11 +25,35 @@ module Brief
25
25
  fenced_code_blocks: true,
26
26
  footnotes: true)
27
27
 
28
- ::Redcarpet::Markdown.new(r, :tables => true, :autolink => true, :gh_blockcode => true, :fenced_code_blocks => true, :footnotes => true)
28
+ ::Redcarpet::Markdown.new(r, :tables => true,
29
+ :autolink => true,
30
+ :gh_blockcode => true,
31
+ :fenced_code_blocks => true,
32
+ :footnotes => true)
29
33
  end
30
34
  end
31
35
  end
32
36
 
37
+ def script_preamble
38
+ <<-EOF
39
+ <script type="text/javascript">
40
+ if(typeof(global)==="undefined"){
41
+ global = window
42
+ }
43
+ global.Brief = global.Brief || {}
44
+ Brief.documents = Brief.documents || {}
45
+ </script>
46
+ EOF
47
+ end
48
+
49
+ def script_contents(options={})
50
+ <<-EOF
51
+ <script type="text/javascript">
52
+ Brief.documents['#{ self.relative_path }'] = #{ to_model.as_json(options).to_json };
53
+ </script>
54
+ EOF
55
+ end
56
+
33
57
  # Documents can be rendered into HTML.
34
58
  #
35
59
  # They will first be put through a Nokogiri processor pipeline
@@ -41,7 +65,7 @@ module Brief
41
65
  unwrapped_html
42
66
  else
43
67
  wrapper = options.fetch(:wrapper, 'div')
44
- "<#{ wrapper } data-brief-model='#{ model_class.type_alias }' data-brief-path='#{ relative_path_identifier }'>#{ unwrapped_html }</#{wrapper}>"
68
+ "#{script_preamble if options[:script] && !options[:skip_preamble]}<#{ wrapper } data-brief-model='#{ model_class.type_alias }' data-brief-path='#{ relative_path }'>#{ unwrapped_html }</#{wrapper}>#{ script_contents(options) if options[:script]}"
45
69
  end
46
70
 
47
71
  html.respond_to?(:html_safe) ? html.html_safe : html.to_s
@@ -19,6 +19,8 @@ module Brief::Model::Serializers
19
19
  title: document_title,
20
20
  actions: self.class.defined_actions,
21
21
  updated_at: File.mtime(path).to_i,
22
+ id: (doc_id = file_hash),
23
+ hash: doc_id,
22
24
  urls: {
23
25
  view_content_url: "/view/content/#{ doc_path }",
24
26
  view_rendered_url: "/view/rendered/#{ doc_path }",
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.8.4'
2
+ VERSION = '1.8.5'
3
3
  end
@@ -6,7 +6,7 @@ describe "Brief HTML Rendering" do
6
6
  end
7
7
 
8
8
  it "wraps the document with some identifying details" do
9
- expect(sample.to_html).to include("docs/epics/epic.html.md")
9
+ expect(sample.to_html).to include("epics/epic.html.md")
10
10
  end
11
11
 
12
12
  it "wraps the higher level headings under section elements" do
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.8.4
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
@@ -241,6 +241,7 @@ files:
241
241
  - apps/blueprint/models/diagram.rb
242
242
  - apps/blueprint/models/epic.rb
243
243
  - apps/blueprint/models/milestone.rb
244
+ - apps/blueprint/models/outline.rb
244
245
  - apps/blueprint/models/page.rb
245
246
  - apps/blueprint/models/persona.rb
246
247
  - apps/blueprint/models/project.rb
@@ -261,6 +262,7 @@ files:
261
262
  - lib/brief/cli/export.rb
262
263
  - lib/brief/cli/init.rb
263
264
  - lib/brief/cli/parse.rb
265
+ - lib/brief/cli/render.rb
264
266
  - lib/brief/cli/write.rb
265
267
  - lib/brief/configuration.rb
266
268
  - lib/brief/core_ext.rb