From 685f1b4de211501389d9f375f231bbf33f4a292e Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Tue, 16 Jul 2013 11:28:32 -0400 Subject: [PATCH 1/2] expose license data as an api, fixes #40 --- licenses.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 licenses.json diff --git a/licenses.json b/licenses.json new file mode 100644 index 0000000..d70fa41 --- /dev/null +++ b/licenses.json @@ -0,0 +1,28 @@ +--- +comment: \ + because the for loop is being filtered by layout, the normal rindex0 check + for the trailing comma doesn't work. Count the number of licenses and manually + increment an index to see if we're on the true last iteration. +--- +{% assign count = 0 %}{% for page in site.pages %}{% if page.layout == "license" %}{% assign count = count | plus: 1 %}{% endif %}{% endfor %}{% assign i = 0 %} +[ +{% for page in site.pages %}{% if page.layout == "license" %} + { + "title": "{{ page.title }}", + "permalink": "{{ page.permalink }}", + "featured": {% if page.featured %}true{% else %}false{% endif %}, + "description": "{{ page.description | replace: '"', '\"' }}", + "how": "{{ page.how | replace: '"', '\"' }}", + "rules": { + {% for category in site.rules %} + {% assign cat = category[0] %} + "{{ cat }}": [ + {% for rule in page[cat] %} + "{{ rule }}"{% if forloop.rindex0 > 0 %},{% endif %} + {% endfor %} + ]{% if forloop.rindex0 > 0 %},{% endif %} + {% endfor %} + }{% assign i = i | plus: 1 %} + }{% if i < count %},{% endif %} + {% endif %}{% endfor %} +] \ No newline at end of file From 73def230ea672e9b045f0c6da323692435c8e970 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Tue, 16 Jul 2013 11:33:33 -0400 Subject: [PATCH 2/2] cleanup yaml comment --- licenses.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/licenses.json b/licenses.json index d70fa41..30d207f 100644 --- a/licenses.json +++ b/licenses.json @@ -1,8 +1,8 @@ --- comment: \ - because the for loop is being filtered by layout, the normal rindex0 check - for the trailing comma doesn't work. Count the number of licenses and manually - increment an index to see if we're on the true last iteration. + because the for loop is being filtered by layout, the normal rindex0 check + for the trailing comma doesn't work. Count the number of licenses and manually + increment an index to see if we're on the true last iteration. --- {% assign count = 0 %}{% for page in site.pages %}{% if page.layout == "license" %}{% assign count = count | plus: 1 %}{% endif %}{% endfor %}{% assign i = 0 %} [