Skip to content

Instantly share code, notes, and snippets.

@ralsina
ralsina / apply_mincss.py
Last active December 18, 2015 17:09
Process a Nikola output folder and replace all CSS files with versions where mincss has removed all the unused crud, making them much smaller.
import os
import sys
output_folder = os.path.abspath(sys.argv[1])
from mincss.processor import Processor
p = Processor()
urls = []
css_files = {}
for root, dirs, files in os.walk(output_folder):
for f in files:
@ralsina
ralsina / hyphenate-poc.py
Created August 19, 2013 02:38
A proof of concept hyphenator for HTML files using pyphen, based on https://github.com/dmalinovsky/kindle-hyphens/blob/master/main.py
import codecs
import sys
import lxml.html
from lxml import etree
import pyphen
lang="en"
def insert_hyphens(node, hyphenator):
@ralsina
ralsina / gist:6320971
Last active December 21, 2015 14:39
Livefyre comments for Nikola
## -*- coding: utf-8 -*-
<%def name="html_disqus(url, title, identifier)">
<!-- START: Livefyre Embed -->
<div id="livefyre-comments"></div>
<script type="text/javascript" src="http://zor.livefyre.com/wjs/v3.0/javascripts/livefyre.js"></script>
<script type="text/javascript">
(function () {
var articleId = "${identifier}";
fyre.conv.load({}, [{
el: 'livefyre-comments',
@ralsina
ralsina / gist:6321613
Created August 23, 2013 17:01
IntenseDebate comments for Nikola
## -*- coding: utf-8 -*-
<%def name="html_disqus(url, title, identifier)">
<a name="#disqus_thread"></a>
<script>
var idcomments_acct = '${disqus_forum}';
var idcomments_post_id = "${identifier}";
var idcomments_post_url = "${url}";
</script>
<span id="IDCommentsPostTitle" style="display:none"></span>
<script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>
@ralsina
ralsina / gist:6322377
Created August 23, 2013 18:20
moot.it comments for Nikola
## -*- coding: utf-8 -*-
<%def name="html_disqus(url, title, identifier)">
<a class="moot" href="https://moot.it/i/${disqus_forum}/${identifier}">${disqus_forum} forums</a>
</%def>
<%def name="html_disqus_link(link, identifier)">
</%def>
@ralsina
ralsina / gist:6322518
Created August 23, 2013 18:31
Nikola config fragment for moot.it comments
ANALYTICS = """
<script src="//cdn.moot.it/1/moot.min.js"></script>
"""
EXTRA_HEAD_DATA = """
<link rel="stylesheet" type="text/css" href="//cdn.moot.it/1/moot.css">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
"""
asdasdasdasdasd
## -*- coding: utf-8 -*-
<%namespace name="helper" file="post_helper.tmpl"/>
<%namespace name="pheader" file="post_header.tmpl"/>
<%namespace name="comments" file="comments_helper.tmpl"/>
<%inherit file="post.tmpl"/>
<%block name="content">
<article class="storypage" itemscope="itemscope" itemtype="http://schema.org/Article">
<header>
${pheader.html_title()}
@ralsina
ralsina / book.tmpl
Last active September 12, 2015 16:59
First attempt at a custom template
## -*- coding: utf-8 -*-
<%namespace name="helper" file="post_helper.tmpl"/>
<%namespace name="pheader" file="post_header.tmpl"/>
<%namespace name="comments" file="comments_helper.tmpl"/>
<%inherit file="post.tmpl"/>
<%block name="extra_head">
${parent.extra_head()}
<style>
.chapter {
@ralsina
ralsina / book2.tmpl
Last active September 12, 2015 17:36
book template with better typesetting
## -*- coding: utf-8 -*-
<%namespace name="helper" file="post_helper.tmpl"/>
<%namespace name="pheader" file="post_header.tmpl"/>
<%namespace name="comments" file="comments_helper.tmpl"/>
<%inherit file="post.tmpl"/>
<%block name="extra_head">
${parent.extra_head()}
<script src="/assets/js/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>