From eda4c4992164367e2d708d3dc74933a8e5a4f72d Mon Sep 17 00:00:00 2001 From: William Zhang Date: Wed, 28 Feb 2018 15:52:20 -0500 Subject: [PATCH] firebase data --- Gemfile | 2 + _config.yml | 5 ++ _data/about/excomm.json | 98 --------------------------------------- _data/about/officers.json | 35 -------------- _data/about/senators.json | 49 -------------------- _data/about/sponsors.json | 21 --------- _data/forms/events.json | 10 ---- _data/forms/general.json | 10 ---- _plugins/jekyll_get.rb | 40 ++++++++++++++++ about.html | 16 +++---- forms.html | 13 ++---- 11 files changed, 59 insertions(+), 240 deletions(-) delete mode 100644 _data/about/excomm.json delete mode 100644 _data/about/officers.json delete mode 100644 _data/about/senators.json delete mode 100644 _data/about/sponsors.json delete mode 100644 _data/forms/events.json delete mode 100644 _data/forms/general.json create mode 100644 _plugins/jekyll_get.rb diff --git a/Gemfile b/Gemfile index 7f21fd4..d87e1e9 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,8 @@ gem "jekyll", "3.5.2" # This is the default theme for new Jekyll sites. You may change this to anything you like. gem "minima", "~> 2.0" +gem "hash-joiner", "~> 0.0.7" +gem "json", "~> 2.1.0" # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. diff --git a/_config.yml b/_config.yml index 7b3c891..0bb39d1 100644 --- a/_config.yml +++ b/_config.yml @@ -28,6 +28,11 @@ markdown: kramdown plugins: - jekyll-feed +jekyll_get: + - data: about + json: 'https://sgawebsite-e30e2.firebaseio.com/about.json' + - data: forms + json: 'https://sgawebsite-e30e2.firebaseio.com/forms.json' # Exclude from processing. # The following items will not be processed, by default. Create a custom list # to override the default setting. diff --git a/_data/about/excomm.json b/_data/about/excomm.json deleted file mode 100644 index a57e63a..0000000 --- a/_data/about/excomm.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "username" : "excomm", - "name": "SGA Executive Committee", - "description": "The Executive Committee (ExComm) is a integral sub-group of the SGA. Its members act as representatives of the student body. The members work with the officers to organize events and activities throughout to year. While several ExComm positions may have more specific roles, all are working towards the goals of the SGA. Applications to be on ExComm are released every June after Class Council elections have been completed.", - "members": [ - { - "first": "MiJin", - "last": "Cho", - "year": 2019, - "title": "General Activities Coordinator", - "intro": "" - }, - { - "first": "Michael", - "last": "Huang", - "year": 2020, - "title": "General Activities Coordinator", - "intro": "" - }, - { - "first": "Rohan", - "last": "Kalra", - "year": 2020, - "title": "General Activities Coordinator", - "intro": "" - }, - { - "first": "Michael", - "last": "Kyrychenko", - "year": 2020, - "title": "General Activities Coordinator", - "intro": "" - }, - { - "first": "Jade", - "last": "Wang", - "year": 2018, - "title": "General Activities Coordinator", - "intro": "" - }, - { - "first": "Liana", - "last": "Keesing", - "year": 2019, - "title": "Policy Specialist", - "intro": "" - }, - { - "first": "Lulu", - "last": "Lin", - "year": 2018, - "title": "Policy Specialist", - "intro": "" - }, - { - "first": "Afreen", - "last": "Mohideen", - "year": 2019, - "title": "Policy Specialist", - "intro": "" - }, - { - "first": "Ethan", - "last": "Phillips", - "year": 2019, - "title": "Policy Specialist", - "intro": "" - }, - { - "first": "Jahnavi", - "last": "Prabhala", - "year": 2018, - "title": "Policy Specialist", - "intro": "" - }, - { - "first": "William", - "last": "Zhang", - "year": 2018, - "title": "Technology Specialist", - "intro": "" - }, - { - "first": "Beyonce", - "last": "Andrades", - "year": 2020, - "title": "Technology Specialist", - "intro": "" - }, - { - "first": "Katherine", - "last": "Du", - "year": 2018, - "title": "Technology Specialist", - "intro": "" - } - ] -} diff --git a/_data/about/officers.json b/_data/about/officers.json deleted file mode 100644 index d22a4c2..0000000 --- a/_data/about/officers.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "username" : "officers", - "name": "SGA Officers", - "description": "", - "members": [ - { - "first": "Nick", - "last": "Begotka", - "year": 2018, - "title": "", - "intro": "" - }, - { - "first": "Sherry", - "last": "Xie", - "year": 2018, - "title": "", - "intro": "" - }, - { - "first": "Shreya", - "last": "Chappidi", - "year": 2018, - "title": "", - "intro": "" - }, - { - "first": "Sitara", - "last": "Uppalapati", - "year": 2019, - "title": "", - "intro": "" - } - ] -} diff --git a/_data/about/senators.json b/_data/about/senators.json deleted file mode 100644 index bd77ac2..0000000 --- a/_data/about/senators.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "username" : "senators", - "name": "SGA Class Senators", - "description": "Jefferson's student government is divided into school-wide student government (SGA) and grade-level student government (Class Council). While the SGA organizes school-wide events and addresses school-wide concerns and issues, Class Councils represent their grade's needs and host fundraisers and events with the goal to raise money for both Prom and Graduation at the end of senior year. SGA Class Senators serve as Class Council members who are liaisons with the SGA.", - "members": [ - { - "first": "Ashley", - "last": "Lin", - "year": 2018, - "title": "2018 Senator", - "intro": "" - }, - { - "first": "Anna", - "last": "Lulushi", - "year": 2018, - "title": "2018 Senator", - "intro": "" - }, - { - "first": "Laura", - "last": "Gersony", - "year": 2019, - "title": "2019 Senator", - "intro": "" - }, - { - "first": "Sabria", - "last": "Kazmi", - "year": 2019, - "title": "2019 Senator", - "intro": "" - }, - { - "first": "Divjot", - "last": "Bedi", - "year": 2020, - "title": "2020 Senator", - "intro": "" - }, - { - "first": "Megan", - "last": "Dass", - "year": 2020, - "title": "2020 Senator", - "intro": "" - } - ] -} diff --git a/_data/about/sponsors.json b/_data/about/sponsors.json deleted file mode 100644 index 4814dfa..0000000 --- a/_data/about/sponsors.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "username" : "sponsors", - "name": "SGA Sponsors", - "description": "The SGA Sponsors attend all SGA meetings and functions. They also provide invaluable guidance and feedback - whether through late night emails, frigid-cold morning meetings, lunch discussions, or anything in between.", - "members": [ - { - "first": "Amanda", - "last": "Hurowitz", - "year": -1, - "title": "TJ Humanities", - "intro": "" - }, - { - "first": "Marianne", - "last": "Razzino", - "year": -1, - "title": "TJ Mathematics", - "intro": "" - } - ] -} diff --git a/_data/forms/events.json b/_data/forms/events.json deleted file mode 100644 index 415e8a7..0000000 --- a/_data/forms/events.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "username": "events", - "name": "Events", - "items": [ - { - "name": "February Frenzy Volleyball Tournament 2018", - "link": "https://docs.google.com/document/d/1rjzg8tW_NH52lUESdEZMJRsc2Bd-lntKaFYqZ1srmOQ/edit" - } - ] -} diff --git a/_data/forms/general.json b/_data/forms/general.json deleted file mode 100644 index d6c8e25..0000000 --- a/_data/forms/general.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "username": "general", - "name": "General", - "items": [ - { - "name": "Feedback and Suggestions", - "link": "https://docs.google.com/forms/d/18KRo3RritoN6RddNvI-l2zZs1h_1mmVWWgRQGOk2vvQ/viewform" - } - ] -} diff --git a/_plugins/jekyll_get.rb b/_plugins/jekyll_get.rb new file mode 100644 index 0000000..f5fb7e3 --- /dev/null +++ b/_plugins/jekyll_get.rb @@ -0,0 +1,40 @@ +require 'json' +require 'hash-joiner' +require 'open-uri' + +module Jekyll_Get + class Generator < Jekyll::Generator + safe true + priority :highest + + def generate(site) + config = site.config['jekyll_get'] + if !config + return + end + if !config.kind_of?(Array) + config = [config] + end + config.each do |d| + begin + target = site.data[d['data']] + source = JSON.load(open(d['json'])) + if target + HashJoiner.deep_merge target, source + else + site.data[d['data']] = source + end + if d['cache'] + data_source = (site.config['data_source'] || '_data') + path = "#{data_source}/#{d['data']}.json" + open(path, 'wb') do |file| + file << JSON.generate(site.data[d['data']]) + end + end + rescue + next + end + end + end + end +end diff --git a/about.html b/about.html index 2c520e7..97dd1e2 100644 --- a/about.html +++ b/about.html @@ -27,17 +27,15 @@ orgs: ["officers", "excomm", "senators", "sponsors"]
- {% for org_name in site.data.about %} - {% assign name = page.orgs[forloop.index0] %} - {% assign org = site.data.about[name] %} -
-

{{ org.name }}

+ {% for org in site.data.about %} +
+

{{ org['name'] }}

{% for member in org.members %}
{% assign year = member.year | downcase %} {% assign first = member.first | slice: 0 %} {% assign last = member.last | slice: 0,7 %} - {% if name != "sponsors" %} + {% if org['username'] != "sponsors" %} {% capture filename %}img/people/{{ year }}{{ first }}{{ last }}.jpg{% endcapture %} {% else %} {% capture filename %}img/people/{{ first }}{{ last }}.jpg{% endcapture %} @@ -53,15 +51,15 @@ orgs: ["officers", "excomm", "senators", "sponsors"]
{{ member.first }} {{ member.last }} - {% if name != "sponsors" and name != "senators" %} + {% if org['username'] != "sponsors" and org['username'] != "senators" %} {{ year }} {% endif %} - {% if name != "officers" %} + {% if org['username'] != "officers" %} {{ member.title }} {% endif %} - {% if name == "officers" %} + {% if org['username'] == "officers" %}

{{ member.intro }}

{% endif %}
diff --git a/forms.html b/forms.html index 04825b2..2be2879 100644 --- a/forms.html +++ b/forms.html @@ -14,17 +14,14 @@ sections: ["general", "events", "elections"] {% include header.html %}
- {% for form_name in site.data.forms %} - {% assign name = page.sections[forloop.index0] %} - {% assign form = site.data.forms[name] %} + {% for form in site.data.forms %}
- -

{{ form.name }}

+

{{ form['name'] }}