atproto-based blog in ruby
1require "sinatra"
2require "sinatra/contrib"
3
4require "haml"
5require "markaby/kernel_method"
6require "kramdown"
7require_relative "extra/helpers"
8ENV["LUA_LIB"] = abs_path("./liblua.dylib")
9require_relative "app/env"
10require_relative "atproto/blog"
11
12MainBlog = AtBlog::Blog.new(AtBlog::Config)
13
14get "/" do
15 page = params[:page]
16 backbutton = page != nil
17 data = MainBlog.post_list(page)
18 cursor = data[:cursor]
19 posts = data[:records]
20 @title = MainBlog.home_rec["title"]
21 haml :index, locals: { cursor: cursor, posts: posts, backbutton: backbutton }
22end
23
24get "/post/:post_id" do
25 post = MainBlog.get_post(params[:post_id])
26 @title = post["value"]["title"] + " | " + MainBlog.home_rec["title"]
27 haml :post, locals: { post_content: post["value"] }
28end
29
30Sinatra::Application.run