Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tags and categories to blogs

  • Loading branch information...
commit c7b8efefaa5260092b09b3cef0ee8d744e1f3609 1 parent 1a69fbd
Maciej Paruszewski pinoss authored
14 README.md
View
@@ -97,11 +97,13 @@ blogs:
feed: "http://blog.cuboxlabs.com/atom.xml" # => RSS/Atom feed
image: "http://cubox-website.s3.amazonaws.com/i-work-at-cubox/i-work-at-cubox-badge-small.png" # => Image to use when doing credits
- - author: "Pablo Astigarraga"
- feed: "http://blog.poteland.com/atom.xml"
- image: "http://poteland.com/images/avatars/red_mage.png"
- twitter: "poteland" # => Do you want a link to the user's twitter account next to the credits? You got it.
- url: "http://blog.poteland.com" # => This is not needed in most cases, because it's picked up from the feed, but if it's not on the feed
+ - author: "Pablo Astigarraga"
+ feed: "http://blog.poteland.com/atom.xml"
+ image: "http://poteland.com/images/avatars/red_mage.png"
+ categories: "programming" # => If you want to group your posts by categories or
+ tags: "go ruby jekyll git" # => tag them, you can do that.
+ twitter: "poteland" # => Do you want a link to the user's twitter account next to the credits? You got it.
+ url: "http://blog.poteland.com" # => This is not needed in most cases, because it's picked up from the feed, but if it's not on the feed
# then planet will ask you to specify it. :)
```
@@ -118,6 +120,8 @@ So this is pretty sweet: planet.rb doesn't really want to inject html and random
{{ blog_name }} # => "This is where I tell you stuff"
{{ blog_slug }} # => "this-is-where-i-tell-you-stuff"
{{ blog_url }} # => "http://blog.poteland.com"
+ {{ blog_categories }} # => "programming planet"
+ {{ blog_tags }} # => "go ruby jekyll"
{{ image_url }} # => "http://poteland.com/images/avatars/red_mage.png"
{{ author }} # => "Pablo Astigarraga"
{{ twitter }} # => "poteland"
4 bin/planet
View
@@ -154,6 +154,8 @@ title: "{{ post_title }}"
kind: article
created_at: {{ post_date }}
author: {{ author }}
+categories: {{ blog_categories }}
+tags: {{ blog_tags }}
layout: post
---
@@ -176,4 +178,6 @@ blogs:
image: "http://poteland.com/images/avatars/red_mage.png"
# Other fields:
twitter: "poteland"
+ categories: "programming"
+ tags: "go ruby jekyll git"
url: "http://blog.poteland.com" # => only required for people that don\'t have a \'url\' field on their RSS/Atom field'
16 lib/planet.rb
View
@@ -36,13 +36,15 @@ def read_config_file(config_file_path)
planet = config.fetch('planet', {})
blogs = config.fetch('blogs', []).map do |blog|
Blog.new(
- feed: blog['feed'],
- url: blog['url'],
- author: blog['author'],
- image: blog['image'],
- posts: [],
- planet: self,
- twitter: blog['twitter']
+ feed: blog['feed'],
+ url: blog['url'],
+ author: blog['author'],
+ image: blog['image'],
+ posts: [],
+ planet: self,
+ twitter: blog['twitter'],
+ categories: blog['categories'],
+ tags: blog['tags']
)
end
22 lib/planet/blog.rb
View
@@ -12,19 +12,23 @@ class Blog
:image,
:twitter,
:posts,
+ :categories,
+ :tags,
:planet,
:rss_data
def initialize(attributes = {})
- self.url = attributes[:url]
- self.feed = attributes[:feed]
- self.type = attributes[:type]
- self.name = attributes[:name]
- self.author = attributes[:author]
- self.image = attributes[:image]
- self.twitter = attributes[:twitter]
- self.posts = attributes.fetch(:posts, [])
- self.planet = attributes[:planet]
+ self.url = attributes[:url]
+ self.feed = attributes[:feed]
+ self.type = attributes[:type]
+ self.name = attributes[:name]
+ self.author = attributes[:author]
+ self.image = attributes[:image]
+ self.twitter = attributes[:twitter]
+ self.posts = attributes.fetch(:posts, [])
+ self.planet = attributes[:planet]
+ self.categories = attributes.fetch(:categories, '')
+ self.tags = attributes.fetch(:tags, '')
# Feedzirra parsed data is made available for when the information
# provides is not enough. Transparency should help use cases we're
3  lib/planet/post.rb
View
@@ -28,6 +28,8 @@ def to_h
blog_url: self.blog.url,
blog_name: self.blog.name,
blog_slug: self.blog.name.to_url(:limit => 50, :truncate_words => true),
+ blog_categories: self.blog.categories,
+ blog_tags: self.blog.tags,
post_url: self.url,
twitter: self.blog.twitter,
twitter_url: "http://twitter.com/#{ self.blog.twitter }",
@@ -39,7 +41,6 @@ def to_h
alias_method :to_hash, :to_h
def header
- ## TODO: We need categories/tags
file = self.blog.planet.config.fetch('templates_directory', '_layouts/') + 'header.md'
file_contents = File.read(file)
Please sign in to comment.
Something went wrong with that request. Please try again.