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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c7ed19617651e9d232b89512c6e8a0143fc3785
4
- data.tar.gz: c759b550a9c5f19a94d23c2088056eb879613fcf
3
+ metadata.gz: 5245592ecae601d7fd337c52a1412a1404006dee
4
+ data.tar.gz: 1fd696089e7f1b0f7260f7c9d97ef54481230e95
5
5
  SHA512:
6
- metadata.gz: f8b25e997dce9f305222a13d4a8c36f15f9d2a4d4bdbf04e5c9c42266852e7905a4f15e2a8b6d4c2b5f4839e6d10af7e1405c31da5d7df01683f87db24a5624f
7
- data.tar.gz: 80ec47648f484c1c7a3d8211e660c38169c334beadbd6d089fa2222dc51c5cabbeeb1dfa5b60c5cdb88a15f0a4d23b977d6e391178be42849d114ea4a8404b13
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
+ [![Gem Version](https://badge.fury.io/rb/jekyll-lab-notebook-plugins.svg)](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
@@ -1,3 +1,3 @@
1
1
  module JekyllLabNotebookPlugins
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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
- # load in the all generated HTML for the project page, we're going to clone
127
- # this and inject our new content into it to avoid having to deal with liquid
128
- template = File.read(File.join(dest, dir, 'index.html'))
129
- doc = Nokogiri::HTML template
130
-
131
- site.data["tagmap"].each_key do |tag|
132
- path = File.join(dest, dir, tag)
133
- FileUtils.mkdir_p path
134
- File.open(File.join(path, "index.html"), 'w') do |f|
135
- # inject new title
136
- doc.at_css('h1.post-title').inner_html = "Project ##{tag} <a href=\"#latest\">&#8617;</a>"
137
-
138
- # construct one body of HTML from all the separate fragments
139
- new_node_set = Nokogiri::XML::NodeSet.new(doc)
140
- site.data["tagmap"][tag].each do |content|
141
- new_node_set << Nokogiri::HTML::fragment(content)
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\">&#8617;</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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-lab-notebook-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamas Nagy