neocities/app/tutorial.rb
2015-12-14 14:55:33 -08:00

45 lines
714 B
Ruby

def default_tutorial_html
<<-EOT.strip
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My web site</title>
</head>
<body>
Hello World!
</body>
</html>
EOT
end
get '/tutorials' do
erb :'tutorials'
end
get '/tutorial/?' do
require_login
erb :'tutorial/index'
end
get '/tutorial/:section/?' do
require_login
redirect "/tutorial/#{params[:section]}/1"
end
get '/tutorial/:section/:page/?' do
require_login
@page = params[:page]
not_found if @page.to_i == 0
not_found unless %w{html css js}.include?(params[:section])
@section = params[:section]
@title = "#{params[:section].upcase} Tutorial - #{@page}/10"
erb "tutorial/layout".to_sym
end