jekyll-web-novel 0.1.8 → 0.2.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: 27f7bdb99fdcea68ae850684c57b89fe4e0f184d9797280ebda14add3c4326b5
4
- data.tar.gz: ba94c3657418d77b7ced99e28653ef9fe8f65bda6bcb619f42bb8a183e63a2ab
3
+ metadata.gz: bfd69738895f6a9f448a7a7f1d7051feb43cbc65343d59042ad4b8d4ae3ba4e9
4
+ data.tar.gz: cfc5bb72afe4e8279634c9d25155bce896011a3bb315b30b150bff1565d37fd7
5
5
  SHA512:
6
- metadata.gz: 05f1f05492200f0632fa09b6d442ddcd138230f9ad2420c85807109d0cdf21d54a45451c1995694a7f0c1423ec1fa3ef5ba7329de6f79710f45101699636c47d
7
- data.tar.gz: 4a885cd64fecc342394934ad1710f851320937b0b2ceedec163f11396e2878a34004a02f21c660d4c9fd2234033c099e115812ccd7733eb0b0e18e9f74a3b6aa
6
+ metadata.gz: 063da2bdcff1144efb9e56fb0044db4d4243c1eb219790f470a3152d3d55b3bc696245074328e2f4b138dcfd5242ca4310ef0c2454739ec3439942a5caecd6cd
7
+ data.tar.gz: f6e6908d27d5c9dbcc4250f6a7eea1e988a6b4feb4e09edc96903e5d633cdb753382ce9d7814fab668d89ce7a1e5e64ec112e03bb83e014c49130510ae8ebfa2
@@ -3,7 +3,7 @@ _boilerplate:
3
3
  path: '_chapters'
4
4
  timestamp: false
5
5
  title: title
6
- slug: "{{ vol }}-{{ cht }}-{{ title }}.md"
6
+ slug: "{{ vol }}-{{ cht }}-{{ title }}"
7
7
  vol: '01'
8
8
 
9
9
  title: {{ boilerplate.title }}
@@ -3,10 +3,8 @@ _boilerplate:
3
3
  path: '_previews'
4
4
  timestamp: false
5
5
  title: title
6
- slug: "{{ vol }}-{{ cht }}-{{ title }}.md"
6
+ slug: "{{ vol }}-{{ cht }}-{{ title }}"
7
7
  vol: '01'
8
- localhost:
9
- baseurl:
10
8
 
11
9
  # http://localhost:4000/chapters/{{ boilerplate.random_url }}#reader
12
10
  # https://example.com/chapters/{{ boilerplate.random_url }}#reader
@@ -1,11 +1,12 @@
1
1
  ---
2
2
  _boilerplate:
3
- path: pages
3
+ path: _tabs
4
+ order: 0
4
5
 
5
6
  title: {{ boilerplate.title }}
6
7
  created: {{ boilerplate.time }}
7
8
  permalink: {{ boilerplate.slug }}
8
- layout: default
9
+ order: {{ boilerplate.order }}
9
10
  ---
10
11
 
11
12
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
@@ -4,7 +4,7 @@ _boilerplate:
4
4
  path: '_volumes'
5
5
  timestamp: false
6
6
  title: title
7
- slug: "{{ vol }}-{{ title }}.md"
7
+ slug: "{{ vol }}-{{ title }}"
8
8
 
9
9
  title: {{ boilerplate.title }}
10
10
  created: {{ boilerplate.time }}
data/_config.yml CHANGED
@@ -22,6 +22,7 @@ novel:
22
22
  title: "The Upper Crust"
23
23
  author: "John Doe"
24
24
  lang: en
25
+ start_chapter: 1
25
26
  copyright:
26
27
  short: >-
27
28
  **The Upper Crust, Vol 1**
@@ -44,10 +45,12 @@ collections:
44
45
  previews:
45
46
  sort_by: chapter
46
47
  output: true
47
- layout: chapter
48
48
  volumes:
49
49
  sort_by: volume
50
50
  output: false
51
+ tabs:
52
+ sort_by: order
53
+ output: true
51
54
 
52
55
 
53
56
  defaults:
@@ -61,10 +64,12 @@ defaults:
61
64
  values:
62
65
  layout: "preview"
63
66
  type: 'previews'
67
+ published: false
64
68
  - scope:
65
- path: "pages/*"
69
+ path: "_tabs/*"
66
70
  values:
67
71
  layout: "page"
72
+ type: 'tabs'
68
73
 
69
74
  plugins:
70
75
  - jekyll-feed
