Offline Mode
Offer content creators the opportunity to generate and view draft HTML in the Bootstrap style when not connected to the Internet through creating a custom DITA-OT plugin.
This scenario walks through the process of creating a simple plug-in
(com.example.bootstrap.offline
) that bundles all the necessary Bootstrap JavaScript and CSS
locally into the generated HTML output.
This could be used to allow writers to view an incomplete draft of the DITA content whilst maintaining Bootstrap interactivity and look-and-feel.
Procedure
-
In the plugins directory, create a directory named com.example.bootstrap-offine.
-
In the new com.example.bootstrap-offline directory, create a plug-in configuration file (plugin.xml) that uses the bootstrap.process.pre extension point.
Note: This plug-in will extend the default HTML5 Bootstrap transformation, so the<require>
element explicitly defines net.infotexture.dita-bootstrap as a dependency. -
In the com.example.bootstrap-offline directory, create a subdirectory named include.
-
In the new include subdirectory, create a file named offline-bootstrap-js.xml containing the minified Bootstrap JavaScript code.
The division wrapper will be discarded when generating HTML files, and the contents will be inserted into the
<header>
element of each page. -
In the new include subdirectory, create a file named offline-bootstrap.css containing the minified Bootstrap CSS.
-
In the com.example.bootstrap-offline root directory, add an Ant script (process_offline.xml) to predefine various parameters prior to calling the html5-bootstrap transform
Results
The plug-in directory has the following layout and files:
com.example.bootstrap-offline
├── include
│ ├── offline-bootstrap-js.xml
│ └── offline-bootstrap.css
├── plugin.xml
└── process_offline.xml
What to do next
- Run dita --install to install the plug-in.
- Build output with the html5-bootstrap type to verify that the output is available offline
as intended.
dita --input=path/to/your.ditamap \ --format=html5-bootstrap \ --offline.mode=yes
- Refine the styles in your offline-bootstrap.css file as necessary.