samhuri.net/lib/pressa/views/post_view.rb
Sami Samhuri 007b1058b6
Migrate from Swift to Ruby (#33)
Replace the Swift site generator with a Ruby and Phlex implementation.
Loads site and projects from TOML, derive site metadata from posts.

Migrate from make to bake and add standardrb and code coverage tasks.

Update CI and docs to match the new workflow, and remove unused
assets/dependencies plus obsolete tooling.
2026-02-07 21:19:03 -08:00

46 lines
1,005 B
Ruby

require "phlex"
require "pressa/views/icons"
module Pressa
module Views
class PostView < Phlex::HTML
def initialize(post:, site:, article_class: nil)
@post = post
@site = site
@article_class = article_class
end
def view_template
article(**article_attributes) do
header do
h2 do
if @post.link_post?
a(href: @post.link) { "#{@post.title}" }
else
a(href: @post.path) { @post.title }
end
end
time { @post.formatted_date }
a(href: @post.path, class: "permalink") { "" }
end
raw(safe(@post.body))
end
div(class: "row clearfix") do
p(class: "fin") do
raw(safe(Icons.code))
end
end
end
private
def article_attributes
return {} unless @article_class
{class: @article_class}
end
end
end
end