Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hyakugei/a3d38a1957ecc8284df936f172cc0002 to your computer and use it in GitHub Desktop.
Save hyakugei/a3d38a1957ecc8284df936f172cc0002 to your computer and use it in GitHub Desktop.
nvALT Preview Template featuring relative paths

Run this from your terminal to execute the setup script. It creates the directory and downloads the template right into this new folder.

curl -s https://gist.githubusercontent.com/DivineDominion/ab1abe8d2b93d4b73d69/raw/6a7066f1fbcf45e3c47a8d85acee475dd33bd32c/install.sh | bash 

Aferwards, you can change the base directory in ~/Library/Application\ Support/nvALT/template.html as expected.

#!/usr/bin/env bash
# Sets the path and the template source
the_path=$HOME/Library/Application\ Support/nvALT
the_source=https://gist.githubusercontent.com/DivineDominion/ab1abe8d2b93d4b73d69/raw/a0609a6757d6e64c7a3b425e1f46c6596aaf02b0/template.html
# Create the nvALT directory
mkdir -p "$the_path"
# Downloads the template from the source and stores it
curl -s $the_source > "$the_path/template.html"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{%title%}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
{%style%}
</style>
<base href="file:///Users/HERE BE YOUR BASE PATH">
</head>
<body>
<div id="wrapper">
<header>
<h1 class="doctitle">{%title%}</h1>
</header>
<div id="contentdiv">
{%content%}
</div>
</div> <!-- end of #container -->
<script src="{%support%}/jquery.js"></script> <script>(function($){$('h1,h2,h3,h4').each(function(){$(this).html($(this).text().replace(/([^\\s])\\s+([^\\s]{1,5})\\s*$/,'$1&nbsp;$2'));});$('a[href^=#]').click(function(){if(location.pathname.replace(/^\\//,'')==this.pathname.replace(/^\\//,'')&&location.hostname==this.hostname){var $target=$(this.hash);$target=$target.length&&$target||$('[id='+this.hash.slice(1)+']');if($target.length){var targetOffset=$target.offset().top;$('#contentdiv').animate({scrollTop:targetOffset-40},1000);return false;}}});$('#contentdiv').scroll(function(){if(this.scrollTop>150){if($('#backtotop').length==0)
$('h1.doctitle').append($('<a href="javascript:void()" id="backtotop" />').text('Back to top').css({'float':'right','display':'none'}).click(function(){$('#contentdiv').animate({scrollTop:0},1000);}));$('#backtotop').fadeIn('slow');}else{$('#backtotop').fadeOut('slow',function(){$(this).remove();});}});})(jQuery);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment