WIP #1723: Reworked transformation of site.devsearches

This commit is contained in:
Igor Kuzmenko 2017-11-23 00:10:51 +01:00
parent 819368a991
commit c310832313
3 changed files with 40 additions and 22 deletions

View File

@ -5,7 +5,11 @@ http://opensource.org/licenses/MIT.
><a href="https://github.com/bitcoin-dot-org/bitcoin.org/edit/master/{{filename|uri_escape}}">{% translate subheadlinkedit developer-documentation %}</a>
| <a href="https://github.com/bitcoin-dot-org/bitcoin.org/commits/master/{{filename|uri_escape}}">{% translate subheadlinkhistory developer-documentation %}</a>
| <a href="https://github.com/bitcoin-dot-org/bitcoin.org/issues/new?body=Source%20File%3A%20{{filename|uri_escape}}%0A%0A">{% translate subheadlinkreport developer-documentation %}</a>
| <a href="/{{ page.lang }}/development#devcommunities">{% translate subheadlinkdiscuss developer-documentation %}</a></div>
| <a href="/{{ page.lang }}/development#devcommunities">{% translate subheadlinkdiscuss developer-documentation %}</a>
{% if page.lang != "en" %}
| <a href="/{{ page.lang }}/development#devcommunities">{% translate subheadlinktranslate developer-documentation %}</a>
{% endif %}
</div>
{% else %}
{% die "source filename not set" %}
{% endif %}

View File

@ -133,7 +133,40 @@ module Jekyll
site.pages << GlossaryPage.new(site, site.source, lang, glossary_dir, src, output_directory)
end
site.config["devsearches_json"] = site.config["devsearches"].to_json
devsearches_json = []
site.config["devsearches"].each {| cat, items |
devsearches_data_item = {}
if cat == "Glossary"
items.each {| lang, list |
list.each {| el |
flat = el.flatten
devsearches_json.push({
"label" => flat[0],
"uri" => flat[1],
"category" => cat,
"lang" => lang
})
}
# puts list
}
else
items.each {| el |
flat = el.flatten
devsearches_json.push({
"label" => flat[0],
"uri" => flat[1],
"category" => cat,
"lang" => "en"
})
}
end
# devsearches_json.unshift({ term => output_full_path })
# puts items
}
site.config["devsearches_json"] = devsearches_json.to_json
# #TODO definition pages are only generated for English language,
# #but they could also be translated at some point. They would however

View File

@ -21,26 +21,7 @@ Nested loops below:
"use strict";
var search_data = [
{% for list in site.devsearches %}{% for item in list %}
{% if forloop.first %}{% capture category_name %}{{item}}{% endcapture %}
{% else %}{% for sublist in item %}{% for term in sublist %}
{% if category_name == "Glossary" %}
{% for subterm in term %}
{
label: "{{subterm[0]}}",
uri: "{{subterm[1]}}",
category: "{{category_name}}",
lang: "{{sublist[0]}}"
}
{% unless forloop.last %},{% endunless %}{% endfor %}
{% else %}
{
label: "{{term[0]}}",
uri: "{{term[1]}}",
category: "{{category_name}}"
}{% endif %}{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %}{% endif %}{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %}
];
var search_data = {{ site.devsearches_json }}
{% raw %}