Added markdown support
This commit is contained in:
parent
e1c2687cdf
commit
4fd0725169
2 changed files with 9 additions and 2 deletions
1
Gemfile
1
Gemfile
|
@ -2,3 +2,4 @@ gem 'erb'
|
|||
gem 'rackup'
|
||||
|
||||
gem 'nokogiri'
|
||||
gem 'redcarpet'
|
||||
|
|
8
app.rb
8
app.rb
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue