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 +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +3 -0
- data/lib/octopress-linkblog.rb +50 -34
- data/lib/octopress-linkblog/configuration.rb +2 -1
- data/lib/octopress-linkblog/version.rb +1 -1
- data/test/_expected/articles.html +1 -0
- data/test/_expected/linkposts.html +4 -0
- data/test/_expected/posts.html +2 -0
- data/test/_includes/post.html +1 -0
- data/test/linkposts.html +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 229e1770b7c86baa60043417aa597b3302ac2463
|
4
|
+
data.tar.gz: 2e7c77c125d43c9f009c3a175e4a118e3869613e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c04ad260e8a47e5a96ed82ca4f5abb3eb5f856dc0c5594485ccd52b86c0258e031095d970e51786842040e6356e08f950883294f4e108315a7e78e2e1524c90e
|
7
|
+
data.tar.gz: 6f9333d04546b2f1e4ef40c947216abf292906041a36fb73eab63da293541632d41c8b1a0a756369b52e6691cf1945a7eb276ae6712ed13000b52252302b5b93
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
### 1.
|
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 Awesome <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
|
data/lib/octopress-linkblog.rb
CHANGED
@@ -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'] =
|
44
|
-
post.data['title_html'] =
|
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'] =
|
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
|
-
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.unorphan(title)
|
63
|
+
if LinkBlog.config['unorphan']
|
52
64
|
title.sub(/\s+(\S+)\s*$/, ' \1')
|
65
|
+
else
|
66
|
+
title
|
53
67
|
end
|
68
|
+
end
|
54
69
|
|
55
|
-
|
56
|
-
|
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
|
-
|
63
|
-
position = config['marker_position']
|
73
|
+
return title if !config['marker']
|
64
74
|
|
65
|
-
|
66
|
-
|
67
|
-
else
|
68
|
-
title = "#{title} #{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
|
-
|
78
|
+
if config['marker_position'] == 'before'
|
79
|
+
title = "#{marker} #{title}"
|
80
|
+
else
|
81
|
+
title = "#{title} #{marker}"
|
72
82
|
end
|
73
83
|
|
74
|
-
|
75
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
@@ -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> Some Awesome 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 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 Post <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
|
|
data/test/_expected/posts.html
CHANGED
@@ -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 Post <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> Some Awesome 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
|
|
data/test/_includes/post.html
CHANGED
data/test/linkposts.html
CHANGED
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
|
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-
|
11
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octopress-hooks
|