bridgetown_writebook 0.1.0.1 → 0.1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ecde4cf7c2246af31a117f402935e342064314ab25f9ce3c38c50520682a769
4
- data.tar.gz: 78fcd4f3b88571eb92f8953c627b01bb19a17145d0b94251955dfd46462213c2
3
+ metadata.gz: c06a57adfb0a777881b47fb84f7c717c6c0439f0b0ec6001581d7ef9b8b72751
4
+ data.tar.gz: afe0547db9d8f408168a4c5afdbc5e135e25f9dbe5134c8061736bca81486bc4
5
5
  SHA512:
6
- metadata.gz: dcd86b0250d74ca12824716bac756083d46e1990b4fd86e698c35928a1250f32d955048d07bf074b2dac8176a7f91621e3797f5b60a66e86c49d7535fa9f1f58
7
- data.tar.gz: 391edeb2c0e1dc1b5502da043b23df3ea71f7db0570b3b1dddeb71cb71041b37d2493a6324768a7200a06e5556805fcdec0e48d569816c878e8e761c6461b4e4
6
+ metadata.gz: 31b8f3e13fe8ab9de5f8fc5aaf4b7d9377b67a0e8e87160fda7eb264036422e00572704b30d3161d399e0192bb75a198aaaef66a2253c926106928b7e34e616d
7
+ data.tar.gz: a628df1c6cf3cd0c27b4d6ea32abe5d7e2ea076f6d2d3eacbec2b3a1b6db71106c31edaa4682e4f97d971f6f7643decdec38dc2a40d0b07791f767f677cd8d92
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
@@ -0,0 +1,111 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="jdk" jdkName="asdf: 3.3.3" jdkType="RUBY_SDK" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v7.2.2.2, asdf: 3.3.3) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.2.2.2, asdf: 3.3.3) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.7, asdf: 3.3.3) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="amazing_print (v1.8.1, asdf: 3.3.3) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="ansi (v1.5.0, asdf: 3.3.3) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, asdf: 3.3.3) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="base64 (v0.3.0, asdf: 3.3.3) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="benchmark (v0.4.1, asdf: 3.3.3) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.2.2, asdf: 3.3.3) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="bridgetown (v1.3.4, asdf: 3.3.3) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="bridgetown-builder (v1.3.4, asdf: 3.3.3) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="bridgetown-core (v1.3.4, asdf: 3.3.3) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="bridgetown-paginate (v1.3.4, asdf: 3.3.3) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.3.0, asdf: 3.3.3) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.7.1, asdf: 3.3.3) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="colorator (v1.1.0, asdf: 3.3.3) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.3.5, asdf: 3.3.3) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.5.3, asdf: 3.3.3) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="csv (v3.3.5, asdf: 3.3.3) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="drb (v2.2.3, asdf: 3.3.3) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="erubi (v1.13.1, asdf: 3.3.3) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="faraday (v2.13.4, asdf: 3.3.3) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="faraday-follow_redirects (v0.3.0, asdf: 3.3.3) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v3.4.1, asdf: 3.3.3) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.17.2, asdf: 3.3.3) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="hash_with_dot_access (v1.2.0, asdf: 3.3.3) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.7, asdf: 3.3.3) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.13.2, asdf: 3.3.3) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="kramdown (v2.5.1, asdf: 3.3.3) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="kramdown-parser-gfm (v1.1.0, asdf: 3.3.3) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.5, asdf: 3.3.3) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, asdf: 3.3.3) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="liquid (v5.4.0, asdf: 3.3.3) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="listen (v3.9.0, asdf: 3.3.3) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="logger (v1.7.0, asdf: 3.3.3) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.25.5, asdf: 3.3.3) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="minitest-profile (v0.0.2, asdf: 3.3.3) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="minitest-reporters (v1.7.1, asdf: 3.3.3) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="net-http (v0.6.0, asdf: 3.3.3) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.27.0, asdf: 3.3.3) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.3.9.0, asdf: 3.3.3) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="prism (v1.4.0, asdf: 3.3.3) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v6.0.2, asdf: 3.3.3) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, asdf: 3.3.3) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="rack (v3.2.0, asdf: 3.3.3) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, asdf: 3.3.3) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.3.0, asdf: 3.3.3) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.11.2, asdf: 3.3.3) [gem]" level="application" />
58
+ <orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.11.1, asdf: 3.3.3) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.11.2, asdf: 3.3.3) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.4.2, asdf: 3.3.3) [gem]" level="application" />
61
+ <orderEntry type="library" scope="PROVIDED" name="roda (v3.95.0, asdf: 3.3.3) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="rouge (v4.6.0, asdf: 3.3.3) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.80.0, asdf: 3.3.3) [gem]" level="application" />
64
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.46.0, asdf: 3.3.3) [gem]" level="application" />
65
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-bridgetown (v0.6.1, asdf: 3.3.3) [gem]" level="application" />
66
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.25.0, asdf: 3.3.3) [gem]" level="application" />
67
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, asdf: 3.3.3) [gem]" level="application" />
68
+ <orderEntry type="library" scope="PROVIDED" name="securerandom (v0.4.1, asdf: 3.3.3) [gem]" level="application" />
69
+ <orderEntry type="library" scope="PROVIDED" name="serbea (v1.0.1, asdf: 3.3.3) [gem]" level="application" />
70
+ <orderEntry type="library" scope="PROVIDED" name="thor (v1.4.0, asdf: 3.3.3) [gem]" level="application" />
71
+ <orderEntry type="library" scope="PROVIDED" name="tilt (v2.6.1, asdf: 3.3.3) [gem]" level="application" />
72
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, asdf: 3.3.3) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.1.5, asdf: 3.3.3) [gem]" level="application" />
74
+ <orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.0.4, asdf: 3.3.3) [gem]" level="application" />
75
+ <orderEntry type="library" scope="PROVIDED" name="uri (v1.0.3, asdf: 3.3.3) [gem]" level="application" />
76
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.7.3, asdf: 3.3.3) [gem]" level="application" />
77
+ </component>
78
+ <component name="RakeTasksCache-v2">
79
+ <option name="myRootTask">
80
+ <RakeTaskImpl id="rake">
81
+ <subtasks>
82
+ <RakeTaskImpl description="Build bridgetown_writebook-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
83
+ <RakeTaskImpl id="build">
84
+ <subtasks>
85
+ <RakeTaskImpl description="Generate SHA512 checksum of bridgetown_writebook-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
86
+ </subtasks>
87
+ </RakeTaskImpl>
88
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
89
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
90
+ <RakeTaskImpl description="Build and install bridgetown_writebook-0.1.0.gem into system gems" fullCommand="install" id="install" />
91
+ <RakeTaskImpl id="install">
92
+ <subtasks>
93
+ <RakeTaskImpl description="Build and install bridgetown_writebook-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
94
+ </subtasks>
95
+ </RakeTaskImpl>
96
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push bridgetown_writebook-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
97
+ <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
98
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
99
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
100
+ <RakeTaskImpl id="release">
101
+ <subtasks>
102
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
103
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
104
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
105
+ </subtasks>
106
+ </RakeTaskImpl>
107
+ </subtasks>
108
+ </RakeTaskImpl>
109
+ </option>
110
+ </component>
111
+ </module>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/bridgetown_writebook.iml" filepath="$PROJECT_DIR$/.idea/bridgetown_writebook.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
6
+ </component>
7
+ </project>
@@ -50,8 +50,27 @@
50
50
  #
