Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions Bonobo.Git.Server/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
string guid_regex = @"[\da-z]{8}-[\da-z]{4}-[\da-z]{4}-[\da-z]{4}-[\da-z]{12}";

routes.MapRoute("SecureInfoRefs",
"{repositoryName}.git/info/refs",
new { controller = "Git", action = "SecureGetInfoRefs" },
Expand Down Expand Up @@ -37,65 +39,65 @@ public static void RegisterRoutes(RouteCollection routes)
new { action = "Create" });

routes.MapRoute("RepositoryTree",
"Repository/{id}/{encodedName}/Tree/{*encodedPath}",
"Repository/{id}/Tree/{encodedName}/{*encodedPath}",
new { controller = "Repository", action = "Tree" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryBlob",
"Repository/{id}/{encodedName}/Blob/{*encodedPath}",
new { controller = "Repository", action = "Blob" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryRaw",
"Repository/{id}/{encodedName}/Raw/{*encodedPath}",
new { controller = "Repository", action = "Raw" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryBlame",
"Repository/{id}/{encodedName}/Blame/{*encodedPath}",
new { controller = "Repository", action = "Blame" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryDownload",
"Repository/{id}/{encodedName}/Download/{*encodedPath}",
new { controller = "Repository", action = "Download" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryCommits",
"Repository/{id}/{encodedName}/Commits",
new { controller = "Repository", action = "Commits" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryCommit",
"Repository/{id}/{encodedName}/Commit/{commit}/",
"Repository/{id}/Commit/{commit}/",
new { controller = "Repository", action = "Commit" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("RepositoryHistory",
"Repository/{id}/{encodedName}/History/{*encodedPath}",
new { controller = "Repository", action = "History" },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("Repository",
"Repository/{id}/{action}/{reponame}",
new { controller = "Repository", action = "Detail", reponame = UrlParameter.Optional },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("Account",
"Account/{id}/{action}/{username}",
new { controller = "Account", action = "Detail", username = UrlParameter.Optional },
new { id = @"\d+" });
new { id = guid_regex });

routes.MapRoute("Team",
"Team/{id}/{action}/{teamname}",
new { controller = "Team", action = "Detail", teamname = UrlParameter.Optional },
new { id = @"\d+" });
new { id = guid_regex });


routes.MapRoute("Validation", "Validation/{action}", new { controller = "Validation", action = String.Empty });

routes.MapRoute("RepoCommits",
"Repository/Commits/{id}",
"Repository/{id}/Commits",
new { controller = "Repository", action = "Commits", id = string.Empty, page = 1 });

routes.MapRoute("Default",
Expand Down
8 changes: 4 additions & 4 deletions Bonobo.Git.Server/Views/Repository/Blame.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
@{
<div class="controls">
<span>@Model.LineCount lines | @FileDisplayHandler.GetFileSizeString(Model.FileSize)</span>
<a href="@Url.Action("Blob", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-code"></i> @Resources.Repository_Tree_Blob</a>
<a href="@Url.Action("History", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
<a href="@Url.RouteUrl("RepositoryBlob", new { id = ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-code"></i> @Resources.Repository_Tree_Blob</a>
<a href="@Url.RouteUrl("RepositoryHistory", new { id = ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
<a href="@Url.RouteUrl("RepositoryRaw", new { id = ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
<a href="@Url.RouteUrl("RepositoryRaw", new { id = ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
</div>
<div class="blame">
<table id="blame_table">
Expand Down
10 changes: 5 additions & 5 deletions Bonobo.Git.Server/Views/Repository/Blob.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
@{
<div class="controls">
<span>@(Model.IsText ? Model.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).Length + " lines |" : "") @FileDisplayHandler.GetFileSizeString(Model.Data.LongLength)</span>
<a href="@Url.Action("Blame", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-comments"></i> @Resources.Repository_Tree_Blame</a>
<a href="@Url.Action("History", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
<a href="@Url.RouteUrl("RepositoryBlame", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-comments"></i> @Resources.Repository_Tree_Blame</a>
<a href="@Url.RouteUrl("RepositoryHistory", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
<a href="@Url.RouteUrl("RepositoryRaw", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
<a href="@Url.RouteUrl("RepositoryRaw", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this isn't really fixing a bug - it's just renaming a bunch of actions to include the controller name within the action name - what was the motivation here?

}
@if (Model.IsImage)
{
<img class="fileImage" alt="@Model.Name" src="@Url.Action("Raw", new { encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })" />
<img class="fileImage" alt="@Model.Name" src="@Url.RouteUrl("RepositoryRaw", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })" />
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks - I'll commit this outside this PR while we get the rest sorted.

else if (Model.IsText && Model.IsMarkdown)
{
Expand Down