jekyll-lab-notebook-plugins 0.1.2 → 0.1.7
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 +5 -5
- data/jekyll-lab-notebook-plugins.gemspec +4 -4
- data/lib/count_days.rb +1 -1
- data/lib/jekyll-lab-notebook-plugins.rb +1 -0
- data/lib/jekyll-lab-notebook-plugins/version.rb +1 -1
- data/lib/jekyll_build_search.rb +76 -0
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f94171108989cf9dcd4dff371294f8d70b85a05a9b4f69bb5e70310f557b4dfe
|
4
|
+
data.tar.gz: 92786ecf480961e87cf63a2b87671b29acfc960ce2ecef2184ecb7ada8e9fad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d17ef28da11d8fd68da3ef4781ccc1e7413c8b1173007eb92d5f7d5888e162a4c300961766c7e6cc8b00a254279d2771929430ae0c1a9e631da2a55ab557d89
|
7
|
+
data.tar.gz: b759956e11609a7ace23af22c6487b7983ae1856ce262a2492914d2958c16f511dbe84848a0f5955d7edead2858b2289246eb2af7703d8f0906a0aff9c31e935
|
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "nokogiri", "~> 1
|
24
|
-
spec.add_runtime_dependency "jekyll", "~> 3
|
23
|
+
spec.add_runtime_dependency "nokogiri", "~> 1"
|
24
|
+
spec.add_runtime_dependency "jekyll", "~> 3"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_development_dependency "bundler", "~> 2"
|
27
|
+
spec.add_development_dependency "rake", "~> 13"
|
28
28
|
end
|
data/lib/count_days.rb
CHANGED
@@ -17,7 +17,7 @@ module DayLister
|
|
17
17
|
doc = Nokogiri::HTML::DocumentFragment.parse(post.content)
|
18
18
|
|
19
19
|
doc.search('h3').each do |header|
|
20
|
-
if dt = DateTime.parse(header.
|
20
|
+
if dt = DateTime.parse(header.attribute("id")) rescue false
|
21
21
|
result += (dt + Rational(12, 24)).strftime('%s') + ": 4,\n"
|
22
22
|
end
|
23
23
|
end
|
@@ -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.reverse_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("%b %e, %Y")
|
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.7
|
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: 2020-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jekyll
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3
|
33
|
+
version: '3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3
|
40
|
+
version: '3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13'
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- tamas@tamasnagy.com
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/jekyll-lab-notebook-plugins.rb
|
89
89
|
- lib/jekyll-lab-notebook-plugins/version.rb
|
90
90
|
- lib/jekyll-postfiles.rb
|
91
|
+
- lib/jekyll_build_search.rb
|
91
92
|
- lib/logtags.rb
|
92
93
|
- lib/thought_tag.rb
|
93
94
|
homepage: https://github.com/tlnagy/jekyll-lab-notebook-plugins
|
@@ -109,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.6.11
|
113
|
+
rubygems_version: 3.1.2
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: A collection of Jekyll plugins for better electronic lab notebooks
|