Skip to content

Commit

Permalink
Добавлена поддержка формата FB2
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganov committed Jan 28, 2023
1 parent 445ba51 commit 86410db
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release from master
on:
push:
branches: [ master ]

workflow_dispatch:

jobs:
Expand All @@ -28,14 +28,14 @@ jobs:
with:
ruby-version: 2.7
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Build release assets
run: bundle exec rake book:build

- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.compute-tag.outputs.tagname }}
commit: master
artifacts: './progit.epub,./progit.mobi,./progit.pdf,./progit.html'
artifacts: './progit.epub,./progit.fb2.zip,./progit.mobi,./progit.pdf,./progit.html'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Gemfile.lock
*.pdf
*.pdfmarks
*.epub
*.fb2.zip
*-kf8.epub
*.mobi
contributors.txt
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'asciidoctor', '2.0.17'
gem 'json', '2.6.2'
gem 'awesome_print', '1.9.2'

gem 'asciidoctor-fb2', '0.7.0'
gem 'asciidoctor-epub3', '1.5.1'
gem 'asciidoctor-pdf', '2.0.8'

Expand Down
10 changes: 9 additions & 1 deletion README.asc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Converting to HTML...
-- HTML output at progit.html
Converting to EPUB...
-- EPUB output at progit.epub
Converting to FB2...
-- FB2 output at progit.fb2.zip
Converting to Mobi (kf8)...
-- Mobi output at progit.mobi
Converting to PDF...
Expand All @@ -63,7 +65,7 @@ Messages: 0 fatals / 0 errors / 0 warnings / 0 infos
EPUBCheck completed
----

Здесь используются проекты `asciidoctor`, `asciidoctor-pdf` и `asciidoctor-epub`.
Здесь используются проекты `asciidoctor`, `asciidoctor-pdf`, `asciidoctor-fb2` и `asciidoctor-epub`.

По умолчанию, `bundle install` устанавливает зависимости глобально в систему.
Чтобы этого избежать, в примере выше менеджер пакетов дополнительно конфигурируется перед установкой зависимостей с помощью следующей команды:
Expand All @@ -86,6 +88,12 @@ bundle exec rake book:build_html
bundle exec rake book:build_epub
----

Для генерации только FB2 файла:

----
bundle exec rake book:build_fb2
----

Для генерации только PDF файла:

----
Expand Down
13 changes: 11 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace :book do

# Tasks list
desc 'build basic book formats'
task :build => [:build_html, :build_epub, :build_mobi, :build_pdf] do
task :build => [:build_html, :build_epub, :build_fb2, :build_mobi, :build_pdf] do
begin
puts 'Validating generated files...'
Rake::Task['book:check'].invoke
Expand Down Expand Up @@ -72,6 +72,15 @@ namespace :book do
puts ' -- EPUB output at progit.epub'
end

desc 'build FB2 format'
task :build_fb2 do
Rake::Task['book:prebuild'].invoke(96)

puts 'Converting to FB2...'
`bundle exec asciidoctor-fb2 #{params} progit.asc`
puts ' -- FB2 output at progit.fb2.zip'
end

desc 'build Mobi format'
task :build_mobi do
Rake::Task['book:prebuild'].invoke(96)
Expand Down Expand Up @@ -118,7 +127,7 @@ namespace :book do
begin
puts 'Removing downloaded and generated files'

FileList[locale_file, 'book/contributors.txt', 'progit.html', 'progit.epub', 'progit.pdf', 'progit.mobi'].each do |file|
FileList[locale_file, 'book/contributors.txt', 'progit.html', 'progit.epub', 'progit.fb2.zip' 'progit.pdf', 'progit.mobi'].each do |file|
rm file
rescue Errno::ENOENT
end
Expand Down

0 comments on commit 86410db

Please sign in to comment.