adjusted accordion feature by removing setting for this

You now have to manually adjust a few things in the sidebar.html if you
do not want the accordion feature.
This commit is contained in:
Tom Johnson 2015-09-22 15:43:59 -07:00
parent 9bb039429d
commit 44fed9602a
6 changed files with 135 additions and 18 deletions

View File

@ -9,7 +9,7 @@
// Initialize navgoco with default options
$("#mysidebar").navgoco({
caretHtml: '',
accordion: {% if site.sidebar_accordion %}{{site.sidebar_accordion}}{% else %}true{% endif %},
accordion: true,
openClass: 'active', // open
save: false, // leave false or nav highlighting doesn't work right
cookie: {
@ -49,7 +49,7 @@
{% for subcategory in entry.subcategories %}
{% if subcategory.audience contains audience and subcategory.product contains product and subcategory.platform contains platform and subcategory.version contains version and subcategory.web != false %}
<li><a href="#">{{ subcategory.title }}</a>
{% if subcategory.class == "series" %}<ul class="series">{% else %}<ul>{% endif %}
<ul>
{% for item in subcategory.items %}
{% if item.audience contains audience and item.product contains product and item.platform contains platform and item.version contains version and item.web != false %}
{% if item.external_url %}
@ -83,17 +83,19 @@
{% endif %}
{% endfor %}
</ul> </li>
</ul>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
{% if site.sidebar_accordion == false %}
<!-- if you aren't using the accordion, uncomment this block:
<p class="external">
<a href="#" id="collapseAll">Collapse All</a> | <a href="#" id="expandAll">Expand All</a>
</p>
{% endif %}
-->
</div>
<!-- this highlights the active parent class in the navgoco sidebar. this is critical so that the parent expands when you're viewing a page. This must appear below the sidebar code above.-->
<script>$("li.active").parents('li').toggleClass("active");</script>

View File

@ -30,7 +30,6 @@ exclude:
# same for all
host: 127.0.0.1
feedback_email: tomjohnson1492@gmail.com
sidebar_accordion: true
markdown: redcarpet
print: false
theme_file: theme-blue.css

View File

@ -194,6 +194,7 @@ p.external a {
font-size:12px;
font-color: #0088cc;
display:inline;
margin-top:7px;
}
#definition-box-container div a.active {

View File

@ -39,7 +39,6 @@ Note that you can define arbitrary key-value pairs in the configuration file, an
| **site_title**| Appears in the webpage title area (on the browser tab, not in the page viewing area). In the sample theme files, the site title is the "page name | homepage title." |
| **port** | Required | The port used in the preview mode. This is only for the live preview and doesn't affect the published output. If you serve multiple outputs simultaneously, the port must be unique. |
| **feedback_email** | Gets configured as the email address in the Send Feedback button in the top navigation bar.|
| **sidebar_accordion** | Optional | Boolean. The default value is true. Whether you want the navigation sidebar to use the accordion effect or not. The accordion effect means when you expand a section, the other sections automatically collapse. If you put `false`, then you can expand multiple sections at once. At the bottom of the navigation sidebar, two links will appear: Collapse All and Expand All. |
| **disqus_shortname** | Optional | The disqus site shortname, which is used for comments. If you don't want comment forms via disqus, leave this blank or omit it altogether and Disqus won't appear. |
| **markdown** | Required | The processor to use for Markdown. This is a Jekyll-specific setting. Use `redcarpet`. Another option is `kramdown`. However, my examples will follow redcarpet. |
| **redcarpet** | Required | Extensions used with redcarpet. You can read more about them by searching for redcarpet extensions online. |

View File

@ -55,26 +55,24 @@ Each of the items in the sidebar needs to have the attributes shown here:
version: all
```
The audience, platform, product, and version are specified in the includes/custom/conditions.html file:
The project, audience, platform, product, and version are specified in the includes/custom/conditions.html file:
```liquid
{% raw %}
{% if site.project == "doc_designers" %}
{% assign audience = "designers" %}
{% assign sidebar = site.data.sidebar_doc.entries %}
{% assign topnav = site.data.topnav_doc.topnav %}
{% assign topnav_dropdowns = site.data.topnav_doc.topnav_dropdowns %}
{% assign sidebar = site.data.sidebar.entries %}
{% assign topnav = site.data.topnav.topnav %}
{% assign topnav_dropdowns = site.data.topnav.topnav_dropdowns %}
{% assign version = "all" %}
{% assign product = "all" %}
{% assign platform = "all" %}
{% assign link = "custom/doc/links_doc.html" %}
{% assign projectTags = site.data.tags_doc.allowed-tags %}
{% assign searchGroup = "doc" %}
{% endif %}
{% endraw %}
```
Additionally, note how some assignments are set here as well. The conditions.html file set things like `sidebar = site.data.sidebar_doc.entries`.
Additionally, note how some assignments are set here as well. The conditions.html file set things like `sidebar = site.data.sidebar.entries`. You could use this logic to extend the single sourcing possibilities of the theme.
When the sidebar.html file runs the logic, it includes these statements:
@ -94,14 +92,27 @@ The assignment of the `sidebar` value through the conditions.html file means thi
{% raw %}
{% include custom/conditions.html %}
{% for entry in site.data.sidebar_doc.entries %}
{% for entry in site.data.sidebar.entries %}
{% endraw %}
```
Since different projects will use different data files, I had to make the logic run using the standard `sidebar` variable, but change the meaning of that variable based on the project.
Since different projects might use different data files, I had to made the logic run using the standard `sidebar` variable but change the meaning of that variable based on the project.
# Sidebar accordion
The configuration file (configs/config_writers.yml) file includes a value (`sidebar_accordion`) that lets you choose whether to use the accordion feature in the sidebar or not. The accordion feature collapses other sections when a section is opened, which conserves space on the screen. Put `true` or `false` for the value.
If you don't want the accordion feature in the sidebar, open the \_includes/sidebar.html file and change the value for `accordion` in the `.navgoco` options from `true` to `false` (don't surround the value with quotes).
Additionally, to show "Collapse All" and "Expand All" buttons, uncomment this section near bottom on the same sidebar.html page:
```
<!-- if you aren't using the accordion, uncomment this block:
<p class="external">
<a href="#" id="collapseAll">Collapse All</a> | <a href="#" id="expandAll">Expand All</a>
</p>
-->
```
Note that if you Expand all sections in your sidebar and you have a lot of items, the sidebar will likely extend past the viewing frame. In this case, you should disable the fixed sidebar setting by removing the JavaScript code explained in the next section ("Sidebar fixed or moving").
## Sidebar fixed or moving

105
title-checker2.html Normal file
View File

@ -0,0 +1,105 @@
---
layout: none
search: exclude
---
<html>
<head>
<title>Page checker</title>
</head>
<body>
<h2>Page Checker Report</h2>
{% include custom/conditions.html %}
{% for entry in sidebar %}
{% for subcategory in entry.subcategories %}
{% for item in subcategory.items %}
{% assign count = '0' %}
{% unless item.frontmatter == true %}
{% assign itemTitle = item.title | replace: '"', '' %}
{% assign itemUrl = item.url %}
{% for page in site.pages %}
{% if page.url == item.url %}
{% assign pageTitle = page.title | replace: '"', '' %}
{% assign pageUrl = page.url %}
{% if pageTitle != itemTitle %}
<hr/>
<p>Problem: The sidebar item title "{{itemTitle}}" does not match the page title "{{pageTitle}}".</p>
{% endif %}
{% endif %}
{% if pageUrl != itemUrl %}
{% capture count %}{{ count | plus: '1' }}{% endcapture %}
{% if forloop.last %}
{% assign totalPages = site.pages.size %}
{% if count != totalPages %}
<p>something is missing</p>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endunless %}
{% for thirdlevel in item.thirdlevel %}
{% for deeplevel in thirdlevel.thirdlevelitems %}
{% unless deeplevel.frontmatter == true %}
{% assign deeplevelTitle = deeplevel.title | replace: '"', '' %}
{% assign deeplevelUrl = deeplevel.url %}
{% for page in site.pages %}
{% if page.url == deeplevel.url %}
{% assign pageTitle = page.title | replace: '"', '' %}
{% assign pageUrl = page.url %}
{% if pageTitle != deeplevelTitle %}
<hr/>
<p>Problem: The sidebar deeplevel title "{{deeplevelTitle}}" does not match the page title "{{pageTitle}}".</p>
{% endif %}
{% endif %}
{% endfor %}
{% endunless %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% for entry in topnav %}
{% for subcategory in entry.subcategories %}
{% unless subcategory.external_url or subcategory.frontmatter %}
<hr/>
{% assign subcategoryTitle = subcategory.title | replace: '"', '' %}
{% assign subcategoryUrl = subcategory.url %}
{% for page in site.pages %}
{% if page.url == subcategory.url %}
{% assign pageTitle = page.title | replace: '"', '' %}
{% assign pageUrl = page.url %}
{% if pageTitle != subcategoryTitle %}
<p>Problem: The top navigation item title "{{subcategoryTitle}}" does not match the page title "{{pageTitle}}".</p>
{% endif %}
{% endif %}
{% endfor %}
{% endunless %}
{% endfor %}
{% endfor %}
{% for entry in topnav_dropdowns %}
{% for subcategory in entry.subcategories %}
{% for subitem in subcategory.items %}
{% unless subitem.external_url or subitem.frontmatter %}
{% assign subitemTitle = subitem.title | replace: '"', '' %}
{% assign subitemUrl = subitem.url %}
{% for page in site.pages %}
{% if page.url == subitem.url %}
{% assign pageTitle = page.title | replace: '"', '' %}
{% assign pageUrl = page.url %}
{% if pageTitle != subitemTitle %}
Problem: The top drop-down navigation item title "{{subitemTitle}}" does not match the page title "{{pageTitle}}".
{% endif %}
{% endif %}
{% endfor %}
{% endunless %}
{% endfor %}
{% endfor %}
{% endfor %}
</body>
</html>