Added markdown support

This commit is contained in:
Pranshu Sharma 2025-05-31 14:57:44 +10:00
parent e1c2687cdf
commit 4fd0725169
2 changed files with 9 additions and 2 deletions

View file

@ -2,3 +2,4 @@ gem 'erb'
gem 'rackup'
gem 'nokogiri'
gem 'redcarpet'

8
app.rb
View file

@ -2,6 +2,7 @@
require 'sinatra'
require 'erb'
require 'nokogiri'
require 'redcarpet'
$root = "/home/pranshu/Documents/proj/perc/test"
Dir.chdir $root;
@ -78,6 +79,7 @@ $sidebar = Sidebar.new
class Perc < Sinatra::Application
set :views, "."
set :markdown, :layout_engine => :erb
# @sidebar = Sidebar.new
get "/" do
@ -85,8 +87,12 @@ class Perc < Sinatra::Application
end
get "/*.*" do |path, ext|
if ext == "md"
md = markdown File.read(path + ".md")
else
erb path.to_sym
# path + "<br>" + ext
end
end
helpers do