Created
March 2, 2013 00:26
-
-
Save TrevorBramble/5069017 to your computer and use it in GitHub Desktop.
auto-updating render of markdown file as html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
exit 1, 'no markdown file specified' if ARGV[0].nil? | |
require 'bundler' | |
Bundler.setup | |
Bundler.require | |
configure do | |
set converter: ARGV.fetch(1, 'markdown-calibre') | |
set md_file: ARGV.fetch(0) | |
end | |
helpers do | |
def title | |
"#{File.basename(settings.md_file)} :: mddy" | |
end | |
def md_content | |
`#{settings.converter} #{settings.md_file}` | |
end | |
end | |
get '/' do | |
erb :index | |
end | |
get '/favicon.ico' do | |
status 418 | |
end | |
__END__ | |
@@ index | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title><%= title %></title> | |
<style> | |
body { | |
font-family: helvetica, Arial, "Lucida Grande", sans-serif; | |
background-color: rgb(215,215,215); | |
color: rgb(25,25,25); | |
} | |
</style> | |
</head> | |
<body> | |
<%= md_content %> | |
<script> | |
reload = function () { window.location.reload(true) } | |
// refresh every 10000 milliseconds | |
setInterval(reload, 5000); | |
</script> | |
</body> | |
</html> |
Author
TrevorBramble
commented
Mar 2, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment