Browse Source

fixed readme路径转换问题处理

pull/348/head
xxq250 1 year ago
parent
commit
33138aed80
2 changed files with 4 additions and 2 deletions
  1. +3
    -1
      app/helpers/repositories_helper.rb
  2. +1
    -1
      app/models/commit_log.rb

+ 3
- 1
app/helpers/repositories_helper.rb View File

@@ -161,6 +161,7 @@ module RepositoriesHelper
s_content = s_content.starts_with?("/") ? s_content[1..-1] : s_content[0..-1]
s_content = File.expand_path(s_content, file_path)
s_content = s_content.split("#{Rails.root}/")[1]
next if s_content.blank?
# content = content.gsub(s[0], "/#{s_content}")
join_xxx = s_content.include?("?") ? "&" : "?"
s_content = [base_url, "/api/#{owner&.login}/#{repo.identifier}/raw/#{s_content}#{join_xxx}ref=#{ref}"].join
@@ -190,6 +191,7 @@ module RepositoriesHelper
path = [owner&.login, repo&.identifier, 'tree', ref, file_path].join("/")
s_content = File.expand_path(s_content, path)
s_content = s_content.split("#{Rails.root}")[1]
next if s_content.blank?
case k.to_s
when 'ss_src'
content = content.gsub("src=\"#{s[0]}\"", "src=\"/#{s_content}\"")
@@ -202,7 +204,7 @@ module RepositoriesHelper
when 'ss_href_1'
content = content.gsub("href=\'#{s[0]}\'", "href=\'#{s_content}\'")
else
content = content.gsub("(#{s[0]})", "(/#{s_content})")
content = content.gsub("(#{s[0]})", "(#{s_content})")
end
end
rescue


+ 1
- 1
app/models/commit_log.rb View File

@@ -24,7 +24,7 @@
class CommitLog < ApplicationRecord
belongs_to :user
belongs_to :project
belongs_to :repository
# belongs_to :repository

has_many :project_trends, as: :trend, dependent: :destroy



Loading…
Cancel
Save