jekyll-theme-open-project-helpers 1.0.0.rc5 → 1.0.1

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: 905882f12a5d505fb7535d96b7f1c8b52a174200
4
- data.tar.gz: 8c6f12cd854586c181b74a9a469d3812ba958e68
3
+ metadata.gz: 6b0cb77746966548999e685bca5a80c37c5486a2
4
+ data.tar.gz: 3e56cf45ea5251b49f9540e7b2ec11df6244da06
5
5
  SHA512:
6
- metadata.gz: 3cc3e706e19a520699df1f965bcd863c48bde072e8a899eb2ef11f307c10a0748d836a8e2c2b347c4095968c8206e7efe8ed1c50c0b83c827273e096af5bdbef
7
- data.tar.gz: cae265cbaf51cb2b398fa845afe0fbcd24ca331678acbbc5c5fcd0b38bdd06b06631ddf1dfb5507bc9341478c67bf41a0486e226ae174afb108b573e77f043f2
6
+ metadata.gz: deffc10af730eb1a94c77c2a1eb8a13ddda05322fbc60ac526b5600432b640756c86c435e027b6bdca2d4c7ea5974bed7a76421ebcc5d48948c3dbf8cd640597
7
+ data.tar.gz: 62f7e67d05891a63872d5ce4a3da7aa8e7ed6df0ebfbb51b1696cf05c8baf0f795cb16c46e9d53d589578bd31d7171873c244d61dd937ee2627780b5dc9ebaa1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jekyll-theme-open-project-helpers'
5
- s.version = '1.0.0.rc5'
5
+ s.version = '1.0.1'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -1,19 +1,20 @@
1
1
  module Jekyll
2
2
  module OpenProjectHelpers
3
3
 
4
- # Below passes an array of posts of open hub blog
5
- # and from each individual project blog, combined and sorted by date,
6
- # to open hub blog index page.
7
4
  #
8
- # (It also does some processing on the posts.)
9
-
10
- class BlogIndexGenerator < Jekyll::Generator
5
+ # Adds a variable holding the array of posts of open hub blog
6
+ # and from each individual project blog, combined and sorted by date.
7
+ #
8
+ # It also does some processing on the posts
9
+ # as required by the Open Project theme.
10
+ #
11
+ class CombinedPostArrayGenerator < Generator
11
12
  safe true
12
13
 
13
14
  def generate(site)
14
15
  site_posts = site.posts.docs
15
16
 
16
- if Jekyll::OpenProjectHelpers::is_hub(site)
17
+ if site.config['is_hub']
17
18
  # Get documents representing projects
18
19
  projects = site.collections['projects'].docs.select do |item|
19
20
  pieces = item.url.split('/')
@@ -53,8 +54,9 @@ module Jekyll
53
54
  post
54
55
  end
55
56
 
56
- blog_index = site.site_payload["site"]["pages"].detect { |page| page.url == '/blog/' }
57
- blog_index.data['posts_combined'] = posts_combined
57
+ # Make combined blog post array available site-wide
58
+ site.config['posts_combined'] = posts_combined
59
+ site.config['num_posts_combined'] = posts_combined.size
58
60
  end
59
61
  end
60
62
 
@@ -43,7 +43,7 @@ module Jekyll
43
43
  safe true
44
44
 
45
45
  def generate(site)
46
- if Jekyll::OpenProjectHelpers::is_hub(site)
46
+ if site.config['is_hub']
47
47
  INDEXES.each do |index_name, params|
48
48
  items = site.collections['projects'].docs.select { |item| params[:item_test].call(item) }
49
49
 
@@ -85,18 +85,26 @@ module Jekyll
85
85
  safe true
86
86
 
87
87
  def generate(site)
88
+ site.config['num_featured_software'] = 3
89
+ site.config['num_featured_specs'] = 3
90
+ site.config['num_featured_posts'] = 3
88
91
 
89
92
  INDEXES.each do |index_name, params|
90
- if Jekyll::OpenProjectHelpers::is_hub(site)
91
- items = site.collections['projects'].docs.select { |item| params[:item_test].call(item) }
93
+ if site.config['is_hub']
94
+ collection_name = 'projects'
92
95
  else
93
- items = site.collections[index_name].docs.select { |item| params[:item_test].call(item) }
96
+ collection_name = index_name
94
97
  end
95
98
 
96
- page = site.site_payload["site"]["pages"].detect { |p| p.url == "/#{index_name}/" }
97
- page.data['items'] = items
98
- end
99
+ if site.collections.key? collection_name
100
+ # Filters items from given collection_name through item_test function
101
+ items = site.collections[collection_name].docs.select { |item| params[:item_test].call(item) }
99
102
 
103
+ # Makes items available in templates via e.g. site.all_specs, site.all_software
104
+ site.config["all_#{index_name}"] = items
105
+ site.config["num_all_#{index_name}"] = items.size
106
+ end
107
+ end
100
108
  end
101
109
  end
102
110
 
@@ -11,7 +11,7 @@ module Jekyll
11
11
  return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
12
12
 
13
13
  entries = Dir.chdir(dir) do
14
- Dir["*.{md,markdown,html,svg,png}"] + Dir["*"].select { |fn| File.directory?(fn) }
14
+ Dir["*.{adoc,md,markdown,html,svg,png}"] + Dir["*"].select { |fn| File.directory?(fn) }
15
15
  end
16
16
 
17
17
  entries.each do |entry|
@@ -22,7 +22,7 @@ module Jekyll
22
22
 
23
23
  elsif nested or (File.basename(entry, '.*') != 'index')
24
24
  ext = File.extname(path)
25
- if ['.md', '.markdown', '.html'].include? ext
25
+ if ['.adoc', '.md', '.markdown', '.html'].include? ext
26
26
  doc = Jekyll::Document.new(path, :site => @site, :collection => collection)
27
27
  doc.read
28
28
  collection.docs << doc
@@ -50,7 +50,7 @@ module Jekyll
50
50
 
51
51
  def read
52
52
  super
53
- if Jekyll::OpenProjectHelpers::is_hub(@site)
53
+ if @site.config['is_hub']
54
54
  fetch_and_read_projects
55
55
  else
56
56
  fetch_and_read_docs_for_items('software')
@@ -111,6 +111,8 @@ module Jekyll
111
111
  # collection_name would be either software, specs, or (for hub site) projects
112
112
  # index_collection_name would be either software or specs
113
113
 
114
+ return unless @site.collections.key?(collection_name)
115
+
114
116
  index_collection_name = index_collection_name or collection_name
115
117
 
116
118
  entry_points = @site.collections[collection_name].docs.select do |doc|
@@ -1,19 +1,25 @@
1
1
  module Jekyll
2
2
  module OpenProjectHelpers
3
3
 
4
- def self.is_hub(site)
4
+ #
5
+ # Infers from available content whether the site is a hub
6
+ # or individual project site, and adds site-wide config variable
7
+ # accessible as {{ site.is_hub }} in Liquid.
8
+ #
9
+ class SiteTypeVariableGenerator < Generator
10
+ def generate(site)
11
+ site.config['is_hub'] = false
5
12
 
6
- # If there’re projects defined, we assume it is indeed
7
- # a Jekyll Open Project hub site.
8
- if site.collections.key? 'projects'
9
- if site.collections['projects'] != nil
10
- if site.collections['projects'].docs.length > 0
11
- return true
13
+ # If there’re projects defined, we assume it is indeed
14
+ # a Jekyll Open Project hub site.
15
+ if site.collections.key? 'projects'
16
+ if site.collections['projects'] != nil
17
+ if site.collections['projects'].docs.length > 0
18
+ site.config['is_hub'] = true
19
+ end
12
20
  end
13
21
  end
14
22
  end
15
-
16
- return false
17
23
  end
18
24
 
19
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-open-project-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc5
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-14 00:00:00.000000000 Z
11
+ date: 2018-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -97,9 +97,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ">"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 1.3.1
102
+ version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
105
  rubygems_version: 2.6.14.1