bridgetown_writebook 0.1.2 → 0.1.3
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/components/bridgetown_writebook/book_content.rb +8 -11
- data/components/bridgetown_writebook/book_cover.rb +17 -21
- data/components/bridgetown_writebook/book_list.rb +2 -6
- data/components/bridgetown_writebook/chapter_content.rb +8 -9
- data/components/bridgetown_writebook/chapter_list_item.rb +12 -17
- data/lib/bridgetown_writebook/version.rb +1 -1
- data/package.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88b8c7ae28fb5428c579de86efa51745635811330d85928a2cdb5825c115caf0
|
|
4
|
+
data.tar.gz: 5088b538984af2befd8dd4f0b0ea3f41036c448c8694dc2a58deee3a6007fe3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9cffab6ece98f82aeee0b9fafc78ba7f1c6b42a031d374bc90c91c3e447ec5c121dfd4aa5ad5af299a2df1d649d74a8203e37884e1c3c059fb8a95ba0ada192c
|
|
7
|
+
data.tar.gz: 2c0d4e28fc86827f3870b38e4f650e19cf802960954bb573a1a825ef4a7e9f1758eed0650f4f5083adbbb0a624345614faaa77e3b1ac8d567dd4a9651847e468
|
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
module BridgetownWritebook
|
|
4
4
|
class BookContent < Bridgetown::Component
|
|
5
5
|
def initialize(book:)
|
|
6
|
-
super
|
|
6
|
+
super()
|
|
7
7
|
@book = book
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def template
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
text_node chapters_list.join
|
|
19
|
-
end
|
|
20
|
-
end
|
|
11
|
+
data_attrs = [
|
|
12
|
+
'data-controller="bookmark"',
|
|
13
|
+
'data-bookmark-chapter-outlet=".chapter"',
|
|
14
|
+
"data-bookmark-book-value=\"#{@book.id}\"",
|
|
15
|
+
].join(" ")
|
|
16
|
+
|
|
17
|
+
"<ul class=\"book-content-list\" #{data_attrs}>#{chapters_list}</ul>"
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
def chapters_list
|
|
@@ -5,21 +5,22 @@ module BridgetownWritebook
|
|
|
5
5
|
attr_accessor :book
|
|
6
6
|
|
|
7
7
|
def initialize(book:)
|
|
8
|
-
super
|
|
8
|
+
super()
|
|
9
9
|
@book = book
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def template
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
data_attrs = cover_data_attributes.map do |k, v|
|
|
14
|
+
%(data-#{k.to_s.tr("_", "-")}="#{v}")
|
|
15
|
+
end.join(" ")
|
|
16
|
+
|
|
17
|
+
link_inner = [
|
|
18
|
+
render_cover_image,
|
|
19
|
+
render_book_title,
|
|
20
|
+
render_book_authors,
|
|
21
|
+
].join
|
|
22
|
+
|
|
23
|
+
"<li class=\"book-cover-item\" #{data_attrs}><a class=\"book-cover-link\" href=\"#{book.link}\">#{link_inner}</a></li>"
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
private
|
|
@@ -34,22 +35,17 @@ module BridgetownWritebook
|
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def render_cover_image
|
|
37
|
-
div class
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end
|
|
38
|
+
'<div class="book-cover-image-wrapper" data-book-target="cover">' \
|
|
39
|
+
+ "<img src=\"#{book.cover}\" class=\"book-cover-image\" />" \
|
|
40
|
+
+ "</div>"
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def render_book_title
|
|
44
|
-
div class
|
|
45
|
-
text_node book.name
|
|
46
|
-
end
|
|
44
|
+
"<div class=\"book-cover-title\">#{book.name}</div>"
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
def render_book_authors
|
|
50
|
-
div class
|
|
51
|
-
text_node book.authors
|
|
52
|
-
end
|
|
48
|
+
"<div class=\"book-cover-authors\">#{book.authors}</div>"
|
|
53
49
|
end
|
|
54
50
|
end
|
|
55
51
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module BridgetownWritebook
|
|
4
4
|
class BookList < Bridgetown::Component
|
|
5
5
|
def initialize(books:)
|
|
6
|
-
super
|
|
6
|
+
super()
|
|
7
7
|
@books = books
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -12,11 +12,7 @@ module BridgetownWritebook
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def template
|
|
15
|
-
|
|
16
|
-
ul class: "book-list" do
|
|
17
|
-
text_node book_covers
|
|
18
|
-
end
|
|
19
|
-
end
|
|
15
|
+
"<ul class=\"book-list\">#{book_covers}</ul>"
|
|
20
16
|
end
|
|
21
17
|
end
|
|
22
18
|
end
|
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
module BridgetownWritebook
|
|
4
4
|
class ChapterContent < Bridgetown::Component
|
|
5
5
|
def initialize(chapter:)
|
|
6
|
-
super
|
|
6
|
+
super()
|
|
7
7
|
@chapter = chapter
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def template
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
11
|
+
data_attrs = [
|
|
12
|
+
'data-controller="reading"',
|
|
13
|
+
"data-reading-id-value=\"#{@chapter.id}\"",
|
|
14
|
+
"data-reading-book-value=\"#{@chapter.book.id}\"",
|
|
15
|
+
].join(" ")
|
|
16
|
+
|
|
17
|
+
"#{@chapter.resource.content}<div #{data_attrs}></div>"
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
end
|
|
@@ -5,27 +5,22 @@ module BridgetownWritebook
|
|
|
5
5
|
attr_accessor :chapter
|
|
6
6
|
|
|
7
7
|
def initialize(chapter:)
|
|
8
|
-
super
|
|
8
|
+
super()
|
|
9
9
|
@chapter = chapter
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def template
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
span class: "chapter-word-count" do
|
|
25
|
-
text_node chapter.word_count
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
13
|
+
data_attrs = [
|
|
14
|
+
'data-controller="chapter"',
|
|
15
|
+
"data-chapter-id-value=\"#{chapter.id}\"",
|
|
16
|
+
'data-chapter-ellipsis-class="chapter-highlight"',
|
|
17
|
+
].join(" ")
|
|
18
|
+
|
|
19
|
+
link = "<a class=\"chapter-link\" href=\"#{chapter.link}\">#{chapter.title}</a>"
|
|
20
|
+
ellipsis = '<span class="chapter-ellipsis" data-chapter-target="ellipsis"></span>'
|
|
21
|
+
word_count = "<span class=\"chapter-word-count\">#{chapter.word_count}</span>"
|
|
22
|
+
|
|
23
|
+
"<li class=\"chapter\" #{data_attrs}>#{link}#{ellipsis}#{word_count}</li>"
|
|
29
24
|
end
|
|
30
25
|
end
|
|
31
26
|
end
|
data/package.json
CHANGED