51
51
  # Read the Automations documentation: https://www.bridgetownrb.com/docs/automations
52
52
 
53
- append_to_file "config/boot.rb" do
53
+ if File.exist?("config/boot.rb")
54
+ append_to_file "config/boot.rb" do
55
+ <<~RUBY
56
+
57
+ require "bridgetown_writebook/commands"
58
+ RUBY
59
+ end
60
+ else
61
+ create_file "config/boot.rb" do
62
+ <<~RUBY
63
+ # frozen_string_literal: true
64
+
65
+ require "bridgetown_writebook/commands"
66
+ RUBY
67
+ end
68
+ end
69
+
70
+ create_file "config/boot.rb" do
54
71
  <<~RUBY
55
- require 'bridgetown_writebook/commands'
56
- RUBY
72
+ # frozen_string_literal: true
73
+
74
+ require "bridgetown_writebook/commands"
75
+ RUBY
57
76
  end
@@ -6,6 +6,13 @@ require_relative "chapter"
6
6
  module BridgetownWritebook
7
7
  module Commands
8
8
  class Book < Thor
9
+ include Bridgetown::Commands::ConfigurationOverridable
10
+
11
+ Bridgetown::Commands::Registrations.register do
12
+ desc "book <command>", "Take me to the book"
13
+ subcommand "book", Book
14
+ end
15
+
9
16
  desc "setup", "Setup folders and files for books"
