|
- if @project.forge?
- is_dir = @sub_entries.is_a?(Array)
- file_name = entry['name']
- file_type = file_name.starts_with?('.') ? file_name[1..-1] : File.extname(file_name.to_s)[1..-1]
- # direct_download = %w(makefile dockerfile readme).exclude?(file_name.to_s.downcase) && download_type(file_type)
- direct_download = entry['is_text_file'] == true ? false : true
- image_type = image_type?(file_type)
- json.name file_name
- json.sha entry['sha']
- json.path entry['path']
- json.type entry['type']
- json.submodule_git_url entry['submodule_git_url'].nil? ? nil : repo_git_submodule_url(@owner, @repository, entry['submodule_git_url'])
- json.size entry['size']
- is_readme = is_readme?(entry['type'], entry['name'])
- if is_readme
- json.replace_content readme_decode64_content(entry, @owner, @repository, @ref, @path)
- end
- json.content (direct_download || image_type || is_dir) ? nil : decode64_content(entry, @owner, @repository, @ref, @path)
- json.target entry['target']
-
- 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
- json.image_type image_type
- json.is_readme_file is_readme
- json.commit do
- json.partial! 'last_commit', latest_commit: entry['latest_commit']
- end
- end
-
- if @project.educoder?
- 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.sha nil
- json.path file_path
- json.type entry['type'] === 'blob'? 'file' : 'dir'
- json.size 0
- json.content entry['content']
- json.target nil
- json.download_url nil
- json.direct_download false
- json.image_type image_type
- json.is_readme_file false
- json.commit do
- json.message entry['title']
- json.time_from_now entry['time']
- json.sha nil
- json.created_at_unix nil
- json.created_at nil
- end
- end
|