Class: Octopress::Linkblog::PostHook

Inherits:
Hooks::Post
  • Object
show all
Defined in:
lib/octopress-linkblog.rb

Instance Method Summary collapse

Instance Method Details

#add_post_vars(post) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/octopress-linkblog.rb', line 39

def add_post_vars(post)
  # Grab external url from post data, reading dashed value for legacy pattern support
  linkpost = post.data['external_url'] || post.data['external-url']

  post.data['title'].titlecase! if Linkblog.config['titlecase']

  if linkpost
    config = Linkblog.config['linkpost']
  else
    config = Linkblog.config['post']
  end

  post_url = File.join('/',post.site.config['baseurl'], post.url)

  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
end

#post_init(post) ⇒ Object



35
36
37
# File 'lib/octopress-linkblog.rb', line 35

def post_init(post)
  add_post_vars(post)
end