10
17
  def setup
11
18
  create_books_folder
@@ -64,8 +64,8 @@ module BridgetownWritebook
64
64
 
65
65
  def content
66
66
  <<~HTML
67
- <ul class="pl-0" data-controller="bookmark" data-bookmark-chapter-outlet='.chapter' data-bookmark-book-value="#{text id}">
68
- #{html chapters.map do |chapter|
67
+ <ul class="pl-0" data-controller="bookmark" data-bookmark-chapter-outlet='.chapter' data-bookmark-book-value="#{id}">
68
+ #{chapters.map do |chapter|
69
69
  li chapter
70
70
  end.join }
71
71
  </ul>
@@ -78,12 +78,12 @@ module BridgetownWritebook
78
78
  <<~HTML
79
79
  <li class='chapter flex justify-between items-end gap-4'
80
80
  data-controller='chapter'
81
- data-chapter-id-value='#{text chapter.id}'
81
+ data-chapter-id-value='#{chapter.id}'
82
82
  data-chapter-ellipsis-class="text-orange-500"
83
83
  >
84
- <a href='#{text chapter.link}' class="text-nowrap">#{text chapter.title}</a>
84
+ <a href='#{chapter.link}' class="text-nowrap">#{chapter.title}</a>
85
85
  <span class="grow overflow-hidden border-b border-dotted border-black mb-1.5" data-chapter-target="ellipsis"></span>
86
- <span class="text-nowrap">#{text chapter.word_count}</span>
86
+ <span class="text-nowrap">#{chapter.word_count}</span>
87
87
  </li>
88
88
  HTML
89
89
  end
@@ -52,8 +52,8 @@ module BridgetownWritebook
52
52
  resource.content = <<~HTML
53
53
  #{html resource.content}
54
54
  <div data-controller="reading"
55
- data-reading-id-value="#{text id}"
56
- data-reading-book-value="#{text book.id}">
55
+ data-reading-id-value="#{id}"
56
+ data-reading-book-value="#{book.id}">
57
57
  </div>
58
58
  HTML
59
59
  end
@@ -0,0 +1,63 @@
1
+ require 'active_support/core_ext/numeric/conversions'
2
+
3
+ # frozen_string_literal: true
4
+ class Builders::Books < SiteBuilder
5
+ def initialize(name = nil, current_site = nil)
6
+ super
7
+ @books = []
8
+ end
9
+
10
+ def build
11
+ generator do
12
+ create_book_objects
13
+ generate_books
14
+ generate_index_page_for_books
15
+ end
16
+ end
17
+
18
+ def generate_index_page_for_books
19
+ books = @books
20
+ book_covers = books.map { |book| cover_for(book) }.join
21
+ add_resource nil, "books.md" do
22
+ layout "default"
23
+ permalink "/books/"
24
+ content <<-HTML
25
+ <ul class="list-none flex justify-center sm:grid sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-y-6 py-10 px-0 flex-wrap">
26
+ #{book_covers}
27
+ </ul>
28
+ HTML
29
+ end
30
+ end
31
+
32
+ def cover_for(book)
33
+ chapters_json = book.chapter_ids.to_json.gsub('"', '&quot;')
34
+
35
+ <<-HTML
36
+ <li data-controller="book" data-book-id-value="#{book.id}" data-book-chapters-value="#{chapters_json}" >
37
+ <a class="flex flex-col gap-2 max-w-[236px]" href="#{book.link}">
38
+ <div class="max-h-[378px] border rounded relative box-border" data-book-target="cover">
39
+ <img src="#{book.cover}" class="max-h-[378px] max-w-[236px] rounded">
40
+ </div>
41
+ <div class="text-center">#{book.name}</div>
42
+ <div class="text-sm text-center">#{book.authors}</div>
43
+ </a>
44
+ </li>
45
+ HTML
46
+ end
47
+
48
+ def create_book_objects
49
+ site.collections.books.resources
50
+ .group_by { |b| b.id.split("_books/").last.split("/").first }
51
+ .each do |book_id, chapters|
52
+ meta_file = chapters.find { |c| c.relative_path.to_s.end_with?('00-meta.md') }
53
+ regular_chapters = chapters.reject { |c| c.relative_path.to_s.end_with?('00-meta.md') }
54
+
55
+ resource = add_resource(:book, "books/#{book_id}.md") { permalink "/books/:slug/" }
56
+ @books << Book.new(resource, chapters: regular_chapters, meta: meta_file)
57
+ end
58
+ end
59
+
60
+ def generate_books
61
+ @books.each(&:generate)
62
+ end
63
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BridgetownWritebook
4
- VERSION = "0.1.0.1"
4
+ VERSION = "0.1.0.3"
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "bridgetown"
4
4
  require "bridgetown_writebook/builder"
5
- require_relative "bridgetown_writebook/commands"
5
+ require_relative "bridgetown_writebook/commands/book"
6
6
 
7
7
  # @param config [Bridgetown::Configuration::ConfigurationDSL]
8
8
  Bridgetown.initializer :bridgetown_writebook do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown_writebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: 0.1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
@@ -80,6 +80,10 @@ extra_rdoc_files: []
80
80
  files:
81
81
  - ".github/workflows/tests.yml"
82
82
  - ".gitignore"
83
+ - ".idea/.gitignore"
84
+ - ".idea/bridgetown_writebook.iml"
85
+ - ".idea/modules.xml"
86
+ - ".idea/vcs.xml"
83
87
  - ".rubocop.yml"
84
88
  - CHANGELOG.md
85
89
  - Gemfile
@@ -95,11 +99,11 @@ files:
95
99
  - layouts/bridgetown_writebook/layout.html
96
100
  - lib/bridgetown_writebook.rb
97
101
  - lib/bridgetown_writebook/builder.rb
98
- - lib/bridgetown_writebook/commands.rb
99
102
  - lib/bridgetown_writebook/commands/book.rb
100
103
  - lib/bridgetown_writebook/commands/chapter.rb
101
104
  - lib/bridgetown_writebook/models/book.rb
102
105
  - lib/bridgetown_writebook/models/chapter.rb
106
+ - lib/bridgetown_writebook/models/something.rb
103
107
  - lib/bridgetown_writebook/version.rb
104
108
  - package.json
105
109
  homepage: https://github.com/username/bridgetown_writebook
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_all "bridgetown-core/commands/concerns"
4
- require "commands/book"
5
-
6
- module BridgetownWritebook
7
- class Commands
8
- include Bridgetown::Commands::ConfigurationOverridable
9
-
10
- Bridgetown::Commands::Registrations.register do
11
- desc "book <command>", "Take me to the book"
12
- subcommand "book", Book
13
- end
14
- end
15
- end