Commit 11f5d06a authored by charlie-ablett's avatar charlie-ablett
Browse files

Add Human Readable Name. Update tests to reflect InkStep changes. Move Zip Methods to InkStep

parent 62d7238e
GIT
remote: https://gitlab.coko.foundation/INK/ink-step.git
revision: 7920763ad5bc41a4dc483bb58103ca86843d2df4
revision: c0dcc1a38e16b49ea5d66f7eb988fbb96079b156
specs:
ink_step (1.2.0)
ink_step (1.3.0)
awesome_print
httparty
rubyzip
......@@ -10,7 +10,7 @@ GIT
PATH
remote: .
specs:
inkstep_coko_conversion (1.0.0)
inkstep_coko_conversion (1.0.2)
GEM
remote: https://rubygems.org/
......
......@@ -22,7 +22,11 @@ module InkStep::Coko
end
def self.description
"Converts target .html file to .epub"
"Converts target file via Calibre - generic step, customisable"
end
def self.human_readable_name
"Generic Calibre converter"
end
def required_parameters
......
......@@ -10,7 +10,7 @@ module InkStep::Coko
output_file_path = File.join(working_directory, "#{source_file_name}.epub")
perform_epub_conversion(File.join(working_directory, source_file_path), output_file_path)
@successful = true
success!
end
def version
......@@ -21,6 +21,10 @@ module InkStep::Coko
"Converts target .html file to .epub"
end
def self.human_readable_name
"Calibre HTML to EPUB converter"
end
def required_parameters
# e.g. [:foo, :bar]
[]
......
require 'coko_conversion/version'
require 'ink_step/conversion_step'
module InkStep::Coko
class MogrifyConversionStep < InkStep::ConversionStep
def perform_step
source_file_path = find_source_file(regex: /\.jpg$/)
perform_conversion(File.join(working_directory, source_file_path))
@successful = true
end
def version
CokoConversion::VERSION
end
def self.description
"Runs ImageMagick's Mogrify terminal command against an image file. The input file is modified."
end
def self.human_readable_name
"Generic Mogrify 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.imagemagick.org/script/mogrify.php)"
}
end
def default_parameter_values
# e.g. {foo: 1, bar: nil}
{options: ""}
end
private
def perform_conversion(source_file_path)
# Modifies the supplied image file
# magick mogrify -resize 50% rose.jpg
# ubuntu doesn't need the 'magick' bit
command = "mogrify #{parameter(:options)} -m #{source_file_path}"
log_as_step "running #{command}"
perform_command(command: command, error_prefix: "Error running mogrify")
end
end
end
\ No newline at end of file
......@@ -23,6 +23,10 @@ module InkStep::Coko
"Converts target file via pandoc (input and output are specified via parameters)"
end
def self.human_readable_name
"Generic Pandoc Converter"
end
def required_parameters
# e.g. [:foo, :bar]
[:output_format, :input_format]
......
......@@ -14,6 +14,10 @@ module InkStep::Coko
CokoConversion::VERSION
end
def self.human_readable_name
"Pandoc Docx to HTML converter"
end
def self.description
"Converts target .docx file to .html using pandoc"
end
......
......@@ -18,6 +18,10 @@ module InkStep::Coko
"Converts target .epub file to .html via Pandoc"
end
def self.human_readable_name
"Pandoc Epub to HTML converter"
end
def version
CokoConversion::VERSION
end
......
......@@ -18,6 +18,10 @@ module InkStep::Coko
CokoConversion::VERSION
end
def self.human_readable_name
"Pandoc Epub to ICML converter"
end
def default_parameter_values
# e.g. {foo: 1, bar: nil}
{
......
require 'coko_conversion/version'
require 'ink_step/conversion_step'
module InkStep::Coko
class TidyConversionStep < InkStep::ConversionStep
def perform_step
source_file_path = find_source_file(regex: /\.html$/)
perform_conversion(File.join(working_directory, source_file_path))
@successful = true
end
def version
CokoConversion::VERSION
end
def self.description
"Runs HTML Tidy terminal command against an HTML file. The input file is modified."
end
def self.human_readable_name
"Generic HTML Tidy 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 http://www.html-tidy.org/documentation/)"
}
end
def default_parameter_values
# e.g. {foo: 1, bar: nil}
{options: ""}
end
private
def perform_conversion(source_file_path)
# see readme for more info about usage
# Modifies the supplied html file
# tidy -m index.html
command = "tidy -m #{source_file_path} #{parameter(:options)} "
log_as_step "running #{command}"
perform_command(command: command, error_prefix: "Error running tidy")
end
end
end
\ No newline at end of file
......@@ -18,6 +18,10 @@ module InkStep::Coko
"Runs vivliostyle conversion html to pdf"
end
def self.human_readable_name
"Vivliostyle HTML to PDF converter"
end
def version
CokoConversion::VERSION
end
......
......@@ -22,6 +22,10 @@ module InkStep::Coko
"Runs wkhtmltopdf conversion html to pdf"
end
def self.human_readable_name
"wkhtmltopdf HTML to PDF converter"
end
def required_parameters
# e.g. [:foo, :bar]
[]
......
......@@ -17,6 +17,10 @@ module InkStep::Coko
def self.description
"Identifies headers by font size"
end
def self.human_readable_name
"Xsweet Paragraph Collapser"
end
end
end
end
......
......@@ -14,6 +14,10 @@ module InkStep::Coko
"Extracts content from a .docx file to a HTML Typescript-conforming .html file"
end
def self.human_readable_name
"Xsweet Docx to HTML Extractor"
end
def remote_xsl_location
"https://gitlab.coko.foundation/wendell/XSweet/raw/ink-api-publish/applications/docx-extract/docx-html-extract.xsl"
end
......
......@@ -17,6 +17,10 @@ module InkStep::Coko
def self.description
"Rearranges and cleans up footnotes. Lines up all the links and renumbers them in case they are out of order."
end
def self.human_readable_name
"Xsweet Notes Handler"
end
end
end
end
......
......@@ -17,6 +17,10 @@ module InkStep::Coko
def self.description
"Joins identical elements (e.g. <span>the </span><span>fish</span> => <span>the fish</span>)"
end
def self.human_readable_name
"Xsweet Elements Joiner"
end
end
end
end
......
......@@ -14,6 +14,10 @@ module InkStep::Coko
"Removes superfluous elements (e.g. <i/>)"
end
def self.human_readable_name
"Xsweet Scrubber"
end
def remote_xsl_location
"https://gitlab.coko.foundation/wendell/XSweet/raw/ink-api-publish/applications/docx-extract/scrub.xsl"
end
......
require 'ink_step/conversion_step'
require 'coko_conversion/utilities/saxon_xsl_methods'
require 'coko_conversion/utilities/zip_methods'
require 'ink_step/mixins/zip_methods'
require 'httparty'
module InkStep::Coko
module XsweetPipeline
class DownloadAndExecuteXslViaSaxon < InkStep::ConversionStep
include Utilities::SaxonXslMethods
include Utilities::ZipMethods
include InkStep::Mixins::ZipMethods
attr_accessor :remote_xsl_uri
......@@ -72,6 +72,10 @@ module InkStep::Coko
"Downloads and applies the target XSL sheet URL against the target html document"
end
def self.human_readable_name
"XSL Executor via Saxon"
end
def version
CokoConversion::VERSION
end
......
require 'ink_step/conversion_step'
require 'coko_conversion/utilities/saxon_xsl_methods'
require 'coko_conversion/utilities/zip_methods'
require 'ink_step/mixins/zip_methods'
require 'httparty'
module InkStep::Coko
module XsweetPipeline
class DownloadAndExecuteXslViaSaxonOnDocx < InkStep::ConversionStep
include Utilities::SaxonXslMethods
include Utilities::ZipMethods
include InkStep::Mixins::ZipMethods
attr_accessor :remote_xsl_uri
......@@ -19,7 +19,7 @@ module InkStep::Coko
output_file_path = File.join(working_directory, "#{source_file_name}.html")
log_as_step "converting #{source_file_path} to #{File.basename(output_file_path)}"
unzip_docx(File.join(working_directory, source_file_path))
unzip_archive(File.join(working_directory, source_file_path))
download_file(remote_xsl_uri)
apply_xslt_transformation(input_file_path: document_xml_path,
......@@ -40,6 +40,10 @@ module InkStep::Coko
"Downloads and applies the target XSL sheet URL against the target docx file"
end
def self.human_readable_name
"XSL Executor via Saxon (docx only)"
end
def version
CokoConversion::VERSION
end
......
......@@ -14,6 +14,10 @@ module InkStep::Coko
"Tidies up the HTML by removing noise."
end
def self.human_readable_name
"Xsweet Final Rinse"
end
def remote_xsl_location
"https://gitlab.coko.foundation/wendell/XSweet/raw/ink-api-publish/applications/html-polish/final-rinse.xsl"
end
......
......@@ -40,6 +40,10 @@ module InkStep::Coko
"Detects headers by font size and promotes them to be headers (e.g. h2)"
end
def self.human_readable_name
"Xsweet Header Promoter"
end
def required_parameters
[:make_header_excalator_xslt_uri, :digest_paragraphs_xsl_uri]
end
......
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