#!/usr/bin/env ruby $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') require 'rubygems' require 'bundler/setup' require 'sinatra_auth_github' require 'gollum/app' require 'stoor' require 'rack/null_logger' ENV['RACK_ENV'] ||= 'development' config = Stoor::Config.new(__FILE__, ENV['STOOR_RUNNING_VIA_CMD']) domain = config.env('DOMAIN') || 'localhost' secret = config.env('SECRET') || 'stoor' expire_after = (config.env('EXPIRE_AFTER') || '3600').to_i gollum_path = config.env('WIKI_PATH') || config.dirname config.dump_env config.log "gollum_path: #{gollum_path}" if message = config.repo_missing?(gollum_path) puts message run Proc.new { |env| [ 200, { 'Content-Type' => 'text/plain' }, [ message ] ] } else use Rack::Session::Cookie, :domain => domain, :key => 'rack.session', :secret => secret, :expire_after => expire_after use Rack::CommonLogger, config.access_logger use Stoor::Logger, config.log_stream, Logger::INFO scopes = [ 'user:email' ] scopes << 'user' if config.env('GITHUB_TEAM_ID') Stoor::GithubAuth.set :github_options, { scopes: scopes.join(','), client_id: config.env('GITHUB_CLIENT_ID'), secret: config.env('GITHUB_CLIENT_SECRET') } Stoor::GithubAuth.set :stoor_options, { github_team_id: config.env('GITHUB_TEAM_ID'), github_email_domain: config.env('GITHUB_EMAIL_DOMAIN') } use Stoor::GithubAuth use Stoor::GitConfig, gollum_path use Stoor::TransformContent, pass_condition: ->(request) { request.session['gollum.author'].nil? }, regexp: /(