]> git.mdlowis.com Git - projs/mdlowis.com.git/commitdiff
Prototype ruby generation script
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 5 Jan 2017 03:42:29 +0000 (22:42 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 5 Jan 2017 03:42:29 +0000 (22:42 -0500)
13 files changed:
pages/0-home.md [moved from pages/home.md with 99% similarity]
pages/1-articles.md [moved from pages/articles.md with 55% similarity]
pages/2-projects.md [new file with mode: 0644]
pages/3-prototypes.md [new file with mode: 0644]
pages/projects.md [deleted file]
pages/prototypes.md [deleted file]
site/articles.html
site/home.html
site/index.html [deleted file]
site/projects.html
site/prototypes.html
templates/page.erb [new file with mode: 0644]
update.rb [new file with mode: 0755]

similarity index 99%
rename from pages/home.md
rename to pages/0-home.md
index 7f8275fa3df7d3831ca7068a87221ee28d0975d8..8fc59563a8fb4f8f127c46ee0d2f0f0cc91b0eb9 100644 (file)
@@ -1,6 +1,3 @@
-TYPE page
-MENUID 0
----
 # Header 1
 
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sed accumsan sapien. Phasellus consequat metus sit amet est imperdiet vestibulum. Morbi vitae placerat mauris. Etiam ac mauris finibus, sagittis augue vitae, tempus dolor. Mauris egestas maximus urna eu fringilla. Pellentesque et pulvinar mi. Phasellus massa ipsum, mattis vel ipsum dictum, pretium dignissim dui. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut mattis risus elit, sit amet commodo lacus tincidunt eget. Phasellus arcu lorem, consequat ut augue sed, iaculis lobortis ex. Integer non sem tincidunt urna aliquam tempor eget sed libero. Aliquam hendrerit velit quis augue ullamcorper, quis maximus sapien volutpat. In hac habitasse platea dictumst. Aenean tincidunt, odio at luctus suscipit, justo mauris faucibus turpis, et posuere enim nibh in nulla. Nam in lorem vel sem vehicula consectetur a et tortor.
similarity index 55%
rename from pages/articles.md
rename to pages/1-articles.md
index 998a635febb5c64a87457d39d559d1533cfedf53..4759ec5f7d11fa3236e41eb4eb23ecbbe4ec28f9 100644 (file)
@@ -1,6 +1,3 @@
-TYPE page
-MENUID 1
----
 # Articles
 
 articles
diff --git a/pages/2-projects.md b/pages/2-projects.md
new file mode 100644 (file)
index 0000000..e6e5dd7
--- /dev/null
@@ -0,0 +1,9 @@
+# Projects
+
+* [mikedlowis.github.io](https://github.com/mikedlowis/mikedlowis.github.io) - 
+* [atf](https://github.com/mikedlowis/atf) - Aardvark Test Framework
+* [carl](https://github.com/mikedlowis/carl) - 
+* [onward](https://github.com/mikedlowis/onward) - 
+* [libcds](https://github.com/mikedlowis/libcds) - A collection of data structures implemented in C to be included in multiple projects.
+* [opts](https://github.com/mikedlowis/opts) - A simple and lightweight options parsing library written in C
+* [build-system](https://github.com/mikedlowis/build-system) - Build scripts based on RScons for a variety of different projects.
diff --git a/pages/3-prototypes.md b/pages/3-prototypes.md
new file mode 100644 (file)
index 0000000..5aa4263
--- /dev/null
@@ -0,0 +1,14 @@
+# Prototypes
+
+* [editor](https://github.com/mikedlowis-prototypes/editor) - 
+* [sclpl](https://github.com/mikedlowis-prototypes/sclpl) - 
+* [albase](https://github.com/mikedlowis-prototypes/albase) - Base tools for aardvark-linux
+* [abt](https://github.com/mikedlowis-prototypes/abt) - Aardvark Build Tool
+* [aardvark-linux](https://github.com/mikedlowis-prototypes/aardvark-linux) - 
+* [acc](https://github.com/mikedlowis-prototypes/acc) - Aardvark Chat Client - terminal based xmpp chat client
+* [gir](https://github.com/mikedlowis-prototypes/gir) - 
+* [libbk](https://github.com/mikedlowis-prototypes/libbk) - A static library implementing several garbage collection algorithms which can be selected at link time.
+* [atc](https://github.com/mikedlowis-prototypes/atc) - Algebraic Types in C
+* [lfs](https://github.com/mikedlowis-prototypes/lfs) - 
+* [mabs](https://github.com/mikedlowis-prototypes/mabs) - 
+* [afm](https://github.com/mikedlowis-prototypes/afm) - Aardvark File Manager
diff --git a/pages/projects.md b/pages/projects.md
deleted file mode 100644 (file)
index 0439d65..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-TYPE page
-MENUID 2
----
-# Projects
-
-projects
diff --git a/pages/prototypes.md b/pages/prototypes.md
deleted file mode 100644 (file)
index 49d20d8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-TYPE page
-MENUID 3
----
-# Prototypes
-
-prototypes
-
index ff442188ab49b46e37e028a8f98565df65c74963..a44fbf92035d3f5a037d54746ee6d83dc856e5c7 100644 (file)
     </div>
 
     <div class="menu">
-        <span class="left">
-            <a id="menuitem0" href="home.html">home</a>
-            <a id="menuitem1" href="articles.html">articles</a>
-            <a id="menuitem2" href="projects.html">projects</a>
-            <a id="menuitem3" href="prototypes.html">prototypes</a>
-        </span>
+        <span class='left'>
+<a id='menuitem0' href='home.html'>home</a>
+<a id='menuitem1' href='articles.html'>articles</a>
+<a id='menuitem2' href='projects.html'>projects</a>
+<a id='menuitem3' href='prototypes.html'>prototypes</a>
+</span>
+
     </div>
 
     <div class="content">
 
         <div class="main">
             <h1>Articles</h1>
-<p>articles</p>
+<h2>articles</h2>
+<p>foo</p>
+
+
         </div>
     </div>
 
     <div class="footer">
-        <span class="right">© 2015 Michael D. Lowis</span>
+        <span class="right">© 2017 Michael D. Lowis</span>
     </div>
 </body><div></div></html>
index 54a39cb3bae8286a7f22ca86a5db796eae937bf0..7343942b1cec795b21d6331048a4b0e3a504d405 100644 (file)
     </div>
 
     <div class="menu">
-        <span class="left">
-            <a id="menuitem0" href="home.html">home</a>
-            <a id="menuitem1" href="articles.html">articles</a>
-            <a id="menuitem2" href="projects.html">projects</a>
-            <a id="menuitem3" href="prototypes.html">prototypes</a>
-        </span>
+        <span class='left'>
+<a id='menuitem0' href='home.html'>home</a>
+<a id='menuitem1' href='articles.html'>articles</a>
+<a id='menuitem2' href='projects.html'>projects</a>
+<a id='menuitem3' href='prototypes.html'>prototypes</a>
+</span>
+
     </div>
 
     <div class="content">
 <p>Cras interdum sodales nisl, sed iaculis orci venenatis ac. Duis vel finibus risus, ac tincidunt elit. Vivamus ut lectus bibendum, consectetur nisi eget, tincidunt mi. Phasellus vulputate urna in lacus cursus, eu condimentum ligula porta. Phasellus posuere condimentum diam, id luctus nibh. Mauris at sodales odio. Vivamus tincidunt a ante a rhoncus. Sed augue turpis, lobortis ut placerat sed, auctor nec lectus. Ut elementum cursus est, sed tristique ante malesuada nec. Maecenas vitae mattis urna, vel commodo dolor. Sed eu efficitur augue. Cras enim velit, fermentum et nibh sed, pharetra pulvinar sem. Sed quis ullamcorper dolor. Donec dictum imperdiet sapien vitae mattis. Mauris sit amet leo vitae purus sodales posuere eget id dui.</p>
 <h4>Header 4</h4>
 <p>Nullam vulputate, quam sed congue convallis, arcu lectus feugiat nibh, eget efficitur nunc tortor a velit. Aliquam ultrices tellus quis mollis lobortis. Cras et dolor porttitor nisi suscipit venenatis vel vel sem. Mauris tristique lectus quis dolor mattis, rhoncus scelerisque tortor pellentesque. Sed eu tincidunt urna. Morbi a euismod mauris. Nunc nec nibh et augue tristique mattis et eget augue. Mauris lobortis, felis in fringilla euismod, sapien libero consequat dui, id maximus nisi eros quis turpis. Quisque nec lobortis augue, sed rutrum sem. Ut ultricies pellentesque felis, a luctus nulla finibus ut. Morbi eu nunc sapien. Etiam scelerisque ex ut lacus gravida, sed consectetur mauris suscipit. Aliquam sed cursus urna, sit amet efficitur eros. Mauris in metus vitae augue aliquet convallis. Quisque eget odio egestas, gravida nisl at, accumsan mauris.</p>
+
+
         </div>
     </div>
 
     <div class="footer">
-        <span class="right">© 2015 Michael D. Lowis</span>
+        <span class="right">© 2017 Michael D. Lowis</span>
     </div>
 </body><div></div></html>
diff --git a/site/index.html b/site/index.html
deleted file mode 100644 (file)
index fa7a7e9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-        <meta charset="utf-8">
-    </head>
-    <body>
-        <script>
-            window.location = "/site/home.html";
-        </script>
-    </body>
-</html>
index 051853c66cf26d46229c443ed1d40da9188e892c..2effe87ff0ba1c8c215c6623a4064f6a90e9b487 100644 (file)
     </div>
 
     <div class="menu">
-        <span class="left">
-            <a id="menuitem0" href="home.html">home</a>
-            <a id="menuitem1" href="articles.html">articles</a>
-            <a id="menuitem2" href="projects.html">projects</a>
-            <a id="menuitem3" href="prototypes.html">prototypes</a>
-        </span>
+        <span class='left'>
+<a id='menuitem0' href='home.html'>home</a>
+<a id='menuitem1' href='articles.html'>articles</a>
+<a id='menuitem2' href='projects.html'>projects</a>
+<a id='menuitem3' href='prototypes.html'>prototypes</a>
+</span>
+
     </div>
 
     <div class="content">
 
         <div class="main">
             <h1>Projects</h1>
-<p>projects</p>
+<ul>
+<li>
+<a href="https://github.com/mikedlowis/mikedlowis.github.io">mikedlowis.github.io</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis/atf">atf</a> - Aardvark Test Framework
+</li><li>
+<a href="https://github.com/mikedlowis/carl">carl</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis/onward">onward</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis/libcds">libcds</a> - A collection of data structures implemented in C to be included in multiple projects.
+</li><li>
+<a href="https://github.com/mikedlowis/opts">opts</a> - A simple and lightweight options parsing library written in C
+</li><li>
+<a href="https://github.com/mikedlowis/build-system">build-system</a> - Build scripts based on RScons for a variety of different projects.
+</li>
+</ul>
+
+
         </div>
     </div>
 
     <div class="footer">
-        <span class="right">© 2015 Michael D. Lowis</span>
+        <span class="right">© 2017 Michael D. Lowis</span>
     </div>
 </body><div></div></html>
index 1fa2443660b1cb17bae96775def4a49e8435029d..eaf6681e5f9dc595cc77ae38eff53310dc76180e 100644 (file)
     </div>
 
     <div class="menu">
-        <span class="left">
-            <a id="menuitem0" href="home.html">home</a>
-            <a id="menuitem1" href="articles.html">articles</a>
-            <a id="menuitem2" href="projects.html">projects</a>
-            <a id="menuitem3" href="prototypes.html">prototypes</a>
-        </span>
+        <span class='left'>
+<a id='menuitem0' href='home.html'>home</a>
+<a id='menuitem1' href='articles.html'>articles</a>
+<a id='menuitem2' href='projects.html'>projects</a>
+<a id='menuitem3' href='prototypes.html'>prototypes</a>
+</span>
+
     </div>
 
     <div class="content">
 
         <div class="main">
             <h1>Prototypes</h1>
-<p>prototypes</p>
+<ul>
+<li>
+<a href="https://github.com/mikedlowis-prototypes/editor">editor</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/sclpl">sclpl</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/albase">albase</a> - Base tools for aardvark-linux
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/abt">abt</a> - Aardvark Build Tool
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/aardvark-linux">aardvark-linux</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/acc">acc</a> - Aardvark Chat Client - terminal based xmpp chat client
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/gir">gir</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/libbk">libbk</a> - A static library implementing several garbage collection algorithms which can be selected at link time.
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/atc">atc</a> - Algebraic Types in C
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/lfs">lfs</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/mabs">mabs</a> - 
+</li><li>
+<a href="https://github.com/mikedlowis-prototypes/afm">afm</a> - Aardvark File Manager
+</li>
+</ul>
+
+
         </div>
     </div>
 
     <div class="footer">
-        <span class="right">© 2015 Michael D. Lowis</span>
+        <span class="right">© 2017 Michael D. Lowis</span>
     </div>
 </body><div></div></html>
diff --git a/templates/page.erb b/templates/page.erb
new file mode 100644 (file)
index 0000000..a34d16c
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<!-- Site design *heavily* based on the excellent design of http://suckless.org/ -->
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Simplicity is the ultimate sophistication</title>
+    <link rel="shortcut icon" type="image/x-icon" href="/site/logo.png" />
+    <link rel="stylesheet" type="text/css" href="/site/style.css">
+    <meta charset="utf-8">
+    <style>
+    #menuitem<%= @menuid %> { font-weight: bold; }
+    </style>
+</head>
+<body>
+    <div class="header">
+        <a href="index.html"><img src="/site/logo.png"></a>
+        <a class="headerLink" href="index.html">mdlowis</a>
+        <span class="headerSubtitle">Simplicity is the ultimate sophistication</span>
+    </div>
+
+    <div class="menu">
+        <%= getmenu() %>
+    </div>
+
+    <div class="content">
+        <div class="nav">
+            <ul>
+                <li><a href="" class="thisPage">link1</a></li>
+                <li><a href="">link2</a></li>
+                <li><a href="">link3</a></li>
+            </ul>
+        </div>
+
+        <div class="main">
+            <%= @contents %>
+        </div>
+    </div>
+
+    <div class="footer">
+        <span class="right">© 2017 Michael D. Lowis</span>
+    </div>
+</body><div></div></html>
diff --git a/update.rb b/update.rb
new file mode 100755 (executable)
index 0000000..ca1235a
--- /dev/null
+++ b/update.rb
@@ -0,0 +1,91 @@
+#!/usr/bin/ruby
+require 'open-uri'
+require 'nokogiri'
+require 'erb'
+
+def trim(str)
+  str.sub(/^[\t\n ]*/, "").sub(/[\t\n ]*$/, "")
+end
+
+def user_repos(user)
+  url = "https://github.com/#{user}?tab=repositories"
+  sel = 'div[class=js-repo-list] li[class~=source]'
+  items = Nokogiri::HTML(open(url)).css(sel).map do |e|
+    reponame = trim(e.css('div h3 a').text)
+    { name: reponame, 
+      desc: trim(e.css('div p').text),
+      url:  "https://github.com/#{user}/#{reponame}" }
+  end
+end
+
+def org_repos(org)
+  url = "https://github.com/#{org}"
+  sel = 'div[class~=repo-list] li[class~=source]'
+  items = Nokogiri::HTML(open(url)).css(sel).map do |e|
+    reponame = trim(e.css('div h3 a').text)
+    { name: reponame, 
+      desc: trim(e.css('div p').text),
+      url:  "https://github.com/#{org}/#{reponame}" }
+  end
+end
+
+#------------------------------------------------------------------------------
+
+class Page
+  include ERB::Util
+  attr_accessor :title, :menuid, :contents
+  
+  def initialize(page)
+    match = page.match(/(\d+)-(.+).md/)
+    @title = match[2].capitalize
+    @menuid = match[1]
+    @contents = `tools/md2html.awk #{page}`
+  end
+
+  def render()
+    ERB.new(IO.read("templates/page.erb")).result(binding)
+  end
+
+  def save(file)
+    File.open(file, "w+") do |f|
+      f.write(render)
+    end
+  end
+  
+  def getmenu()
+    menu = "<span class='left'>\n"
+    Dir.glob('pages/*.md').each_with_index do |e,idx|
+        page = e.match(/\d+-(.+).md/)[1]
+        menu += "<a id='menuitem#{idx}' href='#{page}.html'>#{page}</a>\n" 
+    end
+    menu += "</span>\n"
+    menu
+  end
+end
+
+#------------------------------------------------------------------------------
+
+File.open("pages/2-projects.md", "w") do |f|
+  f.puts "# Projects\n\n"
+  user_repos('mikedlowis').each do |e|
+    f.puts "* [#{e[:name]}](#{e[:url]}) - #{e[:desc]}"
+  end
+end
+
+File.open("pages/3-prototypes.md", "w") do |f|
+  f.puts "# Prototypes\n\n"
+  org_repos('mikedlowis-prototypes').each do |e|
+    f.puts "* [#{e[:name]}](#{e[:url]}) - #{e[:desc]}"
+  end
+end
+
+Dir.glob('pages/*.md').each do |md|
+  html = "site/" + md.match(/\d+-(.+).md/)[1] + ".html"
+  puts "#{md} -> #{html}"
+  Page.new(md).save(html)
+end
+
+# Generate Home Page
+# Generate Articles Page
+# Generate Projects Page
+# Generate Prototypes Page
\ No newline at end of file