Skip to content

Commit

Permalink
Tags and channels (2)
Browse files Browse the repository at this point in the history
xokomola committed Jan 3, 2014
1 parent 6ad16cd commit ee431ac
Showing 6 changed files with 262 additions and 0 deletions.
23 changes: 23 additions & 0 deletions _data/channels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# An article can be put in 0 or more channels (categories)
# This describes the channels.

all: {
url: '/channels/all',
feed: '/channels/all/atom.xml',
desc: 'All posts go here',
active: true
}

software: {
url: '/channels/software',
feed: '/channels/software/atom.xml',
desc: 'This is about **me** or about the **blog**',
active: true
}

music: {
url: '/channels/music',
feed: '/channels/music/atom.xml',
desc: 'The [markup](http://google.nl) language that is.',
active: false
}
7 changes: 7 additions & 0 deletions _data/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
about: {
desc: 'This is about **me** or about the **blog**'
}

xml: {
desc: 'The [markup](http://google.nl) language that is.'
}
30 changes: 30 additions & 0 deletions _layouts/atom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
layout: nil
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ site.data.urls.base }}/tags/{{ page.tag }}</id>
<title>{{ site.name }}</title>
<link href="{{ site.data.urls.base }}{{ page.url }}" rel="self"/>
<link href="{{ site.data.urls.base }}/tags/{{ page.tag }}/"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
{% comment %}<category term="{{ tag }}"/>{% endcomment %}

{% for cat in site.categories %}
<category cat="{{ cat | first }}"/>
{% endfor %}

{% for tag in site.tags %}
<category term="{{ tag | first }}"/>
{% endfor %}
<author>
<name>{{ site.name }}</name>
</author>{% for post in site.posts %}{% for tag in post.tags %}{% if tag == page.tag %}
<entry>
<id>{{ site.data.urls.base }}{{ post.id }}</id>
<title type="text">{{ post.title }}</title>
<link href="{{ site.data.urls.base }}{{ post.url }}"/>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<content type="html">{{ post.content | markdownify | xml_escape }}</content>
</entry>{% endif %}{% endfor %}{% endfor %}
</feed>
162 changes: 162 additions & 0 deletions _layouts/tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<!DOCTYPE html>
{% capture banner_name %}{% if page.banner %}{{ page.banner }}{% else %}{{ site.banner }}{% endif %}{% endcapture %}
{% assign banner = site.data.banners[banner_name] %}
{% assign sidebar = site.data.sidebar %}
{% assign show_sidebar = site.sidebar | plus: page.sidebar | plus: post.sidebar %}
{% assign show_comments = site.comments | plus: page.comments | plus: post.comments %}
{% assign profile_twitter = sidebar.twitter | plus: page.twitter %}
{% assign profile_github = sidebar.github | plus: page.github %}
{% assign profile_youtube = sidebar.youtube | plus: page.youtube %}
{% assign profile_soundcloud = sidebar.soundcloud | plus: page.soundcloud %}
{% assign profile_linkedin = sidebar.linkedin | plus: page.linkedin %}
{% assign tweet_button = sidebar.tweet | plus: page.tweet %}
{% assign followers_button = sidebar.followers | plus: page.followers %}
{% assign tweet_buttons = tweet_button | plus: followers_button %}

{% assign analytics = site.data.site.analytics %}
{% assign analytics_code = site.data.site.analytics_code %}

{% assign tag_info = site.data.tags %}
{% capture tag_list %}
{% for tag in site.tags %}
{{ tag[0] }}
{% endfor %}
{% endcapture %}
{% assign sorted_tags = tag_list | split:' ' | sort %}

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>
{% if page.title %}
{{ page.title }} //
{% endif %}
{{site.name}}
</title>
<meta name="author" content="Xokomola" />
<!-- TODO: add different description and keywords variable -->
{% if page.summary %}
<meta namne="description" content="{{ page.summary }}" />
{% endif %}
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro%3A300%2C400%2C700%2C300italic%2C400italic%2C700italic%7CBitter%3A400%2C700&amp;subset=latin%2Clatin-ext" type="text/css" media="all">
<link rel="stylesheet" href="/css/main.css" type="text/css" />
<link rel="stylesheet" href="/css/zenburn.css" type="text/css" />

{% for css in page.css %}
<link rel="stylesheet" href="{{ css }}" type="text/css" />
{% endfor %}
</head>
<body>
<div id="header">
<div class="container">
{% include menu.html %}
<div id="overlay"><i>&lt;/&gt;</i></div>
<h1 id="title"><a href="/">{{site.name}}</a></h1>
</div>
</div>
<div id="header_spacer"/>
<div id="banner" style="background-image: url({{ banner.src }});background-position: {{ banner.position }};">
<div id="banner_credit">
<a href="{{ banner.url }}">"{{ banner.title }}"</a> by <a href="{{ banner.profile }}">{{ banner.author }}</a>
</div>
</div>
<div id="meat">
<div id="site">

<div id="sidebar">
<ul id="profiles">
{% for tag_name in sorted_tags %}
<li><a href="#{{ tag_name }}">{{ tag_name }}&nbsp;({{ site.tags[tag_name].size }})</a></li>
{% endfor %}
</ul>
</div>

<div id="content">
<section id="posts">
{% for tag_name in sorted_tags %}
{% if site.tags[tag_name].size > 0 %}
<h3><a name="{{ tag_name }}"></a>{{ tag_name }}</h3>
<hr>
{% for post in site.tags[tag_name] %}
<span class="date">{{ post.date | date:"%d %b %Y" }}</span>
<h4><a href="{{ post.url }}">{{ post.title }}</a></h4>
<p>{{ post.summary }}</p>
<p><small>{% if post.tags %}Tags: {% endif %}{% for tag in post.tags %} <a href="#{{ tag }}" title="View posts tagged with &quot;{{ tag }}&quot;">{{ tag }}</a>{% if forloop.last != true %}, {% endif %} {% endfor %}</small></p>
{% endfor %}
{% endif %}
{% endfor %}
</section>

{% if show_comments > 0 %}
<div id="comments">
<hr>
<!-- This is the actual comments section -->
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'xokomola'; // required: replace example with your forum shortname

/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'xokomola'; // required: replace example with your forum shortname

/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
</div>
{% endif %}

</div>

<div id="imprint">Downloaded from xokomola.com</div>
<div class="clear"></div>

</div>
</div>
{% if page.nofooter != true %}
{% include footer.html %}
{% endif %}

{% for js in page.javascript %}
<script type="text/javascript" src="{{ js }}"></script>
{% endfor %}

{% if analytics %}
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ analytics_code }}', 'auto');
ga('send', 'pageview');

</script>
{% endif %}

{% if tweet_button > 0 %}
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
{% endif %}

{% if followers_button > 0 %}
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
{% endif %}

</body>
</html>
37 changes: 37 additions & 0 deletions _plugins/atom_gen.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Jekyll

class TagFeed < Page
def initialize(site, base, dir, tag)
@site = site
@base = base
@dir = dir
@name = 'atom.xml'

self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'atom.xml')
self.data['tag'] = tag
self.data['title'] = "Posts Tagged &ldquo;"+tag+"&rdquo;"
end
end

class FeedGenerator < Generator
safe true

def generate(site)
if site.layouts.key? 'atom'
dir = 'tags'
site.tags.keys.each do |tag|
write_tag_feed(site, File.join(dir, tag), tag)
end
end
end

def write_tag_feed(site, dir, tag)
index = TagFeed.new(site, site.source, dir, tag)
index.render(site.layouts, site.site_payload)
index.write(site.dest)
site.pages << index
end
end

end
3 changes: 3 additions & 0 deletions tags/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
layout: tags
---

0 comments on commit ee431ac

Please sign in to comment.