Commit 55a62a93 authored by charlie-ablett's avatar charlie-ablett
Browse files

Add PDFTK generic step, add command templates to description, update README

parent 69cd6823
......@@ -5,53 +5,47 @@ This is a step gem that is meant to run as a plugin for [the Ink API](https://gi
This gem includes a couple of ways to do conversion, each of which has its own step class.
## Convert Docx to HTML via Pandoc
## Pandoc conversion steps
DocxToHtmlPandoc requires Pandoc to be installed on the host machine for it to run properly.
The steps require Pandoc to be installed on the host machine for them to run properly.
Installation: http://pandoc.org/installing.html
Usage directions and options (lots): http://pandoc.org/getting-started.html
## Convert to Epub via Calibre
## Calibre conversion steps
This step converts a HTML file to .epub via Calibre. Calibre must be installed before it will work.
Calibre must be installed before these steps will work.
Installation: https://calibre-ebook.com/download
Usage directions and options (lots): https://manual.calibre-ebook.com/generated/en/ebook-convert.html
Usage directions and options (lots): https://manual.calibre-ebook.com/generated/en/ebook-convert.html
## Mogrify conversion step
## XSweet XSL pipeline
The XSweet steps all use [Coko's Docx to HTML XSL sheets](https://gitlab.coko.foundation/wendell/XSweet/tree/ink-api-publish). The step will download and run the latest in the `ink-api-production` branch. The steps are all meant to be run in sequence.
### DocxToHtmlExtractStep
On Ubuntu, use `mogrify` instead of `magick`
https://www.imagemagick.org/script/command-line-processing.php
Extracts from Docx to HTML
## PDFTK conversion step
### HandleNotesStep
PDFTK Server installation:
Prunes orphan references and unreferenced footnotes.
https://www.pdflabs.com/tools/pdftk-server/
### ScrubStep
https://packages.ubuntu.com/xenial/pdftk
Removes superfluous content tags (e.g. `<p></p>`)
Man page: https://www.pdflabs.com/docs/pdftk-man-page/
### JoinElementsStep
## HTML Tidy conversion step
Joins element tags with identical `<span>` element types and attributes (e.g. `<span>H</span><span>i</span>` becomes `<span>Hi</span>`)
HTML Tidy installation: http://www.html-tidy.org/
### ZorbaMapStep
## XSweet XSL pipeline
Detects headers.
The XSweet steps all use [Coko's Docx to HTML XSL sheets](https://gitlab.coko.foundation/wendell/XSweet/tree/ink-api-publish). The step will download and run the latest in the `ink-api-production` branch. The steps are all meant to be run in sequence.
## Vivliostyle and WkHtmlToPdf
If you want to run the PDF conversion steps, you'll need to get one or both of the following up and running on your INK server:
- Vivliostyle
- wkhtmltopdf
Directions for these forthcoming.
Charlie Ablett
Collaborative Knowledge Foundation
......
......@@ -22,7 +22,7 @@ module InkStep::Coko
end
def self.description
"Converts target file via Calibre - generic step, customisable"
"Generic Calibre converter - template: ebook-convert <input file> <output file> <options>"
end
def self.human_readable_name
......
......@@ -17,7 +17,7 @@ module InkStep::Coko
end
def self.description
"Runs ImageMagick's Mogrify terminal command against an image file. The input file is modified."
"Runs ImageMagick's Mogrify terminal command against an image file. The input file is modified. Template: mogrify <options> <input file> <output file>"
end
def self.human_readable_name
......
......@@ -20,7 +20,7 @@ module InkStep::Coko
end
def self.description
"Converts target file via pandoc (input and output are specified via parameters)"
"Converts target file via pandoc. Template: pandoc <input file> -f <input format> -t <output format> -s -o <output file>"
end
def self.human_readable_name
......
require 'coko_conversion/version'
require 'ink_step/conversion_step'
module InkStep::Coko
class CalibreConversionStep < InkStep::ConversionStep
def perform_step
source_file_path = find_source_file(regex: /\.#{parameter(:input_file_format)}$/)
perform_pdftk_conversion(File.join(working_directory, source_file_path))
success!
end
def version
CokoConversion::VERSION
end
def self.description
"PdfTK converter - template: pdftk <input file> <options>"
end
def self.human_readable_name
"Generic PdfTK converter"
end
def required_parameters
# e.g. [:foo, :bar]
[:options]
end
def accepted_parameters
# e.g. {foo: "For setting the grobblegronx measure", bar: "Can be X, Y or Z"}
{
options: "Any options for the conversion (see https://www.pdflabs.com/docs/pdftk-cli-examples/)"
}
end
def default_parameter_values
# e.g. {foo: 1, bar: nil}
{options: ""}
end
private
def perform_pdftk_conversion(source_file_path)
# see readme for more info about usage
# pdftk input_file <options>
command = "pdftk #{source_file_path} #{parameter(:options)}"
perform_command(command: command, error_prefix: "Error running pdftk")
end
end
end
\ No newline at end of file
......@@ -16,7 +16,7 @@ module InkStep::Coko
end
def self.description
"Runs HTML Tidy terminal command against an HTML file. The input file is modified."
"Runs HTML Tidy terminal command against an HTML file. Template: tidy -m <input file> <options>"
end
def self.human_readable_name
......
......@@ -15,7 +15,7 @@ module InkStep::Coko
end
def self.description
"Runs vivliostyle conversion html to pdf"
"Runs vivliostyle conversion html to pdf. Template: vivliostyle-electron <input file> -o <output file>"
end
def self.human_readable_name
......@@ -54,26 +54,20 @@ module InkStep::Coko
end
def set_xvfb_variable_command(key, value)
command = "export #{key}='#{value}'"
# perform_command(command: command, error_prefix: "error setting Xvfb variable")
"export #{key}='#{value}'"
end
def run_xvfb_command
# Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
command = "Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1" #removed & to make it wait
# perform_command(command: command, print_out: true, error_prefix: "error running Xvfb")
"Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1" #removed & to make it wait
end
def vivliostyle_command(source_file_path, destination_file_path)
# see readme for more information about usage
# vivliostyle-electron input.html -o output.pdf
command = "vivliostyle-electron #{source_file_path} -o #{destination_file_path}"
# perform_command(command: command, error_prefix: "Error running vivliostyle")
"vivliostyle-electron #{source_file_path} -o #{destination_file_path}"
end
end
end
\ No newline at end of file
......@@ -19,7 +19,7 @@ module InkStep::Coko
end
def self.description
"Runs wkhtmltopdf conversion html to pdf"
"Runs wkhtmltopdf conversion html to pdf. Template: wkthtmltopdf <input file> <output file>"
end
def self.human_readable_name
......
module CokoConversion
VERSION = '1.0.3'
VERSION = '1.0.4'
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment