Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Last active December 22, 2015 03:59
Show Gist options
  • Save sawanoboly/6413893 to your computer and use it in GitHub Desktop.
Save sawanoboly/6413893 to your computer and use it in GitHub Desktop.
Sphinxで作成したドキュメントをherokuでホスティング、Continuous Documentationなススメ(Basic認証付き) ref: http://qiita.com/sawanoboly/items/be1dbc9f19e93e4b62cf
require 'sinatra'
set :public_folder, File.dirname(__FILE__) + '/build/html'
get '/' do
redirect "/index.html", 301
end
run Sinatra::Application
require 'sinatra'
set :public_folder, File.dirname(__FILE__) + '/build/html'
## >>>追記部分
use Rack::Auth::Basic do |username, password|
username == 'hogehoge' && password == 'mogemoge'
end
before '*' do
# authenticate!
end
## <<<<追記部分
get '/' do
redirect "/index.html", 301
end
get '/:dir' do ## 修正2,3
unless request.path_info.end_with?('.ico')
redirect "#{request.path_info}.html", 301
end
end
run Sinatra::Application
$ git push heroku
Counting objects: 38, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (37/37), done.
Writing objects: 100% (37/37), 148.40 KiB, done.
Total 37 (delta 4), reused 0 (delta 0)
-----> Ruby/Rack app detected
-----> Using Ruby version: ruby-2.0.0
-- snip --
-----> Compiled slug size: 26.2MB
-----> Launching... done, v4
web: bundle exec rackup -p $PORT
source "https://rubygems.org"
gem "sinatra"
gem "rake"
gem "thin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment