Skip to content

@andyhawthorne /main.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Completed blog file
require 'sinatra'
require 'find'
require 'rdiscount'
def get_files(path)
dir_list_array = Array.new
Find.find(path) do |f|
dir_list_array << File.basename(f, ".*") if !File.directory?(f)
end
return dir_list_array
end
helpers do
def formatter(page)
formatted = ""
formatted = page.gsub(/[-]/, ' ').capitalize
return formatted
end
end
get '/' do
@arr = get_files('./views/posts/')
erb :index
end
get '/view/:link' do
halt 404 unless File.exist?("views/posts/#{params[:link]}.md")
markdown :"posts/#{params[:link]}", :layout_engine => :erb
end
get '/about' do
#if you don't want to use Markdown for pages, do this:
#erb :"pages/about"
#Then create about.erb in views/pages
markdown :"pages/about", :layout_engine => :erb
end
not_found do
erb :missing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.