Sha256: d493569bd95c62a167ec2a24b5d35d7e2f12051fd226095ac9b9a5844dfdb8d7
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
#!/usr/bin/env ruby require "thin" require "sinatra/base" require "dolt/repo_actions" require "dolt/template_renderer" require "dolt/view" require "dolt/disk_repo_resolver" if ARGV.length == 0 puts("Dolt should be run with a directory as its sole argument") puts("The directory should either be a Git repository or a directory") puts("that holds Git repositories.") exit(1) end ### TODO: Extract this into a testable API def is_git_repo?(dir) File.exists?(File.join(dir, ".git")) end def create_app(dir, view) if is_git_repo?(dir) require "dolt/sinatra/single_repo_browser" dir = File.expand_path(dir) resolver = Dolt::DiskRepoResolver.new(File.dirname(dir)) actions = Dolt::RepoActions.new(resolver) Dolt::Sinatra::SingleRepoBrowser.new(File.basename(dir), actions, view) else resolver = Dolt::DiskRepoResolver.new(dir) actions = Dolt::RepoActions.new(resolver) require "dolt/sinatra/multi_repo_browser" Dolt::Sinatra::MultiRepoBrowser.new(actions, view) end end base = File.join(File.dirname(__FILE__), "..") template_root = File.join(base, "views") view = Dolt::TemplateRenderer.new(template_root, { :cache => false, :layout => "layout", :attributes => { :multi_repo_mode => !is_git_repo?(ARGV[0]) } }) view.helper(Dolt::View) Sinatra::Base.set(:public_folder, File.join(base, "vendor/ui")) server = create_app(ARGV[0], view) Thin::Server.start("0.0.0.0", 3000, server)
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dolt-0.1.1 | ./bin/dolt |
dolt-0.1.1 | bin/dolt |