atproto-based blog in ruby

add more formatting options

+2
Gemfile
··· 11 11 gem "kramdown", "~> 2.5" 12 12 13 13 gem "sinatra-contrib", "~> 4.1" 14 + 15 + gem "markaby", "~> 0.9.4"
+4
Gemfile.lock
··· 2 2 remote: https://rubygems.org/ 3 3 specs: 4 4 base64 (0.2.0) 5 + builder (3.3.0) 5 6 ffi (1.17.1-arm64-darwin) 6 7 haml (6.3.0) 7 8 temple (>= 0.8.2) ··· 10 11 kramdown (2.5.1) 11 12 rexml (>= 3.3.9) 12 13 logger (1.7.0) 14 + markaby (0.9.4) 15 + builder 13 16 minisky (0.5.0) 14 17 base64 (~> 0.1) 15 18 multi_json (1.15.0) ··· 56 59 DEPENDENCIES 57 60 haml 58 61 kramdown (~> 2.5) 62 + markaby (~> 0.9.4) 59 63 minisky 60 64 puma (~> 6.6) 61 65 rackup (~> 2.2)
+3
main.rb
··· 2 2 require "sinatra/contrib" 3 3 4 4 require "haml" 5 + require "markaby/kernel_method" 5 6 require "kramdown" 6 7 require_relative "extra/helpers" 7 8 ENV["LUA_LIB"] = abs_path("./liblua.dylib") ··· 16 17 data = MainBlog.post_list(page) 17 18 cursor = data[:cursor] 18 19 posts = data[:records] 20 + @title = MainBlog.home_rec["title"] 19 21 haml :index, locals: { cursor: cursor, posts: posts, backbutton: backbutton } 20 22 end 21 23 22 24 get "/post/:post_id" do 23 25 post = MainBlog.get_post(params[:post_id]) 26 + @title = post["value"]["title"] + " | " + MainBlog.home_rec["title"] 24 27 haml :post, locals: { post_content: post["value"] } 25 28 end 26 29
+9 -1
views/block.haml
··· 4 4 - @text = section["text"] 5 5 - if @text.empty? 6 6 - else 7 - != haml :paragraph 7 + %p<>!= haml :paragraph 8 + - when "list" 9 + %ol 10 + - section["text"].each do |elem| 11 + - @text = elem 12 + %li<>!= haml :paragraph 13 + - when "code" 14 + %pre 15 + %code<>= section["text"] 8 16 - when "heading" 9 17 %h3>= section["text"] 10 18 - when "subheading"
-5
views/index.haml
··· 1 - %html 2 - %head 3 - %link{ :rel => "stylesheet", :href => "/style.css" } 4 - %title= MainBlog.home_rec["title"] 5 - 6 1 %h2= MainBlog.home_rec["title"] 7 2 8 3 - @content = MainBlog.home_rec["content"]
+5
views/layout.haml
··· 1 + %html 2 + %head 3 + %link{ :rel => "stylesheet", :href => "/style.css" } 4 + %title= @title 5 + 1 6 != yield 2 7 3 8 %br
-5
views/post.haml
··· 1 - %html 2 - %head 3 - %link{ :rel => "stylesheet", :href => "/style.css" } 4 - %title= post_content["title"] + " | " + MainBlog.home_rec["title"] 5 - 6 1 %h1= post_content["title"] 7 2 %strong= post_content["createdAt"] 8 3 - @content = post_content["content"]