Class: Mint::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/mint/plugin.rb

Direct Known Subclasses

EPub

Class Method Summary collapse

Class Method Details

.after_publish(document) ⇒ Object

Supports:

  • Change file, filesystem once written

  • Automatic cleanup of intermediate files, including all edge cases currently covered by transformation library. (For example, if I generated a CSS file but am ultimately generating a PDF, I would want to have an automatic way to delete that CSS file.)

Use cases:

  • Zip set of documents into ePub and create manifest

  • Change file extension

  • Generate PDF from emitted HTML and get rid of intermediate files

  • Generate .doc (or any other OO UNO format) and get rid of intermediate files

NOTE: Unlike the other two callbacks, this doesn’t use the result of

the callback expression for anything. This callback is purely for 
side effects like rearranging the file system.


133
134
# File 'lib/mint/plugin.rb', line 133

def self.after_publish(document)
end

.after_render(html_document) ⇒ Object

Supports:

  • Change preview HTML

Use cases:

  • Transform elements based on position or other HTML attributes For example: Add a class to the first paragraph of a document if it is italicized

Questions:

  • Could I allow jQuery use here?



113
114
115
# File 'lib/mint/plugin.rb', line 113

def self.after_render(html_document)
  html_document
end

.before_render(text_document) ⇒ Object

Supports:

  • Change raw text

Use cases:

  • Add footnote syntax on top of Markdown

  • Perform text analysis for use in later callbacks (?)



99
100
101
# File 'lib/mint/plugin.rb', line 99

def self.before_render(text_document)
  text_document
end

.commandline_nameObject



89
90
91
# File 'lib/mint/plugin.rb', line 89

def self.commandline_name
  Mint.commandline_name(self)
end

.commandline_options_fileObject



85
86
87
# File 'lib/mint/plugin.rb', line 85

def self.commandline_options_file
  Mint.commandline_options_file(self)
end

.config_directoryObject



81
82
83
# File 'lib/mint/plugin.rb', line 81

def self.config_directory
  Mint.config_directory(self)
end

.inherited(plugin) ⇒ Object



68
69
70
# File 'lib/mint/plugin.rb', line 68

def self.inherited(plugin)
  Mint.register_plugin! plugin
end

.template_directoryObject



77
78
79
# File 'lib/mint/plugin.rb', line 77

def self.template_directory
  Mint.template_directory(self)
end

.underscore(opts = {}) ⇒ Object



72
73
74
75
# File 'lib/mint/plugin.rb', line 72

def self.underscore(opts={})
  opts[:ignore_prefix] ||= true
  Helpers.underscore self.name, :ignore_prefix => opts[:ignore_prefix]
end