jekyll-lab-notebook-plugins 0.1.3 → 0.1.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0df49d03532de947b0ca9aa305c732f9fec1f4
|
4
|
+
data.tar.gz: 635d494be00da50685b7dc3777df1d3a8ea41302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4877420a4f271bc3290a5586e2e38bd1a9266a59492c48b10b11da6c3ac6d6f52df455b7343513cd471484a4ba9b1640125d3146d7f819a952d65cc65684309
|
7
|
+
data.tar.gz: 17ba0361f38555b5501d66e4b6a5be8a1fcdf4ea27f07eecddad1510ffb2c88427b697deb39b1214fca9ad31b5824572128ae931a5604929f5392cbbe44c7cdb
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "nokogiri", "~> 1.8"
|
24
|
+
spec.add_runtime_dependency "sanitize", "~> 4.6"
|
24
25
|
spec.add_runtime_dependency "jekyll", "~> 3.5"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.15"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
class SearchFileGenerator < Generator
|
6
|
+
safe true
|
7
|
+
|
8
|
+
def generate(site)
|
9
|
+
output = [{"title" => "Test"}]
|
10
|
+
|
11
|
+
path = Pathname.new(site.dest) + "search.json"
|
12
|
+
|
13
|
+
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
|
14
|
+
search_list = []
|
15
|
+
|
16
|
+
site.posts.docs.each do |post|
|
17
|
+
search_list.push(*build_post_hashes(post, converter))
|
18
|
+
end
|
19
|
+
|
20
|
+
FileUtils.mkdir_p(File.dirname(path))
|
21
|
+
File.open(path, 'w') do |f|
|
22
|
+
f.write(search_list.to_json)
|
23
|
+
end
|
24
|
+
site.keep_files << "search.json"
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_post_hashes(post, converter)
|
28
|
+
post_hashes = []
|
29
|
+
curr_post = nil
|
30
|
+
curr_hash = {}
|
31
|
+
curr_hash["content"] = []
|
32
|
+
|
33
|
+
converted_lines = post.content.split("\n").map do |line|
|
34
|
+
|
35
|
+
curr_hash["content"] << line
|
36
|
+
|
37
|
+
# skip code blocks
|
38
|
+
in_code_block = !in_code_block if line.match(/^```/)
|
39
|
+
next line if in_code_block
|
40
|
+
|
41
|
+
# drop lines that aren't markdown headers
|
42
|
+
matched = line.match(/^(#+) /)
|
43
|
+
next line unless matched
|
44
|
+
|
45
|
+
# drop headers that don't start with dates
|
46
|
+
DateTime.parse(line.strip) rescue next line
|
47
|
+
|
48
|
+
# pretty format dates
|
49
|
+
date = DateTime.parse(line.strip)
|
50
|
+
yearmonth = date.strftime("%Y_%m")
|
51
|
+
iddate = date.strftime("%Y%m%d")
|
52
|
+
displaydate = date.strftime("%a, %b %e")
|
53
|
+
|
54
|
+
# we've found a new entry, remove it from the previous entry's lines
|
55
|
+
curr_hash["content"].pop()
|
56
|
+
|
57
|
+
# extract project tags and flatten into a single array
|
58
|
+
tags = line.strip.scan(/#([a-zA-Z0-9._-]{3,} ?)/).flatten(1)
|
59
|
+
|
60
|
+
if !curr_post.nil?
|
61
|
+
curr_hash["content"] = converter.convert(curr_hash["content"].join("\n"))
|
62
|
+
post_hashes << curr_hash
|
63
|
+
end
|
64
|
+
|
65
|
+
curr_hash = {}
|
66
|
+
curr_hash["content"] = []
|
67
|
+
curr_hash["title"] = displaydate
|
68
|
+
curr_hash["url"] = "/log/#{yearmonth}/##{iddate}"
|
69
|
+
curr_hash["tags"] = tags
|
70
|
+
|
71
|
+
curr_post = date
|
72
|
+
end
|
73
|
+
return post_hashes
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-lab-notebook-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tamas Nagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sanitize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.6'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: jekyll
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +102,7 @@ files:
|
|
88
102
|
- lib/jekyll-lab-notebook-plugins.rb
|
89
103
|
- lib/jekyll-lab-notebook-plugins/version.rb
|
90
104
|
- lib/jekyll-postfiles.rb
|
105
|
+
- lib/jekyll_build_search.rb
|
91
106
|
- lib/logtags.rb
|
92
107
|
- lib/thought_tag.rb
|
93
108
|
homepage: https://github.com/tlnagy/jekyll-lab-notebook-plugins
|
@@ -110,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
125
|
version: '0'
|
111
126
|
requirements: []
|
112
127
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.6.
|
128
|
+
rubygems_version: 2.6.14
|
114
129
|
signing_key:
|
115
130
|
specification_version: 4
|
116
131
|
summary: A collection of Jekyll plugins for better electronic lab notebooks
|