brief 1.17.9 → 1.17.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apps/blueprint/extensions/middleman.rb +1 -1
- data/docs/advanced-features.md +3 -0
- data/docs/application-interfaces.md +4 -0
- data/docs/brief-apps.md +5 -0
- data/docs/brief-cli.md +5 -0
- data/docs/brief-model-classes.md +4 -0
- data/docs/briefcase-document-structure.md +0 -0
- data/docs/briefcase-folder-structure.md +3 -0
- data/docs/briefcase-renderers.md +5 -0
- data/docs/document-sections.md +0 -0
- data/docs/index.md +15 -0
- data/docs/intro.md +122 -0
- data/docs/markdown-extensions.md +5 -0
- data/docs/real-world-examples.md +0 -0
- data/docs/views-and-commands.md +3 -0
- data/lib/brief.rb +1 -0
- data/lib/brief/briefcase.rb +48 -2
- data/lib/brief/model.rb +16 -1
- data/spec/spec_helper.rb +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29b72df28a6667259acc1ee62242da76037e02fa
|
4
|
+
data.tar.gz: bbd15b759f0b16bfd3f70fd3cf323f35133db188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d62db93d1df6b6c47fcac79acdd1ee12b8a77f0752fe2731e5632b2060074cecc2d04630c5f72ef26f5431e52cae10ba8b0cdde19a8671a51c05610fcb81a2
|
7
|
+
data.tar.gz: b48a215e6ecfef573bb611f0423546db4f0298efddaac410104884b266dc07d557568ac57b323c1e6fd06f978f3bec6d0dee1c0b3eeb841fddf7be353f64d481
|
@@ -15,7 +15,7 @@
|
|
15
15
|
patterns = [
|
16
16
|
'.png', '.gif', '.jpg', '.jpeg', '.svg', # Images
|
17
17
|
'.eot', '.otf', '.svc', '.woff', '.ttf', # Fonts
|
18
|
-
'.js', '.slim', '.erb', '.md', # Javascript
|
18
|
+
'.js', '.slim', '.erb', '.md', '.psd' # Javascript
|
19
19
|
].map { |e| File.join(blueprint.assets_path, "**", "*#{e}" ) }
|
20
20
|
|
21
21
|
sprockets.prepend_path(blueprint.assets_path)
|
data/docs/brief-apps.md
ADDED
data/docs/brief-cli.md
ADDED
File without changes
|
File without changes
|
data/docs/index.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Brief Documentation
|
2
|
+
|
3
|
+
- Intro
|
4
|
+
- Briefcase Folder Structure
|
5
|
+
- Brief Model Classes
|
6
|
+
- Briefcase Document Structure
|
7
|
+
- Brief Command Line Interface
|
8
|
+
- Views and Commands
|
9
|
+
- Markdown Extensions
|
10
|
+
- Brief Apps
|
11
|
+
- Briefcase Renderers
|
12
|
+
- Application Interfaces
|
13
|
+
- Advanced Features
|
14
|
+
- Real world examples
|
15
|
+
|
data/docs/intro.md
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
# A Brief Introduction to Brief
|
2
|
+
|
3
|
+
Brief provides an object / relational data layer on top of collections of markdown documents.
|
4
|
+
|
5
|
+
It lets you use normal writing that occurs in files and folders with a person's favorite text editor
|
6
|
+
as your application's main user interface.
|
7
|
+
|
8
|
+
A Briefcase is a folder which contains Markdown documents. These
|
9
|
+
Markdown documents may contain YAML Frontmatter and/or Github Flavored
|
10
|
+
Markdown.
|
11
|
+
|
12
|
+
Through either the `type` value that is specified as YAML in the header,
|
13
|
+
or through the name of the folder it belongs to, a document can be
|
14
|
+
assigned a specific `Brief::Model` class which can give the document
|
15
|
+
and writing the same kind of special powers we give to a row in a SQL
|
16
|
+
table.
|
17
|
+
|
18
|
+
### What is a Brief Model
|
19
|
+
|
20
|
+
The Model class acts as a specification for that type of document.
|
21
|
+
|
22
|
+
The specification defines the metadata it expects to see, and the
|
23
|
+
general structure the document should follow. It then lets the
|
24
|
+
programmer treat each individual document as an object, and do whatever
|
25
|
+
you want with it.
|
26
|
+
|
27
|
+
A document turned into a Brief object model will determine its state and
|
28
|
+
attributes in one of two ways:
|
29
|
+
|
30
|
+
1) YAML Frontmatter that gets embedded in the header of the document
|
31
|
+
2) Content extracted from the rendered markdown using a system of simple
|
32
|
+
CSS selectors
|
33
|
+
|
34
|
+
### Why is this valuable?
|
35
|
+
|
36
|
+
I think this is great because a collection of markdown documents that
|
37
|
+
exists on Github is more than sufficient as a database of record for a
|
38
|
+
lot of different projects, and you get a lot of great features this way
|
39
|
+
for free such as audit trails, branching, discussions, task management,
|
40
|
+
etc.
|
41
|
+
|
42
|
+
Blogs are the most obvious example, but using Brief to write your blog
|
43
|
+
would be overkill. Brief is made to power much more ambitious kinds of
|
44
|
+
applications, and making it easier to use text editors and written
|
45
|
+
language as one of the primary interfaces.
|
46
|
+
|
47
|
+
### An Example Brief Model
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class Post
|
51
|
+
include Brief::Model
|
52
|
+
|
53
|
+
meta do
|
54
|
+
title
|
55
|
+
subtitle
|
56
|
+
status :default => "draft"
|
57
|
+
end
|
58
|
+
|
59
|
+
content do
|
60
|
+
title "h1:first-of-type"
|
61
|
+
subtitle "h2:first-of-type"
|
62
|
+
excerpt "h3#excerpt p", hide: true
|
63
|
+
end
|
64
|
+
|
65
|
+
actions do
|
66
|
+
def publish
|
67
|
+
set(state:"published", published_at: Time.now)
|
68
|
+
save
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
In this specification for the `Post` model, we declared some acceptable
|
75
|
+
values in the YAML frontmatter, such as the title and subtitle of the
|
76
|
+
post.
|
77
|
+
|
78
|
+
We also say that the same values can be extracted from the document's h1
|
79
|
+
and h2 tags.
|
80
|
+
|
81
|
+
An example document might look like:
|
82
|
+
|
83
|
+
```markdown
|
84
|
+
---
|
85
|
+
type: post
|
86
|
+
title: Introduction to Brief
|
87
|
+
---
|
88
|
+
|
89
|
+
### Excerpt
|
90
|
+
|
91
|
+
We're going to go over some basics about the Brief gem. This content
|
92
|
+
won't be rendered in the final output, but will be extracted into an
|
93
|
+
excerpt attribute for the model.
|
94
|
+
|
95
|
+
# Brief
|
96
|
+
## An introduction to brief
|
97
|
+
|
98
|
+
This content will get rendered.
|
99
|
+
```
|
100
|
+
|
101
|
+
The Post model will turn this document into an object, and let us do
|
102
|
+
different things with it in our code.
|
103
|
+
|
104
|
+
A post model can be used as application data in a Ruby app.
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
post = Post.where(:title.matches => "Intro")
|
108
|
+
post.title # "Introduction to Brief"
|
109
|
+
post.status # "draft"
|
110
|
+
```
|
111
|
+
|
112
|
+
Or interacted with from the command line:
|
113
|
+
|
114
|
+
```bash
|
115
|
+
brief publish post docs/posts/introduction-to-brief.md
|
116
|
+
```
|
117
|
+
|
118
|
+
### The rest is up to you.
|
119
|
+
|
120
|
+
There is more to the gem which we will cover later, but this is
|
121
|
+
a very powerful way to build applications which are powered primarily by
|
122
|
+
structured writing.
|
File without changes
|
data/lib/brief.rb
CHANGED
data/lib/brief/briefcase.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# A Briefcase is a repository of markdown documents which are turned into active-record like model objects.
|
2
|
+
#
|
3
|
+
# Special behaviors can be built into these documents by assigning them a `type` value. Doing this is done either
|
4
|
+
# by
|
5
|
+
#
|
6
|
+
# A Briefcase contains a query interface for different Brief::Documents. A Brief::Document takes YAML frontmatter,
|
7
|
+
# and rendered markdown, and builds key / value attribute pairs for the document. Each document expects to be able
|
8
|
+
# to determine its type by accessing the type field contained in the YAML frontmatter
|
9
|
+
#
|
10
|
+
# The Briefcase allows you to treat each markdown document as
|
11
|
+
#
|
1
12
|
module Brief
|
2
13
|
class Briefcase
|
3
14
|
include Brief::DSL
|
@@ -9,9 +20,25 @@ module Brief
|
|
9
20
|
attr_accessor :asset_finder,
|
10
21
|
:href_builder
|
11
22
|
|
23
|
+
# Creates a new briefcase
|
24
|
+
#
|
25
|
+
# options:
|
26
|
+
# - root: (required) the root folder of the briefcase project. will default to PWD
|
27
|
+
#
|
28
|
+
# - app: (optional) the name of the app this briefcase should use
|
29
|
+
#
|
30
|
+
# - logger: a logger instance, will default to Logger.new(STDOUT)
|
31
|
+
#
|
32
|
+
# - href_builder: (optional) reference to a block which will be used to post-process any generated
|
33
|
+
# href values for the documents in this briefcase. This will generally be used by
|
34
|
+
# apps which render the briefcase content.
|
35
|
+
# - asset_finder: (optional) reference to a block which will be used to find assets when used as attachments
|
36
|
+
# or when embedding inline:svg through the special image markdown syntax
|
12
37
|
def initialize(options = {})
|
13
38
|
@options = options.to_mash
|
14
39
|
|
40
|
+
debug "Created briefcase instance #{ object_id } at #{ root }"
|
41
|
+
|
15
42
|
load_configuration
|
16
43
|
use(:app, options[:app]) if options[:app]
|
17
44
|
|
@@ -26,15 +53,34 @@ module Brief
|
|
26
53
|
|
27
54
|
Brief.cases[root.basename.to_s] ||= self
|
28
55
|
|
56
|
+
@logger = options.fetch(:logger, nil)
|
57
|
+
|
58
|
+
debug "Loading briefcase lib entries"
|
29
59
|
load_briefcase_lib_entries()
|
30
60
|
end
|
31
61
|
|
62
|
+
def logger
|
63
|
+
@logger ||= Logger.new(STDOUT)
|
64
|
+
end
|
65
|
+
|
66
|
+
def log message
|
67
|
+
logger.info(message)
|
68
|
+
end
|
69
|
+
|
70
|
+
def debug message
|
71
|
+
logger.debug(message) if debug?
|
72
|
+
end
|
73
|
+
|
74
|
+
def debug?
|
75
|
+
options.fetch(:debug, nil) || ENV['BRIEF_DEBUG']
|
76
|
+
end
|
77
|
+
|
32
78
|
def load_briefcase_lib_entries
|
33
79
|
begin
|
34
80
|
etc = Dir[briefcase_lib_path.join("**/*.rb")]
|
35
81
|
etc.each {|f| require(f) } if briefcase_lib_path.exist?
|
36
|
-
rescue
|
37
|
-
|
82
|
+
rescue => e
|
83
|
+
debug "Error while loading briefcase entries: #{ e.message }"
|
38
84
|
end
|
39
85
|
end
|
40
86
|
|
data/lib/brief/model.rb
CHANGED
@@ -11,11 +11,12 @@ module Brief
|
|
11
11
|
include Virtus.model(finalize: false)
|
12
12
|
include Initializers
|
13
13
|
include AccessorMethods
|
14
|
+
include LoggerMethods
|
14
15
|
include Persistence
|
15
16
|
include Serializers
|
16
17
|
include Reports
|
17
18
|
|
18
|
-
class_attribute :models, :after_initialization_hooks
|
19
|
+
class_attribute :models, :after_initialization_hooks, :logger
|
19
20
|
|
20
21
|
self.models = Array(models).to_set
|
21
22
|
|
@@ -29,6 +30,20 @@ module Brief
|
|
29
30
|
Brief::Model.classes << self
|
30
31
|
end
|
31
32
|
|
33
|
+
module LoggerMethods
|
34
|
+
def log message
|
35
|
+
(!briefcase.nil? && briefcase.log(message))
|
36
|
+
end
|
37
|
+
|
38
|
+
def debug message
|
39
|
+
(!briefcase.nil? && briefcase.debug(message))
|
40
|
+
end
|
41
|
+
|
42
|
+
def puts message
|
43
|
+
(!briefcase.nil? && briefcase.log(message)) || super
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
32
47
|
module AccessorMethods
|
33
48
|
def title
|
34
49
|
document_title
|
data/spec/spec_helper.rb
CHANGED
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.17.
|
4
|
+
version: 1.17.10
|
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-07-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -386,6 +386,20 @@ files:
|
|
386
386
|
- bin/brief
|
387
387
|
- bin/console
|
388
388
|
- brief.gemspec
|
389
|
+
- docs/advanced-features.md
|
390
|
+
- docs/application-interfaces.md
|
391
|
+
- docs/brief-apps.md
|
392
|
+
- docs/brief-cli.md
|
393
|
+
- docs/brief-model-classes.md
|
394
|
+
- docs/briefcase-document-structure.md
|
395
|
+
- docs/briefcase-folder-structure.md
|
396
|
+
- docs/briefcase-renderers.md
|
397
|
+
- docs/document-sections.md
|
398
|
+
- docs/index.md
|
399
|
+
- docs/intro.md
|
400
|
+
- docs/markdown-extensions.md
|
401
|
+
- docs/real-world-examples.md
|
402
|
+
- docs/views-and-commands.md
|
389
403
|
- examples/blog/brief.rb
|
390
404
|
- examples/blog/docs/posts/this-is-my-first-post.md
|
391
405
|
- lib/brief.rb
|