Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ end
group :test, :development do
gem 'classifier-reborn', github: 'jekyll/classifier-reborn'
gem 'github-pages-health-check'
#gem 'gsl', github: 'SciRuby/rb-gsl' Not compatible with Ruby 3.0
gem 'numo-narray'
gem 'numo-linalg'
# gem 'gsl', github: 'SciRuby/rb-gsl' Not compatible with Ruby 3.0
gem 'html-proofer'
gem 'nokogiri'
gem 'numo-linalg'
gem 'numo-narray'
gem 'pry'
gem 'rake'
gem 'rspec'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ task :format_yaml do
next unless content.match?(Jekyll::Document::YAML_FRONT_MATTER_REGEXP)

parts = content.split Jekyll::Document::YAML_FRONT_MATTER_REGEXP
yaml = YAML.load_file(parts[1], permitted_classes: [Psych, Symbol])
yaml = YAML.load(parts[1], permitted_classes: [Psych, Symbol])
%w[title description].each { |key| yaml[key] = strip_whitespace(yaml[key]) if yaml[key] }
%w[tags category categories post_format].each { |key| yaml.delete(key) }
File.write(path, "#{yaml.to_yaml(line_width: -1)}---\n\n#{parts[4]}")
Expand Down
6 changes: 3 additions & 3 deletions script/build-related-posts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ require 'psych'
options = {
'source' => File.expand_path('../', __dir__),
'lsi' => true,
'verbose' => true,
'verbose' => true
}

ignore_list = [
'_posts/2011-11-29-towards-a-more-agile-government.md',
'_posts/2012-12-26-securing-the-status-quo.md'
]

Jekyll.logger.info "Building site"
Jekyll.logger.info 'Building site'
config = Jekyll.configuration(options)
site = Jekyll::Site.new(config)

site.reset
site.read
site.posts.docs.delete_if { |post| ignore_list.include?(post.relative_path) || post.data['archived'] }

Jekyll.logger.info "Building related posts"
Jekyll.logger.info 'Building related posts'
relations = {}
site.posts.docs.each do |post|
relations[post.relative_path] = post.related_posts.map(&:relative_path)
Expand Down
9 changes: 8 additions & 1 deletion script/lint-front-matter
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ require 'open3'

exitstatus = 0

# Pre-collect all files to avoid re-reading during iteration
files_with_yaml = []
Dir['*/**.md'].each do |path|
content = File.read(path)
next unless content.match?(Jekyll::Document::YAML_FRONT_MATTER_REGEXP)

parts = content.split Jekyll::Document::YAML_FRONT_MATTER_REGEXP
output, status = Open3.capture2e('yamllint', '-', '-c', '.yamllint.yml', '-f', 'colored', stdin_data: parts[1])
files_with_yaml << [path, parts[1]]
end

# Process all collected files
files_with_yaml.each do |path, yaml_content|
output, status = Open3.capture2e('yamllint', '-', '-c', '.yamllint.yml', '-f', 'colored', stdin_data: yaml_content)
next if status.exitstatus.zero?

puts path
Expand Down
12 changes: 7 additions & 5 deletions spec/amazon_link_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ def affiliate_id
end

def uri
URI.parse(@link.href)
@uri ||= URI.parse(@link.href)
end

def params
CGI.parse(uri.query) if uri.query
@params ||= CGI.parse(uri.query) if uri.query
end

def amazon_link?
uri.host =~ /amazon\.com/
end

def afiiliate_id?
def affiliate_id?
return false unless params&.key?('tag')

params['tag'].first == affiliate_id
Expand All @@ -26,10 +26,12 @@ def afiiliate_id?
def run
@html.css('a').each do |node|
@link = create_element(node)
@uri = nil # Reset memoized URI for new link
@params = nil # Reset memoized params for new link
next if @link.data_proofer_ignore || @link.href.nil?

if amazon_link? && !afiiliate_id?
msg = "Misssing Amazon Affiliate ID: #{@link.href}"
if amazon_link? && !affiliate_id?
msg = "Missing Amazon Affiliate ID: #{@link.href}"
add_issue(msg, line: node.line)
end
end
Expand Down