nanoc-conref-fs 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/nanoc-conref-fs/conref-fs.rb +7 -2
- data/lib/nanoc-conref-fs/datafiles.rb +0 -1
- data/nanoc-conref-fs.gemspec +1 -1
- 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: 3b9b74d13a2d5e87fcc3a90d5072c25ad3dd82b2
|
4
|
+
data.tar.gz: 0a943c2e008ecd7b8f22e0b4fc4f7fcac64e867e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ce48cb1edf56f86eb87d398c8626ab38e437c9b41b790e9274624d666cfe254aaf41453fc9738b90363077144f6eed0533d249c01d70d9f23c627e9d4ee5cd
|
7
|
+
data.tar.gz: 1414c576b31ece94c1bc30c38e56b3a443a02407c0b75b6eb3b6783f351665134ee861dc391222d5057d81592858c732eb0c77d55496bfa7a6f3945d5d4050c9
|
data/README.md
CHANGED
@@ -6,6 +6,21 @@ The idea is that you have a set of YAML files in a data folder which act as your
|
|
6
6
|
|
7
7
|
[![Build Status](https://travis-ci.org/gjtorikian/nanoc-conref-fs.svg)](https://travis-ci.org/gjtorikian/nanoc-conref-fs)
|
8
8
|
|
9
|
+
**NOTE:** If you use this library with nanoc's ERB filter, and want to use `render`, you'll need to monkey-patch an alias to avoid conflicts:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
require 'nanoc-conref-fs'
|
13
|
+
include Nanoc::Helpers::Rendering
|
14
|
+
Nanoc::Helpers::Rendering.module_eval do
|
15
|
+
if respond_to? :render
|
16
|
+
alias_method :renderp, :render
|
17
|
+
remove_method :render
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
Then, use `renderp` instead of `render`.
|
23
|
+
|
9
24
|
## Usage
|
10
25
|
|
11
26
|
Nearly all the usage of this gem relies on a *data* folder, sibling to your *content* and *layouts* folders. See [the test fixture](test/fixtures/data) for an example.
|
@@ -8,8 +8,10 @@ class ConrefFS < Nanoc::DataSource
|
|
8
8
|
# Before iterating over the file objects, this method loads the data folder
|
9
9
|
# and applies to to an ivar for later usage.
|
10
10
|
def load_objects(dir_name, kind, klass)
|
11
|
-
|
12
|
-
|
11
|
+
if klass == Nanoc::Int::Item && @vars.nil?
|
12
|
+
data = Datafiles.process(@site_config)
|
13
|
+
@vars = { 'site' => { 'config' => @site_config.to_h, 'data' => data } }
|
14
|
+
end
|
13
15
|
super
|
14
16
|
end
|
15
17
|
|
@@ -65,12 +67,15 @@ class ConrefFS < Nanoc::DataSource
|
|
65
67
|
data = File.read(filename)
|
66
68
|
return data unless filename.start_with?('content')
|
67
69
|
|
70
|
+
# we must obfuscate essential ExtendedMarkdownFilter content
|
71
|
+
data = data.gsub(/\{\{#/, '[[#').gsub(/\{\{ octicon-/, '[[ octicon-')
|
68
72
|
# This first pass converts the frontmatter variables,
|
69
73
|
# and inserts data variables into the body
|
70
74
|
result = Conrefifier.apply_liquid(data, page_vars)
|
71
75
|
# This second application renders the previously inserted
|
72
76
|
# data conditionals within the body
|
73
77
|
result = Conrefifier.apply_liquid(result, page_vars)
|
78
|
+
result.gsub('[[#', '{{#').gsub('{{ octicon-', '[[ octicon-')
|
74
79
|
rescue => e
|
75
80
|
raise RuntimeError.new("Could not read #{filename}: #{e.inspect}")
|
76
81
|
end
|
data/nanoc-conref-fs.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'nanoc-conref-fs'
|
6
|
-
spec.version = '0.0
|
6
|
+
spec.version = '0.1.0'
|
7
7
|
spec.authors = ['Garen Torikian']
|
8
8
|
spec.email = ['gjtorikian@gmail.com']
|
9
9
|
spec.summary = 'A Nanoc filesystem to permit using conrefs/reusables in your content.'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-conref-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nanoc
|