Port main drift updates into Pressa

This commit is contained in:
Sami Samhuri 2026-02-07 15:51:38 -08:00
parent 08c6dbc458
commit cb42616c91
No known key found for this signature in database
10 changed files with 61 additions and 33 deletions

View file

@ -33,14 +33,14 @@ end
def publish_beta
beta
puts "Deploying to beta server..."
system('rsync -avz --delete www/ beta.samhuri.net:/var/www/beta/')
system('rsync -avz --delete www/ mudge:/var/www/beta.samhuri.net/public')
end
# Publish to production server
def publish
release
puts "Deploying to production server..."
system('rsync -avz --delete www/ samhuri.net:/var/www/html/')
system('rsync -avz --delete www/ mudge:/var/www/samhuri.net/public')
end
# Clean generated files

View file

@ -19,20 +19,17 @@ module Pressa
end
projects = [
build_project.call('samhuri.net', 'samhuri.net', 'this site'),
build_project.call('bin', 'bin', 'my collection of scripts in ~/bin'),
build_project.call('config', 'config', 'important dot files (zsh, emacs, vim, screen)'),
build_project.call('compiler', 'compiler', 'a compiler targeting x86 in Ruby'),
build_project.call('lake', 'lake', 'a simple implementation of Scheme in C'),
build_project.call('AsyncMonitor', 'AsyncMonitor', 'easily monitor async sequences using Swift concurrency'),
build_project.call('NotificationSmuggler', 'NotificationSmuggler', 'embed strongly-typed values in notifications on Apple platforms'),
build_project.call('strftime', 'strftime', 'strftime for JavaScript'),
build_project.call('format', 'format', 'printf for JavaScript'),
build_project.call('gitter', 'gitter', 'a GitHub client for Node (v3 API)'),
build_project.call('mojo.el', 'mojo.el', 'turn emacs into a sweet mojo editor'),
build_project.call('ThePusher', 'ThePusher', 'Github post-receive hook router'),
build_project.call('NorthWatcher', 'NorthWatcher', 'cron for filesystem changes'),
build_project.call('repl-edit', 'repl-edit', 'edit Node repl commands with your text editor'),
build_project.call('cheat.el', 'cheat.el', 'cheat from emacs'),
build_project.call('batteries', 'batteries', 'a general purpose node library'),
build_project.call('samhuri.net', 'samhuri.net', 'this site')
build_project.call('cheat.el', 'cheat.el', 'cheat from emacs')
]
project_scripts = [
@ -53,10 +50,7 @@ module Pressa
styles: [
Stylesheet.new(href: 'css/normalize.css'),
Stylesheet.new(href: 'css/style.css'),
Stylesheet.new(href: 'css/syntax.css'),
Stylesheet.new(href: 'css/fontawesome.min.css'),
Stylesheet.new(href: 'css/brands.min.css'),
Stylesheet.new(href: 'css/solid.min.css')
Stylesheet.new(href: 'css/syntax.css')
],
plugins: [
Posts::Plugin.new,

View file

@ -3,6 +3,7 @@ require 'yaml'
require_relative 'file_writer'
require_relative '../site'
require_relative '../views/layout'
require_relative '../views/icons'
class String
include Phlex::SGML::SafeObject
@ -112,7 +113,7 @@ module Pressa
div(class: 'row clearfix') do
p(class: 'fin') do
i(class: 'fa fa-code')
raw(Views::Icons.code)
end
end
end

34
pressa/lib/views/icons.rb Normal file
View file

@ -0,0 +1,34 @@
module Pressa
module Views
module Icons
module_function
def mastodon
svg(class_name: 'icon icon-mastodon', view_box: '0 0 448 512', path: IconPath::MASTODON)
end
def github
svg(class_name: 'icon icon-github', view_box: '0 0 496 512', path: IconPath::GITHUB)
end
def rss
svg(class_name: 'icon icon-rss', view_box: '0 0 448 512', path: IconPath::RSS)
end
def code
svg(class_name: 'icon icon-code', view_box: '0 0 640 512', path: IconPath::CODE)
end
private_class_method def svg(class_name:, view_box:, path:)
"<svg class=\"#{class_name}\" viewBox=\"#{view_box}\" aria-hidden=\"true\" focusable=\"false\"><path transform=\"translate(0,448) scale(1,-1)\" d=\"#{path}\"/></svg>"
end
module IconPath
MASTODON = "M433 268.89c0 0 0.799805 -71.6992 -9 -121.5c-6.23047 -31.5996 -55.1104 -66.1992 -111.23 -72.8994c-20.0996 -2.40039 -93.1191 -14.2002 -178.75 6.7002c0 -0.116211 -0.00390625 -0.119141 -0.00390625 -0.235352c0 -4.63281 0.307617 -9.19434 0.904297 -13.665 c6.62988 -49.5996 49.2197 -52.5996 89.6299 -54c40.8105 -1.2998 77.1201 10.0996 77.1201 10.0996l1.7002 -36.8994s-28.5098 -15.2998 -79.3203 -18.1006c-28.0098 -1.59961 -62.8193 0.700195 -103.33 11.4004c-112.229 29.7002 -105.63 173.4 -105.63 289.1 c0 97.2002 63.7197 125.7 63.7197 125.7c61.9209 28.4004 227.96 28.7002 290.48 0c0 0 63.71 -28.5 63.71 -125.7zM357.88 143.69c0 122 5.29004 147.71 -18.4199 175.01c-25.71 28.7002 -79.7197 31 -103.83 -6.10059l-11.5996 -19.5l-11.6006 19.5 c-24.0098 36.9004 -77.9297 35 -103.83 6.10059c-23.6094 -27.1006 -18.4092 -52.9004 -18.4092 -175h46.7295v114.2c0 49.6992 64 51.5996 64 -6.90039v-62.5098h46.3301v62.5c0 58.5 64 56.5996 64 6.89941v-114.199h46.6299z"
GITHUB = "M165.9 50.5996c0 -2 -2.30078 -3.59961 -5.2002 -3.59961c-3.2998 -0.299805 -5.60059 1.2998 -5.60059 3.59961c0 2 2.30078 3.60059 5.2002 3.60059c3 0.299805 5.60059 -1.2998 5.60059 -3.60059zM134.8 55.0996c0.700195 2 3.60059 3 6.2002 2.30078 c3 -0.900391 4.90039 -3.2002 4.2998 -5.2002c-0.599609 -2 -3.59961 -3 -6.2002 -2c-3 0.599609 -5 2.89941 -4.2998 4.89941zM179 56.7998c2.90039 0.299805 5.59961 -1 5.90039 -2.89941c0.299805 -2 -1.7002 -3.90039 -4.60059 -4.60059 c-3 -0.700195 -5.59961 0.600586 -5.89941 2.60059c-0.300781 2.2998 1.69922 4.19922 4.59961 4.89941zM244.8 440c138.7 0 251.2 -105.3 251.2 -244c0 -110.9 -67.7998 -205.8 -167.8 -239c-12.7002 -2.2998 -17.2998 5.59961 -17.2998 12.0996 c0 8.2002 0.299805 49.9004 0.299805 83.6006c0 23.5 -7.7998 38.5 -17 46.3994c55.8994 6.30078 114.8 14 114.8 110.5c0 27.4004 -9.7998 41.2002 -25.7998 58.9004c2.59961 6.5 11.0996 33.2002 -2.60059 67.9004c-20.8994 6.59961 -69 -27 -69 -27 c-20 5.59961 -41.5 8.5 -62.7998 8.5s-42.7998 -2.90039 -62.7998 -8.5c0 0 -48.0996 33.5 -69 27c-13.7002 -34.6006 -5.2002 -61.4004 -2.59961 -67.9004c-16 -17.5996 -23.6006 -31.4004 -23.6006 -58.9004c0 -96.1992 56.4004 -104.3 112.3 -110.5 c-7.19922 -6.59961 -13.6992 -17.6992 -16 -33.6992c-14.2998 -6.60059 -51 -17.7002 -72.8994 20.8994c-13.7002 23.7998 -38.6006 25.7998 -38.6006 25.7998c-24.5 0.300781 -1.59961 -15.3994 -1.59961 -15.3994c16.4004 -7.5 27.7998 -36.6006 27.7998 -36.6006 c14.7002 -44.7998 84.7002 -29.7998 84.7002 -29.7998c0 -21 0.299805 -55.2002 0.299805 -61.3994c0 -6.5 -4.5 -14.4004 -17.2998 -12.1006c-99.7002 33.4004 -169.5 128.3 -169.5 239.2c0 138.7 106.1 244 244.8 244zM97.2002 95.0996 c1.2998 1.30078 3.59961 0.600586 5.2002 -1c1.69922 -1.89941 2 -4.19922 0.699219 -5.19922c-1.2998 -1.30078 -3.59961 -0.600586 -5.19922 1c-1.7002 1.89941 -2 4.19922 -0.700195 5.19922zM86.4004 103.2c0.699219 1 2.2998 1.2998 4.2998 0.700195 c2 -1 3 -2.60059 2.2998 -3.90039c-0.700195 -1.40039 -2.7002 -1.7002 -4.2998 -0.700195c-2 1 -3 2.60059 -2.2998 3.90039zM118.8 67.5996c1.2998 1.60059 4.2998 1.30078 6.5 -1c2 -1.89941 2.60059 -4.89941 1.2998 -6.19922 c-1.2998 -1.60059 -4.19922 -1.30078 -6.5 1c-2.2998 1.89941 -2.89941 4.89941 -1.2998 6.19922zM107.4 82.2998c1.59961 1.2998 4.19922 0.299805 5.59961 -2c1.59961 -2.2998 1.59961 -4.89941 0 -6.2002c-1.2998 -1 -4 0 -5.59961 2.30078 c-1.60059 2.2998 -1.60059 4.89941 0 5.89941z"
RSS = "M128.081 32.041c0 -35.3691 -28.6719 -64.041 -64.041 -64.041s-64.04 28.6719 -64.04 64.041s28.6719 64.041 64.041 64.041s64.04 -28.6729 64.04 -64.041zM303.741 -15.209c0.494141 -9.13477 -6.84668 -16.791 -15.9951 -16.79h-48.0693 c-8.41406 0 -15.4707 6.49023 -16.0176 14.8867c-7.29883 112.07 -96.9404 201.488 -208.772 208.772c-8.39648 0.545898 -14.8867 7.60254 -14.8867 16.0176v48.0693c0 9.14746 7.65625 16.4883 16.791 15.9941c154.765 -8.36328 278.596 -132.351 286.95 -286.95z M447.99 -15.4971c0.324219 -9.03027 -6.97168 -16.5029 -16.0049 -16.5039h-48.0684c-8.62598 0 -15.6455 6.83496 -15.999 15.4531c-7.83789 191.148 -161.286 344.626 -352.465 352.465c-8.61816 0.354492 -15.4531 7.37402 -15.4531 15.999v48.0684 c0 9.03418 7.47266 16.3301 16.5029 16.0059c234.962 -8.43555 423.093 -197.667 431.487 -431.487z"
CODE = "M278.9 -63.5l-61 17.7002c-6.40039 1.7998 -10 8.5 -8.2002 14.8994l136.5 470.2c1.7998 6.40039 8.5 10 14.8994 8.2002l61 -17.7002c6.40039 -1.7998 10 -8.5 8.2002 -14.8994l-136.5 -470.2c-1.89941 -6.40039 -8.5 -10.1006 -14.8994 -8.2002zM164.9 48.7002 c-4.5 -4.90039 -12.1006 -5.10059 -17 -0.5l-144.101 135.1c-5.09961 4.7002 -5.09961 12.7998 0 17.5l144.101 135c4.89941 4.60059 12.5 4.2998 17 -0.5l43.5 -46.3994c4.69922 -4.90039 4.2998 -12.7002 -0.800781 -17.2002l-90.5996 -79.7002l90.5996 -79.7002 c5.10059 -4.5 5.40039 -12.2998 0.800781 -17.2002zM492.1 48.0996c-4.89941 -4.5 -12.5 -4.2998 -17 0.600586l-43.5 46.3994c-4.69922 4.90039 -4.2998 12.7002 0.800781 17.2002l90.5996 79.7002l-90.5996 79.7998c-5.10059 4.5 -5.40039 12.2998 -0.800781 17.2002 l43.5 46.4004c4.60059 4.7998 12.2002 5 17 0.5l144.101 -135.2c5.09961 -4.7002 5.09961 -12.7998 0 -17.5z"
end
end
end
end

View file

@ -1,4 +1,5 @@
require 'phlex'
require_relative 'icons'
module Pressa
module Views
@ -82,8 +83,6 @@ module Pressa
meta(name: 'msapplication-config', content: site.url_for('/images/browserconfig.xml'))
meta(name: 'theme-color', content: '#121212')
meta(name: 'viewport', content: 'width=device-width, initial-scale=1.0, viewport-fit=cover')
link(rel: 'dns-prefetch', href: 'https://use.typekit.net')
link(rel: 'dns-prefetch', href: 'https://netdna.bootstrapcdn.com')
link(rel: 'dns-prefetch', href: 'https://gist.github.com')
all_styles.each do |style|
@ -140,18 +139,18 @@ module Pressa
nav(class: 'remote') do
ul do
li(class: 'mastodon') do
a(rel: 'me', href: 'https://techhub.social/@sjs') do
i(class: 'fab fa-mastodon')
a(rel: 'me', 'aria-label': 'Mastodon', href: 'https://techhub.social/@sjs') do
raw(Icons.mastodon)
end
end
li(class: 'github') do
a(href: 'https://github.com/samsonjs') do
i(class: 'fab fa-github')
a('aria-label': 'GitHub', href: 'https://github.com/samsonjs') do
raw(Icons.github)
end
end
li(class: 'rss') do
a(href: site.url_for('/feed.xml')) do
i(class: 'fa fa-rss')
a('aria-label': 'RSS', href: site.url_for('/feed.xml')) do
raw(Icons.rss)
end
end
end
@ -182,9 +181,6 @@ module Pressa
attrs[:defer] = true if scr.defer
script(**attrs)
end
script(src: 'https://use.typekit.net/tcm1whv.js', crossorigin: 'anonymous')
script { plain 'try{Typekit.load({ async: true });}catch(e){}' }
end
def script_src(src)

View file

@ -1,4 +1,5 @@
require 'phlex'
require_relative 'icons'
class String
include Phlex::SGML::SafeObject
@ -32,7 +33,7 @@ module Pressa
div(class: 'row clearfix') do
p(class: 'fin') do
i(class: 'fa fa-code')
raw(Icons.code)
end
end
end

View file

@ -1,4 +1,5 @@
require 'phlex'
require_relative 'icons'
module Pressa
module Views
@ -43,7 +44,7 @@ module Pressa
div(class: 'row clearfix') do
p(class: 'fin') do
i(class: 'fa fa-code')
raw(Icons.code)
end
end

View file

@ -1,4 +1,5 @@
require 'phlex'
require_relative 'icons'
module Pressa
module Views
@ -24,7 +25,7 @@ module Pressa
div(class: 'row clearfix') do
p(class: 'fin') do
i(class: 'fa fa-code')
raw(Icons.code)
end
end
end

View file

@ -28,8 +28,8 @@ RSpec.describe Pressa::Posts::PostMetadata do
expect(metadata.date.day).to eq(5)
expect(metadata.link).to eq('https://example.net/external')
expect(metadata.tags).to eq(['Ruby', 'Testing'])
expect(metadata.scripts.map(&:src)).to eq(['highlight.js'])
expect(metadata.styles.map(&:href)).to eq(['code.css'])
expect(metadata.scripts.map(&:src)).to eq(['js/highlight.js'])
expect(metadata.styles.map(&:href)).to eq(['css/code.css'])
end
it 'raises error when required fields are missing' do

View file

@ -46,7 +46,7 @@ RSpec.describe Pressa::Utils::FrontmatterConverter do
output = described_class.convert_content(input)
expect(output).to include("Title: \"Zelda Tones for iOS\"")
expect(output).to include("Tags:\n - zelda\n - nintendo\n - pacman\n - ringtones\n - tones\n - ios")
expect(output).to include("Tags: [zelda, nintendo, pacman, ringtones, tones, ios]")
expect(output).to include("<h2>Zelda</h2>")
end
@ -67,7 +67,7 @@ RSpec.describe Pressa::Utils::FrontmatterConverter do
output = described_class.convert_content(input)
expect(output).to include("Link: http://en.wikipedia.org/wiki/Buffalo_buffalo_buffalo_buffalo_buffalo_buffalo_buffalo_buffalo")
expect(output).to include("Tags:\n - amusement\n - buffalo")
expect(output).to include("Tags: [amusement, buffalo]")
end
it 'converts front-matter with Scripts and Styles' do
@ -169,7 +169,7 @@ RSpec.describe Pressa::Utils::FrontmatterConverter do
expect(yaml).to include("Author: Sami Samhuri")
expect(yaml).to include("Date: \"11th November, 2025\"")
expect(yaml).to include("Timestamp: 2025-11-11T14:00:00-08:00")
expect(yaml).to include("Tags:\n - Ruby\n - Testing")
expect(yaml).to include("Tags: [Ruby, Testing]")
expect(yaml).to include("Link: https://example.net")
expect(yaml).to include("Scripts: app.js")
expect(yaml).to include("Styles: style.css")