Module: Octopress::Linkblog

Defined in:
lib/octopress-linkblog.rb,
lib/octopress-linkblog/version.rb,
lib/octopress-linkblog/configuration.rb

Defined Under Namespace

Classes: PageHook, PostHook, SiteHook

Constant Summary collapse

VERSION =
"2.0.2"
DEFAULT_OPTIONS =
{
  'linkblog' => {
    'linkpost' => {
      'marker' => "",
      'marker_position' => 'after'
    },

    'post' => {
      'marker' => false,
      'marker_position' => 'before'
    },

    'titlecase' => true,
    'unorphan'  => true,
    'permalink_label' => 'Permalink'
  }
}

Class Method Summary collapse

Class Method Details

.config(options = {}) ⇒ Object



23
24
25
26
# File 'lib/octopress-linkblog/configuration.rb', line 23

def self.config(options={})
  @config ||= Jekyll::Utils.deep_merge_hashes(DEFAULT_OPTIONS, options)
  @config['linkblog']
end

.post_link(title, url, classnames) ⇒ Object



96
97
98
# File 'lib/octopress-linkblog.rb', line 96

def self.post_link(title, url, classnames)
  "<a href='#{url}' class='#{classnames}'>#{title}</a>"
end

.post_title_html(title, config) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/octopress-linkblog.rb', line 73

def self.post_title_html(title, config)
  title = unorphan(title)

  return title if !config['marker']

  marker = "<span class='post-marker post-marker-#{config['marker_position']}'>#{config['marker']}</span>"
  position = config['marker_position']

  if config['marker_position'] == 'before'
    title = "#{marker}&nbsp;#{title}"
  else
    title = "#{title}&nbsp;#{marker}"
  end

  title
end

.post_title_link(data) ⇒ Object



90
91
92
93
94
# File 'lib/octopress-linkblog.rb', line 90

def self.post_title_link(data)
  classname = "article-link"
  classname << " linkpost" if data['linkpost']
  post_link(data['title_html'], data['title_url'], classname)
end

.post_title_text(title, config) ⇒ Object



100
101
102
103
104
105
106
107
108
109
# File 'lib/octopress-linkblog.rb', line 100

def self.post_title_text(title, config)
  return title if !config['marker']
  position = config['marker_position']

  if config['marker_position'] == 'before'
    "#{config['marker']} #{title}"
  else
    "#{title} #{config['marker']}"
  end
end

.unorphan(title) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/octopress-linkblog.rb', line 65

def self.unorphan(title)
  if Linkblog.config['unorphan']
    title.sub(/\s+(\S+)\s*$/, '&nbsp;\1')
  else
    title
  end
end