diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-25 10:40:23 +0300 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 16:46:03 +0300 |
commit | eda001565c5afbf6e2eb9b8b5cf4fa9d6525ed71 (patch) | |
tree | 44eb6484077618fa444fb85d4e0e8e6a2914430f /app/controllers/projects/commits_controller.rb | |
parent | c4c44c6a1bb892dc17989cef3cc9b6c23fecb2c8 (diff) |
fetch gpg signature badges by ajax
Diffstat (limited to 'app/controllers/projects/commits_controller.rb')
-rw-r--r-- | app/controllers/projects/commits_controller.rb | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 37b5a6e9d48..2de9900d449 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -6,18 +6,9 @@ class Projects::CommitsController < Projects::ApplicationController before_action :require_non_empty_project before_action :assign_ref_vars before_action :authorize_download_code! + before_action :set_commits def show - @limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i - search = params[:search] - - @commits = - if search.present? - @repository.find_commits_by_message(search, @ref, @path, @limit, @offset) - else - @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) - end - @note_counts = project.notes.where(commit_id: @commits.map(&:id)) .group(:commit_id).count @@ -37,4 +28,33 @@ class Projects::CommitsController < Projects::ApplicationController end end end + + def signatures + respond_to do |format| + format.json do + render json: { + signatures: @commits.select(&:has_signature?).map do |commit| + { + commit_sha: commit.sha, + html: view_to_html_string('projects/commit/_signature', signature: commit.signature) + } + end + } + end + end + end + + private + + def set_commits + @limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i + search = params[:search] + + @commits = + if search.present? + @repository.find_commits_by_message(search, @ref, @path, @limit, @offset) + else + @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) + end + end end |