quivjek 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/README.md +35 -19
- data/lib/quivjek.rb +55 -29
- data/lib/quivjek/version.rb +1 -1
- data/quivjek.gemspec +2 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cddb138a8ddddbc65215afc6014cd62855558b8a
|
4
|
+
data.tar.gz: e0e2064128abfdcfd12316f257b44c2cbe7957ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f0fe9e24a397a5d7e47e36b03a787780099b5c1de9e1c9c5b765e6b7eb643cf96459eee85b0eee2cd5cc6e1b81d58438e127f58ebfba12ad374970115010e7
|
7
|
+
data.tar.gz: e1c94c28e1eda6225d15aefad543a777291758ee0c1042acd98479a1f4ada284c38b4c0924200929eb6d8617cf4b5d7ffd028cb2fb8f4a1256873430476991a5
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,55 @@
|
|
1
1
|
# Quivjek: A Jekyll plugin for seamless publication of Quiver notebooks
|
2
2
|
[![Build Status](https://travis-ci.org/benbjurstrom/quivjek.svg?branch=master)](https://travis-ci.org/benbjurstrom/quivjek)
|
3
3
|
|
4
|
-
Quivjek is a Jekyll plugin that automatically exports all notes from a specified Quiver notebook to your _posts folder when the jekyll build command is run. Quivjek also copies and properly links any images contained in a Quiver note to your Jekyll images folder.
|
4
|
+
Quivjek is a [Jekyll](https://jekyllrb.com/) plugin that automatically exports all notes from a specified [Quiver](http://happenapps.com/#quiver) notebook to your _posts folder when the jekyll build command is run. Quivjek also copies and properly links any images contained in a Quiver note to your Jekyll images folder.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
1. Install the quivjek gem
|
8
|
-
```
|
9
|
-
gem install quivjek
|
10
|
-
```
|
8
|
+
```bash
|
9
|
+
gem install quivjek
|
10
|
+
```
|
11
11
|
2. Add quivjek to the gems array found in the _config.yml file.
|
12
|
-
```
|
13
|
-
#jekyll_dir/_config.yml
|
14
|
-
gems: [quivjek]
|
15
|
-
```
|
12
|
+
```yaml
|
13
|
+
#jekyll_dir/_config.yml
|
14
|
+
gems: [quivjek]
|
15
|
+
```
|
16
16
|
3. Point quivjek to the Quiver notebook of choice by adding the `notebook_dir:` key to the \_config.yml file with a value equal to your notebooks file path. For example:
|
17
|
-
```
|
18
|
-
#jekyll_dir/_config.yml
|
19
|
-
notebook_dir:~/Dropbox/Quiver/Quiver.qvlibrary/14F2BCE0-1B08-4ED6-993A-17C8AB0316E2.qvnotebook
|
20
|
-
```
|
17
|
+
```yaml
|
18
|
+
#jekyll_dir/_config.yml
|
19
|
+
notebook_dir:~/Dropbox/Quiver/Quiver.qvlibrary/14F2BCE0-1B08-4ED6-993A-17C8AB0316E2.qvnotebook
|
20
|
+
```
|
21
21
|
|
22
|
-
To determine a notebook's filepath right click on the note in the Quiver sidebar and choose open in finder. Be aware that Quiver notebooks are folders ending in the .qvnotebook extension and named with a random UUID as in the example above.
|
22
|
+
To determine a Quiver notebook's filepath right click on the note in the Quiver sidebar and choose open in finder. Be aware that Quiver notebooks are folders ending in the .qvnotebook extension and named with a random UUID as in the example above.
|
23
23
|
|
24
24
|
## Usage
|
25
|
-
|
25
|
+
Run `jekyll build` and quivjek will automatically copy your Quiver notes to your jekyll _posts folder prior to build.
|
26
26
|
|
27
27
|
## Things you should know
|
28
|
-
All quiver notes must be entirely composed of markdown or code cells.
|
28
|
+
1. All quiver notes must be entirely composed of markdown or code cells.
|
29
29
|
|
30
|
-
Quivjek will ignore any posts tagged as `draft`
|
30
|
+
1. Quivjek will ignore any posts tagged as `draft`
|
31
31
|
|
32
|
-
|
32
|
+
1. Optionally you can include a YAML front matter envelope to your Quiver note.
|
33
33
|
|
34
|
-
|
34
|
+
```yaml
|
35
|
+
|
36
|
+
---
|
37
|
+
title: This is an example post
|
38
|
+
date: '2016-09-14'
|
39
|
+
---
|
40
|
+
|
41
|
+
Some content...
|
42
|
+
```
|
35
43
|
|
36
|
-
|
44
|
+
* By default Quivjek sets the front matter date (and markdown file name) based on the Quiver note's created date metadata. This can be overridden by adding the date front matter to your Quiver note.
|
45
|
+
|
46
|
+
* By default Quivjek sets the front matter title (and markdown file name) equal to the Quiver note's title. This can be overridden by adding the title front matter to your quiver note.
|
47
|
+
|
48
|
+
* By default Quivjek adds the Quiver note's tags as front matter tags.
|
49
|
+
|
50
|
+
1. Quivjek currently copies all notes and images to the jekyll directory within the subfolders `/_posts/quiver` and `/images/q` respectively. On build quivjek deletes all files from these subfolders and re-copies the notes and images from the Quiver notebook. This is done to clean up any deleted or renamed items. Eventually I'd like to save a manifest and only update the notes and images that have been modified or deleted since the last build.
|
51
|
+
|
52
|
+
1. When an image is added to a markdown cell, Quiver renames the file and sets the original file name as the image tag's alt attribute. For example the image `big-claw-puppy-on-wood-floor.jpg` becomes `![big-claw-puppy-on-wood-floor.jpg](quiver-image-url/642370E09A291BC1601CFD68B44A5C16.jpg)`. For SEO purposes quivjek reverses this process by renaming the image to whatever is found in your alt tag. Therefore it is recommended your alt tags are lowercase, slug-ified, unique, and end in the image file extension.
|
37
53
|
|
38
54
|
## Development
|
39
55
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/quivjek.rb
CHANGED
@@ -4,6 +4,8 @@ require "json"
|
|
4
4
|
require "fileutils"
|
5
5
|
require "quivjek/version"
|
6
6
|
require "jekyll"
|
7
|
+
require "front_matter_parser"
|
8
|
+
require "yaml"
|
7
9
|
|
8
10
|
Jekyll::Hooks.register :site, :after_init do |site|
|
9
11
|
q = Quivjek.new(site)
|
@@ -48,29 +50,51 @@ class Quivjek
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def copy_note(note_dir)
|
51
|
-
|
52
|
-
|
53
|
-
imagepath = File.join(note_dir, "resources")
|
54
|
-
|
55
|
-
showhelp("meta.json doesn't exist") unless File.exist? metapath
|
56
|
-
metajson = JSON.parse(File.read(metapath))
|
53
|
+
# Load the quiver note meta.json file.
|
54
|
+
metajson = load_meta_json(note_dir)
|
57
55
|
|
58
56
|
# Skip this note if tagged with draft
|
59
57
|
metajson["tags"].each do |tag|
|
60
58
|
return if tag == 'draft'
|
61
59
|
end
|
62
60
|
|
63
|
-
|
64
|
-
|
61
|
+
# Copy the notes images to the jekyll directory
|
62
|
+
imagepath = File.join(note_dir, "resources")
|
65
63
|
self.copy_note_images(imagepath) if File.exist?(imagepath)
|
66
64
|
|
67
|
-
|
68
|
-
|
65
|
+
# Load the quiver note content.json file and merge its cells.
|
66
|
+
contentjson = load_content_json(note_dir)
|
67
|
+
content = self.merge_cells(contentjson, '')
|
69
68
|
|
70
|
-
|
71
|
-
|
69
|
+
# Parse out optional frontmatter from the content
|
70
|
+
parsed = FrontMatterParser.parse(content)
|
71
|
+
fm = parsed.front_matter
|
72
|
+
content = parsed.content
|
72
73
|
|
74
|
+
# Set some default frontmatter and combine with content
|
75
|
+
fm = set_default_frontmatter(fm, metajson)
|
76
|
+
output = fm.to_yaml + "---\n" + content
|
77
|
+
|
78
|
+
# Write the markdown file to the jekyll dir
|
79
|
+
filename = self.get_filename(fm)
|
73
80
|
File.open(File.join(@post_dir, filename), "w") { |file| file.write(output) }
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def load_meta_json(dir)
|
85
|
+
metapath = File.join(dir, "meta.json")
|
86
|
+
showhelp("meta.json doesn't exist") unless File.exist? metapath
|
87
|
+
metajson = JSON.parse(File.read(metapath))
|
88
|
+
|
89
|
+
return metajson
|
90
|
+
end
|
91
|
+
|
92
|
+
def load_content_json(dir)
|
93
|
+
contentpath = File.join(dir, "content.json")
|
94
|
+
showhelp(contentpath + "content.json doesn't exist") unless File.exist? contentpath
|
95
|
+
contentjson = JSON.parse(File.read(contentpath))
|
96
|
+
|
97
|
+
return contentjson
|
74
98
|
end
|
75
99
|
|
76
100
|
def copy_note_images(imagepath)
|
@@ -83,35 +107,37 @@ class Quivjek
|
|
83
107
|
|
84
108
|
end
|
85
109
|
|
86
|
-
def get_filename(
|
87
|
-
title =
|
110
|
+
def get_filename(fm)
|
111
|
+
title = fm["title"].gsub(" ", "-").downcase
|
112
|
+
date = DateTime.parse(fm["date"])
|
88
113
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
year = created_at_date.year
|
114
|
+
day = "%02d" % date.day
|
115
|
+
month = "%02d" % date.month
|
116
|
+
year = date.year
|
93
117
|
|
94
118
|
return "#{year}-#{month}-#{day}-#{title}.md"
|
95
119
|
end
|
96
120
|
|
97
|
-
def
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
layout: post
|
102
|
-
title: "#{metajson["title"]}"
|
103
|
-
eos
|
121
|
+
def set_default_frontmatter(fm, metajson)
|
122
|
+
|
123
|
+
# If certain frontmatter is missing default to quiver metadata
|
124
|
+
fm['title'] = metajson['title'] unless fm['title']
|
104
125
|
|
126
|
+
if !fm.key?("date")
|
127
|
+
date = DateTime.strptime(metajson["created_at"].to_s, "%s")
|
128
|
+
fm['date'] = date.strftime('%Y-%m-%d')
|
129
|
+
end
|
130
|
+
|
131
|
+
tags = metajson["tags"].map { |tag| " - #{tag}" }.join("\n")
|
105
132
|
if !tags.empty?
|
106
|
-
|
133
|
+
fm['tags'] = tags
|
107
134
|
end
|
108
135
|
|
109
|
-
|
136
|
+
return fm
|
110
137
|
|
111
|
-
return output
|
112
138
|
end
|
113
139
|
|
114
|
-
def
|
140
|
+
def merge_cells(contentjson, output)
|
115
141
|
contentjson["cells"].each do |cell|
|
116
142
|
case cell["type"]
|
117
143
|
when "code"
|
data/lib/quivjek/version.rb
CHANGED
data/quivjek.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.add_runtime_dependency "front_matter_parser", "0.0.4"
|
23
|
+
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.12"
|
23
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
26
|
spec.add_development_dependency "minitest", "~> 5.0"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quivjek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Bjurstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: front_matter_parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.4
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
120
|
version: '0'
|
107
121
|
requirements: []
|
108
122
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.10
|
110
124
|
signing_key:
|
111
125
|
specification_version: 4
|
112
126
|
summary: A Jekyll plugin for seamless publication of Quiver notebooks
|