@@ -0,0 +1,5 @@
1
+ <div id="alerts" class="alerts vbox" alerts>
2
+
3
+
4
+ </div>
5
+
@@ -1,16 +1,22 @@
1
1
 
2
2
  <header scroll-nav class="hbox nav hbox:long">
3
- <h1>
4
- <a href={{site.baseurl}}>
5
- {{ site.title }}
6
- </a>
7
- </h1>
3
+ <h1>
4
+ <a href={{site.baseurl}}>
5
+ {{ site.title }}
6
+ </a>
7
+ </h1>
8
8
 
9
- <div class="hbox nav">
10
- <a href="{{'chapters' | relative_url }}">Index</a>
11
- {% if page.start_chapter %}
12
- {% assign cht1 = site.chapters | find: 'chapter', page.start_chapter %}
13
- <a class="big-link" href="{{ cht1.url }}#reader">Read</a>
14
- {% endif %}
15
- </div>
9
+ <div class="hbox nav">
10
+
11
+ {% for tab in site.tabs %}
12
+ {% unless page.path == tab.path %}
13
+ <a href="{{ tab.url }}">{{ tab.title }}</a>
14
+ {% endunless %}
15
+ {% endfor %}
16
+
17
+ {% if site.novel.start_chapter %}
18
+ {% assign cht1 = site.chapters | find: 'chapter', page.start_chapter %}
19
+ <a go-to-bookmark class="big-link" href="{{ cht1.url }}#reader">Read</a>
20
+ {% endif %}
21
+ </div>
16
22
  </header>
@@ -1,8 +1,6 @@
1
1
 
2
- <div data-page="{{ page.chapter }}" class="reader" id="reader" lang="{{ site.novel.lang }}">
2
+ <div data-page="{{ page.chapter }}" class="reader container" id="reader" lang="{{ site.novel.lang }}">
3
3
  <div class="chapter__content">
4
4
  {{ content }}
5
5
  </div>
6
6
  </div>
7
-
8
- <script src="{{ '/assets/js/bookReader.js' | relative_url }}"></script>
data/_includes/toc.html CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  <h1 id="#{{page.title | slugify }}">{{ page.title }}</h1>
3
3
 
4
- {% assign volumes = site.chapters | group_by: 'volume' %}
4
+ {% assign volumes = include.chapters | group_by: 'volume' %}
5
5
  {% for vol in volumes %}
6
6
 
7
7
  {% assign volume = site.volumes | find: 'volume', vol.name %}
@@ -7,6 +7,6 @@ layout: root
7
7
  {% include reader.html %}
8
8
 
9
9
 
10
- <div class="max-width-1">
10
+ <div class="container">
11
11
  {% include chapter_nav.html %}
12
12
  </div>
data/_layouts/home.html CHANGED
@@ -2,7 +2,7 @@
2
2
  layout: default
3
3
  ---
4
4
 
5
- <div class="reader {{ page.title | slugify}}">
5
+ <div class="reader container{{ page.title | slugify}}">
6
6
  {{ content }}
7
7
  </div>
8
8
 
data/_layouts/page.html CHANGED
@@ -2,6 +2,6 @@
2
2
  layout: default
3
3
  ---
4
4
 
5
- <div class="reader {{ page.title | slugify}}">
5
+ <div class="reader container {{ page.title | slugify}}">
6
6
  {{ content }}
7
7
  </div>
@@ -3,4 +3,12 @@ layout: root
3
3
  ---
4
4
 
5
5
  {% include header.html %}
6
+
7
+ <div class="container mt">
8
+
9
+ <button copy="{{ page.url | prepend: site.url }}">
10
+ Copy URL
11
+ </button>
12
+ </div>
13
+
6
14
  {% include reader.html %}
data/_layouts/root.html CHANGED
@@ -5,11 +5,16 @@
5
5
  </head>
6
6
  <body>
7
7
 
8
+ {% include alerts.html %}
8
9
 
9
10
  {{content}}
10
11
 
11
12
  {% include footer.html %}
12
13
 
14
+
15
+ <script src="{{ '/assets/js/bookReader.js' | relative_url }}"></script>
13
16
  <script src="{{ '/assets/js/scrollNav.js' | relative_url }}"></script>
17
+ <!-- vvv keep as last script to run vvv -->
18
+ <script src="{{ '/assets/js/CopyBtn.js' | relative_url }}"></script>
14
19
  </body>
15
20
  </html>
@@ -5,14 +5,11 @@
5
5
  @import 'web-novel/footer'
6
6
  @import 'web-novel/header'
7
7
  @import 'web-novel/scrollNav'
