Skip to content

Commit

Permalink
v0.11.3: link checker IsADirectory fix; template tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mDuo13 committed Jun 4, 2020
1 parent 1683c0a commit 288732a
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 63 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
node_modules/

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -45,9 +46,6 @@ coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
Expand Down
2 changes: 1 addition & 1 deletion dactyl/dactyl_link_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def check_local_file(endpoint, in_file, dirpath, top_dir, site_prefix):
# Assume index.html if path is a directory.
# This won't work for certain unusual server configurations or if you're
# building PHP files or something weird like that
if full_file_path[-1:] == "/":
if os.path.isdir(full_file_path):
full_file_path = full_file_path + "index.html"

logger.info("Testing local link in %s to '%s'" %
Expand Down
117 changes: 70 additions & 47 deletions dactyl/styles/dactyl.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ $black: #000000;
$code-color: $gray-800;
$body-color: $black;
$navbar-light-color: $gray-600;

$breadcrumb-bg: $white;

$navbar-padding-y: 0;
$navbar-nav-link-padding-x: 1rem;

$code-bg-color: $gray-100;

// Bootstrap v4 ================================================================
@import "node_modules/bootstrap/scss/bootstrap.scss";

Expand Down Expand Up @@ -82,6 +84,16 @@ $navbar-nav-link-padding-x: 1rem;
font-size: 80%;
}

blockquote {
padding: 0.5rem;
margin: 0.5rem 0.5rem 0.5rem 0;
border-left: 0.5rem solid $gray-500;

p:last-of-type {
margin-bottom: 0;
}
}

