Much of MarkdownRecord's behavior is configurable. This section covers what can be configured.
You can configure MarkdownRecord
in the initializer that is generated upon installation. The config attributes available are:
content_root
: the path to the directory containing your markdown source files. This is markdown_record/content
inside your application root by default.rendered_content_root
: the path to the directory where rendered content will be saves. This is markdown_record/rendered
inside your application root by default.layout_directory
: the path to the directory containing the layouts used during rendering. This is markdown_record/layouts
inside your application root by default.concatenated_layout_path
: the relative path (from layout_directory
) to the layout that should be used for files rendered from the concatenated contents of a directory.file_layout_path
: the relative path (from layout_directory
) to the layout that should be used for files rendered from a single markdown source file.global_layout_path
: the relative path (from layout_directory
) to the layout that should be used for all rendered files.markdown_extensions
: MarkdownRecord uses the Redcarpet
gem under the hood to process markdown. This value is the configuration that gets passed to ::Redcarpet::Markdown
. The default value is {:fenced_code_blocks => true, :disable_indented_code_blocks => true, :no_intra_emphasis => true}
. Please see Redcarpet's documentation for more details.html_render_options
: the render_options
that get passed to Redcarpet's Redcarpet::Render::HTML
class. The default value is an empty Hash. Please see Redcarpet's documentation for more details.public_layout
: the path to the layout (from the application root) that should be used when the controllers provided by MarkdownRecord render HTML. The default value is "layouts/application".render_strategy
: the render strategy that should be use when running the render_content
Thor task. The default value is :full
but it can be changed to :directory
of :file
. If the :file
strategy is used then MarkdownRecord will render your markdown content each time MarkdownRecord models queries are executed.html_routes
: the routes that are generated to render only HTML. This value is an array of symbols that can include :show
and :download
. By default the value is [:show]
.json_routes
: the routes that are generated to render only JSON. This value is an array of symbols that can include :show
and :download
. By default the value is [:show]
.content_routes
: the routes that are generated to render either HTML or JSON depending on the request. This value is an array of symbols that can include :show
and :download
. By default the value is [:show]
.mount_path
: the path where the MarkdownRecord engine is mounted inside the host application. It is mdr
by default.render_content_fragment_json
: a boolean value that determines whether MarkdownRecord renders content fragments and saves them to the rendered_content_root
in JSON files with the _fragments
suffix. If this is set to false
, then MarkdownRecord will render your markdown content each time MarkdownRecord models queries are executed. This is set to true
by default.render_controller
: the controller used to render ERB content during the rendering process. If this isn't set, then the host application's ApplicationController
will be used. By default this is nil
.ignore_numeric_prefix
: configures whether or not MarkdownRecord ignores the numeric prefixes of filenames. The default value is true
. When it is set to false
, the numeric prefixes will be included in the filename
attribute of models, the id
attribute of content fragments, and the content_path
parameter of requests to the routes for rendered content.filename_sorter
: the file sorting instance to be used to organized concatenated content. The default value is MarkdownRecord::FileSorting::Base.new
MarkdownRecord uses an instance of MarkdownRecord::FileSorting::Base
by default to sort files in order to determine concatenation order of the markdown content it renders. This class is also responsible for trimming the numeric prefix prefixes off filenames. However, two additional classes are available for this purpose to allow the use of different kinds of prefixes and sort orders. They are:
MarkdownRecord::FileSorting::DateSorter
: this class sorts files by a date prefix. By default it expects to find a prefix matching the regular expression: /^(\d\d\d\d?_\d\d?_\d\d?)/
and parses that prefix using the data pattern: "%Y_%m_%d"
. However you can override both of these upon instantiation like so:
MarkdownRecord::FileSorting::DateSorter.new(<regexp>, <date_pattern_string>)
MarkdownRecord::FileSorting::SemVerSorter
: this class sorts files by a semantive version prefix. By default it expects to find a prefix matching the regular expression: /(\d+(?:_\d+)*)(?:_|$)/
. This allows any number of version parts, including just a single number, which would make it functionally equivalent to the default file sorter MarkdownRecord::FileSorting::Base
. However, you can override the regex used like so:
MarkdownRecord::FileSorting::SemVerSorter.new(<regexp>)
You may also implement your own file sorter. It only needs to implement a to_sort_value(value)
method which returns an object that responds to <=>
.
The above content was rendered from source files at: content/v_0_1/configuration