2024-03-05 17:04:12 +01:00
|
|
|
require "jekyll"
|
|
|
|
require "time"
|
|
|
|
|
|
|
|
desc "create a new note"
|
2024-05-02 22:53:26 +02:00
|
|
|
task :note, [:content] do |_t, args|
|
2024-03-05 17:04:12 +01:00
|
|
|
slug = "#{Date.today}-#{('a'..'z').to_a.repeated_permutation(1).to_a.sample(2).join}"
|
|
|
|
|
2024-05-02 22:53:26 +02:00
|
|
|
content = args[:content]
|
|
|
|
|
2024-03-05 17:04:12 +01:00
|
|
|
file = File.join(
|
|
|
|
File.dirname(__FILE__),
|
2024-05-02 22:53:26 +02:00
|
|
|
'_notes',
|
|
|
|
"#{slug}.md"
|
2024-03-05 17:04:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
frontmatter = <<~EONOTE
|
2024-05-02 22:53:26 +02:00
|
|
|
---
|
|
|
|
layout: default
|
|
|
|
title: Note
|
|
|
|
date: "#{DateTime.now.strftime("%Y-%m-%d %H:%M")}"
|
|
|
|
---
|
2024-03-05 17:04:12 +01:00
|
|
|
|
|
|
|
EONOTE
|
|
|
|
|
2024-05-02 22:53:26 +02:00
|
|
|
unless content.nil?
|
|
|
|
File.write(file, frontmatter + content)
|
|
|
|
else
|
|
|
|
File.write(file, frontmatter)
|
|
|
|
|
|
|
|
system("#{ENV['EDITOR']} #{file}")
|
|
|
|
end
|
2024-03-05 17:04:12 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "build site"
|
|
|
|
task :build do
|
|
|
|
Jekyll::Commands::Build.process({})
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "clean site"
|
|
|
|
task :clean do
|
|
|
|
Jekyll::Commands::Clean.process({})
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "serve local site"
|
|
|
|
task :serve => [:build] do
|
|
|
|
Jekyll::Commands::Serve.process({
|
|
|
|
incremental: true,
|
|
|
|
livereload: true,
|
|
|
|
skip_initial_build: false,
|
|
|
|
open_url: true,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "deploy site"
|
|
|
|
task :deploy => [:build] do
|
2024-03-07 12:05:12 +01:00
|
|
|
sh "rsync -az --delete ./_site/ srv.muhh.lol:/var/www/htdocs/muhh.lol/"
|
2024-03-05 17:04:12 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
task :default => [:clean, :build, :serve]
|