Sha256: 544e14355f1a7974b69ea8e8085f6ab6f730622630d7aedc001a6f193fe61ad8

Contents?: true

Size: 1.95 KB

Versions: 10

Compression:

Stored size: 1.95 KB

Contents

#!/usr/bin/env ruby
require "libdolt"
require "tiltout"
require "thin"
require "sinatra/base"

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)
    dir = File.expand_path(dir)
    resolver = Dolt::DiskRepoResolver.new(File.dirname(dir))
    actions = Dolt::RepoActions.new(resolver)
    view.helper(Dolt::View::SingleRepository)
    require "dolt/sinatra/single_repo_browser"
    Dolt::Sinatra::SingleRepoBrowser.new(File.basename(dir), actions, view)
  else
    resolver = Dolt::DiskRepoResolver.new(dir)
    actions = Dolt::RepoActions.new(resolver)
    view.helper(Dolt::View::MultiRepository)
    require "dolt/sinatra/multi_repo_browser"
    Dolt::Sinatra::MultiRepoBrowser.new(actions, view)
  end
end

base = File.join(File.dirname(__FILE__), "..")

view = Tiltout.new(Dolt.template_dir, {
  :cache => false,
  :layout => "layout"
})

view.helper(Dolt::View::Object)
view.helper(Dolt::View::Urls)
view.helper(Dolt::View::Blob)
view.helper(Dolt::View::Blame)
view.helper(Dolt::View::Breadcrumb)
view.helper(Dolt::View::Tree)
view.helper(Dolt::View::Commit)
view.helper(Dolt::View::Gravatar)
view.helper(Dolt::View::TabWidth)
view.helper(Dolt::View::BinaryBlobEmbedder)
view.helper(:tab_width => 4, :maxdepth => 3)

# Configure blob rendering module

# Attempt to syntax highlight every blob
# view.helper(Dolt::View::SyntaxHighlight)

# Attempt to render every blob as markup
# view.helper(Dolt::View::Markup)

# Render supported formats as markup, syntax highlight the rest
view.helper(Dolt::View::SmartBlobRenderer)

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

10 entries across 5 versions & 1 rubygems

Version Path
dolt-0.12.0 ./bin/dolt
dolt-0.12.0 bin/dolt
dolt-0.11.0 ./bin/dolt
dolt-0.11.0 bin/dolt
dolt-0.10.0 ./bin/dolt
dolt-0.10.0 bin/dolt
dolt-0.9.0 ./bin/dolt
dolt-0.9.0 bin/dolt
dolt-0.8.0 ./bin/dolt
dolt-0.8.0 bin/dolt