jekyll-lab-notebook-plugins 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +2 -0
- data/lib/jekyll-lab-notebook-plugins/version.rb +1 -1
- data/lib/logtags.rb +57 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5245592ecae601d7fd337c52a1412a1404006dee
|
4
|
+
data.tar.gz: 1fd696089e7f1b0f7260f7c9d97ef54481230e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 653a0bc93fc4193fcc38cce7ddf494d4a9663921bd7dddd8a8466374ca2f8b560ac307f53a3f3b4202c793dc489963e68b5afe6846346983df4b4c411329cfd5
|
7
|
+
data.tar.gz: 464384b73b22ff98537fdbbde41c6d7a9c31b8f5b875163a1abd06db7600a87ad7ed39733d3b60f1d3f2ff3823ea98b9dbb7b27624e0af9c700fedf014337763
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# jekyll-lab-notebook-plugins
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/jekyll-lab-notebook-plugins)
|
4
|
+
|
3
5
|
A collection of plugins for super charging your electronic lab notebook. See <https://github.com/tlnagy/jekyll-lab-notebook> for more details.
|
4
6
|
|
5
7
|
## Development
|
data/lib/logtags.rb
CHANGED
@@ -7,6 +7,36 @@ require 'set'
|
|
7
7
|
require 'pathname'
|
8
8
|
require 'uri'
|
9
9
|
|
10
|
+
module Jekyll
|
11
|
+
|
12
|
+
class ProjectPage < Page
|
13
|
+
def initialize(site, base, dir)
|
14
|
+
@site = site
|
15
|
+
@base = base
|
16
|
+
@dir = dir
|
17
|
+
@name = 'index.html'
|
18
|
+
|
19
|
+
self.process(@name)
|
20
|
+
@path = site.layouts["project-home"].path
|
21
|
+
self.read_yaml("", "") # uses path from above first
|
22
|
+
|
23
|
+
self.data['title'] = "Projects"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class CategoryPageGenerator < Generator
|
28
|
+
safe true
|
29
|
+
|
30
|
+
def generate(site)
|
31
|
+
if site.layouts.key? 'project-home'
|
32
|
+
dir = site.config['project-dir'] || 'projects'
|
33
|
+
site.pages << ProjectPage.new(site, site.source, dir)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
10
40
|
# Pre-render
|
11
41
|
#
|
12
42
|
# This is the first step. When posts are built, this block goes through and
|
@@ -123,32 +153,34 @@ Jekyll::Hooks.register :site, :post_write do |site|
|
|
123
153
|
dir = site.config['projects_dir'] || 'projects'
|
124
154
|
dest = site.config["destination"]
|
125
155
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
156
|
+
if site.data.key?("tagmap")
|
157
|
+
# load in the all generated HTML for the project page, we're going to clone
|
158
|
+
# this and inject our new content into it to avoid having to deal with liquid
|
159
|
+
template = File.read(File.join(dest, dir, 'index.html'))
|
160
|
+
doc = Nokogiri::HTML template
|
161
|
+
|
162
|
+
site.data["tagmap"].each_key do |tag|
|
163
|
+
path = File.join(dest, dir, tag)
|
164
|
+
FileUtils.mkdir_p path
|
165
|
+
File.open(File.join(path, "index.html"), 'w') do |f|
|
166
|
+
# inject new title
|
167
|
+
doc.at_css('h1.post-title').inner_html = "Project ##{tag} <a href=\"#latest\">↩</a>"
|
168
|
+
|
169
|
+
# construct one body of HTML from all the separate fragments
|
170
|
+
new_node_set = Nokogiri::XML::NodeSet.new(doc)
|
171
|
+
site.data["tagmap"][tag].each do |content|
|
172
|
+
new_node_set << Nokogiri::HTML::fragment(content)
|
173
|
+
end
|
174
|
+
|
175
|
+
content = doc.at_css('div.post-content')
|
176
|
+
|
177
|
+
# skeletonize page and inject new content
|
178
|
+
content.children.remove rescue nil
|
179
|
+
content << new_node_set.to_html
|
180
|
+
content << "<div id=latest></div>"
|
181
|
+
|
182
|
+
f.write(doc.to_html)
|
142
183
|
end
|
143
|
-
|
144
|
-
content = doc.at_css('div.post-content')
|
145
|
-
|
146
|
-
# skeletonize page and inject new content
|
147
|
-
content.children.remove rescue nil
|
148
|
-
content << new_node_set.to_html
|
149
|
-
content << "<div id=latest></div>"
|
150
|
-
|
151
|
-
f.write(doc.to_html)
|
152
184
|
end
|
153
185
|
end
|
154
186
|
end
|