From f7a3f8ec5d65ddf7aa309dc65b22f8fc11801a65 Mon Sep 17 00:00:00 2001
From: Riccardo Spagni <ric@spagni.net>
Date: Sat, 21 Feb 2015 15:55:37 +0200
Subject: [PATCH] moneropedia auto-fill index, entry for mining

---
 _plugins/moneropedia.rb              | 18 ++++++++++++++++++
 knowledge-base/moneropedia/index.md  | 11 ++++++++++-
 knowledge-base/moneropedia/miners.md | 10 ++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 knowledge-base/moneropedia/miners.md

diff --git a/_plugins/moneropedia.rb b/_plugins/moneropedia.rb
index 631d9120..4b07bb9e 100644
--- a/_plugins/moneropedia.rb
+++ b/_plugins/moneropedia.rb
@@ -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|
diff --git a/knowledge-base/moneropedia/index.md b/knowledge-base/moneropedia/index.md
index a822ffa7..f32ee3f8 100644
--- a/knowledge-base/moneropedia/index.md
+++ b/knowledge-base/moneropedia/index.md
@@ -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.
diff --git a/knowledge-base/moneropedia/miners.md b/knowledge-base/moneropedia/miners.md
new file mode 100644
index 00000000..294befe6
--- /dev/null
+++ b/knowledge-base/moneropedia/miners.md
@@ -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 }}.
\ No newline at end of file