sawsge 0.2.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e97f4efdfda6c24333e69d1e5a213ff5cf838886620b6a66253e4b15a270bec7
4
- data.tar.gz: 9e3d40a49c624280265c5189a20bb95bdab602227e9161925b737f42d0fcd701
3
+ metadata.gz: 7a24e5324f67a6309a03ea07a5ab5eebae04a659fa02e98630318ca969fef453
4
+ data.tar.gz: ea77f1a1783d721e5f0ba179082f4c0fb8a1c19b85a0920a5fc66b46ec0d0613
5
5
  SHA512:
6
- metadata.gz: 25633584a07e77f02536dfbe23cba4e91ad68c72b3c55d7def67e48775cb14db57e1d9459d26514bdc7f42261d129fe017b6432e1fc9de54909907dbf74c2e4c
7
- data.tar.gz: 2aa82092c2e6a97afb34a639f02dd93f4f342c8491232812c6ea0da99782d9092cbb777642b4da0a0d2e495d204da80785395abc87cbf76760b8c8a0959efc6f
6
+ metadata.gz: 0a274f48701502b7378a7559af7f087835f3ffdbccb649ab8e9e4f6dd5d6a3027ae1170f58290a1412eceb1e4d826522c29943aa38db649dcc9dd6c0d1c4e902
7
+ data.tar.gz: bf5a0c3298253361bf7101df64fed299d8508ad0fe23c4253bd7a7cc13227e696162ecfc818c9c120799f383cf2f4b8335260eaef810a1ac66af7869dd897aab
data/lib/sawsge/blog.rb CHANGED
@@ -10,13 +10,24 @@ class Sawsge
10
10
  post_paths = @resource_paths.select do |path|
11
11
  top_parent_dir(path) == @config.posts_dirname && File.extname(path) == '.md'
12
12
  end
13
- # So posts are added to Home in chronological order
14
- post_paths.reverse!
15
13
 
16
14
  @resource_paths -= post_paths
17
15
  @resource_paths.delete home_path
18
16
 
19
17
  post_objects = post_paths.map { |path| Post.new(path, @config) }
18
+
19
+ post_objects.sort_by! { |x| x.date }
20
+ # Posts are now in reverse chronological order
21
+
22
+ i_last_nil_date = 0
23
+ while post_objects[i_last_nil_date].date.empty?
24
+ i_last_nil_date += 1
25
+ end
26
+
27
+ post_objects.rotate!(i_last_nil_date).reverse!
28
+ # Posts are now in chronological order with dateless
29
+ # posts being first
30
+
20
31
  home_object = Home.new(home_path, post_objects, @config)
21
32
  @all_objects = post_objects + [home_object]
22
33
  end
data/lib/sawsge/config.rb CHANGED
@@ -24,9 +24,10 @@ class Sawsge
24
24
  @header_path = File.expand_path(File.join(@src_dir, @header_filename))
25
25
  @footer_path = File.expand_path(File.join(@src_dir, @footer_filename))
26
26
 
27
- @reserved_filenames = config[:general][:ignore] + [CONFIG_FILENAME, @header_filename, @footer_filename]
27
+ ignored_files = config[:general][:ignore] || []
28
+ @reserved_filenames = ignored_files + [CONFIG_FILENAME, @header_filename, @footer_filename]
28
29
 
29
- @external_links_target_blank = config[:general][:external_links_target_blank]
30
+ @external_links_target_blank = config[:general][:external_links_target_blank] || true
30
31
 
31
32
  @posts_dirname = config[:blog][:posts_dirname]
32
33
  end
data/lib/sawsge/home.rb CHANGED
@@ -5,6 +5,7 @@ class Sawsge
5
5
  class Home < Page
6
6
  def initialize(path, posts, config)
7
7
  super(path, config)
8
+
8
9
  posts.each_with_index do |post, _i|
9
10
  # Adds collapseable summary of each post on the front
10
11
  # page
@@ -19,6 +20,7 @@ class Sawsge
19
20
  HTML
20
21
  @document.at_css('footer').add_previous_sibling summary_fragment
21
22
  end
23
+
22
24
  end
23
25
  end
