merge from develop
This commit is contained in:
commit
c983df57ee
|
@ -213,5 +213,13 @@ module RepositoriesHelper
|
||||||
def tmp_dir
|
def tmp_dir
|
||||||
"repo"
|
"repo"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def repo_git_submodule_url(owner, repo, path)
|
||||||
|
unless (path.starts_with?('http://') || path.starts_with?('https://'))
|
||||||
|
path = File.expand_path(path, "#{base_url}/#{owner&.login}/#{repo&.identifier}")
|
||||||
|
path = path.split("#{Rails.root}/")[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
return path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,6 +39,15 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
collection
|
collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def main_collection
|
||||||
|
collection = Project.visible
|
||||||
|
# 增加私有组织中项目过滤
|
||||||
|
collection = collection.joins("left join organization_extensions on organization_extensions.organization_id = projects.user_id")
|
||||||
|
.where("organization_extensions.visibility is null or organization_extensions.visibility in (0,1)")
|
||||||
|
.where("projects.user_id > 0")
|
||||||
|
collection
|
||||||
|
end
|
||||||
|
|
||||||
def by_search(items)
|
def by_search(items)
|
||||||
@ids = Projects::ElasticsearchService.call(params[:search])
|
@ids = Projects::ElasticsearchService.call(params[:search])
|
||||||
items = items.where(platform: 'forge')
|
items = items.where(platform: 'forge')
|
||||||
|
@ -80,5 +89,14 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
relations
|
relations
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def by_recommend(items)
|
||||||
|
params[:recommend].to_s == "true" ? items.where(recommend: true) : items
|
||||||
|
end
|
||||||
|
|
||||||
|
def exclude_fork(items)
|
||||||
|
return items if params[:exclude_forked].blank?
|
||||||
|
params[:exclude_forked].to_s == "true" ? items.where("forked_from_project_id is null") : items.where("forked_from_project_id is not null")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,7 @@ if @project.forge?
|
||||||
json.sha entry['sha']
|
json.sha entry['sha']
|
||||||
json.path entry['path']
|
json.path entry['path']
|
||||||
json.type entry['type']
|
json.type entry['type']
|
||||||
|
json.submodule_git_url repo_git_submodule_url(@owner, @repository, entry['submodule_git_url'])
|
||||||
json.size entry['size']
|
json.size entry['size']
|
||||||
is_readme = is_readme?(entry['type'], entry['name'])
|
is_readme = is_readme?(entry['type'], entry['name'])
|
||||||
if is_readme
|
if is_readme
|
||||||
|
|
|
@ -51,6 +51,7 @@ if @project.forge?
|
||||||
json.path entry['path']
|
json.path entry['path']
|
||||||
json.sha entry['sha']
|
json.sha entry['sha']
|
||||||
json.type entry['type']
|
json.type entry['type']
|
||||||
|
json.submodule_git_url repo_git_submodule_url(@owner, @repository, entry['submodule_git_url'])
|
||||||
json.size entry['size']
|
json.size entry['size']
|
||||||
json.is_readme_file is_readme?(entry['type'], entry['name'])
|
json.is_readme_file is_readme?(entry['type'], entry['name'])
|
||||||
json.content decode64_content(entry, @owner, @repository, @ref, @path)
|
json.content decode64_content(entry, @owner, @repository, @ref, @path)
|
||||||
|
|
Loading…
Reference in New Issue