Skip to content

Instantly share code, notes, and snippets.

@sheeran
Created January 31, 2013 04:23
Show Gist options
  • Save sheeran/4680168 to your computer and use it in GitHub Desktop.
Save sheeran/4680168 to your computer and use it in GitHub Desktop.
"Single File" version of cats2tags.rb. Takes a single Octopress/Jekyll markdown file as an argument. Reads "categories" from YAML and applies those as OpenMeta tags. Run with a Hazel rule.
#!/usr/bin/ruby
# By Neal Sheeran www.nealsheeran.com
#
# Single version of cats2tags.rb
# Receives a file name (Octopress markdown file)
# as an argument and processes the YAML frontmatter.
# The categories are written to the file as OpenMeta tags.
#
# Hazel is used to execute this script on a folder of markdown files:
# IF ALL
# Date Last Modified is after Date Last Matched
# Extension is 'markdown'
# Do:
# Run shell script (embedded): "ruby tags2.rb $1"
require 'yaml'
post = ARGV[0]
readin = YAML.load_file(post)
title = readin['title']
tags = readin['categories'].join(', ')
%x{/usr/local/bin/openmeta -a #{tags} -p #{post}}
# For testing / command-line use
puts "#{post} = #{title}: #{tags}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment