sawsge 0.2.1 → 1.0.0

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
  SHA256:
3
- metadata.gz: e97f4efdfda6c24333e69d1e5a213ff5cf838886620b6a66253e4b15a270bec7
4
- data.tar.gz: 9e3d40a49c624280265c5189a20bb95bdab602227e9161925b737f42d0fcd701
3
+ metadata.gz: b2a7067cfade9bf1831c7bf6f46d09bd23912b8f02ca9739ab3b281383a1348b
4
+ data.tar.gz: 04cb0c0e02a735460b7f3b0688abeac45d771ec702b6a8227d610b134458345c
5
5
  SHA512:
6
- metadata.gz: 25633584a07e77f02536dfbe23cba4e91ad68c72b3c55d7def67e48775cb14db57e1d9459d26514bdc7f42261d129fe017b6432e1fc9de54909907dbf74c2e4c
7
- data.tar.gz: 2aa82092c2e6a97afb34a639f02dd93f4f342c8491232812c6ea0da99782d9092cbb777642b4da0a0d2e495d204da80785395abc87cbf76760b8c8a0959efc6f
6
+ metadata.gz: b458f8adb18c62f8e6b101ecc572ae41bce854e8970aa0564fbec70e7b278bd133795b69ff1255fa13bc7d027fcc4c223cab06bff8fa92c908714f109b6006bd
7
+ data.tar.gz: 4e1da958f57c9b4feacbe0d655e4db6093ef977efb8ed6a544791146582177fe44c96339e54c1710ede9cd317a877228f39cdab7348287c9c236d42f84da56d6
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.0'
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
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.0
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-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pandoc-ruby