From: Michael D. Lowis Date: Thu, 5 Jan 2017 03:42:29 +0000 (-0500) Subject: Prototype ruby generation script X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=5f8379e9bf666a403955713fcbb9bbf31a1cca28;p=projs%2Fmdlowis.com.git Prototype ruby generation script --- diff --git a/pages/home.md b/pages/0-home.md similarity index 99% rename from pages/home.md rename to pages/0-home.md index 7f8275f..8fc5956 100644 --- a/pages/home.md +++ b/pages/0-home.md @@ -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. diff --git a/pages/articles.md b/pages/1-articles.md similarity index 55% rename from pages/articles.md rename to pages/1-articles.md index 998a635..4759ec5 100644 --- a/pages/articles.md +++ b/pages/1-articles.md @@ -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 index 0000000..e6e5dd7 --- /dev/null +++ b/pages/2-projects.md @@ -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 index 0000000..5aa4263 --- /dev/null +++ b/pages/3-prototypes.md @@ -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 index 0439d65..0000000 --- a/pages/projects.md +++ /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 index 49d20d8..0000000 --- a/pages/prototypes.md +++ /dev/null @@ -1,7 +0,0 @@ -TYPE page -MENUID 3 ---- -# Prototypes - -prototypes - diff --git a/site/articles.html b/site/articles.html index ff44218..a44fbf9 100644 --- a/site/articles.html +++ b/site/articles.html @@ -17,12 +17,13 @@
@@ -36,11 +37,14 @@

Articles

-

articles

+

articles

+

foo

+ +
diff --git a/site/home.html b/site/home.html index 54a39cb..7343942 100644 --- a/site/home.html +++ b/site/home.html @@ -17,12 +17,13 @@
@@ -43,10 +44,12 @@

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.

Header 4

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.

+ +
diff --git a/site/index.html b/site/index.html deleted file mode 100644 index fa7a7e9..0000000 --- a/site/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/site/projects.html b/site/projects.html index 051853c..2effe87 100644 --- a/site/projects.html +++ b/site/projects.html @@ -17,12 +17,13 @@
@@ -36,11 +37,29 @@

Projects

-

projects

+
    +
  • +mikedlowis.github.io - +
  • +atf - Aardvark Test Framework +
  • +carl - +
  • +onward - +
  • +libcds - A collection of data structures implemented in C to be included in multiple projects. +
  • +opts - A simple and lightweight options parsing library written in C +
  • +build-system - Build scripts based on RScons for a variety of different projects. +
  • +
+ +
diff --git a/site/prototypes.html b/site/prototypes.html index 1fa2443..eaf6681 100644 --- a/site/prototypes.html +++ b/site/prototypes.html @@ -17,12 +17,13 @@
@@ -36,11 +37,39 @@

Prototypes

-

prototypes

+
    +
  • +editor - +
  • +sclpl - +
  • +albase - Base tools for aardvark-linux +
  • +abt - Aardvark Build Tool +
  • +aardvark-linux - +
  • +acc - Aardvark Chat Client - terminal based xmpp chat client +
  • +gir - +
  • +libbk - A static library implementing several garbage collection algorithms which can be selected at link time. +
  • +atc - Algebraic Types in C +
  • +lfs - +
  • +mabs - +
  • +afm - Aardvark File Manager +
  • +
+ +
diff --git a/templates/page.erb b/templates/page.erb new file mode 100644 index 0000000..a34d16c --- /dev/null +++ b/templates/page.erb @@ -0,0 +1,40 @@ + + + + Simplicity is the ultimate sophistication + + + + + + +
+ + mdlowis + Simplicity is the ultimate sophistication +
+ + + +
+ + +
+ <%= @contents %> +
+
+ + +
diff --git a/update.rb b/update.rb new file mode 100755 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 = "\n" + Dir.glob('pages/*.md').each_with_index do |e,idx| + page = e.match(/\d+-(.+).md/)[1] + menu += "#{page}\n" + end + menu += "\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