./lib/dolt/sinatra/multi_repo_browser.rb in dolt-0.1.1 vs ./lib/dolt/sinatra/multi_repo_browser.rb in dolt-0.2.0
- old
+ new
@@ -14,32 +14,59 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#++
require "dolt/sinatra/base"
+require "dolt/view/single_repository"
+require "dolt/view/blob"
+require "dolt/view/tree"
module Dolt
module Sinatra
class MultiRepoBrowser < Dolt::Sinatra::Base
+ include Dolt::View::SingleRepository
+ include Dolt::View::Blob
+ include Dolt::View::Tree
+
aget "/" do
response["Content-Type"] = "text/html"
- body("<h1>Welcome to Dolt</h1>")
+ body(renderer.render(:index, { :repositories => actions.repositories }))
end
aget "/*/tree/*:*" do
- tree(params[:splat][0], params[:splat][2], params[:splat][1])
+ repo, ref, path = params[:splat]
+ tree(repo, ref, path)
end
aget "/*/tree/*" do
force_ref(params[:splat], "tree", "master")
end
aget "/*/blob/*:*" do
- blob(params[:splat][0], params[:splat][2], params[:splat][1])
+ repo, ref, path = params[:splat]
+ blob(repo, ref, path)
end
aget "/*/blob/*" do
force_ref(params[:splat], "blob", "master")
+ end
+
+ aget "/*/raw/*:*" do
+ repo, ref, path = params[:splat]
+ raw(repo, ref, path)
+ end
+
+ aget "/*/raw/*" do
+ force_ref(params[:splat], "raw", "master")
+ end
+
+ aget "/*/blame/*:*" do
+ repo, ref, path = params[:splat]
+ blame(repo, ref, path)
+ end
+
+ aget "/*/blame/*" do
+ force_ref(params[:splat], "blame", "master")
end
private
def force_ref(args, action, ref)
redirect(args.shift + "/#{action}/#{ref}:" + args.join)