octopress-linkblog 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7336205a860a6b39469f177e0fe655a8d4e45eef
4
+ data.tar.gz: c368edb5152708003d12abf168c62de83d7f906e
5
+ SHA512:
6
+ metadata.gz: 44dc6b098ec41c585671624edc64a20f7d413f5a0117f83ab91679dff85d2c0d4acf304c0838234fad4f14c88dc44d310e80a69dc104e80eae4133c4657ee5ff
7
+ data.tar.gz: 14afc967f243ccee7168013fe20ed60d39b6b67dc7d608988a5cd931cec17e49b1a9f871aa816b06c003d22df4fa35eb8c5b3ba3ec3c8d2302bcc3149c356a5c
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ _site
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ script: cd test && bundle exec clash
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ### 1.0.0 - 2014-07-26
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in octopress_render_tag.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brandon Mathis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # Octopress Link Blog
2
+
3
+ Adds link blogging features, along with some other niceties, to any Jekyll site.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'octopress-linkblog'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install octopress-linkblog
18
+
19
+ Next add it to your gems list in Jekyll's `_config.yml`
20
+
21
+ gems:
22
+ - octopress-linkblog
23
+
24
+ ## Usage
25
+
26
+ ### Post features
27
+
28
+ With the gem installed, your site's posts will automatically have new data attributes.
29
+
30
+ - `post.title` - The post title, properly capitalized with titlecase.
31
+ - `post.title_html` - The post title, unorphaned and with html wrapping any post markers.
32
+ - `post.title_text` - The post title with markers, but all in plain text (great for RSS).
33
+ - `post.title_url` - The URL that post titles should link to.
34
+ - `post.title_link` - A `<a>` tag filled with the `title_html` pointing to the `title_url`.
35
+ - `post.linkpost` - A boolean indicating whether the post is a link post.
36
+
37
+ Here is an example. Given the following YAML front-matter:
38
+
39
+ ```
40
+ ---
41
+ title: cats are awesome
42
+ external-url: http://cats.example.com
43
+ ---
44
+ ```
45
+
46
+ The post would have these attributes:
47
+
48
+ ```
49
+ title => Cats Are Awesome
50
+ title_html => Cats Are&nbsp;Awesome&nbsp;<span class='post-marker post-marker-after'>→</span>
51
+ title_text => Cats Are Awesome →
52
+ title_url => http://cats.example.com
53
+ title_link => <a href='http://cats.example.com' class='article-link linkpost'>...</a>
54
+ linkpost => true
55
+ ```
56
+
57
+ Note: the `<a>` in this demo has been shortened, but it will contain the `title_html`.
58
+
59
+
60
+ ### Site features
61
+
62
+ In addition, the site payload will have two new post arrays:
63
+
64
+ - `site.articles` - Will contain standard posts only.
65
+ - `site.linkposts` - Will contain only posts with an `external-url`
66
+
67
+ This may have many uses, but one in particular is the option to allow RSS feeds for each type
68
+ of post.
69
+
70
+ ## Configuration
71
+
72
+ In your site's `_octopress.yml` you can configure the Link Blog features. Here are the defaults.
73
+
74
+ ```ruby
75
+ linkpost:
76
+ marker: →
77
+ marker_position: after
78
+ posts:
79
+ marker: false
80
+ marker_position: before
81
+
82
+ titlecase: true
83
+ unorphan: true
84
+ ```
85
+
86
+ ## Contributing
87
+
88
+ 1. Fork it ( https://github.com/octopress/linkblog/fork )
89
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
90
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
91
+ 4. Push to the branch (`git push origin my-new-feature`)
92
+ 5. Create a new Pull Request
93
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,94 @@
1
+ require 'octopress-linkblog/version'
2
+ require 'octopress-linkblog/configuration'
3
+ require 'titlecase'
4
+
5
+ require 'octopress-hooks'
6
+ require 'jekyll'
7
+
8
+ module Octopress
9
+ module LinkBlog
10
+
11
+ def self.config
12
+ LinkBlog::Configuration.config
13
+ end
14
+
15
+ class SiteHook < Hooks::Site
16
+ def merge_payload(payload, site)
17
+ {
18
+ 'site' => {
19
+ 'linkposts' => site.posts.select {|p| p.data['linkpost']},
20
+ 'articles' => site.posts.reject {|p| p.data['linkpost']}
21
+ }
22
+ }
23
+ end
24
+ end
25
+
26
+ class PostHook < Hooks::Post
27
+ def post_init(post)
28
+ add_post_vars(post)
29
+ end
30
+
31
+ def add_post_vars(post)
32
+ linkpost = post.data['external-url']
33
+
34
+ if LinkBlog.config['titlecase']
35
+ post.data['title'].titlecase!
36
+ end
37
+
38
+ if linkpost
39
+ config = LinkBlog.config['linkpost']
40
+ else
41
+ config = LinkBlog.config['post']
42
+ end
43
+
44
+ post.data['title_text'] = title_text(post.data['title'], config)
45
+ post.data['title_html'] = title_html(post.data['title'], config)
46
+ post.data['title_url'] = linkpost || post.url
47
+ post.data['linkpost'] = !linkpost.nil?
48
+ post.data['title_link'] = title_link(post.data)
49
+ post
50
+ end
51
+
52
+ def unorphan(title)
53
+ title.sub(/\s+(\S+)\s*$/, '&nbsp;\1')
54
+ end
55
+
56
+ def title_html(title, config)
57
+ if LinkBlog.config['unorphan']
58
+ title = unorphan(title)
59
+ end
60
+
61
+ return title if !config['marker']
62
+
63
+ marker = "<span class='post-marker post-marker-#{config['marker_position']}'>#{config['marker']}</span>"
64
+ position = config['marker_position']
65
+
66
+ if config['marker_position'] == 'before'
67
+ title = "#{marker}&nbsp;#{title}"
68
+ else
69
+ title = "#{title}&nbsp;#{marker}"
70
+ end
71
+
72
+ title
73
+ end
74
+
75
+ def title_link(data)
76
+ classname = "article-link"
77
+ classname << " linkpost" if data['linkpost']
78
+ "<a href='#{data['title_url']}' class='#{classname}'>#{data['title_html']}</a>"
79
+ end
80
+
81
+ def title_text(title, config)
82
+ return title if !config['marker']
83
+ position = config['marker_position']
84
+
85
+ if config['marker_position'] == 'before'
86
+ "#{config['marker']} #{title}"
87
+ else
88
+ "#{title} #{config['marker']}"
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+
@@ -0,0 +1,35 @@
1
+ module Octopress
2
+ unless defined? Octopress.config
3
+ def self.config
4
+ file = '_octopress.yml'
5
+ if File.exist?(file)
6
+ SafeYAML.load_file(file) || {}
7
+ else
8
+ {}
9
+ end
10
+ end
11
+ end
12
+
13
+ module LinkBlog
14
+ module Configuration
15
+ DEFAULTS = {
16
+ 'linkpost' => {
17
+ 'marker' => "→",
18
+ 'marker_position' => 'after'
19
+ },
20
+
21
+ 'post' => {
22
+ 'marker' => false,
23
+ 'marker_position' => 'before'
24
+ },
25
+
26
+ 'titlecase' => true,
27
+ 'unorphan' => true
28
+ }
29
+
30
+ def self.config
31
+ @config ||= Jekyll::Utils.deep_merge_hashes(DEFAULTS, Octopress.config)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Octopress
2
+ module Tags
3
+ module LinkBlog
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'octopress-linkblog/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "octopress-linkblog"
8
+ spec.version = Octopress::Tags::LinkBlog::VERSION
9
+ spec.authors = ["Brandon Mathis"]
10
+ spec.email = ["brandon@imathis.com"]
11
+ spec.summary = %q{Add linkblog features to your Jekyll site.}
12
+ spec.description = %q{Add linkblog features to your Jekyll site.}
13
+ spec.homepage = "https://github.com/octopress/linkblog"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "jekyll", "~> 2.0"
22
+ spec.add_runtime_dependency "octopress-hooks", "~> 2.1"
23
+ spec.add_runtime_dependency "titlecase"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "clash"
28
+ end
data/test/.clash.yml ADDED
@@ -0,0 +1,2 @@
1
+ build: true
2
+ compare: _expected _site
data/test/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'octopress-linkblog', path: '../'
4
+ gem 'octopress', path: '../../cli'
5
+ gem 'octopress-hooks', path: '../../hooks'
6
+ gem 'pry-debugger'
7
+ gem 'clash'
data/test/_config.yml ADDED
@@ -0,0 +1,14 @@
1
+ # Site settings
2
+ title: Your awesome title
3
+ email: your-email@domain.com
4
+ baseurl: ""
5
+ url: "http://yourdomain.com"
6
+ timezone: UTC
7
+
8
+ exclude:
9
+ - Gemfile*
10
+
11
+ # Build settings
12
+ markdown: kramdown
13
+ gems:
14
+ - octopress-linkblog
@@ -0,0 +1 @@
1
+ Hey Guys.
@@ -0,0 +1 @@
1
+ Sup.
@@ -0,0 +1,14 @@
1
+
2
+ Titles:
3
+ normal: Some Awesome Post
4
+ html: <span class='post-marker post-marker-before'>★</span>&nbsp;Some Awesome&nbsp;Post
5
+ text: ★ Some Awesome Post
6
+
7
+ Urls:
8
+ normal: /2014/05/25/awesome-things.html
9
+ title_url: /2014/05/25/awesome-things.html
10
+ title_link: <a class='article-link' href='/2014/05/25/awesome-things.html'><span class='post-marker post-marker-before'>★</span>&nbsp;Some Awesome&nbsp;Post</a>
11
+
12
+ linkpost: false
13
+
14
+
@@ -0,0 +1,14 @@
1
+
2
+ Titles:
3
+ normal: Some Link Post
4
+ html: Some Link&nbsp;Post&nbsp;<span class='post-marker post-marker-after'>→</span>
5
+ text: Some Link Post →
6
+
7
+ Urls:
8
+ normal: /2014/06/25/some-linkpost.html
9
+ title_url: http://timecube.com
10
+ title_link: <a class='article-link linkpost' href='http://timecube.com'>Some Link&nbsp;Post&nbsp;<span class='post-marker post-marker-after'>→</span></a>
11
+
12
+ linkpost: true
13
+
14
+
@@ -0,0 +1,27 @@
1
+
2
+ Titles:
3
+ normal: Some Link Post
4
+ html: Some Link&nbsp;Post&nbsp;<span class='post-marker post-marker-after'>→</span>
5
+ text: Some Link Post →
6
+
7
+ Urls:
8
+ normal: /2014/06/25/some-linkpost.html
9
+ title_url: http://timecube.com
10
+ title_link: <a class='article-link linkpost' href='http://timecube.com'>Some Link&nbsp;Post&nbsp;<span class='post-marker post-marker-after'>→</span></a>
11
+
12
+ linkpost: true
13
+
14
+
15
+ Titles:
16
+ normal: Some Awesome Post
17
+ html: <span class='post-marker post-marker-before'>★</span>&nbsp;Some Awesome&nbsp;Post
18
+ text: ★ Some Awesome Post
19
+
20
+ Urls:
21
+ normal: /2014/05/25/awesome-things.html
22
+ title_url: /2014/05/25/awesome-things.html
23
+ title_link: <a class='article-link' href='/2014/05/25/awesome-things.html'><span class='post-marker post-marker-before'>★</span>&nbsp;Some Awesome&nbsp;Post</a>
24
+
25
+ linkpost: false
26
+
27
+
@@ -0,0 +1,11 @@
1
+ Titles:
2
+ normal: {{ post.title }}
3
+ html: {{ post.title_html }}
4
+ text: {{ post.title_text }}
5
+
6
+ Urls:
7
+ normal: {{ post.url }}
8
+ title_url: {{ post.title_url }}
9
+ title_link: {{ post.title_link }}
10
+
11
+ linkpost: {{ post.linkpost }}
@@ -0,0 +1,2 @@
1
+ post:
2
+ marker: ★
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Some awesome post
3
+ ---
4
+
5
+ Hey Guys.
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Some link post
3
+ external-url: http://timecube.com
4
+ ---
5
+
6
+ Sup.
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+
4
+ {% for post in site.articles %}
5
+ {% include post.html %}
6
+ {% endfor %}
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+
4
+ {% for post in site.linkposts %}
5
+ {% include post.html %}
6
+ {% endfor %}
data/test/posts.html ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+
4
+ {% for post in site.posts %}
5
+ {% include post.html %}
6
+ {% endfor %}
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-linkblog
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Mathis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octopress-hooks
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: titlecase
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: clash
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Add linkblog features to your Jekyll site.
98
+ email:
99
+ - brandon@imathis.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - CHANGELOG.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/octopress-linkblog.rb
112
+ - lib/octopress-linkblog/configuration.rb
113
+ - lib/octopress-linkblog/version.rb
114
+ - octopress-linkblog.gemspec
115
+ - test/.clash.yml
116
+ - test/Gemfile
117
+ - test/_config.yml
118
+ - test/_expected/2014/05/25/awesome-things.html
119
+ - test/_expected/2014/06/25/some-linkpost.html
120
+ - test/_expected/articles.html
121
+ - test/_expected/linkposts.html
122
+ - test/_expected/posts.html
123
+ - test/_includes/post.html
124
+ - test/_octopress.yml
125
+ - test/_posts/2014-05-25-awesome-things.html
126
+ - test/_posts/2014-06-25-some-linkpost.html
127
+ - test/articles.html
128
+ - test/linkposts.html
129
+ - test/posts.html
130
+ homepage: https://github.com/octopress/linkblog
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.2.2
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Add linkblog features to your Jekyll site.
154
+ test_files:
155
+ - test/.clash.yml
156
+ - test/Gemfile
157
+ - test/_config.yml
158
+ - test/_expected/2014/05/25/awesome-things.html
159
+ - test/_expected/2014/06/25/some-linkpost.html
160
+ - test/_expected/articles.html
161
+ - test/_expected/linkposts.html
162
+ - test/_expected/posts.html
163
+ - test/_includes/post.html
164
+ - test/_octopress.yml
165
+ - test/_posts/2014-05-25-awesome-things.html
166
+ - test/_posts/2014-06-25-some-linkpost.html
167
+ - test/articles.html
168
+ - test/linkposts.html
169
+ - test/posts.html