Skip to content

Commit

Permalink
WIP #1723: Reworked transformation of site.devsearches
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzzmi committed Nov 22, 2017
1 parent 819368a commit c310832
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
6 changes: 5 additions & 1 deletion _includes/helpers/subhead-links.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
35 changes: 34 additions & 1 deletion _plugins/glossary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,40 @@ def generate(site)
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
Expand Down
21 changes: 1 addition & 20 deletions js/devsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit c310832

Please sign in to comment.