jekyll-jupyter-notebook 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 +5 -5
- data/README.md +7 -1
- data/doc/text/news.md +14 -0
- data/lib/jekyll-jupyter-notebook.rb +2 -0
- data/lib/jekyll-jupyter-notebook/converter.rb +70 -0
- data/lib/jekyll-jupyter-notebook/generator.rb +37 -0
- data/lib/jekyll-jupyter-notebook/tag.rb +15 -21
- data/lib/jekyll-jupyter-notebook/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 672a0c4369f87053a77bc6065f5fe6c7793c530c006cb92d54ba894efc83879e
|
4
|
+
data.tar.gz: 9d6548fbab78a3632b5e1feb81cf98b0602ad3f7366af1e3b623d3fac2f53497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e84f567d3997d8799d419f0f0a6f7f5c60c46204b8a34b145e62d37f0bfc91e43e27d0182e407c5288b9fe988bf51d7e6aa38d5ba6e4f3cfedd6e5e220058271
|
7
|
+
data.tar.gz: 1093ca8d586c5c3f442ec1710822c11298a0ab2dfe8ae566339ee1e6693fc3c589c1ec57b44897e617f019194bd9ad56f1da73d03b5fbb349b154f17712a2e74
|
data/README.md
CHANGED
@@ -16,10 +16,16 @@ Add the following line to your site's `Gemfile`:
|
|
16
16
|
gem "jekyll-jupyter-notebook"
|
17
17
|
```
|
18
18
|
|
19
|
+
Run the following command line to make the gem available:
|
20
|
+
|
21
|
+
```console
|
22
|
+
% bundle install
|
23
|
+
```
|
24
|
+
|
19
25
|
Add the following line to your site's `_config.yml`:
|
20
26
|
|
21
27
|
```yaml
|
22
|
-
|
28
|
+
plugins:
|
23
29
|
- jekyll-jupyter-notebook
|
24
30
|
```
|
25
31
|
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 0.0.3 - 2018-03-31
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Improved install document.
|
8
|
+
[GitHub#5][Patch by Jake VanCampen]
|
9
|
+
|
10
|
+
* Changed to use `iframe` instead of embedding `nbconvert`-ed HTML directory.
|
11
|
+
It required JavaScript.
|
12
|
+
|
13
|
+
### Thanks
|
14
|
+
|
15
|
+
* Jake VanCampen
|
16
|
+
|
3
17
|
## 0.0.2 - 2017-09-03
|
4
18
|
|
5
19
|
### Improvements
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require "tempfile"
|
14
|
+
|
15
|
+
module JekyllJupyterNotebook
|
16
|
+
class Converter < Jekyll::Converter
|
17
|
+
def matches(ext)
|
18
|
+
ext == ".ipynb"
|
19
|
+
end
|
20
|
+
|
21
|
+
def output_ext(ext)
|
22
|
+
".html"
|
23
|
+
end
|
24
|
+
|
25
|
+
def convert(content)
|
26
|
+
config = @config["jupyter_notebook"] || {}
|
27
|
+
|
28
|
+
html = convert_notebook(content)
|
29
|
+
html.sub!(/<link.+?href="custom.css">/, "")
|
30
|
+
case config["content"] || "html"
|
31
|
+
when "html"
|
32
|
+
when "body"
|
33
|
+
html.sub!(/\A.*?<\/title>/m, "")
|
34
|
+
html.sub!(/<\/head>/, "")
|
35
|
+
html.sub!(/<body>/, "")
|
36
|
+
html.sub!(/<\/body>.*?\z/m, "")
|
37
|
+
when "body-without-style"
|
38
|
+
html.sub!(/\A.*?<body>/m, "")
|
39
|
+
html.sub!(/<\/body>.*?\z/m, "")
|
40
|
+
end
|
41
|
+
html
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def convert_notebook(content)
|
46
|
+
notebook = Tempfile.new(["jekyll-jupyter-notebook", ".ipynb"])
|
47
|
+
notebook.print(content)
|
48
|
+
notebook.close
|
49
|
+
IO.pipe do |input, output|
|
50
|
+
pid = spawn("jupyter",
|
51
|
+
"nbconvert",
|
52
|
+
"--to", "html",
|
53
|
+
"--stdout",
|
54
|
+
notebook.path,
|
55
|
+
:out => output)
|
56
|
+
begin
|
57
|
+
output.close
|
58
|
+
html = nil
|
59
|
+
read_thread = Thread.new do
|
60
|
+
html = input.read
|
61
|
+
end
|
62
|
+
read_thread.join
|
63
|
+
html
|
64
|
+
ensure
|
65
|
+
Process.waitpid(pid)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
module JekyllJupyterNotebook
|
14
|
+
module IFramePage
|
15
|
+
def output_ext
|
16
|
+
ext + super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Generator < Jekyll::Generator
|
21
|
+
def generate(site)
|
22
|
+
site.static_files.reject! do |static_file|
|
23
|
+
if static_file.extname == ".ipynb"
|
24
|
+
base = static_file.instance_variable_get(:@base)
|
25
|
+
dir = static_file.instance_variable_get(:@dir)
|
26
|
+
name = static_file.name
|
27
|
+
page = Jekyll::Page.new(site, base, dir, name)
|
28
|
+
page.extend(IFramePage)
|
29
|
+
site.pages << page
|
30
|
+
true
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -26,27 +26,21 @@ module JekyllJupyterNotebook
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def render(context)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
html.sub!(/<body>/, "")
|
45
|
-
html.sub!(/<\/body>.*?\z/m, "")
|
46
|
-
<<-HTML
|
47
|
-
<div class="jupyter-notebook">#{html}</div>
|
48
|
-
HTML
|
49
|
-
end
|
29
|
+
notebook_html_path = "#{@notebook_path}.html"
|
30
|
+
<<-HTML
|
31
|
+
<div
|
32
|
+
class="jupyter-notebook"
|
33
|
+
style="position: relative; width: 100%; margin: 0 auto;">
|
34
|
+
<div class="jupyter-notebook-iframe-container">
|
35
|
+
<iframe
|
36
|
+
src="#{CGI.escapeHTML(notebook_html_path)}"
|
37
|
+
style="position: absolute; top: 0; left: 0; border-style: none;"
|
38
|
+
width="100%"
|
39
|
+
height="100%"
|
40
|
+
onload="this.parentElement.style.paddingBottom = (this.contentWindow.document.documentElement.scrollHeight + 10) + 'px'"></iframe>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
HTML
|
50
44
|
end
|
51
45
|
end
|
52
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-jupyter-notebook
|
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
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -109,6 +109,8 @@ files:
|
|
109
109
|
- doc/text/news.md
|
110
110
|
- jekyll-jupyter-notebook.gemspec
|
111
111
|
- lib/jekyll-jupyter-notebook.rb
|
112
|
+
- lib/jekyll-jupyter-notebook/converter.rb
|
113
|
+
- lib/jekyll-jupyter-notebook/generator.rb
|
112
114
|
- lib/jekyll-jupyter-notebook/tag.rb
|
113
115
|
- lib/jekyll-jupyter-notebook/version.rb
|
114
116
|
homepage: https://github.com/red-data-tools/jekyll-jupyter-notebook
|
@@ -131,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
133
|
version: '0'
|
132
134
|
requirements: []
|
133
135
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.7.6
|
135
137
|
signing_key:
|
136
138
|
specification_version: 4
|
137
139
|
summary: Jekyll Jupyter Notebook plugin adds [Jupyter](http://jupyter.org/) Notebook
|