8
+ @import 'web-novel/alerts'
8
9
 
9
10
  \:root
10
11
  font-size: 16px
11
12
 
12
- html
13
- scroll-behavior: smooth
14
-
15
-
16
13
  .hbox
17
14
  display: grid
18
15
  grid-auto-flow: column
@@ -23,6 +20,9 @@ html
23
20
  .vbox > * + *
24
21
  margin-top: 2em
25
22
 
23
+ .vbox > *
24
+ display: block
25
+
26
26
  h1 a
27
27
  color: var(--text-main)
28
28
  text-decoration: none
@@ -42,7 +42,7 @@ h1 a
42
42
 
43
43
  margin: 1em 0
44
44
 
45
- .max-width-1
45
+ .container
46
46
  max-width: 35em
47
47
  margin: 0 auto
48
48
 
@@ -54,6 +54,11 @@ h1 a
54
54
  line-height: 1em
55
55
  margin: 1em 0
56
56
 
57
+ .mt
58
+ margin-top: 2em
59
+
60
+ button
61
+ border: solid 2px var(--text-muted, #888)
57
62
 
58
63
 
59
64
  @media only screen and (max-width: 40rem)
@@ -0,0 +1,45 @@
1
+
2
+ .alerts
3
+ font-size: 1.4rem
4
+ position: fixed
5
+ color: var(--text-bright)
6
+ right: 0
7
+ left: 0
8
+ bottom: 0
9
+ margin: 3px
10
+ max-width: 100vw
11
+ pointer-events: none
12
+
13
+ @keyframes slideOutRight
14
+ 0%
15
+ transform: translateX(0) scaleY(100%)
16
+ 90%
17
+ transform: translateX(0) scaleY(100%)
18
+ opacity: 1
19
+ 99%
20
+ transform: translateX(00%) scaleY(0%)
21
+ opacity: 0
22
+ margin-top: 2em
23
+ 100%
24
+ margin-top: 0
25
+
26
+ .alerts > *
27
+ outline: solid 1px var(--selection)
28
+ box-shadow: 0 0 20px 5px var(--background-body)
29
+ background-color: var(--button-base)
30
+ padding: .2em .6em
31
+ border-radius: 6px
32
+ transform: translateX(200%)
33
+ animation: 2s ease-in 0s slideOutRight
34
+ // transform: translateX(0)
35
+ // transition: transform 150ms ease-in 1s
36
+ // transform: translateX(200%)
37
+
38
+ @media only screen and (min-width: 40rem)
39
+ .alerts
40
+ padding-bottom: 5rem
41
+ @media only screen and (min-width: 60rem)
42
+ .alerts
43
+ left: unset
44
+ max-width: 60%
45
+ padding-right: 5rem
@@ -2,5 +2,6 @@
2
2
  body
3
3
  --background-body: #000
4
4
  --text-muted: #555
5
- // color: red
6
- // background-color: pinawk!important
5
+ --button-base: #1a2335
6
+
7
+
@@ -14,10 +14,9 @@ p
14
14
  padding-left: 1rem
15
15
  font-size: 1.8rem
16
16
  offset-anchor: 10vh
17
+ cursor: pointer
17
18
 
18
19
  .reader
19
- max-width: 35em
20
- margin: 0 auto
21
20
  padding-top: 2em
22
21
  text-align: justify
23
22
  word-break: break-word
@@ -6,3 +6,6 @@
6
6
 
7
7
  [scroll-nav=up]
8
8
  top: 0em
9
+
10
+ // html
11
+ // scroll-behavior: smooth
data/admin/config.yml CHANGED
@@ -13,9 +13,9 @@ public_folder: "/assets/uploads"
13
13
  site_url: https://example.com
14
14
 
15
15
  collections:
16
- - name: pages
16
+ - name: tabs
17
17
  label: 'Pages'
18
- folder: 'pages/'
18
+ folder: '_tabs/'
19
19
  create: false
20
20
  slug: "{{slug}}"
21
21
  summery: "{{title}}"
@@ -23,6 +23,7 @@ collections:
23
23
  preview: false
24
24
  fields:
25
25
  - { label: 'Title', name: "title", widget: 'string' }
26
+ - { label: 'Published', name: 'published', widget: 'boolean', default: true, required: false }
26
27
  - { label: 'Permalink', name: "permalink", widget: 'string', default: '/:basename/', required: false }
27
28
  - { label: 'Body', name: 'body', widget: 'markdown' }
28
29
 
@@ -36,6 +37,7 @@ collections:
36
37
  preview: false
37
38
  fields:
38
39
  - { label: 'Title', name: "title", widget: 'string' }
40
+ - { label: 'Published', name: 'published', widget: 'boolean', default: true, required: false }
39
41
  - { label: 'Chapter', name: "chapter", widget: 'number', default: 01, value_type: 'int' }
40
42
  - { label: 'Volume', name: "volume", widget: 'number', default: 01, value_type: 'int' }
41
43
  - { label: 'Permalink', name: "permalink", widget: 'string', default: '/:basename/', required: false }
@@ -51,6 +53,7 @@ collections:
51
53
  preview: false
52
54
  fields:
53
55
  - { label: 'Title', name: "title", widget: 'string' }
56
+ - { label: 'Published', name: 'published', widget: 'boolean', default: false, required: false }
54
57
  - { label: 'Chapter', name: "chapter", widget: 'number', default: 01, value_type: 'int' }
55
58
  - { label: 'Volume', name: "volume", widget: 'number', default: 01, value_type: 'int' }
56
59
  - { label: 'Permalink', name: "permalink", widget: 'string', default: '/:basename/', required: false }
@@ -0,0 +1,56 @@
1
+ class CopyBtn {
2
+ constructor(
3
+ target = '[copy]',
4
+ attr = 'copy',
5
+ fun = (t) => {
6
+ alert(CopyBtn.copyMsg(t));
7
+ return(t);
8
+ }
9
+ ) {
10
+ this.target = target;
11
+ this.field = attr;
12
+ this.fun = fun;
13
+ this.activateButtons();
14
+ }
15
+
16
+ activateButtons() {
17
+ document.querySelectorAll(this.target).forEach((b)=>{
18
+ b.addEventListener('click', (e)=>{
19
+ this.copyElementText(b);
20
+ })
21
+ })
22
+ }
23
+
24
+ copyElementText(el) {
25
+ var text = el.getAttribute(this.field);
26
+ console.log(text)
27
+ navigator.clipboard.writeText(this.fun(text, el));
28
+ }
29
+
30
+ static copyMsg(m) {
31
+ return('Copied: <code>'+m+'</code>');
32
+ }
33
+ }
34
+
35
+
36
+ // TODO: figure out how to import this vv
37
+ custom_alert_function = function(msg) {
38
+ var sp = document.createElement('span');
39
+ sp.innerHTML = msg;
40
+ document.querySelector('#alerts').appendChild(sp);
41
+ };
42
+
43
+
44
+
45
+ window.addEventListener('load', (e) => {
46
+ new CopyBtn('button[copy]', 'copy', (t) => {
47
+ custom_alert_function(CopyBtn.copyMsg(t));
48
+ return(t);
49
+ });
50
+ new CopyBtn('a[copy]', 'copy', (t)=>{
51
+ var cUrl = new URL(window.location);
52
+ cUrl.hash = t;
53
+ custom_alert_function(CopyBtn.copyMsg(cUrl));
54
+ return(cUrl);
55
+ });
56
+ });
@@ -1,18 +1,24 @@
1
1
  class BookReader {
2
- constructor (selector = '#reader', getCurrent = true) {
2
+ constructor (selector = '#reader', getCurrent = true, anchorTag = 'href') {
3
3
  this.pNodes = document.querySelectorAll(`${selector} p`);
4
4
  this.reader = document.querySelector(selector);
5
- this.pSelected = null;
6
- this.anchorParagraphs();
7
- this.scrollToAnchor();
8
- if(getCurrent){
9
- this.tackSelectedParagraph();
10
- };
5
+ this.setBookMarkLink();
6
+ if(this.reader) {
7
+ this.pSelected = null;
8
+ this.anchorTag = anchorTag;
9
+ this.anchorParagraphs();
10
+ this.scrollToAnchor();
11
+ if(getCurrent){
12
+ this.tackSelectedParagraph();
13
+ };
14
+ }
11
15
  }
12
16
 
13
17
  tackSelectedParagraph() {
14
18
  this.pNodes.forEach((p, i) => {
15
- p.addEventListener('click',(e) => this.setCurrent(p));
19
+ p.addEventListener('click',(e) => {
20
+ this.setCurrent(p)
21
+ });
16
22
  p.addEventListener('select',(e) => this.setCurrent(p));
17
23
  });
18
24
  }
@@ -33,11 +39,13 @@ class BookReader {
33
39
 
34
40
  anchorParagraphs() {
35
41
  var c = 0;
42
+ var anchorTag = this.anchorTag;
36
43
  this.pNodes.forEach(function(p){
37
44
  if(p.innerHTML.match('...')) {
38
45
  c = c+1;
39
- var a = document.createElement('a')
40
- a.setAttribute('href', `#p${c}`)
46
+ var a = document.createElement('a');
47
+ a.addEventListener('click',(e)=>{BookReader.saveBookMark(c)});
48
+ a.setAttribute(anchorTag, `#p${c}`)
41
49
  a.setAttribute('class', `anchor`)
42
50
  p.setAttribute('id', `p${c}`)
43
51
  a.innerHTML = String(c)
@@ -54,7 +62,32 @@ class BookReader {
54
62
  document.querySelector(hash).scrollIntoView()
55
63
  };
56
64
  }
65
+
66
+ static saveBookMark(id) {
67
+ var url = new URL(window.location);
68
+ url.hash = '#p'+String(id);
69
+ window.localStorage.setItem('bookmark', url.href)
70
+ custom_alert_function('Saved Bookmark')
71
+ }
72
+
73
+ setBookMarkLink() {
74
+ var bm = new URL(window.localStorage.getItem('bookmark'));
75
+ if(bm != undefined) {
76
+ document.querySelectorAll('[go-to-bookmark]').forEach((b)=>{
77
+ b.setAttribute('href', bm.href)
78
+ b.setAttribute('title', 'Bookmark: '+bm.pathname+bm.hash)
79
+ })
80
+ }
81
+ }
57
82
  }
83
+
84
+ // TODO: figure out how to import this vv
85
+ custom_alert_function = function(msg) {
86
+ var sp = document.createElement('span');
87
+ sp.innerHTML = msg;
88
+ document.querySelector('#alerts').appendChild(sp);
89
+ };
90
+
58
91
  window.addEventListener('load', (e) => {
59
- new BookReader('#reader', true);
92
+ new BookReader('#reader', true, 'copy');
60
93
  });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-web-novel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - opsaaaaa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-13 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webrick
@@ -36,20 +36,20 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '4.2'
39
+ version: '4.3'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 4.2.1
42
+ version: 4.3.0
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '4.2'
49
+ version: '4.3'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 4.2.1
52
+ version: 4.3.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: jekyll
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -103,10 +103,11 @@ files:
103
103
  - LICENSE.txt
104
104
  - README.md
105
105
  - _boilerplates/chapter.md
106
- - _boilerplates/page.md
107
106
  - _boilerplates/preview.md
107
+ - _boilerplates/tab.md
108
108
  - _boilerplates/volume.md
109
109
  - _config.yml
110
+ - _includes/alerts.html
110
111
  - _includes/chapter_header.html
111
112
  - _includes/chapter_list.html
112
113
  - _includes/chapter_nav.html
@@ -124,6 +125,7 @@ files:
124
125
  - _layouts/root.html
125
126
  - _layouts/volume.html
126
127
  - _sass/jekyll-web-novel.sass
128
+ - _sass/web-novel/alerts.sass
127
129
  - _sass/web-novel/chapter.sass
128
130
  - _sass/web-novel/colors.sass
129
131
  - _sass/web-novel/footer.sass
@@ -134,12 +136,11 @@ files:
134
136
  - admin/index.html
135
137
  - assets/404.html
136
138
  - assets/css/style.sass
139
+ - assets/js/CopyBtn.js
137
140
  - assets/js/bookReader.js
138
141
  - assets/js/forwardNetlifyIdentityToken.js
139
142
  - assets/js/scrollNav.js
140
143
  - exe/jekyll-web-novel
141
- - pages/chapters.md
142
- - pages/home.md
143
144
  homepage: https://github.com/opsaaaaa/web_novel_theme
144
145
  licenses:
145
146
  - MIT
data/pages/chapters.md DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- title: Chapters
3
- layout: page
4
- permalink: chapters
5
- start_chapter: 1
6
- ---
7
-
8
- {% include toc.html %}
9
-
data/pages/home.md DELETED
@@ -1,16 +0,0 @@
1
- ---
2
- title: Web Novel Theme for Jekyll
3
- permalink: /
4
- layout: home
5
- start_chapter: 1
6
- ---
7
-
8
- # {{ site.novel.title }}
9
-
10
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Orci porta non pulvinar neque laoreet suspendisse interdum. Ut porttitor leo a diam sollicitudin tempor id eu nisl.
11
- {: .big-text}
12
-
13
-
14
- {% assign cht1 = site.chapters | find: 'chapter', page.start_chapter %}
15
- [Read Now]({{ cht1.url | relative_url}}#reader){: .mega-link}
16
-