moneropedia auto-fill index, entry for mining

This commit is contained in:
Riccardo Spagni 2015-02-21 15:55:37 +02:00
parent 3851424f2b
commit f7a3f8ec5d
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
3 changed files with 38 additions and 1 deletions

View File

@ -31,6 +31,7 @@ module Jekyll
class Markdown < Converter
alias base_converter convert
@@moneropedia = Array.new
@@moneropedia_ordered = Hash.new
def convert(content)
# build up index of Moneropedia summaries
@ -47,10 +48,27 @@ module Jekyll
if !entry.empty?
@@moneropedia.push({ :terms => entry['terms'], :summary => entry['summary'], :file => File.basename(entry_file, ".*") })
@@moneropedia_ordered = @@moneropedia_ordered.merge({ entry['entry'] => File.basename(entry_file, ".*") })
end
end
end
# Jekyll.logger.warn YAML::dump(@@moneropedia_ordered)
if content.include? '@moneropedia'
# Moneropedia index, replace with a list of entries
cur_letter = 'A'
replace = "<div class='col-lg-4'>\n<h4 class='text-center'>A</h4>\n"
@@moneropedia_ordered.sort.map do |entry, link|
if cur_letter != entry[0]
replace += "</div>\n<div class='col-lg-4'>\n<h4 class='text-center'>" + entry[0] + "</h4>\n"
cur_letter = entry[0]
end
replace += "<a href='/knowledge-base/moneropedia/" + link + "'>" + entry + "</a><br>\n"
end
replace += "</div>"
content = content.gsub(/(\@moneropedia)/i, replace)
end
# replace instances of @term with tooltips of the summary
@@moneropedia.each do |entry|
entry[:terms].each do |term|

View File

@ -9,5 +9,14 @@ icon: "icon_wiki"
attribution: "<!-- Icon is based on work by Freepik (http://www.freepik.com) and is licensed under Creative Commons BY 3.0 -->"
---
### Work in Progress
---
<div class="row">
@moneropedia
</div>
---
If there is an entry you'd like to modify or be added, please [open an issue on this website's Github repository](https://github.com/monero-project/monero-site/issues) or submit changes via pull request.

View File

@ -0,0 +1,10 @@
---
layout: moneropedia
entry: "Mining"
terms: ["mining", "miner", "miners"]
summary: "the process of cryptographically computing a mathematical proof for a block, containing a number of transactions, which is then added to the blockchain"
---
### The Basics
{{ page.summary | capitalize }}.