paperwork 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f8c3450109475a508ced5b1797489164894944e7e86794b6961edf23ce44e6a
4
- data.tar.gz: f090d5a1eb0f3aa63aee49c784968e0e365f340f060b48bf01d1eb9240096d6a
3
+ metadata.gz: 0ce95a4eba79bce8b9489a4f421da5fd2d90eb5814222c4d99dceb39966b25b5
4
+ data.tar.gz: 1c0448b67db7619d2d798b370f9a8020e97885a30ad88588dc809341a9c306df
5
5
  SHA512:
6
- metadata.gz: a62ec73b5be3e1fbf41af291436b9c99ddd28559ebc3e5fb444beff51836e6b0138e2a89915b2d5301b2d1e551450fe2c4d0f06b83cebe7990b95e251eddd7cd
7
- data.tar.gz: b9f1b73b11969e1016239e4e8e2e687a4c42cb4f86214123bbdcd9f02080da4542271bbf7904a4fbf7305f9b679e889d746071c579e9e681c74c972ae772fe3d
6
+ metadata.gz: e0e9dd39efe87a4174ffa674c13a5554a4b9788fecb9c27e276cad5bcfdef26c13b81eee9d6678895c20cf2637ed38fe53d6d58c595730f07e320fb2c94efab3
7
+ data.tar.gz: 6917edf9fa357eda4aa207763057938bf872e64644ce5781c6a98fe667f6655a88cbb4520e8726d66c0cd820b0d5840a972ea6339ef5e9a83311203bd7d5f2f1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperwork (0.4.1)
4
+ paperwork (0.5.0)
5
5
  listen (~> 3.4.1)
6
6
  rake (~> 12.3)
7
7
  redcarpet (~> 3.5.0)
@@ -60,4 +60,10 @@ module InfoHelpers
60
60
  def footer_text
61
61
  data.paperwork.footer if paperwork?
62
62
  end
63
+
64
+ def toc?
65
+ !data.paperwork.config.nil? &&
66
+ !data.paperwork.config.toc.nil? &&
67
+ data.paperwork.config.toc
68
+ end
63
69
  end
@@ -4,5 +4,14 @@ import $ from "jquery";
4
4
  import 'popper.js';
5
5
  import 'bootstrap';
6
6
  import mermaid from "mermaid";
7
+ import {getTableOfContents} from './toc';
7
8
 
8
9
  mermaid.initialize({startOnLoad:true});
10
+
11
+ $(()=>{
12
+ var sidebar = $(".toc.sidebar > ul")
13
+ var topbar = $(".toc.topbar > ul")
14
+ var toc = getTableOfContents();
15
+ toc.insertTo(sidebar);
16
+ toc.insertTo(topbar);
17
+ });
@@ -0,0 +1,64 @@
1
+ import $ from "jquery";
2
+
3
+ var idCounter = 0;
4
+
5
+ class Section {
6
+ constructor(element=null) {
7
+ this.children = [];
8
+ this.element = element;
9
+
10
+ if (this.element) {
11
+ this.anchor = "paperwork-h-" + ++idCounter;
12
+ } else {
13
+ this.element = $("body");
14
+ }
15
+
16
+ this.element.find(":header").each((index, elem)=>{
17
+ this.add(new Section($(elem)));
18
+ });
19
+ }
20
+
21
+ add(childSection) {
22
+ this.children.push(childSection);
23
+ }
24
+
25
+ id() {
26
+ return this.anchor;
27
+ }
28
+
29
+ level() {
30
+ return this.element.prop("tagName").toLowerCase();
31
+ }
32
+
33
+ mark() {
34
+ if (this.level() != "body") {
35
+ // create anchor
36
+ this.element.before("<div id='" + this.id() + "'></div>");
37
+ }
38
+ this.children.forEach((child)=>{
39
+ child.mark();
40
+ });
41
+ }
42
+
43
+ insertTo(target) {
44
+ if (this.level() != "body") {
45
+ // link to anchor
46
+ target.append("<li class='toc-" + this.level() + "'><a href='#" + this.id() + "'>" + this.text() + "</a></li>");
47
+ }
48
+ this.children.forEach((child)=>{
49
+ child.insertTo(target);
50
+ });
51
+ }
52
+
53
+ text() {
54
+ return this.element.text();
55
+ }
56
+ }
57
+
58
+ function getTableOfContents() {
59
+ var toc = new Section();
60
+ toc.mark();
61
+ return toc;
62
+ }
63
+
64
+ export { getTableOfContents };
@@ -0,0 +1,6 @@
1
+ <%= partial "layouts/header" %>
2
+ <div class="row">
3
+ <div class="col">
4
+ <%= body %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,25 @@
1
+ <div class="d-flex">
2
+ <div class="d-xl-block d-lg-block d-md-block d-none">
3
+ <%= partial "layouts/toc", locals: {classes: [:sidebar]} %>
4
+ </div>
5
+
6
+ <div>
7
+ <%= partial "layouts/header" %>
8
+
9
+ <div class="row d-xl-none d-lg-none d-md-none ">
10
+ <div class="col">
11
+ <%= partial "layouts/toc", locals: {classes: [:topbar]} %>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="row">
16
+ <div class="col">
17
+ <%= body %>
18
+ </div>
19
+ </div>
20
+ </div>
21
+
22
+ <div class="v-spacer-2 d-xl-block d-lg-block d-md-block d-sm-none d-xs-none"></div>
23
+ <div class="v-spacer-2 d-xl-block d-lg-block d-md-none d-sm-none d-xs-none"></div>
24
+ <div class="v-spacer-3 d-xl-block d-lg-none d-md-none d-sm-none d-xs-none"></div>
25
+ </div>
@@ -29,14 +29,21 @@
29
29
  <body>
