diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 2b35313dc..ce8de3bfb 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -47,9 +47,20 @@ class RepositoriesController < ApplicationController if @project.educoder? if params[:type] === 'file' @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) + logger.info "######### sub_entries: #{@sub_entries}" 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" => [{}] + } + else + @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) end - @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) else interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: @ref) if interactor.success? diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 625bdfecd..0516b76d8 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -30,7 +30,7 @@ module ProjectsHelper def json_response(project, user) # repo = project.repository - repo = Repository.select(:id).find_by(project: project) + repo = Repository.select(:id, :mirror_url).find_by(project: project) tmp_json = {} unless project.common? @@ -83,6 +83,6 @@ module ProjectsHelper end def render_avatar_url(owner) - [Rails.application.config_for(:configuration)['platform_url'], 'images', url_to_avatar(owner)].join('/') + ['images', url_to_avatar(owner)].join('/') end end diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 50001d4df..91b0e6301 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -27,7 +27,7 @@ if @project.educoder? json.path file_path json.type entry['type'] === 'blob'? 'file' : 'dir' json.size 0 - json.content nil + json.content entry['content'] json.target nil json.download_url nil json.direct_download false diff --git a/app/views/repositories/show.json.jbuilder b/app/views/repositories/show.json.jbuilder index 6993abad8..80e833ed4 100644 --- a/app/views/repositories/show.json.jbuilder +++ b/app/views/repositories/show.json.jbuilder @@ -47,4 +47,4 @@ if @result json.private @result['private'] end -json.partial! 'author' +json.partial! 'author', locals: { user: @project.owner }