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 'rackup'
|
||||||
|
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
|
gem 'redcarpet'
|
||||||
|
|
10
app.rb
10
app.rb
|
@ -2,6 +2,7 @@
|
||||||
require 'sinatra'
|
require 'sinatra'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
|
require 'redcarpet'
|
||||||
|
|
||||||
$root = "/home/pranshu/Documents/proj/perc/test"
|
$root = "/home/pranshu/Documents/proj/perc/test"
|
||||||
Dir.chdir $root;
|
Dir.chdir $root;
|
||||||
|
@ -78,6 +79,7 @@ $sidebar = Sidebar.new
|
||||||
|
|
||||||
class Perc < Sinatra::Application
|
class Perc < Sinatra::Application
|
||||||
set :views, "."
|
set :views, "."
|
||||||
|
set :markdown, :layout_engine => :erb
|
||||||
# @sidebar = Sidebar.new
|
# @sidebar = Sidebar.new
|
||||||
|
|
||||||
get "/" do
|
get "/" do
|
||||||
|
@ -85,8 +87,12 @@ class Perc < Sinatra::Application
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/*.*" do |path, ext|
|
get "/*.*" do |path, ext|
|
||||||
erb path.to_sym
|
if ext == "md"
|
||||||
# path + "<br>" + ext
|
md = markdown File.read(path + ".md")
|
||||||
|
|
||||||
|
else
|
||||||
|
erb path.to_sym
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
helpers do
|
helpers do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue