# # Pinboard Tag # # Generates a list of links to a user's public bookmarks # # Usage: # # {% pinboard user:username limit:# %} # # Example: # # {% pinboard user:ericdfields limit:12 %} # # All paramaters are optional, e.g.: # # {% pinboard user:ericdfields %} # # Default Configuration (override in _config.yml): # # Pinboard_set: # user: 'ericdfields' # limit: 15 # list_tag: 'ol' # list_class: 'pinboard_list' # a_target: '_blank' # # # Author: Eric D. Fields # Site: http://ericdfields.com # Twitter: @ericdfields # Email: ericdfields.com # Plugin Source: http://github.com/ericdfields/jekyll_Pinboard_set_tag # Plugin License: MIT # require 'net/http' require 'json' module Jekyll class Pinboard < Liquid::Tag def initialize(tag_name, config, token) super @config = Jekyll.configuration({})['pinboard'] || {} userMatch = /(?<=user:)\w+/ limitMatch = /(?<=limit:)\w+/ if (config =~ userMatch) @user = userMatch.match(config)[0] end @user ||= @config['user'] @user ||= 'ericdfields' if (config =~ limitMatch) @limit = limitMatch.match(config)[0].to_i end @limit ||= @config['limit'] @limit ||= 10 # max 50 @config['list_tag'] ||= 'ol' @config['list_class'] ||= 'pinboard_list' @config['is_list'] ||= true @config['a_target'] ||= '_blank' end def render(context) <<-EOF <#{@config['list_tag']} class="#{@config['list_class']}"> #{bookmarks.collect {|bookmark| render_bookmark(bookmark)}.join} #{@config['list_tag']}> EOF end def render_bookmark(bookmark) <<-EOF