24
26
  end
data/lib/sawsge/page.rb CHANGED
@@ -7,7 +7,13 @@ class Sawsge
7
7
 
8
8
  def initialize(path, config)
9
9
  super(path)
10
- html_body_fragment = PandocRuby.convert(File.new(@path, 'r').read, from: :markdown, to: :html)
10
+
11
+ markdown = File.read(@path)
12
+ options = {
13
+ :from => :markdown,
14
+ :to => :html
15
+ }
16
+ html_body_fragment = PandocRuby.convert(markdown, options)
11
17
 
12
18
  header = File.read config.header_path
13
19
  footer = File.read config.footer_path
data/lib/sawsge/post.rb CHANGED
@@ -8,17 +8,15 @@ class Sawsge
8
8
  def initialize(path, config)
9
9
  super(path, config)
10
10
 
11
- # There's got to be a more idiomatic way to do this! The
12
- # current implementation is disguisting.
13
- # Also doesn't work if POSTS_DIRNAME is more than 2
14
- # directories
15
- parts = Pathname.new(@path).each_filename.to_a[1..]
16
- parts.delete(config.posts_dirname)
17
- @date = "#{parts[0]}-#{parts[1]}-#{parts[2]}"
18
- @document.css('h1').first.add_next_sibling "<date>#{@date}</date>"
19
-
20
- # Look what's in <summary></summary>
11
+ # Get the summary and date of the post
21
12
  @summary = @document.css('summary').first.content
13
+ # If a date is specified within the <time> tag on the
14
+ # page, use that, otherwise use an empty string
15
+ @date = begin
16
+ date = @document.css('time').first
17
+ date ? date.content : ''
18
+ end
22
19
  end
20
+
23
21
  end
24
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Sawsge
4
- VERSION = '0.2.1'
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/sawsge.rb CHANGED
@@ -3,11 +3,11 @@
3
3
  require 'fileutils'
4
4
  require 'nokogiri'
5
5
  require 'pandoc-ruby'
6
+ require 'parallel'
6
7
  require 'pathname'
7
8
  require 'set'
8
9
  require 'tomlrb'
9
10
  require 'uri'
10
- require 'parallel'
11
11
 
12
12
  require 'sawsge/resource'
13
13
  require 'sawsge/page'
@@ -45,12 +45,14 @@ class Sawsge
45
45
  @resource_paths = Dir.glob('**/*').select do |path|
46
46
  File.file?(path) &&
47
47
  top_parent_dir(path) != @config.out_dirname &&
48
+ # Exclude explicitly ignored files
48
49
  !@config.reserved_filenames.include?(path)
49
50
  end
50
51
 
51
52
  @resource_objects = Set.new
52
53
  @all_objects = Set.new
53
54
 
55
+ # Execute blog or project specific code.
54
56
  send @config.mode
55
57
 
56
58
  resources = @resource_paths.map { |path| Resource.new(path) }
@@ -61,7 +63,6 @@ class Sawsge
61
63
  FileUtils.mkpath @config.out_dirname
62
64
 
63
65
  # Write each file
64
- @all_objects.each { |x| x.build @config.out_dirname }
65
- Parallel.each(@all_object) { |x| x.build @config.out_dirname }
66
+ Parallel.each(@all_objects) { |x| x.build @config.out_dirname }
66
67
  end
67
68
  end
data/sawsge.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  ]
29
29
  s.homepage = 'https://github.com/sawshep/sawsge'
30
30
  s.license = 'GPL-3.0'
31
- s.required_ruby_version = '>= 3.0'
31
+ s.required_ruby_version = '>= 2.7'
32
32
  s.add_runtime_dependency 'pandoc-ruby', '~> 2.1'
33
33
  s.add_runtime_dependency 'tomlrb', '~> 2.0', '>= 2.0.1'
34
34
  s.add_runtime_dependency 'nokogiri', '~> 1.12', '>= 1.12.4'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sawsge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Shepherd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-03 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pandoc-ruby
@@ -119,14 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: '3.0'
122
+ version: '2.7'
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.3.7
129
+ rubygems_version: 3.4.1
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Simple Markdown static site generator for blogs or projects