Skip to content

Instantly share code, notes, and snippets.

@siraskalot
Created August 15, 2012 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siraskalot/3355895 to your computer and use it in GitHub Desktop.
Save siraskalot/3355895 to your computer and use it in GitHub Desktop.
require 'sinatra'
def convert_title_to_filename string
string.gsub(' ','_').downcase + ".md"
end
get '/' do
erb :index
end
post '/' do
file_name = convert_title_to_filename(params[:post_title])
File.open(file_name, 'w') do |f|
f.write params[:post_title]
f.write "\n---\n\n"
f.write params[:post_text]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment