Skip to content

Commit

Permalink
Reduce json size (2factorauth#3133)
Browse files Browse the repository at this point in the history
* Reduce json size

as of build, ~800k to ~200k

* Add json verification

* Cleanup for readability

also saves ~1K of extra space by removing more spaces

* Fix tabs and spaces

* tabbing cleanup
  • Loading branch information
stephengroat authored and brycx committed Aug 29, 2018
1 parent 349afec commit 941ef98
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'github-pages', group: :jekyll_plugins
group :test do
gem 'fastimage'
gem 'html-proofer'
gem 'jsonlint'
gem 'kwalify'
gem 'rake'
gem 'rubocop'
Expand Down
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require 'html-proofer'
require 'rubocop/rake_task'
require 'jekyll'
require 'jsonlint/rake_task'

task default: %w[proof verify rubocop]
task default: %w[proof verify jsonlint rubocop]

task :build do
config = Jekyll.configuration(
Expand Down Expand Up @@ -32,6 +33,10 @@ task proof_external: 'build' do
).run
end

JsonLint::RakeTask.new do |t|
t.paths = %w[_site/data.json]
end

task :verify do
ruby './verify.rb'
end
Expand Down
37 changes: 20 additions & 17 deletions data.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
---
---
{
{% for section in site.data.sections %}
{% assign section_file = site.data[section.id] %}
"{{ section.title }}": {
{% for website in section_file.websites %}
"{{ website.name }}": {
{%for tag in website %}
{%if tag[0] != "exceptions"%}"{{ tag[0] }}": {% if tag[1] == true or tag[1] == false %}{{tag[1]}}{%else%}"{{ tag[1] }}"{%endif%}{%else%}"{{ tag[0] }}": {
{% for exception in tag[1] %}
"{{ exception[0] }}": "{{ exception[1] }}"{%if forloop.last != true%},{%endif%}
{%endfor%}}{%endif%}{%if forloop.last != true%},{%endif%}
{%endfor%}
}{% if forloop.last != true %},{% endif %}
{% endfor %}
}{% if forloop.last != true %},{% endif %}
{% endfor %}
}
{% raw %}{{% endraw %}{%
for section in site.data.sections %}{%
assign section_file = site.data[section.id] %}"{{ section.title }}":{% raw %}{{% endraw %}{%
for website in section_file.websites %}"{{ website.name }}":{% raw %}{{% endraw %}{%
for tag in website %}{%
if tag[0] != "exceptions" %}"{{ tag[0] }}":{%
if tag[1] == true or tag[1] == false %}{{tag[1]}}{%
else %}"{{ tag[1] }}"{%
endif %}{%
else %}"{{ tag[0] }}":{% raw %}{{% endraw %}{%
for exception in tag[1] %}"{{ exception[0] }}":"{{ exception[1] }}"{%
if forloop.last != true %},{% endif %}{%
endfor %}}{%
endif %}{%
if forloop.last != true %},{% endif %}{%
endfor %}}{%
if forloop.last != true %},{% endif %}{%
endfor %}}{%
if forloop.last != true %},{% endif %}{%
endfor %}}

0 comments on commit 941ef98

Please sign in to comment.