Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added showdown for markdown description files; uses readme.md for des…

…cription text.
  • Loading branch information...
commit f03b0d69e1a3f542e064ee4b419ebcdd252294dd 1 parent fcf0df8
Gary Hodgson authored
2  _config.yml
View
@@ -30,7 +30,7 @@ githubiverse:
## Optional. When uncommented appends the content of the file defined here to the project description. Any text in index.md, after the yaml header, will be shown first.
## WARNING: since the github outage on 12th Sep. this feature does not currently work.
- #description_file: readme.md
+ description_file: README.md
## Preview the first STL in the list when the page loads.
autoload_stl: true
2  _includes/footer.html
View
@@ -1,4 +1,4 @@
<footer>
<hr>
- <small>Built with: <a href="https://github.com">Github Pages</a>, <a href="http://twitter.github.com/bootstrap">Twitter Bootstrap</a>, <a href="http://lokeshdhakar.com/projects/lightbox2/">Lightbox2</a>, <a href="http://github.com/tbuser/thingiview.js">Thingiview.js</a>, <a href="https://github.com/k33g/gh3">gh3</a></small>, <a href="https://github.com/zachleat/Humane-Dates">Humane-Dates</a>
+ <small>Built with: <a href="https://github.com">Github Pages</a>, <a href="http://twitter.github.com/bootstrap">Twitter Bootstrap</a>, <a href="http://lokeshdhakar.com/projects/lightbox2/">Lightbox2</a>, <a href="http://github.com/tbuser/thingiview.js">Thingiview.js</a>, <a href="https://github.com/k33g/gh3">gh3</a></small>, <a href="https://github.com/zachleat/Humane-Dates">Humane-Dates</a>, <a href="http://softwaremaniacs.org/playground/showdown-highlight/">Showdown</a>
</footer>
17 _layouts/default.html
View
@@ -116,7 +116,8 @@ <h1 id="title">{{ site.githubiverse.title }}<small> by {{ site.githubiverse.auth
<!-- Javascript -->
<script src="http://code.jquery.com/jquery-1.8.1.min.js"> </script>
- <script src="js/humane.js"> </script>
+ <script src="js/humane.min.js"></script>
+ <script src="js/showdown.min.js"></script>
<script src="js/bootstrap/bootstrap.min.js"></script>
<script src="js/lightbox/lightbox.min.js"></script>
<script src="js/thingiview/Three.js"></script>
@@ -377,11 +378,19 @@ <h1 id="title">{{ site.githubiverse.title }}<small> by {{ site.githubiverse.auth
descriptionFile.fetchContent(function (err, res) {
if(err) { throw "Error retrieving github description file." }
+ var descriptionText = "";
+
+ if ((/.*\.md$/).test(descriptionFile.name) || (/.*\.markdown$/).test(descriptionFile.name)){
+ var converter = new Showdown.converter();
+ descriptionText = converter.makeHtml(descriptionFile.getRawContent());
+ } else {
+ descriptionText = descriptionFile.getRawContent();
+ }
+
if ($('#description').html().trim() == ''){
- $('#description').html(descriptionFile.getRawContent().replace(/\n/g,'<br>'));
+ $('#description').html(descriptionText);
} else {
- var descriptionText = $('#description').html() + "<br>" + descriptionFile.getRawContent().replace(/\n/g,'<br>');
- $('#description').html(descriptionText);
+ $('#description').html($('#description').html() + "<br>" + descriptionText);
}
12 index.md
View
@@ -4,15 +4,3 @@
layout: default
---
-
-An implementation of movement \#27 from ["501 Mechanical Movements"](http://books.google.de/books/about/507_Mechanical_Movements.html?id=CSH5UgzD8oIC&redir_esc=y) by Henry T. Brown.
-
-**This is still a work in progress.**
-
-***
-
-##### Instructions
-
-* Attach three 623ZZ bearings to the small wheel with short M3 bolts or screws
-* Connect the small and large wheel to the frame with an M4 and M5 bolt respectively.
-(Note: So far the wheels have been printed and tested, but not yet the frame.)
134 js/humane.js
View
@@ -1,134 +0,0 @@
-/*
- * Javascript Humane Dates
- * Copyright (c) 2008 Dean Landolt (deanlandolt.com)
- * Re-write by Zach Leatherman (zachleat.com)
- *
- * Adopted from the John Resig's pretty.js
- * at http://ejohn.org/blog/javascript-pretty-date
- * and henrah's proposed modification
- * at http://ejohn.org/blog/javascript-pretty-date/#comment-297458
- *
- * Licensed under the MIT license.
- */
-
-function humaneDate(date, compareTo){
-
- if(!date) {
- return;
- }
-
- var lang = {
- ago: 'Ago',
- from: '',
- now: 'Just Now',
- minute: 'Minute',
- minutes: 'Minutes',
- hour: 'Hour',
- hours: 'Hours',
- day: 'Day',
- days: 'Days',
- week: 'Week',
- weeks: 'Weeks',
- month: 'Month',
- months: 'Months',
- year: 'Year',
- years: 'Years'
- },
- formats = [
- [60, lang.now],
- [3600, lang.minute, lang.minutes, 60], // 60 minutes, 1 minute
- [86400, lang.hour, lang.hours, 3600], // 24 hours, 1 hour
- [604800, lang.day, lang.days, 86400], // 7 days, 1 day
- [2628000, lang.week, lang.weeks, 604800], // ~1 month, 1 week
- [31536000, lang.month, lang.months, 2628000], // 1 year, ~1 month
- [Infinity, lang.year, lang.years, 31536000] // Infinity, 1 year
- ],
- isString = typeof date == 'string',
- date = isString ?
- new Date(('' + date).replace(/-/g,"/").replace(/[TZ]/g," ")) :
- date,
- compareTo = compareTo || new Date,
- seconds = (compareTo - date +
- (compareTo.getTimezoneOffset() -
- // if we received a GMT time from a string, doesn't include time zone bias
- // if we got a date object, the time zone is built in, we need to remove it.
- (isString ? 0 : date.getTimezoneOffset())
- ) * 60000
- ) / 1000,
- token;
-
- if(seconds < 0) {
- seconds = Math.abs(seconds);
- token = lang.from ? ' ' + lang.from : '';
- } else {
- token = lang.ago ? ' ' + lang.ago : '';
- }
-
- /*
- * 0 seconds && < 60 seconds Now
- * 60 seconds 1 Minute
- * > 60 seconds && < 60 minutes X Minutes
- * 60 minutes 1 Hour
- * > 60 minutes && < 24 hours X Hours
- * 24 hours 1 Day
- * > 24 hours && < 7 days X Days
- * 7 days 1 Week
- * > 7 days && < ~ 1 Month X Weeks
- * ~ 1 Month 1 Month
- * > ~ 1 Month && < 1 Year X Months
- * 1 Year 1 Year
- * > 1 Year X Years
- *
- * Single units are +10%. 1 Year shows first at 1 Year + 10%
- */
-
- function normalize(val, single)
- {
- var margin = 0.1;
- if(val >= single && val <= single * (1+margin)) {
- return single;
- }
- return val;
- }
-
- for(var i = 0, format = formats[0]; formats[i]; format = formats[++i]) {
- if(seconds < format[0]) {
- if(i === 0) {
- // Now
- return format[1];
- }
-
- var val = Math.ceil(normalize(seconds, format[3]) / (format[3]));
- return val +
- ' ' +
- (val != 1 ? format[2] : format[1]) +
- (i > 0 ? token : '');
- }
- }
-};
-
-if(typeof jQuery != 'undefined') {
- jQuery.fn.humaneDates = function(options)
- {
- var settings = jQuery.extend({
- 'lowercase': false
- }, options);
-
- return this.each(function()
- {
- var $t = jQuery(this),
- date = $t.attr('datetime') || $t.attr('title');
-
- date = humaneDate(date);
-
- if(date && settings['lowercase']) {
- date = date.toLowerCase();
- }
-
- if(date && $t.html() != date) {
- // don't modify the dom if we don't have to
- $t.html(date);
- }
- });
- };
-}
2  js/humane.min.js
View
@@ -0,0 +1,2 @@
+function humaneDate(c,f){if(c){var b=[[60,"Just Now"],[3600,"Minute","Minutes",60],[86400,"Hour","Hours",3600],[604800,"Day","Days",86400],[2628E3,"Week","Weeks",604800],[31536E3,"Month","Months",2628E3],[Infinity,"Year","Years",31536E3]],a="string"==typeof c,c=a?new Date((""+c).replace(/-/g,"/").replace(/[TZ]/g," ")):c,f=f||new Date,e=(f-c+6E4*(f.getTimezoneOffset()-(a?0:c.getTimezoneOffset())))/1E3;0>e?(e=Math.abs(e),a=""):a=" Ago";for(var g=0,d=b[0];b[g];d=b[++g])if(e<d[0]){if(0===g)return d[1];
+b=Math.ceil((e>=d[3]&&e<=1.1*d[3]?d[3]:e)/d[3]);return b+" "+(1!=b?d[2]:d[1])+(0<g?a:"")}}}"undefined"!=typeof jQuery&&(jQuery.fn.humaneDates=function(c){var f=jQuery.extend({lowercase:!1},c);return this.each(function(){var b=jQuery(this),a=b.attr("datetime")||b.attr("title");(a=humaneDate(a))&&f.lowercase&&(a=a.toLowerCase());a&&b.html()!=a&&b.html(a)})});
14 js/showdown.min.js
View
@@ -0,0 +1,14 @@
+var Showdown={converter:function(){var i,j,n,o=0;this.makeHtml=function(a){i=[];j=[];n=[];a=a.replace(/~/g,"~T");a=a.replace(/\$/g,"~D");a=a.replace(/\r\n/g,"\n");a=a.replace(/\r/g,"\n");a=u("\n\n"+a+"\n\n");a=a.replace(/^[ \t]+$/mg,"");a=v(a);a=a.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(a,b,e,d,g){b=b.toLowerCase();i[b]=w(e);if(d)return d+g;g&&(j[b]=g.replace(/"/g,"&quot;"));return""});a=p(a);a=x(a);a=a.replace(/~D/g,"$$");
+return a=a.replace(/~T/g,"~")};var v=function(a){a=a.replace(/\n/g,"\n\n");a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,l);a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,l);a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,l);a=a.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,l);
+a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,l);return a=a.replace(/\n\n/g,"\n")},l=function(a,c){var b;b=c.replace(/\n\n/g,"\n");b=b.replace(/^\n/,"");b=b.replace(/\n+$/g,"");return b="\n\n~K"+(n.push(b)-1)+"K\n\n"},p=function(a){for(var a=a.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(a,c){return h("<h1>"+m(c)+"</h1>")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return h("<h2>"+m(c)+"</h2>")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,
+b){a=c.length;return h("<h"+a+">"+m(b)+"</h"+a+">")}),c=h("<hr />"),a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,c),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,c),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,c),a=y(a),a=(a+"~0").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,c,b){a=z(q(c));a=u(a);a=a.replace(/^\n+/g,"");a=a.replace(/\n+$/g,"");return h("<pre><code>"+a+"\n</code></pre>")+b}),a=a.replace(/~0/,""),a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
+function(a,c){var b;b=c.replace(/^[ \t]*>[ \t]?/gm,"~0");b=b.replace(/~0/g,"");b=b.replace(/^[ \t]+$/gm,"");b=p(b);b=b.replace(/(^|\n)/g,"$1 ");b=b.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(a,c){var b;b=c.replace(/^ /mg,"~0");return b=b.replace(/~0/g,"")});return h("<blockquote>\n"+b+"\n</blockquote>")}),a=v(a),a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,""),b=a.split(/\n{2,}/g),a=[],c=b.length,e=0;e<c;e++){var d=b[e];0<=d.search(/~K(\d+)K/g)?a.push(d):0<=d.search(/\S/)&&(d=m(d),d=d.replace(/^([ \t]*)/g,
+"<p>"),d+="</p>",a.push(d))}c=a.length;for(e=0;e<c;e++)for(;0<=a[e].search(/~K(\d+)K/);)b=n[RegExp.$1],b=b.replace(/\$/g,"$$$$"),a[e]=a[e].replace(/~K\d+K/,b);return a=a.join("\n\n")},m=function(a){a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,e,d){a=d.replace(/^([ \t]*)/g,"");a=a.replace(/[ \t]*$/g,"");a=z(a);return b+"<code>"+a+"</code>"});a=a.replace(/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi,function(a){a=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return a=k(a,"\\`*_")});
+a=a.replace(/\\(\\)/g,r);a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,r);a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,A);a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,A);a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,s);a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,s);a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,s);a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'<a href="$1">$1</a>');
+a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){var e=x(b),d=[function(a){return"&#"+a.charCodeAt(0)+";"},function(a){a=a.charCodeAt(0);return"&#x"+("0123456789ABCDEF".charAt(a>>4)+"0123456789ABCDEF".charAt(a&15))+";"},function(a){return a}],e=("mailto:"+e).replace(/./g,function(a){if("@"==a)a=d[Math.floor(2*Math.random())](a);else if(":"!=a)var b=Math.random(),a=0.9<b?d[2](a):0.45<b?d[1](a):d[0](a);return a});return e=('<a href="'+e+'">'+e+"</a>").replace(/">.+:/g,
+'">')});a=w(a);a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");return a=a.replace(/ +\n/g," <br />\n")},s=function(a,c,b,e,d,g,h,f){void 0==f&&(f="");a=e.toLowerCase();if(""==d)if(""==a&&(a=b.toLowerCase().replace(/ ?\n/g," ")),void 0!=i[a])d=i[a],void 0!=j[a]&&(f=j[a]);else if(-1<c.search(/\(\s*\)$/m))d="";else return c;d=k(d,"*_");c='<a href="'+d+'"';""!=f&&(f=f.replace(/"/g,"&quot;"),f=k(f,"*_"),c+=' title="'+f+'"');
+return c+(">"+b+"</a>")},A=function(a,c,b,e,d,g,h,f){a=b;e=e.toLowerCase();f||(f="");if(""==d)if(""==e&&(e=a.toLowerCase().replace(/ ?\n/g," ")),void 0!=i[e])d=i[e],void 0!=j[e]&&(f=j[e]);else return c;a=a.replace(/"/g,"&quot;");d=k(d,"*_");c='<img src="'+d+'" alt="'+a+'"';f=f.replace(/"/g,"&quot;");f=k(f,"*_");return c+(' title="'+f+'"')+" />"},t,y=function(a){var a=a+"~0",c=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;o?a=a.replace(c,function(a,c,
+d){a=c;d=-1<d.search(/[*+-]/g)?"ul":"ol";a=a.replace(/\n{2,}/g,"\n\n\n");a=t(a);a=a.replace(/\s+$/,"");return"<"+d+">"+a+"</"+d+">\n"}):(c=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(c,function(a,c,d,g){a=d;g=-1<g.search(/[*+-]/g)?"ul":"ol";a=a.replace(/\n{2,}/g,"\n\n\n");a=t(a);return c+"<"+g+">\n"+a+"</"+g+">\n"}));return a=a.replace(/~0/,"")};t=function(a){o++;a=a.replace(/\n{2,}$/,"\n");a=(a+"~0").replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+function(a,b,e,d,g){a=g;b||-1<a.search(/\n{2,}/)?a=p(q(a)):(a=y(q(a)),a=a.replace(/\n$/,""),a=m(a));return"<li>"+a+"</li>\n"});a=a.replace(/~0/g,"");o--;return a};var h=function(a){a=a.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(n.push(a)-1)+"K\n\n"},z=function(a){a=a.replace(/&/g,"&amp;");a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;");return a=k(a,"*_{}[]\\",!1)},w=function(a){a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");return a=a.replace(/<(?![a-z\/?\$!])/gi,"&lt;")},x=function(a){return a=
+a.replace(/~E(\d+)E/g,function(a,b){var e=parseInt(b);return String.fromCharCode(e)})},q=function(a){a=a.replace(/^(\t|[ ]{1,4})/gm,"~0");return a=a.replace(/~0/g,"")},u=function(a){a=a.replace(/\t(?=\t)/g," ");a=a.replace(/\t/g,"~A~B");a=a.replace(/~B(.+?)~A/g,function(a,b){for(var e=b,d=4-e.length%4,g=0;g<d;g++)e+=" ";return e});a=a.replace(/~A/g," ");return a=a.replace(/~B/g,"")},k=function(a,c,b){c="(["+c.replace(/([\[\]\\])/g,"\\$1")+"])";b&&(c="\\\\"+c);return a=a.replace(RegExp(c,"g"),
+r)},r=function(a,c){return"~E"+c.charCodeAt(0)+"E"}}};
Please sign in to comment.
Something went wrong with that request. Please try again.