lib/octopress-linkblog.rb in octopress-linkblog-1.2.0 vs lib/octopress-linkblog.rb in octopress-linkblog-2.0.0
- old
+ new
@@ -3,17 +3,17 @@
require 'titlecase'
require 'octopress-hooks'
module Octopress
- module LinkBlog
+ module Linkblog
- def self.config
- LinkBlog::Configuration.config
- end
-
class SiteHook < Hooks::Site
+ def pre_read(site)
+ Linkblog.config(site.config)
+ end
+
def merge_payload(payload, site)
{
'site' => {
'linkposts' => site.posts.select {|p| p.data['linkpost']},
'articles' => site.posts.reject {|p| p.data['linkpost']}
@@ -23,12 +23,12 @@
end
class PageHook < Hooks::Page
def post_init(page)
if page.data['title']
- page.data['title'].titlecase! if LinkBlog.config['titlecase']
- page.data['title_html'] = LinkBlog.unorphan(page.data['title'])
+ page.data['title'].titlecase! if Linkblog.config['titlecase']
+ page.data['title_html'] = Linkblog.unorphan(page.data['title'])
end
end
end
class PostHook < Hooks::Post
@@ -37,32 +37,32 @@
end
def add_post_vars(post)
linkpost = post.data['external-url']
- post.data['title'].titlecase! if LinkBlog.config['titlecase']
+ post.data['title'].titlecase! if Linkblog.config['titlecase']
if linkpost
- config = LinkBlog.config['linkpost']
+ config = Linkblog.config['linkpost']
else
- config = LinkBlog.config['post']
+ config = Linkblog.config['post']
end
- post.data['title_text'] = LinkBlog.post_title_text(post.data['title'], config)
- post.data['title_html'] = LinkBlog.post_title_html(post.data['title'], config)
+ post.data['title_text'] = Linkblog.post_title_text(post.data['title'], config)
+ post.data['title_html'] = Linkblog.post_title_html(post.data['title'], config)
post.data['title_url'] = linkpost || post.url
post.data['linkpost'] = !linkpost.nil?
- post.data['title_link'] = LinkBlog.post_title_link(post.data)
- post.data['permalink'] = LinkBlog.post_link(LinkBlog.config['permalink_label'], post.url, 'article-permalink')
-
+ post.data['title_link'] = Linkblog.post_title_link(post.data)
+ post.data['permalink'] = Linkblog.post_link(Linkblog.config['permalink_label'], post.url, 'article-permalink')
+
post
end
end
def self.unorphan(title)
- if LinkBlog.config['unorphan']
+ if Linkblog.config['unorphan']
title.sub(/\s+(\S+)\s*$/, ' \1')
else
title
end
end
@@ -103,7 +103,18 @@
else
"#{title} #{config['marker']}"
end
end
end
+end
+
+if defined? Octopress::Docs
+ Octopress::Docs.add({
+ name: "Octopress Linkblog",
+ gem: "octopress-linkblog",
+ description: "Add link-blogging features to any Jekyll site",
+ path: File.expand_path(File.join(File.dirname(__FILE__), "../")),
+ source_url: "https://github.com/octopress/linkblog",
+ version: Octopress::Linkblog::VERSION
+ })
end