octopress-category-list 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f5cee15f638374082b90708253efcdf2638b4ca
4
+ data.tar.gz: b48b15aae28d13da52186194b3804fdfa5f69421
5
+ SHA512:
6
+ metadata.gz: 91aa4d35835718281801c268e376a074dd51b4530e25b4f7ffdacddde057e31d50050406c1637d8ee9e898a8a0ec0701d5788804186c30276a81e85956edb8cb
7
+ data.tar.gz: 5161e26fa7267a71a6b9269ef4d68a95ed9a14c659fce8dcc3941aa1b8a803f965e68b2e3101e96a3ac754c05a56d070849c07b30ea5c52f8993872f0e6110d2
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2015-05-18
4
+ - Initial release
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Wang Jian
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # OctopressCategoryList
2
+
3
+ A Octopress Ink plugin to generate a category list page for your site.
4
+
5
+ [![Build Status](https://travis-ci.org/wantee/octopress-category-list.svg)](https://travis-ci.org/wantee/octopress-category-list)
6
+ [![Gem Version](https://badge.fury.io/rb/octopress-category-list.svg)](http://badge.fury.io/rb/octopress-category-list)
7
+ [![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/wantee/octopress-category-list/blob/master/LICENSE.txt)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'octopress-category-list'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install octopress-category-list
24
+
25
+ ## Usage
26
+
27
+ Make sure generating category indexes in your site. Set this in your theme config:
28
+
29
+ ```yaml
30
+ category_indexes: true
31
+ ```
32
+
33
+ Then add navigation to categories or other place to link to `/categories/`:
34
+
35
+ ```yaml
36
+ main_nav:
37
+ - { url: '/categories/', title: 'Categories' }
38
+ ```
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/wantee/octopress-category-list/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ categories_dir: "categories"
2
+ category_list_title: "Categories"
@@ -0,0 +1,14 @@
1
+ <article class="archive {{ category }}" role="article">
2
+ {% capture category_permalink %}/categories/{{ category }}/{% endcapture %}
3
+ <header class="archive-entry-header">
4
+ <h2 class="archive-entry-title"><a href='{{ category_permalink }}'>{{ category | titlecase }}</a></h2>
5
+ <div class="archive-entry-date"> posts: {% category_size category %}</div>
6
+ </header>
7
+
8
+
9
+ <footer class='archive-entry-footer' role='contentinfo'>
10
+ <p>
11
+ <a href='{{ category_permalink }}'>Permalink</a>
12
+ </p>
13
+ </footer>
14
+ </article>
@@ -0,0 +1,15 @@
1
+ ---
2
+ layout: theme:default
3
+ ---
4
+ <div class="post-archive limit-width">
5
+ <div class="category-index">
6
+ {% capture categories %}{% for category in site.categories %}|{{ category | first | strip }}{% endfor %}{% endcapture %}
7
+
8
+ {% assign sorted_categories = categories | remove_first:'|' | split:'|' | sort %}
9
+
10
+ {% for category in sorted_categories %}
11
+ {% include octopress-category-list:category_list_category.html %}
12
+ {% endfor %}
13
+ </div>
14
+ </div>
15
+ </div>
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "octopress_category_list"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ require 'octopress-category-list/version'
2
+ require 'octopress-ink'
3
+
4
+ module OctopressCategoryList
5
+ autoload :Plugin, 'octopress-category-list/plugin'
6
+ autoload :Tags, 'octopress-category-list/tags'
7
+ end
8
+
9
+ Liquid::Template.register_tag('category_size', OctopressCategoryList::Tags)
10
+
11
+ Octopress::Ink.register_plugin(OctopressCategoryList::Plugin, {
12
+ name: "Octopress Category List",
13
+ slug: "octopress-category-list",
14
+ gem: "octopress-category-list",
15
+ path: File.expand_path(File.join(File.dirname(__FILE__), "..")),
16
+ type: "plugin",
17
+ version: OctopressCategoryList::VERSION,
18
+ description: "Generating a category list page",
19
+ source_url: "https://github.com/wantee/octopress-category-list",
20
+ websit: "https://github.com/wantee/octopress-category-list"
21
+ })
@@ -0,0 +1,13 @@
1
+ module OctopressCategoryList
2
+
3
+ class Config
4
+
5
+ def self.default_config
6
+ <<-CONFIG
7
+ categories_dir: "categories"
8
+ category_list_title: "Categories"
9
+ CONFIG
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ module OctopressCategoryList
2
+ autoload :Config, 'octopress-category-list/config'
3
+
4
+ class Plugin < Octopress::Ink::Plugin
5
+
6
+ def register
7
+ super
8
+ if Octopress::Ink.enabled?
9
+ self.generate(Octopress.site, config)
10
+ end
11
+ end
12
+
13
+ def generate(site, config)
14
+ @conf = inject_configs
15
+
16
+ @template = find_template('category_list.html')
17
+
18
+ return unless @template
19
+
20
+ permalink = "/" + @conf['categories_dir'] + "/index.html"
21
+ if page = @template.new_page({
22
+ 'lang' => nil,
23
+ 'title' => @conf['category_list_title'],
24
+ 'permalink' => permalink,
25
+ 'plugin' => self
26
+ })
27
+
28
+ Octopress::Ink::Bootstrap.add_page(page, nil)
29
+ Octopress.site.pages << page
30
+ end
31
+
32
+ end
33
+
34
+ def inject_configs
35
+ @conf = self.config
36
+ @conf = Jekyll::Utils.deep_merge_hashes(YAML.load(Config.default_config), @conf)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,31 @@
1
+ module OctopressCategoryList
2
+
3
+ class Tags < Liquid::Tag
4
+ def initialize(tag_name, input, tokens)
5
+ super
6
+ @input = input.strip
7
+ end
8
+
9
+ def render(context)
10
+ site = context.registers[:site]
11
+
12
+ category_name = @input
13
+ if ! site.categories.has_key?(category_name)
14
+ # if it is a variable
15
+ if context[@input]
16
+ category_name = context[@input].strip
17
+ end
18
+
19
+ if ! site.categories.has_key?(category_name)
20
+ raise ArgumentError.new <<-eos
21
+ Could not find category "#{@input}" or "#{category_name}" in tag 'category_size'.
22
+ make sure the category exists and the name is correct.
23
+ eos
24
+ end
25
+ end
26
+
27
+ site.categories[category_name].size
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,3 @@
1
+ module OctopressCategoryList
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-category-list
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wang Jian
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clash
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: octopress-genesis-theme
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octopress-ink
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ description: Generating a category list page.
84
+ email:
85
+ - wantee.wang@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - CHANGELOG.md
91
+ - LICENSE.txt
92
+ - README.md
93
+ - assets/config.yml
94
+ - assets/includes/category_list_category.html
95
+ - assets/templates/category_list.html
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/octopress-category-list.rb
99
+ - lib/octopress-category-list/config.rb
100
+ - lib/octopress-category-list/plugin.rb
101
+ - lib/octopress-category-list/tags.rb
102
+ - lib/octopress-category-list/version.rb
103
+ homepage: https://github.com/wantee/octopress-category-list.git
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.5
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Generating a category list page.
127
+ test_files: []