Merge branch 'develop' into standalone_develop
This commit is contained in:
commit
3888e8c06a
|
@ -31,14 +31,17 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
def get_file
|
||||
normal_status(-1, "参数缺失") if params[:download_url].blank?
|
||||
url = base_url.starts_with?("https:") ? URI.encode(params[:download_url].to_s.gsub("http:", "https:")) : URI.encode(params[:download_url].to_s)
|
||||
url = base_url.starts_with?("https:") ? params[:download_url].to_s.gsub("http:", "https:") : params[:download_url].to_s
|
||||
if url.starts_with?(base_url) && !url.starts_with?("#{base_url}/repo")
|
||||
domain = GiteaService.gitea_config[:domain]
|
||||
api_url = GiteaService.gitea_config[:base_url]
|
||||
url = ("/repos"+url.split(base_url + "/api")[1]).gsub('?filepath=', '/').gsub('&', '?')
|
||||
request_url = [domain, api_url, url, "?ref=#{params[:ref]}&access_token=#{User.where(admin: true).take&.gitea_token}"].join
|
||||
url = ("/repos"+url.split(base_url + "/api")[1])
|
||||
filepath, ref = url.split("/")[-1].split("?")
|
||||
url.gsub!(url.split("/")[-1], '')
|
||||
puts filepath
|
||||
request_url = [domain, api_url, url, CGI.escape(filepath), "?ref=#{CGI.escape(ref.split('ref=')[1])}&access_token=#{User.where(admin: true).take&.gitea_token}"].join
|
||||
response = Faraday.get(request_url)
|
||||
filename = url.to_s.split("/").pop()
|
||||
filename = filepath
|
||||
else
|
||||
response = Faraday.get(url)
|
||||
filename = params[:download_url].to_s.split("/").pop()
|
||||
|
|
|
@ -273,7 +273,7 @@ class RepositoriesController < ApplicationController
|
|||
domain = GiteaService.gitea_config[:domain]
|
||||
api_url = GiteaService.gitea_config[:base_url]
|
||||
|
||||
url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{Addressable::URI.escape(params[:filepath])}?ref=#{Addressable::URI.escape(params[:ref])}"
|
||||
url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{CGI.escape(params[:filepath])}?ref=#{CGI.escape(params[:ref])}"
|
||||
file_path = [domain, api_url, url].join
|
||||
file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("&")
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ module ProjectsHelper
|
|||
end
|
||||
|
||||
def render_download_file_url(owner, repository, filepath, ref)
|
||||
[base_url, "/api/#{owner&.login}/#{repository.identifier}/raw?filepath=#{filepath}&ref=#{ref}"].join
|
||||
[base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{CGI.escape(filepath)}?ref=#{CGI.escape(ref)}"].join
|
||||
end
|
||||
|
||||
def render_http_url(project)
|
||||
|
|
|
@ -3,7 +3,7 @@ json.type webhook["type"]
|
|||
json.content_type webhook['config']['content_type']
|
||||
json.http_method webhook['config']['http_method']
|
||||
json.url webhook['config']['url']
|
||||
json.events webhook["events"]
|
||||
json.events webhook["events"].collect{|i| %w(pull_request issues).include?(i) ? i + "_only" : i}
|
||||
json.active webhook['active']
|
||||
json.branch_filter webhook['branch_filter']
|
||||
json.created_at format_time(webhook['created_at'].to_time)
|
|
@ -2,6 +2,6 @@ json.id @webhook["id"]
|
|||
json.type @webhook["type"]
|
||||
json.content_type @webhook["config"]["content_type"]
|
||||
json.url @webhook["config"]["url"]
|
||||
json.events @webhook["events"]
|
||||
json.events @webhook["events"].collect{|i| %w(pull_request issues).include?(i) ? i + "_only" : i}
|
||||
json.active @webhook["active"]
|
||||
json.create_time @webhook["created_at"].to_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
@ -17,14 +17,15 @@ if @project.forge?
|
|||
json.content (direct_download || image_type || is_dir) ? nil : decode64_content(entry, @owner, @repository, @ref, @path)
|
||||
json.target entry['target']
|
||||
|
||||
download_url =
|
||||
if image_type
|
||||
dir_path = [@owner.login, @repository.identifier, "raw/branch", @ref].join('/')
|
||||
is_dir ? "" : render_download_image_url(dir_path, entry['path'], decode64_content(entry, @owner, @repository, @ref))
|
||||
else
|
||||
# entry['download_url']
|
||||
is_dir ? "" : render_download_file_url(@owner, @repository, entry['path'].to_s, @ref)
|
||||
end
|
||||
download_url = is_dir ? "" : render_download_file_url(@owner, @repository, entry['path'].to_s, @ref)
|
||||
# if image_type
|
||||
# # dir_path = [@owner.login, @repository.identifier, "raw/branch", @ref].join('/')
|
||||
# # is_dir ? "" : render_download_image_url(dir_path, entry['path'], decode64_content(entry, @owner, @repository, @ref))
|
||||
# is_dir ? "" : render_gitea_raw_url(entry['download_url'])
|
||||
# else
|
||||
# # entry['download_url']
|
||||
# is_dir ? "" : render_download_file_url(@owner, @repository, entry['path'].to_s, @ref)
|
||||
# end
|
||||
json.download_url download_url
|
||||
|
||||
json.direct_download direct_download
|
||||
|
|
|
@ -534,7 +534,7 @@ Rails.application.routes.draw do
|
|||
get 'readme'
|
||||
get 'languages'
|
||||
get 'archive/:archive', to: 'repositories#archive', as: "archive", constraints: { archive: /.+/, format: /(zip|gzip)/ }
|
||||
get 'raw', to: 'repositories#raw', as: "raw"
|
||||
get 'raw/*filepath', to: 'repositories#raw', as: "raw", constraints: { filepath: /.+/}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue