forked from apache/lucene-solr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOLR-15458: Move solr-ref-guide/src/meta-docs to dev-docs; remove how…
…-to-contribute.adoc (apache#167)
- Loading branch information
Showing
8 changed files
with
763 additions
and
743 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
= Working with HTML Templates | ||
:toc: | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
The Solr Ref Guide uses Jekyll to build the HTML version of the site. | ||
|
||
== What is Jekyll? | ||
|
||
Jekyll is a static site generator, meaning that it takes some set of documents and produces HTML pages. It allows for templating of the pages, so each page has the same look and feel without having to code headers, footers, logos, etc., into every page. | ||
|
||
Jekyll is an open source project written in Ruby, online at https://jekyllrb.com/. | ||
|
||
== How We Use Jekyll | ||
|
||
The following sections describe the main features of Jekyll that you will encounter while working with the Solr Ref Guide. | ||
|
||
=== Jekyll-Asciidoctor Plugin | ||
We use a plugin for Jekyll from the Asciidoctor project to integrate Jekyll with Asciidoc formatted content. | ||
The source for the plugin is available at https://github.com/asciidoctor/jekyll-asciidoc. | ||
|
||
This plugin allows us to use Asciidoctor-style variables with Jekyll. | ||
|
||
=== _config.yml | ||
|
||
The `_config.yml` is a global configuration file that drives many of the options used when building the site (particularly in our use of Jekyll). | ||
|
||
We have template-ized `_config.yml`, so in our use of Jekyll you will find it in `solr/solr-ref-guide/src` as `_config.yml.template`. | ||
This allows us to define some variables during the build and use common Solr build parameters (such as project versions). | ||
|
||
=== Front Matter | ||
|
||
Front matter for Jekyll is similar to a header that defines the title of the page, and other variables that may be helpful (or even required) when rendering the page. | ||
|
||
Every document that will be converted to HTML *must* include at least the page title at the top of the page. | ||
Page titles are defined with a single equal sign (`=`) followed by the title that will appear at the top of the page (such as `= Topic of the Page`). | ||
|
||
Many guides to Jekyll also say that defining the `layout` in the front matter is required. | ||
However, since we only use one layout for all pages, we have defined this as a default. | ||
|
||
The Solr Ref Guide uses the front matter to define some custom attributes on a per-page basis: | ||
|
||
* `page-children` - ordered list of child pages, this is used to build the site navigation menu that appears to the left of each page's content. | ||
|
||
Other page-level elements can also be defined, such as an Asciidoctor attribute that should apply only to that page, but are not needed on a regular basis. | ||
|
||
The format for adding any parameter to the front matter is to use colons on both sides of the parameter, followed by the value for the parameter (such as `:page-toc: false`). | ||
|
||
==== Table of Contents | ||
There are some optional custom attributes that can be defined in pages to affect the Table of Contents presentation in Jekyll: | ||
|
||
`toclevels`:: | ||
Changes how "deep" the TOC will be in terms of nested section/sub-section titles (default = `2`). Example: `:toclevels: 1`. | ||
|
||
`page-show-toc`:: | ||
If this is `false`, then no TOCs will be generated for the page at all. | ||
The default is `true`, so can usually be left undefined. | ||
Example `:page-show-toc: false`. | ||
|
||
|
||
=== Layouts | ||
|
||
Layouts define the "look and feel" of each page. | ||
Jekyll uses https://shopify.github.io/liquid/[Liquid] for page templates. | ||
|
||
For our implementation of Jekyll, layouts are found in `solr-ref-guide/src/_layouts`. | ||
|
||
We currently use the `_layouts/default.html` layout for overall page structure, for almost all pages and `_layouts/page.html` for the page-level content. | ||
The `page.html` layout is inserted into the `default.html` layout. | ||
|
||
The main page (`index.html`) of the Ref Guide uses the `_layouts/home.html` layout. | ||
It also still uses `_layouts/page.html` for the page-level content. | ||
This is done because `index.html` has some special formatting and rules for how to define the page. | ||
|
||
=== Includes | ||
|
||
Include files are (usually) small HTML files that are pulled into a layout when a page is being built. | ||
They are Liquid templates that define an area of the page. | ||
This allows flexibility across layouts - all pages can have the same header without duplicating code, but different pages could have different menu options. | ||
|
||
Include files that we use define the top navigation, the page header, and the page footer. | ||
|
||
For our implementation of Jekyll, include files are found in `solr-ref-guide/src/_includes`. | ||
|
||
=== Data Files | ||
|
||
Data files include data such as lists that should be included in each page. | ||
The left-hand navigation menu is an example of a data file. | ||
However, in our build, the navigation is built from the `page-children` hierarchies defined on parent pages. | ||
|
||
For our implementation of Jekyll, data files are found in `solr-ref-guide/src/_data`. | ||
|
||
=== Asciidoctor Slim Templates | ||
|
||
Jekyll creates all of the page elements we do not define in each `.adoc` file: the header, footer, top nav, sidebar nav, and other parts of the page that we don't worry about as we write the content of a page. | ||
|
||
Asciidoctor converts the content in each `.adoc` file into HTML and inserts it into the Jekyll page layout we have defined (see <<Layouts>>) to make the individual HTML files that make up the Ref Guide. | ||
|
||
While we have unlimited control over styling page content via CSS, without creating custom Asciidoctor-specific plugins or templates there is little out-of-the-box control over the elements, classes, etc., that make up the HTML pages. | ||
|
||
In order to better support HTML5, we have customized Asciidoc's default conversion with templates found in the `_templates` directory. | ||
These templates use http://slim-lang.com/[Slim] as the template engine. | ||
|
||
Since these templates dictate the very structure of the HTML of our content, customizing these should only be attempted in rare instances and with extensive testing for unforeseen impacts. | ||
|
||
=== Using Bootstrap | ||
|
||
The HTML files include https://getbootstrap.com/docs/4.1/[Bootstrap] (v4.1.3 as of April 2020, see `_includes/head.html` to confirm the Bootstrap version currently being used), so all of the components of Bootstrap are available. | ||
|
||
The design of the Ref Guide makes extensive use of Bootstrap classes to layout the page via the Liquid templates and our customized Asciidoctor templates. | ||
|
||
When we want to use additional components of Boostrap that require specific HTML constructs, we must define those within the page content itself (using either `<div>` elements in the content or with Asciidoctor's roles, discussed in the next section). | ||
|
||
|
||
== Building the HTML Site | ||
|
||
A Gradle target `gradlew checkSite` will build the full HTML site (found in `solr/solr-ref-guide/build/html-site`). | ||
|
||
This target builds the navigation for the left-hand menu, and converts all `.adoc` files to `.html`, including navigation and inter-document links. | ||
|
||
The `checkSite` target also checks that all inter-doc references are correct and resolvable. | ||
See `solr/solr-ref-guide/tools/CheckLinksAndAnchors.java` for details of what that tool does to validate content. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.