diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/blobs_controller.rb | 34 | ||||
-rw-r--r-- | app/controllers/commits_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/repositories_helper.rb | 4 | ||||
-rw-r--r-- | app/views/blobs/_menu.html.erb | 26 | ||||
-rw-r--r-- | app/views/blobs/history.html.erb | 29 | ||||
-rw-r--r-- | app/views/blobs/show.html.erb | 6 | ||||
-rw-r--r-- | app/views/commits/_log.html.erb | 3 |
7 files changed, 94 insertions, 10 deletions
diff --git a/app/controllers/blobs_controller.rb b/app/controllers/blobs_controller.rb index 41a76da..4766d0d 100644 --- a/app/controllers/blobs_controller.rb +++ b/app/controllers/blobs_controller.rb @@ -29,12 +29,12 @@ class BlobsController < ApplicationController @ref, @path = branch_and_path(params[:branch_and_path], @git) @commit = @git.commit(@ref) unless @commit - redirect_to project_repository_blob_path(@project, @repository, - branch_with_tree("HEAD", @path)) and return + redirect_to_head and return end if stale_conditional?(Digest::SHA1.hexdigest(@commit.id + params[:branch_and_path].join), @commit.committed_date.utc) @blob = @git.tree(@commit.tree.id, ["#{@path.join("/")}"]).contents.first + render_not_found and return unless @blob unless @blob.respond_to?(:data) # it's a tree redirect_to repo_owner_path(@repository, :project_repository_tree_path, @project, @repository, params[:branch_and_path]) @@ -42,7 +42,6 @@ class BlobsController < ApplicationController head = @git.get_head(@ref) || Grit::Head.new(@commit.id_abbrev, @commit) @root = Breadcrumb::Blob.new(:paths => @path, :head => head, :repository => @repository, :name => @blob.basename) - render_not_found and return unless @blob expires_in 10.minutes end end @@ -67,4 +66,33 @@ class BlobsController < ApplicationController end end + def history + @git = @repository.git + @ref, @path = branch_and_path(params[:branch_and_path], @git) + @commit = @git.commit(@ref) + unless @commit + redirect_to_head and return + end + @blob = @git.tree(@commit.tree.id, ["#{@path.join("/")}"]).contents.first + render_not_found and return unless @blob + unless @blob.respond_to?(:data) # it's a tree + redirect_to repo_owner_path(@repository, :project_repository_tree_path, + @project, @repository, params[:branch_and_path]) + end + + @root = Breadcrumb::Blob.new({ + :paths => @path, + :head => @git.get_head(@ref) || Grit::Head.new(@commit.id_abbrev, @commit), + :repository => @repository, + :name => @blob.basename + }) + @commits = @git.log(@ref, desplat_path(@path)) + expires_in 30.minutes + end + + protected + def redirect_to_head + redirect_to project_repository_blob_path(@project, @repository, + branch_with_tree("HEAD", @path)) + end end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index d610d77..7c71876 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -30,7 +30,7 @@ class CommitsController < ApplicationController @repository, @repository.head_candidate.name) and return end @git = @repository.git - @ref, _ = branch_and_path(params[:branch], @git) + @ref, @path = branch_and_path(params[:branch], @git) if h = @git.get_head(@ref) head = h else diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index fe974f3..23e2eea 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -53,6 +53,10 @@ module RepositoriesHelper repo_owner_path(@repository, :project_repository_raw_blob_path, @project, @repository, branch_with_tree(shaish, path)) end + def blob_history_path(shaish, path) + repo_owner_path(@repository, :project_repository_blob_history_path, @project, @repository, branch_with_tree(shaish, path)) + end + def namespaced_branch?(branchname) branchname.include?("/") end diff --git a/app/views/blobs/_menu.html.erb b/app/views/blobs/_menu.html.erb new file mode 100644 index 0000000..423f0f4 --- /dev/null +++ b/app/views/blobs/_menu.html.erb @@ -0,0 +1,26 @@ +<% +#-- +# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# 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/>. +#++ +%> + +<div class="page-meta"> + <ul class="page-actions"> + <li><%= link_to_unless_current t("views.blobs.show"), blob_path(@ref, current_path) -%></li> + <li><%= link_to_unless_current t("views.blobs.history"), blob_history_path(@ref, current_path) -%></li> + <li><%= link_to t("views.blobs.raw"), raw_blob_path(@ref, current_path) -%></li> + </ul> +</div>
\ No newline at end of file diff --git a/app/views/blobs/history.html.erb b/app/views/blobs/history.html.erb new file mode 100644 index 0000000..c30b11f --- /dev/null +++ b/app/views/blobs/history.html.erb @@ -0,0 +1,29 @@ +<% +#-- +# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# 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/>. +#++ +%> + +<% @page_title = t("views.blobs.page_title", :path => current_path.join("/"), :repo => @repository.name, :title => @project.title) -%> +<%= breadcrumbs_from(@root) -%> + +<h1><%= t("views.blobs.heading", :ref => h(desplat_path(@ref)), :path => h(desplat_path(@path))) -%></h1> + +<% cache([@project, @repository, :blob_history, @ref, @path], {:expires_in => 20.minutes}) do -%> + <%= render :partial => "commits/log", :locals => { :no_pagination => true } -%> +<% end -%> + +<%= render "menu" -%> diff --git a/app/views/blobs/show.html.erb b/app/views/blobs/show.html.erb index e47508a..ad45c56 100644 --- a/app/views/blobs/show.html.erb +++ b/app/views/blobs/show.html.erb @@ -69,8 +69,4 @@ </p> <% end -%> -<div class="page-meta"> - <ul class="page-actions"> - <li><%= link_to t("views.blobs.raw"), raw_blob_path(@ref, current_path) -%></li> - </ul> -</div>
\ No newline at end of file +<%= render "menu" -%> diff --git a/app/views/commits/_log.html.erb b/app/views/commits/_log.html.erb index 9ffc958..e5a8449 100644 --- a/app/views/commits/_log.html.erb +++ b/app/views/commits/_log.html.erb @@ -18,6 +18,7 @@ %> <% users_by_email = @repository.users_by_commits(@commits) %> +<% no_pagination ||= false -%> <ul class="events"> <% @commits.group_by{|c| c.committed_date.to_s(:human) }.each do |day, commits| -%> <li> @@ -47,4 +48,4 @@ </li> <% end -%> </ul> -<%= will_paginate @commits -%> +<%= will_paginate(@commits) unless no_pagination -%> |