// Headings
h1 {
margin-top: 32px;
Expand Down Expand Up @@ -277,39 +289,44 @@ $navbar-nav-link-padding-x: 1rem;
// Code Tabs -----------------------------------------------------------------

.multicode {
color: $black;
color: $code-color;
}

.multicode a.current {
background-color: $gray-200;
color: $black;
background-color: $code-bg-color;
color: $code-color;
}

.multicode a,
a.current {
// The tabs themselves
color: $black;
}

.multicode li {
border-color: $gray-300;
}

.code_sample pre code {
background-color: $gray-200;
}

.multicode a:hover {
color: $black;
border-bottom: 1px solid $black;
padding-bottom: 7px;
}

.code_sample pre code {
background-color: $code-bg-color;
}

pre {
overflow: visible;
word-wrap: normal;
}
pre code {
white-space: pre;
border-radius: $border-radius;
}
pre code, p code {
color: $code-color;
background: $code-bg-color;
}
p code {
padding: 0.2rem;
}
.code_sample pre {
background: none;
Expand Down Expand Up @@ -355,8 +372,6 @@ $navbar-nav-link-padding-x: 1rem;
list-style-type: none;
margin-right: 0px;
margin-left: 0px;
border-style: none solid;
border-width: 0.5px;
}
.multicode ul > li:before {
background: none;
Expand All @@ -370,6 +385,13 @@ $navbar-nav-link-padding-x: 1rem;
padding-top: 10px;
margin: 0px;
text-decoration: none;
border-style: solid;
border-color: transparent;
border-width: 0.5px 0.5px 0 0.5px;
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.multicode a.current:hover {
border-bottom: none;
Expand Down Expand Up @@ -494,12 +516,40 @@ aside a.active-parent {
padding-left: 34px;
}

.right-sidebar {
padding: 1rem;

@media (max-width: 991px) {
// On this size screen, the right sidebar becomes a block at top instead
border-bottom: 1px solid $gray-200;
}
}

/* main content area ----------------------------------- */
.sidebar-primary .main {
.sidebar-both .main, .sidebar-left .main {
border-left: 1px solid $gray-200;

@media (max-width: 767px) {
// On this size screen, the left sidebar becomes a block at bottom instead
border-left: none;
}
}
.sidebar-both .main, .sidebar-right .main {
border-right: 1px solid $gray-200;

@media (max-width: 991px) {
// On this size screen, the right sidebar becomes a block at top instead
border-right: none;
}
}

.main {
// large tables/images can go over the edge. Better to horizontal scroll than
// to overlap the right sidebar
overflow-x: auto;
z-index: 5;
min-height: 700px;
}

/* Edit on GitHub link ------------------------------------------------------ */
.github-edit-wrap {
Expand Down Expand Up @@ -604,7 +654,6 @@ pre, code {
/* Push content below fixed header ------------------------------------------ */
#main_content_wrapper {
margin-top: 68px;
padding: 0 48px;
}

/* Fix so anchors don't jump under the fixed header ------------------------- */
Expand Down Expand Up @@ -846,17 +895,6 @@ pre, code {
display: inline-block;
}

.main {
// large tables/images can go over the edge. Better to horizontal scroll than
// to overlap the right sidebar
overflow-x: auto;
}

.sidebar-primary .main {
z-index: 5;
min-height: 700px;
}

/* Right navigation --------------------------------------------------------- */

.right-sidebar .card {
Expand All @@ -870,7 +908,7 @@ pre, code {
.right-sidebar .card-header {
border-bottom: none;
background-color: white;
padding: 10px 0;
padding: 0 0 10px 0;
}

.right-sidebar .card-header h4 {
Expand Down Expand Up @@ -1140,35 +1178,18 @@ Adapted for Dactyl Starter Kit

@media (max-width: 991px) {

#main_content_wrapper {
padding: 0 24px;
}
.navbar-brand img {
width: 120px;
}

.sidebar-primary .main {
border-left: none;
border-right: none;
}

.right-sidebar .card {
padding-left: 0;
}

#main_content_body {
padding: 0;
border-left: 0;
border-bottom: 1px solid $gray-200
}
#main_content_body .container-fluid {
padding-left: 0;
}

.dactyl-footer {
margin: 0 24px;
}

#page-toc-wrapper {
position: static;
display: block;
Expand All @@ -1184,6 +1205,8 @@ Adapted for Dactyl Starter Kit
overflow: hidden;
}
}


@media (max-width: 480px) {
html {
overflow-x: hidden !important;
Expand Down Expand Up @@ -1255,10 +1278,10 @@ Adapted for Dactyl Starter Kit
#main_content_body::before {
display: none;
}
.sidebar-primary .main {
#main_content_wrapper .main {
border: 0;
}
.sidebar-primary .row {
.main .row {
display: block;
}
a[href^="#"]:after {
Expand Down
101 changes: 101 additions & 0 deletions dactyl/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Dactyl Built-in Templates

This directory contains the default templates included with Dactyl. Starting with v0.11.0, you can include or extend the built-in templates. These templates contain a bunch of useful stuff in modular format, so you can pull in what you need, replace what you don't, and get updates automatically when Dactyl is updated.

Many of the templates work better if you set certain fields on your target or page definitions. Here's a list of those fields:

| Field | Description |
|---|---|
| `prefix` | The base path for this site. Use `/` for a site served from the top-level of its domain. Required for navigation if your site has subfolders or "pretty URLs". |
| `logo` | URL or path for a logo image to use in the top-left. If not defined, uses a text header instead. |
| `google_analytics_tag` | String tag to use with Google Analytics, e.g. "UA-00000000-0". If not defined, doesn't load Google Analytics. |
| `repository` | URL to this site's source repository on GitHub. Required for the "Edit on GitHub" button. |
| `url` | The fully-qualified URL for the base of the site. Required by the sitemap and Google Search templates. |
| `stylesheet` | URL or path to the default stylesheet. The default includes Bootstrap 4.5 as well as custom CSS for code tabs, callouts, and the page layout. See the [styles dir](./dactyl/styles/) for the source SCSS. The default is served by dactyl.link. |
| `dactyljs` | URL or path to the Dactyl JavaScript file to use. This defines "jump to top" and code tab behavior. The default is served by dactyl.link. |
| `bootstrapjs` | URL or path to the Bootstrap JavaScript file to use. The default is served by BootstrapCDN. |
| `fontawesomecss` | URL or path to FontAwesome (v4) CSS file to use. The default is served by BootstrapCDN. |


#### Page Templates

The following built-in templates represent **full pages**, so you can use them with the `default_template:` and `template:` settings in the config file or frontmatter. You can also derive your own templates from these templates using `{% extends 'template' %}` syntax.

| Template | Description |
|---|---|
| `404.html` | Contains an error message intended to be used as a custom 404 page. |
| `base.html` | A general purpose template with a 3-column layout, fixed header, and a footer. The navigation uses the hierarchy (`parent` and `child`) fields introduced by Dactyl v0.10.0. This uses [Bootstrap 4.5.0](https://getbootstrap.com/docs/4.5/). Most of the other built-in templates are derived from this template. |
| `doc.html` | Specialized for individual documents. This is the new default template. The right sidebar has an in-page table of contents, and this runs code tab and syntax highlighting JavaScript by default. (You still need to enable the multicode_tabs filter in your `dactyl-config.yml` file to get code tab syntax.) |
| `landing.html` | A landing page that displays a list of child pages in the center column. |
| `pdf-cover.html` | A cover page and table of contents for PDFs. |
| `redirect.html` | Redirects the user to another URL, as set by the page's `redirect_url` field. Useful for deprecating pages. |
| `simple.html` | A minimal template with no dependencies. |
| `template-sitemap.txt` | A template for a text [sitemap](https://support.google.com/webmasters/answer/183668?hl=en) for use by search engines. |

When extending the default templates, many of them have blocks you can replace. For the full list, inspect the templates' source code in this directory.

##### Sidebars

When using `base.html` or any of the templates derived from it, you can use the `sidebar` field to control the presence of sidebars. By default, both sidebars are present, with the left sidebar containing a cross-page navigation tree and the right sidebar containing an in-page table of contents. Provide `sidebar: disabled` (in the page definition or frontmatter) to have the center column occupy the full width of the page. Use `sidebar: left_only` to show only the left sidebar, and `sidebar: right_only` to show only the right sidebar.

You can replace the sidebar contents by extending `base.html` and putting your replacements in `{% block left_sidebar %}` for the left sidebar, or `{% block right_sidebar %}` for the right sidebar.

On medium viewscreens (768px to 991px wide) the right sidebar becomes full-width and appears before the main contents and left sidebar. On small viewscreens (less than 768px wide) the left sidebar and content become full-width, with the left sidebar coming after the page content. The following ASCII art attempts to depict this relationship:

```text
Large screens Medium Screens Small screens
| L | C | R | | R | | R |
| | | | | L | C | | C |
| | | | | | | | L |
L = left sidebar
R = right sidebar
C = main content
```


#### Module Templates

The following built-in templates are partial modules you can use with `{% include 'templatehere.html' %}` blocks from other templates. Many of these pieces are used by the page templates above, as well:

| Template | Description |
|---|---|
| `algolia-docsearch.html` | Provides a search box (and accompanying resources) powered by [Algolia DocSearch](https://docsearch.algolia.com/). To use this, you must provide your Algolia API key in the target's `algolia_api_key` field provide your index name in the target's `algolia_index_name` field. |
| `breadcrumbs.html` | Provides [breadcrumbs](https://getbootstrap.com/docs/4.5/components/breadcrumb/) to the current page, based on the hierarchy fields. |
| `children.html` | Displays a bulleted list of children of the current page. You can modify the behavior by setting certain properties before including this template. (See below for an example.) |
| `footer.html` | A footer containing a copyright notice, license link, and language selector (if you have the right fields defined). |
| `github-edit.html` | A button that links to edit the current page's source file on GitHub. Requires the target's `repository` field to be the URL of the site's repository on GitHub. |
| `header.html` | A fixed header containing a logo, navigation to top-level pages, search, and Edit on GitHub buttons if the right fields are defined. |
| `language-dropdown.html` | A language-selector dropdown that points to the equivalent page in other languages, if you have multiple languages defined. (This is the one used in the header.) |
| `language-dropdown.html` | A horizontal language selector that points to the equivalent page in other languages, if you have multiple languages defined. (This is the one used in the footer.) |
| `page-toc.html` | A Bootstrap/ScrollSpy-ready table of contents based on the headers in the current page's Markdown contents. |
| `tree-nav.html` | Tree-style site navigation with collapsible levels. You can set a custom page to be the "top" of the tree to show only a subset of your site. Otherwise it uses the first page (usually the auto-provided cover page) as the top of the tree. Set `nav_omit: true` on a page to hide that page from this navigation. |

##### Children Module

The following demonstrates how to use the `children.html` template to display a list of children of a page (including links):

```html
{% set parent_html = 'some-parent.html' %}
{% set show_blurbs = True %}
{% set depth = 3 %}
{% include 'children.html' %}
```

You can omit any or all of the `{% set ... %}` statements to use the defaults:

| Setting | Description | Default |
|---|---|---|
| `parent_html` | Which page's children to show. The HTML filename of that page. | The current page. |
| `show_blurbs` | If True, add the child page's `blurb` attribute next to its link. | False |
| `depth` | How many levels in the hierarchy to show below the parent. | 5 |

##### Tree Nav Module

The following shows how to display a subset of the tree nav (starting with the file `some_parent.html`) instead of the full tree:

```html
{% set tree_top = pages|selectattr('html', 'defined_and_equalto', 'some_parent.html')|list|first %}
{% include 'tree-nav.html' %}
```
Loading

0 comments on commit 288732a

Please sign in to comment.