Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Merging doc updates, UI improvements, breadcrumb refactor (#893)
Browse files Browse the repository at this point in the history
* second iteration of deprecated docs

* more reference changes

* changed id_token sample (#887)

* replaced skyforms with bootstrap forms (#888)

* Updated live auth docs (#889)

* changed id_token sample

* updated error msg for /otp returning 400 code 16

* Added comma to 4xx json object

* Sandbox UX improvements and analytics (#890)

* Moved sandbox instructions above the form

* Added Google Analytics events for form submissions and errors.

* replaced breadcrumb liquid template with modified jekyll-breadcrumbs module (#892)

* Delete api-draft

Unused file
  • Loading branch information
bhague1281 committed Feb 2, 2017
1 parent e2cc111 commit f572fb6
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 26 deletions.
71 changes: 46 additions & 25 deletions _includes/breadcrumb.html
@@ -1,25 +1,46 @@
<div class="breadcrumbs hidden-print">
<div class="container">
<h1 class="pull-left">{{ page.title }}</h1>
<ol class="pull-right breadcrumb">
<li><a href="{{ site.baseurl }}/">Home</a></li>
{% assign crumbs = page.url | split: '/' %}
{% assign crumbs_total = crumbs | size | minus: 1 %}
{% for crumb in crumbs offset: 1 %}
{% if forloop.index == crumbs_total %}
<li class="active"><a href="{{ site.baseurl | append: page.url }}">{{ page.title }}</a></li>
{% else %}
{% assign crumb_limit = forloop.index | plus: 1 %}
{% capture crumb_url %}{% for c in crumbs limit: crumb_limit %}{{ c | append: '/' }}{% endfor %}{% endcapture %}
{% assign crumb_with_index = crumb_url | append: 'index.html' %}
{% assign current_page = site.baseurl | append: page.url %}
{% for p in site.pages %}
{% if crumb_with_index != current_page and crumb_with_index == p.url %}
<li><a href="{{ crumb_with_index }}">{{ crumb | replace: '-', ' ' | capitalize }}</a>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</ol>
</div>
</div><!--/breadcrumbs-->
{% assign url = page.url | remove: "/" %}

{% if url.size > 0 %}
<nav class="breadcrumbs hidden-print">
<div class="container">
<h1 class="pull-left">{{ page.title }}</h1>

<ol class="pull-right breadcrumb" vocab="http://schema.org/" typeof="BreadcrumbList">

{% comment %} List home page for all bread crumbs {% endcomment %}
{% assign position = 1 %}

<li class="active" property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage" href="{{ "/" | prepend: site.baseurl }}">
<span property="name">Home</span>
</a>
<meta property="position" content="{{ position }}" />
</li>

{% comment %} Iteration breadcrumb item {% endcomment %}
{% for crumb in breadcrumbs %}

{% comment %} Skip if root {% endcomment %}
{% if crumb.url == "/" %}
{% continue %}
{% endif %}

{% comment %} SEO data {% endcomment %}
{% assign position = position | plus: 1 %}

{% comment %} List crumbs leading up to the page title {% endcomment %}
{% if crumb.url != page.url %}
<li class="active" property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage" href="{{ crumb.url | prepend: site.baseurl }}">
<span property="name">{{ crumb.title }}</span>
</a>
<meta property="position" content="{{ position }}" />
</li>
{% endif %}

{% endfor %}

</ol>
</div>
</nav>
{% endif %}
39 changes: 39 additions & 0 deletions _plugins/jekyll-breadcrumbs/breadcrumbs.rb
@@ -0,0 +1,39 @@
require_relative 'drops/breadcrumb_item.rb'

Jekyll::Hooks.register :pages, :pre_render do |page, payload|
drop = Drops::BreadcrumbItem

if page.url == "/"
then payload["breadcrumbs"] = [
drop.new(page, payload)
]
else
payload["breadcrumbs"] = []
pth = page.url.split("/")

0.upto(pth.size - 1) do |int|
joined_path = pth[0..int].join("/")
item = page.site.pages.find { |page_| joined_path == "" && page_.url == "/" || page_.url.chomp("/") == joined_path }
payload["breadcrumbs"] << drop.new(item, payload) if item
end
end
end

Jekyll::Hooks.register :documents, :pre_render do |documents, payload|
drop = Drops::BreadcrumbItem

if documents.url == "/"
then payload["breadcrumbs"] = [
drop.new(documents, payload)
]
else
payload["breadcrumbs"] = []
pth = documents.url.split("/")

0.upto(pth.size - 1) do |int|
joined_path = pth[0..int].join("/")
item = documents.site.documents.find { |documents| joined_path == "" && documents.url == "/" || documents.url.chomp("/") == joined_path }
payload["breadcrumbs"] << drop.new(item, payload) if item
end
end
end
21 changes: 21 additions & 0 deletions _plugins/jekyll-breadcrumbs/drops/breadcrumb_item.rb
@@ -0,0 +1,21 @@
module Drops
class BreadcrumbItem < Liquid::Drop
extend Forwardable

def_delegator :@page, :data
def_delegator :@page, :url

def initialize(page, payload)
@payload = payload
@page = page
end

def title
@page.data["breadcrumb"] != nil ? @page.data["breadcrumb"] : @page.data["title"]
end

def subset
@page.data["subset"]
end
end
end
1 change: 0 additions & 1 deletion api-draft

This file was deleted.

0 comments on commit f572fb6

Please sign in to comment.