nevir/groc — pull request #124 by sjorek (2013-09-24 13:39:43+00:00)
Title: Feature: SEO and user-friendly table of contents

As _groc's_ [google site-search results](https://www.google.de/search?rls=en&q=site:nevir.github.io/groc/&ie=UTF-8&oe=UTF-8) prove, the current on-the-fly generated tables of contents is ignored by search-engines.

As an initial step towards a better solution I changed the implementation to generate the TOC directly in the jade-template `docPage.jade` and restructured the `behavior.coffee` accordingly, hopefully without touching any existing functionality. This step made a split of the single-phase groc-process into a 2-phase groc-process necessary. As before phase 1 reads and parses all sources files to collect this information, but does not render the jade-template yet. After this phase the [TOC's data is generated](https://github.com/sjorek/groc/compare/feature-seo-friendly-toc?expand=1#L1R123) from the infos collected as before. Now starting with [phase 2 all the sources files from phase 1 will be rendered](https://github.com/sjorek/groc/compare/feature-seo-friendly-toc?expand=1#L0R96), _but this time having the TOC's data in their context_.

Other changes introduced by this commit:
1. ESC-key toggles the TOC on and off, without focusing the search-field
2. If the TOC is closed then Return- and TAB-key focus the search-field and open the TOC
3. If the TOC is open TAB-key focus and blurs the search-field, without closing the TOC
4. Beneath the existing `nav ol.toc li.selected`-class an additionally class [`nav ol.toc li.current`](https://github.com/sjorek/groc/compare/feature-seo-friendly-toc?expand=1#L6R574) has been introduced to permanently mark the current document.
5. You can use the rendered result [with javascript disabled](https://github.com/sjorek/groc/compare/feature-seo-friendly-toc?expand=1#L4R2) (not the best but surely enough), hence the search-engine actually sees the TOC's links.
6. The (for now unnecessary) JSON in behavior.coffee is [cleaned before exported](https://github.com/sjorek/groc/compare/feature-seo-friendly-toc?expand=1#L7R88) for the sake of privacy and filesize.