octopress-linkblog 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 473251182466563e6ad34a4b931a28585fc7c8ee
4
- data.tar.gz: c741567bc5a47f0ce9c84cdd0127e108bb4f7ec5
3
+ metadata.gz: 229e1770b7c86baa60043417aa597b3302ac2463
4
+ data.tar.gz: 2e7c77c125d43c9f009c3a175e4a118e3869613e
5
5
  SHA512:
6
- metadata.gz: f9c405aeb62ba847e12f39767efbd424ca8e61b0c7c4c007e7431550307c626d53230bfdfae395fc6611c21e55683aa8a79ef0fecd6ab8acaf4a7889323d33ac
7
- data.tar.gz: 91253325a48a0d3a30c6ca506256b4202fcf065637754180450c3712a3eb54b01891bfdbc481f210659511603583210f34d90f740fe059d3e5ead41e7a44022a
6
+ metadata.gz: c04ad260e8a47e5a96ed82ca4f5abb3eb5f856dc0c5594485ccd52b86c0258e031095d970e51786842040e6356e08f950883294f4e108315a7e78e2e1524c90e
7
+ data.tar.gz: 6f9333d04546b2f1e4ef40c947216abf292906041a36fb73eab63da293541632d41c8b1a0a756369b52e6691cf1945a7eb276ae6712ed13000b52252302b5b93
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ### 1.0.0 - 2014-08-03
3
+ ### 1.2.0 - 2014-08-21
4
+
5
+ - New: `page.title_html` outputs page title, titlecased and unorphaned.
6
+
7
+ ### 1.1.0 - 2014-08-19
8
+
9
+ - New: `post.permalink` outputs an anchor tag with a permanent link to post.
10
+ - New: `permalink_label` configuration sets text for permalink anchor tag.
11
+
12
+ ### 1.0.1 - 2014-08-03
4
13
 
5
14
  - Fixed UTF-8 encoding issue for older Ruby versions
6
15
 
data/README.md CHANGED
@@ -36,6 +36,7 @@ With the gem installed, your site's posts will automatically have new data attri
36
36
  - `post.title_text` - The post title with markers, but all in plain text (great for RSS).
37
37
  - `post.title_url` - The URL that post titles should link to.
38
38
  - `post.title_link` - A `<a>` tag filled with the `title_html` pointing to the `title_url`.
39
+ - `post.permalink` - A `<a>` tag containing your configuration's `pearmalink_label` pointing to the post's URL.
39
40
  - `post.linkpost` - A boolean indicating whether the post is a link post.
40
41
 
41
42
  Here is an example. Given the following YAML front-matter:
@@ -55,6 +56,7 @@ title_html => Cats Are&nbsp;Awesome&nbsp;<span class='post-marker post-marker-
55
56
  title_text => Cats Are Awesome →
56
57
  title_url => http://cats.example.com
57
58
  title_link => <a href='http://cats.example.com' class='article-link linkpost'>...</a>
59
+ permalink => <a href='http://your-site.com/posts/1' class='permalink'>Permalink</a>
58
60
  linkpost => true
59
61
  ```
60
62
 
@@ -85,6 +87,7 @@ posts:
85
87
 
86
88
  titlecase: true
87
89
  unorphan: true
90
+ permalink_label: Permalink
88
91
  ```
89
92
 
90
93
  ## Contributing
@@ -22,6 +22,15 @@ module Octopress
22
22
  end
23
23
  end
24
24
 
25
+ class PageHook < Hooks::Page
26
+ def post_init(page)
27
+ if page.data['title']
28
+ page.data['title'].titlecase! if LinkBlog.config['titlecase']
29
+ page.data['title_html'] = LinkBlog.unorphan(page.data['title'])
30
+ end
31
+ end
32
+ end
33
+
25
34
  class PostHook < Hooks::Post
26
35
  def post_init(post)
27
36
  add_post_vars(post)
@@ -30,9 +39,7 @@ module Octopress
30
39
  def add_post_vars(post)
31
40
  linkpost = post.data['external-url']
32
41
 
33
- if LinkBlog.config['titlecase']
34
- post.data['title'].titlecase!
35
- end
42
+ post.data['title'].titlecase! if LinkBlog.config['titlecase']
36
43
 
37
44
  if linkpost
38
45
  config = LinkBlog.config['linkpost']
@@ -40,52 +47,61 @@ module Octopress
40
47
  config = LinkBlog.config['post']
41
48
  end
42
49
 
43
- post.data['title_text'] = title_text(post.data['title'], config)
44
- post.data['title_html'] = title_html(post.data['title'], config)
50
+ post.data['title_text'] = LinkBlog.post_title_text(post.data['title'], config)
51
+ post.data['title_html'] = LinkBlog.post_title_html(post.data['title'], config)
45
52
  post.data['title_url'] = linkpost || post.url
46
53
  post.data['linkpost'] = !linkpost.nil?
47
- post.data['title_link'] = title_link(post.data)
54
+ post.data['title_link'] = LinkBlog.post_title_link(post.data)
55
+ post.data['permalink'] = LinkBlog.post_link(LinkBlog.config['permalink_label'], post.url, 'article-permalink')
56
+
48
57
  post
49
58
  end
50
59
 
51
- def unorphan(title)
60
+ end
61
+
62
+ def self.unorphan(title)
63
+ if LinkBlog.config['unorphan']
52
64
  title.sub(/\s+(\S+)\s*$/, '&nbsp;\1')
65
+ else
66
+ title
53
67
  end
68
+ end
54
69
 
55
- def title_html(title, config)
56
- if LinkBlog.config['unorphan']
57
- title = unorphan(title)
58
- end
59
-
60
- return title if !config['marker']
70
+ def self.post_title_html(title, config)
71
+ title = unorphan(title)
61
72
 
