<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>*JJ</title><link href="http://blog.jdotjdot.com/" rel="alternate"></link><link href="http://blog.jdotjdot.com/feeds/tag/static-site-generators.atom.xml" rel="self"></link><id>http://blog.jdotjdot.com/</id><updated>2014-03-26T00:00:00-04:00</updated><entry><title>Getting syntax highlighting on Scriptogr.am (and other hosted static site generators)</title><link href="http://blog.jdotjdot.com/2014/03/getting-syntax-highlighting-on-scriptogr-am-and-other-hosted-static-site-generators/" rel="alternate"></link><updated>2014-03-26T00:00:00-04:00</updated><author><name>JJ</name></author><id>tag:blog.jdotjdot.com,2014-03-26:2014/03/getting-syntax-highlighting-on-scriptogr-am-and-other-hosted-static-site-generators/</id><summary type="html">&lt;p&gt;The benefits of hosted static site generators include crazy ease of use, auto-deployment, hosting, etc.&amp;#8212;but on the downside, you&amp;#8217;re sometimes a bit more limited in the control you have over the&amp;nbsp;site.&lt;/p&gt;
&lt;p&gt;When starting out with trying &lt;a href="http://scriptogr.am"&gt;Scriptogr.am&lt;/a&gt;, I was a bit disappointed by the lack of syntax highlighting.  Pelican uses &lt;a href="http://pygments.org"&gt;Pygments&lt;/a&gt;, but that runs on the server side in Python&amp;#8212;so it&amp;#8217;s fine for a personally hosted static site generator, but I wouldn&amp;#8217;t be able to get a hosted solution like Scriptogr.am (or Github Pages, for that matter) to use&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;A solution I found was &lt;a href="http://highlightjs.org/"&gt;HighlightJS&lt;/a&gt;, which is a Javascript-based code syntax detection and highlighting platform.  This is great, because being Javascript based, I can simply throw a link to the code into my Scriptogram (or whatever else) theme, and let the browser rather than the server (or static site generator) do the&amp;nbsp;work.&lt;/p&gt;
&lt;p&gt;I had a bit of difficulty getting it working, so I thought I&amp;#8217;d post this here for those of you with the same issue so you can avoid the&amp;nbsp;trouble.&lt;/p&gt;
&lt;h4&gt;Step 1: &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;This is easy.  They are nice enough to host a prebuilt version of HighlightJS, so you can simply link to it in your &lt;code&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;/code&gt; tag.  At the bottom, paste the&amp;nbsp;following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- any other html stuff --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://yandex.st/highlightjs/8.0/styles/default.min.css&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://yandex.st/highlightjs/8.0/highlight.min.js&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For a different HighlightJS theme for the syntax highlighting, simply change the &lt;code&gt;href&lt;/code&gt; attribute in the &lt;span class="caps"&gt;CSS&lt;/span&gt; &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; to your preferred theme&amp;nbsp;stylesheet.&lt;/p&gt;
&lt;h4&gt;Step 2: Make sure HighlightJS is called&amp;nbsp;last&lt;/h4&gt;
&lt;p&gt;The javascript you&amp;#8217;re already loading is supposed to run HighlightJS after the page loads, but that wasn&amp;#8217;t working for me with Scriptogr.am&amp;#8212;I imagine because Scriptogr.am itself probably had some functions that run after the page fully loads that were overriding and coming after what I had&amp;nbsp;specified.&lt;/p&gt;
&lt;p&gt;The way to get this working is to add another function to the very bottom of your &lt;span class="caps"&gt;HTML&lt;/span&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c"&gt;&amp;lt;!-- above, the rest of your HTML file/theme --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;(function(){hljs.initHighlighting();})();&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Step 3:&amp;nbsp;Profit&lt;/h4&gt;
&lt;p&gt;Reload the page, and see if it works!  All of the code in &lt;code&gt;&amp;lt;pre&amp;gt;&amp;lt;code&amp;gt;&lt;/code&gt; blocks should be automatically detected and&amp;nbsp;highlighted.&lt;/p&gt;
&lt;p&gt;If you need to make any changes or customization (e.g., your code isn&amp;#8217;t in &lt;code&gt;&amp;lt;pre&amp;gt;&amp;lt;code&amp;gt;&lt;/code&gt; blocks), see the &lt;a href="http://highlightjs.org/usage/"&gt;HighlightJS usage docs&lt;/a&gt;, which are very&amp;nbsp;helpful.&lt;/p&gt;</summary><category term="hackerschool"></category><category term="scriptogr.am"></category><category term="static-site-generators"></category><category term="syntax-highlighting"></category><category term="highlightjs"></category></entry><entry><title>Static site generators and choices</title><link href="http://blog.jdotjdot.com/2014/03/static-site-generators-and-choices/" rel="alternate"></link><updated>2014-03-26T00:00:00-04:00</updated><author><name>JJ</name></author><id>tag:blog.jdotjdot.com,2014-03-26:2014/03/static-site-generators-and-choices/</id><summary type="html">&lt;h3&gt;&lt;span class="caps"&gt;TL&lt;/span&gt;;&lt;span class="caps"&gt;DR&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;I&amp;#8217;m undecided on exactly where to settle on hosting my site.  The main things I&amp;#8217;m looking for&amp;nbsp;are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Code syntax&amp;nbsp;highlighting&lt;/li&gt;
&lt;li&gt;Nicely formatted list of categories and full archive on the&amp;nbsp;sidebar&lt;/li&gt;
&lt;li&gt;Editing from&amp;nbsp;anywhere&lt;/li&gt;
&lt;li&gt;Ease of&amp;nbsp;publishing/deployment&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Intro&lt;/h3&gt;
&lt;p&gt;As of this writing, my Hacker School blog is hosted on &lt;a href="http://ghost.org"&gt;Ghost&lt;/a&gt;, and as much as it&amp;#8217;s nice and easy to use with a great online writing platform, my ultimate goal is to be able to write anything from anywhere, and unfortunately Ghost isn&amp;#8217;t going to fit the bill there, by nature of having an online text editor that I have to&amp;nbsp;use.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve heard quite a bit about static site generators like &lt;a href="http://blog.getpelican.com/"&gt;Pelican&lt;/a&gt; and &lt;a href="http://jekyllrb.com"&gt;Jekyll&lt;/a&gt;, and I went in to go take a&amp;nbsp;look.  &lt;/p&gt;
&lt;h3&gt;What is a static site generator, you&amp;nbsp;ask?&lt;/h3&gt;
&lt;p&gt;Fair question.  Most blogging platforms (like Wordpress, for example) are &lt;em&gt;dynamically generated&lt;/em&gt; sites&amp;#8212;meaning that the page is being generated from underlying data in a database every time you load it.  This sounds more complicated than it is.  Think about a site like Craigslist&amp;#8212;every time you view the same &lt;span class="caps"&gt;URL&lt;/span&gt;, the actual listings are actually always changing and being updated.  This is a dynamically generated site, because the page is changing every time.  And how is it changing?  Even though we&amp;#8217;re loading the same formatting and styling every time, the actual content of the posts to be presented to you on each load is being pulled from a database that lives&amp;nbsp;elsewhere.&lt;/p&gt;
&lt;p&gt;A while ago, someone smart noticed that your blog posts are not really going to be changing&amp;#8212;once it&amp;#8217;s published, it&amp;#8217;s unlikely to change.  Even if you edit it, it certainly won&amp;#8217;t be changing every day (hopefully).  As a result, you don&amp;#8217;t need to dynamically create each page each time a user loads&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;The answer is a &lt;strong&gt;static site generator&lt;/strong&gt;, which is a program that lets you build all of the &lt;span class="caps"&gt;HTML&lt;/span&gt; and &lt;span class="caps"&gt;CSS&lt;/span&gt; ahead of time and then post only the static, unchanging files.  Using something like this, you can actually serve your blog right out of something like Dropbox!  (And there are a number of offerings that do&amp;#8212;see &lt;a href="http://scriptogr.am"&gt;Scriptogr.am&lt;/a&gt;.)  Generally, you can write your posts in any text editor using Markdown syntax or something like it.  Markdown is a super-stripped down formatting that enables you to simply and quickly write formatted text that later gets translated into &lt;span class="caps"&gt;HTML&lt;/span&gt;.  (Examples: &lt;code&gt;*italics*&lt;/code&gt; makes things &lt;em&gt;italic&lt;/em&gt;, &lt;code&gt;**bold**&lt;/code&gt; makes things &lt;strong&gt;bold&lt;/strong&gt;, &lt;code&gt;[This is a URL!](http://www.google.com)&lt;/code&gt; makes things into &lt;a href="http://www.google.com"&gt;&lt;span class="caps"&gt;URLS&lt;/span&gt;&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;This means that you can create and edit posts from anywhere.  When you&amp;#8217;re ready, you save them into your site generators posts folder and run the program, which generates a fully featured site based on your posts&amp;#8217; content and your selected theme, which styles&amp;nbsp;everything.&lt;/p&gt;
&lt;h3&gt;Jekyll&lt;/h3&gt;
&lt;p&gt;Jekyll seemed great at first, and I particularly liked the fact that it can be easily hosted on Github Pages without any extra work (or even site generation) on my part, since Github will run the Jekyll page generation for you.  Unfortunately, it only does that for Jekyll, and not for any others, like Pelican.  The other issue I ran into is Jekyll is pretty unwieldy&amp;#8212;and even using Octopress, which sites on top of Jekyll, I still had quite a bit of trouble getting into the meat of it.  After some Googling, I found that I was far from the only Python person having trouble, and you need to have some Ruby skills if Jekyll ever&amp;nbsp;breaks.&lt;/p&gt;
&lt;h3&gt;Pelican&lt;/h3&gt;
&lt;p&gt;Next stop was Pelican, which is a static site generator similar to Jekyll, but in Python.  It&amp;#8217;s also a bit tough to set up, but I&amp;#8217;m liking it a bit more, since I have a better understanding of the internals due to it being in Python.   On the other hand, I&amp;#8217;ve still found it a bit of a handful to set up (spent a few hours on it and I&amp;#8217;m not quite there yet!).  Additionally, it&amp;#8217;s still not &lt;em&gt;quite&lt;/em&gt; &amp;#8220;edit from anywhere&amp;#8221;&amp;#8212;I know that I can create and edit posts in any text editor and offline, but at the end of the day, I&amp;#8217;ll still have to move all of my posts to the contents folder in my blog repo, run the &lt;code&gt;pelican&lt;/code&gt; command to generate the site, and then push the site to the final Github repo.  I can set this all up automatically with Fabric or web hooks, but at the end of the day, it&amp;#8217;s still a little bit&amp;nbsp;annoying.&lt;/p&gt;
&lt;h3&gt;Scriptogr.am&lt;/h3&gt;
&lt;p&gt;Scriptogr.am is a very cool hosted static site generator that runs out of Dropbox.  All you have to do is save your Markdown-formatted files to your special &amp;#8220;Scriptogram&amp;#8221; Dropbox folder, and Scriptogr.am automatically loads the files there, runs them through its own site generator using your selected (or customized) theme, and then hosts the site for you.  This is really great because you truly can edit or post from anywhere, as all you have to do is save to Dropbox, and everything happens automatically from there.  You can even publish right to Scriptogr.am from Markdown-editing programs like Mou for&amp;nbsp;Mac.&lt;/p&gt;
&lt;p&gt;The downside is, given that it&amp;#8217;s a hosted solution, I have quite a bit less control over the blog itself.  I&amp;#8217;m sure I could manage to force the theme to do my will, but it would mean quite a bit of effort messing with the built-in &lt;span class="caps"&gt;HTML&lt;/span&gt; and &lt;span class="caps"&gt;CSS&lt;/span&gt; themes, and given that it&amp;#8217;s still a pretty small site, there aren&amp;#8217;t that many themes offered out of the box.  I&amp;#8217;m also not totally clear if there&amp;#8217;s an &lt;span class="caps"&gt;RSS&lt;/span&gt; feed&amp;nbsp;built-in.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;None yet.  I&amp;#8217;m right now between Scriptogr.am and Pelican, but given that I like the ease of use of Scriptogr.am but the control of Pelican, I&amp;#8217;m likely to go with a combined scenario, where I&amp;#8217;ll basically create my own automatically-publishing version of Pelican out of Dropbox.  Basically, what I will do is create a small Heroku instance that will do nothing but listen for a web hook from Dropbox, and upon receiving it, pull all of the files stored in the Dropbox folder, run the Pelican site generator, commit the repo, and then push to Github pages.
Unfortunately, Dropbox doesn&amp;#8217;t currently support web hooks.  Also, &lt;span class="caps"&gt;IFTTT&lt;/span&gt; only has support for the deprecated Dropbox Public folder, but it seems like Zapier does have decent Dropbox&amp;nbsp;integration.&lt;/p&gt;
&lt;h3&gt;Update&lt;/h3&gt;
&lt;p&gt;I&amp;#8217;m at this very moment moving the site over to Pelican, and by the time you read this, it should already be there.  Dropbox also just this week announced that they&amp;#8217;ll be &lt;a href="https://www.dropbox.com/developers/blog/90/announcing-dropbox-webhooks"&gt;supporting webhooks&lt;/a&gt;, which will be very exciting for enabling me to simply manage all of my post content out of Dropbox and then have the site regenerated upon any&amp;nbsp;changes.&lt;/p&gt;</summary><category term="hackerschool"></category><category term="pelican"></category><category term="jekyll"></category><category term="scriptogr.am"></category><category term="dropbox"></category><category term="zapier"></category><category term="markdown"></category><category term="static-site-generators"></category></entry></feed>