From e10fa1753361f5f043713846f5f61b6e8912e1f2 Mon Sep 17 00:00:00 2001 From: Ashley Davies Date: Tue, 6 Aug 2024 14:56:08 +0200 Subject: [PATCH 1/2] Include JSON representation of upcoming and past conferences --- _layouts/default.html | 2 +- past.json | 32 ++++++++++++++++++++++++++++++++ upcoming.json | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 past.json create mode 100644 upcoming.json diff --git a/_layouts/default.html b/_layouts/default.html index 4f87b33c..60c76e45 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -33,7 +33,7 @@

Android Conferences

{{ content }} diff --git a/past.json b/past.json new file mode 100644 index 00000000..532a2056 --- /dev/null +++ b/past.json @@ -0,0 +1,32 @@ +--- +layout: none +--- +[ +{%- assign sorted_conferences = site.conferences | sort: 'date_start' | reverse -%} +{%- assign today = site.time | date: "%s" -%} +{%- for conference in sorted_conferences -%} + {%- assign date_end = conference.date_end | date: "%s" -%} + {%- if today >= date_end %} + { + "name": "{{ conference.name }}", + "website": "{{ conference.website }}", + "location": "{{ conference.location }}", + {%- if conference.status %} + "status": "{{ conference.status }}", + {%- endif -%} + {%- if conference.online %} + "online": true, + {%- endif %} + "dateStart": "{{ conference.date_start | date: "%Y-%m-%d" }}", + "dateEnd": "{{ conference.date_end | date: "%Y-%m-%d" }}", + {%- if conference.cfp.start %} + "cfp": { + "start": "{{ conference.cfp.start | date: "%Y-%m-%d" }}", + "end": "{{ conference.cfp.end | date: "%Y-%m-%d" }}", + "site": "{% if conference.cfp.site %}{{ conference.cfp.site }}{% else %}{{ conference.website }}{% endif %}" + } + {%- endif -%} + }{% unless forloop.last %}, {% endunless %} + {%- endif -%} +{%- endfor -%} +] diff --git a/upcoming.json b/upcoming.json new file mode 100644 index 00000000..f7c5c916 --- /dev/null +++ b/upcoming.json @@ -0,0 +1,32 @@ +--- +layout: none +--- +[ +{%- assign sorted_conferences = site.conferences | sort: 'date_start' -%} +{%- assign today = site.time | date: "%s" -%} +{%- for conference in sorted_conferences -%} + {%- assign date_end = conference.date_end | date: "%s" -%} + {%- if today < date_end %} + { + "name": "{{ conference.name }}", + "website": "{{ conference.website }}", + "location": "{{ conference.location }}", + {%- if conference.status %} + "status": "{{ conference.status }}", + {%- endif -%} + {%- if conference.online %} + "online": true, + {%- endif %} + "dateStart": "{{ conference.date_start | date: "%Y-%m-%d" }}", + "dateEnd": "{{ conference.date_end | date: "%Y-%m-%d" }}", + {%- if conference.cfp.start %} + "cfp": { + "start": "{{ conference.cfp.start | date: "%Y-%m-%d" }}", + "end": "{{ conference.cfp.end | date: "%Y-%m-%d" }}", + "site": "{% if conference.cfp.site %}{{ conference.cfp.site }}{% else %}{{ conference.website }}{% endif %}" + } + {%- endif -%} + }{% unless forloop.last %}, {% endunless %} + {%- endif -%} +{%- endfor -%} +] From 00b7a321a6452cf2313999a03660820343e59554 Mon Sep 17 00:00:00 2001 From: Ashley Davies Date: Wed, 7 Aug 2024 11:30:21 +0200 Subject: [PATCH 2/2] Apply correct line formatting and leading comma for JSON spec --- past.json | 10 +++++----- upcoming.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/past.json b/past.json index 532a2056..dc3e3287 100644 --- a/past.json +++ b/past.json @@ -18,15 +18,15 @@ layout: none "online": true, {%- endif %} "dateStart": "{{ conference.date_start | date: "%Y-%m-%d" }}", - "dateEnd": "{{ conference.date_end | date: "%Y-%m-%d" }}", - {%- if conference.cfp.start %} + "dateEnd": "{{ conference.date_end | date: "%Y-%m-%d" }}" + {%- if conference.cfp.start -%}, "cfp": { "start": "{{ conference.cfp.start | date: "%Y-%m-%d" }}", "end": "{{ conference.cfp.end | date: "%Y-%m-%d" }}", "site": "{% if conference.cfp.site %}{{ conference.cfp.site }}{% else %}{{ conference.website }}{% endif %}" } - {%- endif -%} - }{% unless forloop.last %}, {% endunless %} + {%- endif %} + }{% unless forloop.last %}, {% endunless %} {%- endif -%} -{%- endfor -%} +{%- endfor %} ] diff --git a/upcoming.json b/upcoming.json index f7c5c916..538b5499 100644 --- a/upcoming.json +++ b/upcoming.json @@ -18,15 +18,15 @@ layout: none "online": true, {%- endif %} "dateStart": "{{ conference.date_start | date: "%Y-%m-%d" }}", - "dateEnd": "{{ conference.date_end | date: "%Y-%m-%d" }}", - {%- if conference.cfp.start %} + "dateEnd": "{{ conference.date_end | date: "%Y-%m-%d" }}" + {%- if conference.cfp.start -%}, "cfp": { "start": "{{ conference.cfp.start | date: "%Y-%m-%d" }}", "end": "{{ conference.cfp.end | date: "%Y-%m-%d" }}", "site": "{% if conference.cfp.site %}{{ conference.cfp.site }}{% else %}{{ conference.website }}{% endif %}" } - {%- endif -%} - }{% unless forloop.last %}, {% endunless %} + {%- endif %} + }{% unless forloop.last %}, {% endunless %} {%- endif -%} -{%- endfor -%} +{%- endfor %} ]