Skip to content

Instantly share code, notes, and snippets.

@alaiacano
Created February 19, 2013 18:41
Show Gist options
  • Save alaiacano/4988657 to your computer and use it in GitHub Desktop.
Save alaiacano/4988657 to your computer and use it in GitHub Desktop.
A mostly-complete Tumblr post template. The input is a post JSON object from the Tumblr API. I think the Audio type is missing still.
<style>
.quote {
border: 1px solid #999;
page-break-inside: avoid;
padding: 4px;
background-color: #333333;
color: #eee;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
<h1 class='thin tumblrlink'>My Blog</h1>
<p>
Here are some of the things I've been thinking about recently. Visit <big><a href="http://adamlaiacano.tumblr.com">adamlaiacano.tumblr.com</a></big> for all posts. I also have a more typical tumblelog as well.
</p>
<hr>
{% for post in posts %}
<div class='post'>
<p><a href="{{post['short_url']}}" class='tumblrlink'>{{post['date']}}</a></p>
{% if post['type']=='quote' %}
<blockquote class='quote'>{{ post['text'] }}</blockquote>
<p>
{{ post['source'] }}
</p>
{% elif post['type'] == 'text' %}
<p>
<strong>{{post['title']}}</strong>
{{ post['body'] }}
</p>
{% elif post['type'] == 'photo' %}
<img src="{{post['photos'][0]['alt_sizes'][1]['url']}}">
{{post['caption']}}
{% elif post['type'] == 'link' %}
<strong><a href="{{post['url']}}">{{post['title']}}</a></strong>
<p>
{{post['description']}}
</p>
{% elif post['type'] == 'video' %}
{{post['player'][-1]['embed_code']}}
<p>
{{post['caption']}}
</p>
{% else %}
<p><strong>{{post['type']}}</strong> {{ ', '.join(post.keys()) }}</p>
<p>{{ post }}</p>
{% end %}
</div>
<hr>
{% end %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment