Merge branch 'standalone_develop' into pre_trustie_server

This commit is contained in:
yystopf 2021-12-10 09:20:04 +08:00
commit b816b6a449
7 changed files with 57 additions and 21 deletions

View File

@ -16,13 +16,13 @@ class ProjectsController < ApplicationController
menu.append(menu_hash_by_name("home")) menu.append(menu_hash_by_name("home"))
menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code") menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code")
menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues") menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues")
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") && @project.forge?
menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") && @project.forge?
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") && @project.forge?
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions") menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources") menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources") && @project.forge?
menu.append(menu_hash_by_name("activity")) menu.append(menu_hash_by_name("activity"))
menu.append(menu_hash_by_name("settings")) if current_user.admin? || @project.manager?(current_user) menu.append(menu_hash_by_name("settings")) if (current_user.admin? || @project.manager?(current_user)) && @project.forge?
render json: menu render json: menu
end end

View File

@ -71,16 +71,32 @@ class RepositoriesController < ApplicationController
logger.info "######### sub_entries: #{@sub_entries}" logger.info "######### sub_entries: #{@sub_entries}"
return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1
tmp_entries = [{ tmp_entries = {
"content" => @sub_entries['data']['content'], "content" => @sub_entries['data']['content'],
"type" => "blob" "type" => "blob"
}] }
@sub_entries = { @sub_entries = {
"trees"=>tmp_entries, "trees"=>tmp_entries,
"commits" => [{}] "commits" => [{}]
} }
else else
@sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) begin
@sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri})
if @sub_entries.blank? || @sub_entries['status'].to_i === -1
@sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri)
return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1
tmp_entries = {
"content" => @sub_entries['data']['content'],
"type" => "blob"
}
@sub_entries = {
"trees"=>tmp_entries,
"commits" => [{}]
}
end
rescue
return render_error('该文件暂未开放,敬请期待.')
end
end end
else else
@path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/" @path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
@ -117,8 +133,7 @@ class RepositoriesController < ApplicationController
def commit def commit
@sha = params[:sha] @sha = params[:sha]
if @project.educoder? if @project.educoder?
@commit = {} return render_error('暂未开放,敬请期待.')
@commit_diff ={}
else else
@commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token) @commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token)
@commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token, {diff: true}) @commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token, {diff: true})

View File

@ -26,8 +26,12 @@ module TagChosenHelper
end end
def render_branches(project) def render_branches(project)
branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier) if project.educoder?
branches.collect{|i| i["name"] if i.is_a?(Hash)} return ['master']
else
branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier)
branches.collect{|i| i["name"] if i.is_a?(Hash)}
end
end end
def render_cache_trackers def render_cache_trackers

View File

@ -7,11 +7,22 @@ if @project.educoder?
json.timestamp 0 json.timestamp 0
json.time_from_now commit[0]['time'] json.time_from_now commit[0]['time']
end end
json.author do if commit[0]['author'].present?
{} json.author do
# json.partial! '/projects/author', user: render_commit_author(commit['author']) json.id nil
end json.login commit[0]['author']['username']
json.committer {} json.name commit[0]['author']['username']
json.type nil
json.image_url commit[0]['author']['image_url']
end
json.committer do
json.id nil
json.login commit[0]['author']['username']
json.name commit[0]['author']['username']
json.type nil
json.image_url commit[0]['author']['image_url']
end
end
end end
if @project.forge? if @project.forge?

View File

@ -32,6 +32,8 @@ end
if @project.educoder? if @project.educoder?
file_path = params[:filepath].present? ? [params[:filepath], entry['name']].join('/') : entry['name'] file_path = params[:filepath].present? ? [params[:filepath], entry['name']].join('/') : entry['name']
file_type = File.extname(entry['name'].to_s)[1..-1]
image_type = image_type?(file_type)
json.name entry['name'] json.name entry['name']
json.sha nil json.sha nil
@ -42,7 +44,7 @@ if @project.educoder?
json.target nil json.target nil
json.download_url nil json.download_url nil
json.direct_download false json.direct_download false
json.image_type false json.image_type image_type
json.is_readme_file false json.is_readme_file false
json.commit do json.commit do
json.message entry['title'] json.message entry['title']

View File

@ -12,7 +12,7 @@ if @hash_commit.blank? || @project.educoder? #如果有状态值,则表示
json.type nil json.type nil
json.image_url commit['author']['image_url'] json.image_url commit['author']['image_url']
end end
json.commiter do json.committer do
json.id nil json.id nil
json.login commit['author']['username'] json.login commit['author']['username']
json.name commit['author']['username'] json.name commit['author']['username']

View File

@ -24,8 +24,12 @@ if @project.educoder?
end end
end end
json.entries do json.entries do
json.array! @sub_entries['trees'] do |entry| if @sub_entries['trees'].is_a?(Array)
json.partial! 'repositories/simple_entry', locals: { entry: entry } json.array! @sub_entries['trees'] do |entry|
json.partial! 'repositories/simple_entry', locals: { entry: entry }
end
elsif @sub_entries['trees'].is_a?(Hash)
json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries['trees'] }
end end
end end
end end