forked from Gitlink/forgeplus
ADD zip、tar url with entries api
This commit is contained in:
parent
acc0bfb7aa
commit
731ddd6fce
|
@ -6,7 +6,8 @@ class RepositoriesController < ApplicationController
|
||||||
before_action :authorizate!, except: [:sync_mirror, :tags, :commit]
|
before_action :authorizate!, except: [:sync_mirror, :tags, :commit]
|
||||||
before_action :find_repository_by_id, only: %i[commit sync_mirror tags]
|
before_action :find_repository_by_id, only: %i[commit sync_mirror tags]
|
||||||
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
||||||
before_action :get_latest_commit, only: %i[entries sub_entries]
|
before_action :get_ref, only: %i[entries sub_entries]
|
||||||
|
before_action :get_latest_commit, :get_ref, only: %i[entries sub_entries]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@branches_count = Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call&.size
|
@branches_count = Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call&.size
|
||||||
|
@ -27,13 +28,13 @@ class RepositoriesController < ApplicationController
|
||||||
def entries
|
def entries
|
||||||
@project.increment!(:visits)
|
@project.increment!(:visits)
|
||||||
|
|
||||||
@entries = Gitea::Repository::Entries::ListService.new(@project.owner, @project.identifier, ref: get_ref).call
|
@entries = Gitea::Repository::Entries::ListService.new(@project.owner, @project.identifier, ref: @ref).call
|
||||||
@entries = @entries.sort_by{ |hash| hash['type'] }
|
@entries = @entries.sort_by{ |hash| hash['type'] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def sub_entries
|
def sub_entries
|
||||||
file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip))
|
file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip))
|
||||||
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: get_ref)
|
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: @ref)
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
@sub_entries = interactor.result
|
@sub_entries = interactor.result
|
||||||
@sub_entries = [] << @sub_entries unless @sub_entries.is_a? Array
|
@sub_entries = [] << @sub_entries unless @sub_entries.is_a? Array
|
||||||
|
@ -137,7 +138,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_ref
|
def get_ref
|
||||||
params[:ref] || "master"
|
@ref = params[:ref] || "master"
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_params
|
def content_params
|
||||||
|
|
|
@ -5,6 +5,8 @@ json.last_commit do
|
||||||
json.nil!
|
json.nil!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
json.zip_url render_zip_url(@project, @ref)
|
||||||
|
json.tar_url render_tar_url(@project, @ref)
|
||||||
json.entries do
|
json.entries do
|
||||||
json.array! @entries do |entry|
|
json.array! @entries do |entry|
|
||||||
json.name entry['name']
|
json.name entry['name']
|
||||||
|
|
Loading…
Reference in New Issue