30
30
  <%= partial "layouts/navbar" %>
31
31
 
32
+ <% if toc? %>
33
+ <div class="container-fluid">
34
+ <div class="row">
35
+ <div class="col">
36
+ <%= partial "layouts/content_with_toc", locals: {body: body} %>
37
+ </div>
38
+ </div>
39
+ <% else %>
32
40
  <div class="container">
33
- <%= partial "layouts/header" %>
34
-
35
41
  <div class="row">
36
42
  <div class="col">
37
- <%= body %>
43
+ <%= partial "layouts/content", locals: {body: body} %>
38
44
  </div>
39
45
  </div>
46
+ <% end %>
40
47
 
41
48
  <div class="row mt-5 pb-4">
42
49
  <div class="col text-right small border-top">
@@ -1,14 +1,14 @@
1
1
  <div class="row">
2
2
  <div class="col-sm-7 mb-5">
3
- <span class="display-2"><%= yield_content :title %></span>
3
+ <span class="page-title"><%= yield_content :title %></span>
4
4
  <br>
5
- <span class="display-4"><%= yield_content :subtitle %></span>
5
+ <span class="page-sub-title"><%= yield_content :subtitle %></span>
6
6
  </div>
7
7
 
8
8
  <div class="col-sm-5">
9
9
 
10
10
  <div class="row">
11
- <div class="col text-right sub-title mb-2">
11
+ <div class="col text-right page-category mb-2">
12
12
  <%= yield_content :category %>
13
13
  </div>
14
14
  </div>
@@ -0,0 +1,9 @@
1
+ <%
2
+ classes ||= []
3
+ classes << "toc"
4
+ %>
5
+
6
+ <div class="<%= classes.join(" ") %>">
7
+ <div class="title">Table of Contents</div>
8
+ <ul class="list-unstyled"></ul>
9
+ </div>
@@ -1,8 +1,16 @@
1
1
  @import "../../node_modules/bootstrap/dist/css/bootstrap";
2
2
  @import "./bootstrap-icons.css";
3
3
 
4
- .sub-title {
5
- font-size: 2.2rem;
4
+ .page-title {
5
+ font-size: 3rem;
6
+ }
7
+
8
+ .page-sub-title {
9
+ font-size: 2rem;
10
+ }
11
+
12
+ .page-category {
13
+ font-size: 1.5rem;
6
14
  }
7
15
 
8
16
  $header-siblings-margin: 1rem;
@@ -29,4 +37,39 @@ pre.highlight {
29
37
  padding: 0.3rem;
30
38
  margin-top: 1rem;
31
39
  margin-bottom: 1rem;
32
- }
40
+ }
41
+
42
+ .toc {
43
+ padding-top: 1rem;
44
+ white-space: nowrap;
45
+
46
+ &.sidebar {
47
+ position: sticky;
48
+ top: 4rem;
49
+ margin-right: 5rem;
50
+ width: 12rem;
51
+ overflow: hidden;
52
+ text-overflow: ellipsis;
53
+ }
54
+
55
+ .title {
56
+ font-weight: bold;
57
+ }
58
+
59
+ @for $i from 1 through 6 {
60
+ .toc-h#{$i} {
61
+ font-size: 0.8rem;
62
+ padding-left: #{($i - 1) * 0.5}rem;
63
+ }
64
+ }
65
+ }
66
+
67
+
68
+ .d-flex {
69
+ @for $i from 1 through 5 {
70
+ .v-spacer-#{$i} {
71
+ margin-left: #{$i * 2}rem;
72
+ }
73
+ }
74
+ }
75
+
@@ -2,6 +2,7 @@ const path = require('path');
2
2
 
3
3
  module.exports = {
4
4
  entry: './source/javascripts/site.js',
5
+ devtool: 'source-map',
5
6
 
6
7
  resolve: {
7
8
  modules: [
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paperwork
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
data/paperwork.yml CHANGED
@@ -8,6 +8,7 @@ navbar:
8
8
 
9
9
  config:
10
10
  name: doc
11
+ toc: true
11
12
  sources:
12
13
  - README.md
13
14
  - nested_example/navdemo.md
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -178,10 +178,14 @@ files:
178
178
  - lib/paperwork/tasks/middleman_template/source/fonts/bootstrap-icons.woff2
179
179
  - lib/paperwork/tasks/middleman_template/source/images/.keep
180
180
  - lib/paperwork/tasks/middleman_template/source/javascripts/site.js
181
+ - lib/paperwork/tasks/middleman_template/source/javascripts/toc.js
182
+ - lib/paperwork/tasks/middleman_template/source/layouts/_content.erb
183
+ - lib/paperwork/tasks/middleman_template/source/layouts/_content_with_toc.erb
181
184
  - lib/paperwork/tasks/middleman_template/source/layouts/_document.erb
182
185
  - lib/paperwork/tasks/middleman_template/source/layouts/_header.erb
183
186
  - lib/paperwork/tasks/middleman_template/source/layouts/_info.erb
184
187
  - lib/paperwork/tasks/middleman_template/source/layouts/_navbar.erb
188
+ - lib/paperwork/tasks/middleman_template/source/layouts/_toc.erb
185
189
  - lib/paperwork/tasks/middleman_template/source/layouts/layout.erb
186
190
  - lib/paperwork/tasks/middleman_template/source/stylesheets/bootstrap-icons.css
187
191
  - lib/paperwork/tasks/middleman_template/source/stylesheets/rogue.css.erb