62
- marker = "<span class='post-marker post-marker-#{config['marker_position']}'>#{config['marker']}</span>"
63
- position = config['marker_position']
73
+ return title if !config['marker']
64
74
 
65
- if config['marker_position'] == 'before'
66
- title = "#{marker}&nbsp;#{title}"
67
- else
68
- title = "#{title}&nbsp;#{marker}"
69
- end
75
+ marker = "<span class='post-marker post-marker-#{config['marker_position']}'>#{config['marker']}</span>"
76
+ position = config['marker_position']
70
77
 
71
- title
78
+ if config['marker_position'] == 'before'
79
+ title = "#{marker}&nbsp;#{title}"
80
+ else
81
+ title = "#{title}&nbsp;#{marker}"
72
82
  end
73
83
 
74
- def title_link(data)
75
- classname = "article-link"
76
- classname << " linkpost" if data['linkpost']
77
- "<a href='#{data['title_url']}' class='#{classname}'>#{data['title_html']}</a>"
78
- end
84
+ title
85
+ end
79
86
 
80
- def title_text(title, config)
81
- return title if !config['marker']
82
- position = config['marker_position']
87
+ def self.post_title_link(data)
88
+ classname = "article-link"
89
+ classname << " linkpost" if data['linkpost']
90
+ post_link(data['title_html'], data['title_url'], classname)
91
+ end
83
92
 
84
- if config['marker_position'] == 'before'
85
- "#{config['marker']} #{title}"
86
- else
87
- "#{title} #{config['marker']}"
88
- end
93
+ def self.post_link(title, url, classnames)
94
+ "<a href='#{url}' class='#{classnames}'>#{title}</a>"
95
+ end
96
+
97
+ def self.post_title_text(title, config)
98
+ return title if !config['marker']
99
+ position = config['marker_position']
100
+
101
+ if config['marker_position'] == 'before'
102
+ "#{config['marker']} #{title}"
103
+ else
104
+ "#{title} #{config['marker']}"
89
105
  end
90
106
  end
91
107
  end
@@ -25,7 +25,8 @@ module Octopress
25
25
  },
26
26
 
27
27
  'titlecase' => true,
28
- 'unorphan' => true
28
+ 'unorphan' => true,
29
+ 'permalink_label' => 'Permalink'
29
30
  }
30
31
 
31
32
  def self.config
@@ -1,7 +1,7 @@
1
1
  module Octopress
2
2
  module Tags
3
3
  module LinkBlog
4
- VERSION = "1.0.1"
4
+ VERSION = "1.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -8,6 +8,7 @@ Urls:
8
8
  normal: /2014/05/25/awesome-things.html
9
9
  title_url: /2014/05/25/awesome-things.html
10
10
  title_link: <a href='/2014/05/25/awesome-things.html' class='article-link'><span class='post-marker post-marker-before'>★</span>&nbsp;Some Awesome&nbsp;Post</a>
11
+ permalink: <a href='/2014/05/25/awesome-things.html' class='article-permalink'>Permalink</a>
11
12
 
12
13
  linkpost: false
13
14
 
@@ -1,3 +1,6 @@
1
+ Linkposts You Guys
2
+ Linkposts You&nbsp;Guys
3
+
1
4
 
2
5
  Titles:
3
6
  normal: Some Link Post
@@ -8,6 +11,7 @@ Urls:
8
11
  normal: /2014/06/25/some-linkpost.html
9
12
  title_url: http://timecube.com
10
13
  title_link: <a href='http://timecube.com' class='article-link linkpost'>Some Link&nbsp;Post&nbsp;<span class='post-marker post-marker-after'>→</span></a>
14
+ permalink: <a href='/2014/06/25/some-linkpost.html' class='article-permalink'>Permalink</a>
11
15
 
12
16
  linkpost: true
13
17
 
@@ -8,6 +8,7 @@ Urls:
8
8
  normal: /2014/06/25/some-linkpost.html
9
9
  title_url: http://timecube.com
10
10
  title_link: <a href='http://timecube.com' class='article-link linkpost'>Some Link&nbsp;Post&nbsp;<span class='post-marker post-marker-after'>→</span></a>
11
+ permalink: <a href='/2014/06/25/some-linkpost.html' class='article-permalink'>Permalink</a>
11
12
 
12
13
  linkpost: true
13
14
 
@@ -21,6 +22,7 @@ Urls:
21
22
  normal: /2014/05/25/awesome-things.html
22
23
  title_url: /2014/05/25/awesome-things.html
23
24
  title_link: <a href='/2014/05/25/awesome-things.html' class='article-link'><span class='post-marker post-marker-before'>★</span>&nbsp;Some Awesome&nbsp;Post</a>
25
+ permalink: <a href='/2014/05/25/awesome-things.html' class='article-permalink'>Permalink</a>
24
26
 
25
27
  linkpost: false
26
28
 
@@ -7,5 +7,6 @@ Urls:
7
7
  normal: {{ post.url }}
8
8
  title_url: {{ post.title_url }}
9
9
  title_link: {{ post.title_link }}
10
+ permalink: {{ post.permalink }}
10
11
 
11
12
  linkpost: {{ post.linkpost }}
data/test/linkposts.html CHANGED
@@ -1,6 +1,10 @@
1
1
  ---
2
+ title: linkposts you guys
2
3
  ---
3
4
 
5
+ {{ page.title }}
6
+ {{ page.title_html }}
7
+
4
8
  {% for post in site.linkposts %}
5
9
  {% include post.html %}
6
10
  {% endfor %}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-linkblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-03 00:00:00.000000000 Z
11
+ date: 2014-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-hooks