diff --git a/app/overrides/repositories/navigation.rb b/app/overrides/repositories/navigation.rb
index ac08134c0..acdcddd8c 100644
--- a/app/overrides/repositories/navigation.rb
+++ b/app/overrides/repositories/navigation.rb
@@ -5,3 +5,8 @@
insert_before: 'erb[loud]:contains("label_statistics")',
original: '88f120e99075ba3246901c6e970ca671d7166855',
text: '<%= call_hook(:view_repositories_navigation, repository: @repository) %>'
+
+module Repositories
+ module Navigation
+ end
+end
diff --git a/app/overrides/repositories/show.rb b/app/overrides/repositories/show.rb
index ab04680fe..6157c285f 100644
--- a/app/overrides/repositories/show.rb
+++ b/app/overrides/repositories/show.rb
@@ -11,3 +11,8 @@
insert_before: 'erb[silent]:contains("html_title")',
original: '2a0a09659d76066b896016c72527d479c69463ec',
partial: 'hooks/show_repositories_sidebar'
+
+module Repositories
+ module Show
+ end
+end
diff --git a/init.rb b/init.rb
index 36194c6e8..74bcffba6 100644
--- a/init.rb
+++ b/init.rb
@@ -1,6 +1,9 @@
# frozen_string_literal: true
require 'redmine'
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
+
require 'redmine_git_hosting'
Redmine::Plugin.register :redmine_git_hosting do
diff --git a/lib/hrack/lib/hrack/bundle.rb b/lib/hrack/bundle.rb
similarity index 92%
rename from lib/hrack/lib/hrack/bundle.rb
rename to lib/hrack/bundle.rb
index fa5ab570b..4534ef9ad 100644
--- a/lib/hrack/lib/hrack/bundle.rb
+++ b/lib/hrack/bundle.rb
@@ -2,7 +2,6 @@
require 'rack/builder'
require 'rack/parser'
-require 'hrack/server'
module Hrack
module Bundle
diff --git a/lib/hrack/init.rb b/lib/hrack/init.rb
deleted file mode 100644
index ae5663c2d..000000000
--- a/lib/hrack/init.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-
-$LOAD_PATH.push File.expand_path('lib', __dir__)
-require 'hrack'
diff --git a/lib/hrack/lib/hrack.rb b/lib/hrack/lib/hrack.rb
deleted file mode 100644
index 231f9c359..000000000
--- a/lib/hrack/lib/hrack.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-module Hrack
- require 'hrack/bundle'
-end
diff --git a/lib/hrack/lib/hrack/server.rb b/lib/hrack/server.rb
similarity index 100%
rename from lib/hrack/lib/hrack/server.rb
rename to lib/hrack/server.rb
diff --git a/lib/hrack/lib/hrack/version.rb b/lib/hrack/version.rb
similarity index 74%
rename from lib/hrack/lib/hrack/version.rb
rename to lib/hrack/version.rb
index 52c448969..acc8bd606 100644
--- a/lib/hrack/lib/hrack/version.rb
+++ b/lib/hrack/version.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
module Hrack
+ module Version
+ end
VERSION = '1.0.0'
end
diff --git a/lib/load_gitolite_hooks.rb b/lib/load_gitolite_hooks.rb
index 9ad3e52d9..7008c9add 100644
--- a/lib/load_gitolite_hooks.rb
+++ b/lib/load_gitolite_hooks.rb
@@ -72,3 +72,6 @@
].each do |file|
require_dependency file if File.exist? file
end
+
+module LoadGitoliteHooks
+end
diff --git a/lib/redmine_git_hosting.rb b/lib/redmine_git_hosting.rb
index b24ddc9f7..65b63eb80 100644
--- a/lib/redmine_git_hosting.rb
+++ b/lib/redmine_git_hosting.rb
@@ -69,5 +69,5 @@ def additionals_help_items
# Redmine SCM adapter
require_dependency 'redmine/scm/adapters/xitolite_adapter'
- require 'hrack/init'
+ require 'hrack/bundle'
end
diff --git a/lib/redmine_git_hosting/hooks.rb b/lib/redmine_git_hosting/hooks.rb
index a6eb0fad1..75ed5665c 100644
--- a/lib/redmine_git_hosting/hooks.rb
+++ b/lib/redmine_git_hosting/hooks.rb
@@ -3,70 +3,72 @@
require 'github/markup'
module RedmineGitHosting
- class GitHostingHookListener < Redmine::Hook::ViewListener
- render_on :view_repository_edit_top, partial: 'repositories/edit_top'
- render_on :view_repositories_show_contextual, partial: 'repositories/show_top'
- render_on :view_repository_edit_bottom, partial: 'repositories/edit_bottom'
- render_on :view_repositories_show_sidebar, partial: 'repositories/git_hosting_sidebar'
- render_on :view_repositories_navigation, partial: 'repositories/git_hosting_navigation'
- render_on :view_layouts_base_html_head, partial: 'common/git_hosting_html_head'
-
- def view_my_account_contextual(context)
- user = context[:user]
- link_to(l(:label_my_public_keys), public_keys_path, class: 'icon icon-passwd') if user.allowed_to_create_ssh_keys?
- end
+ module Hooks
+ class GitHostingHookListener < Redmine::Hook::ViewListener
+ render_on :view_repository_edit_top, partial: 'repositories/edit_top'
+ render_on :view_repositories_show_contextual, partial: 'repositories/show_top'
+ render_on :view_repository_edit_bottom, partial: 'repositories/edit_bottom'
+ render_on :view_repositories_show_sidebar, partial: 'repositories/git_hosting_sidebar'
+ render_on :view_repositories_navigation, partial: 'repositories/git_hosting_navigation'
+ render_on :view_layouts_base_html_head, partial: 'common/git_hosting_html_head'
+
+ def view_my_account_contextual(context)
+ user = context[:user]
+ link_to(l(:label_my_public_keys), public_keys_path, class: 'icon icon-passwd') if user.allowed_to_create_ssh_keys?
+ end
- def self.default_url_options
- { script_name: Redmine::Utils.relative_url_root }
- end
+ def self.default_url_options
+ { script_name: Redmine::Utils.relative_url_root }
+ end
- def view_repositories_show_bottom(context)
- path = get_path context
- rev = get_rev context
- repository = context[:repository]
- readme_file = find_readme_file repository, path, rev
+ def view_repositories_show_bottom(context)
+ path = get_path context
+ rev = get_rev context
+ repository = context[:repository]
+ readme_file = find_readme_file repository, path, rev
- return '' if readme_file.nil?
+ return '' if readme_file.nil?
- content = get_formatted_text repository, readme_file, rev
+ content = get_formatted_text repository, readme_file, rev
- context[:controller].send :render_to_string, partial: 'repositories/readme', locals: { html: content }
- end
-
- private
+ context[:controller].send :render_to_string, partial: 'repositories/readme', locals: { html: content }
+ end
- def get_path(context)
- context[:request].params['path'] || ''
- end
+ private
- def get_rev(context)
- rev = context[:request].params['rev']
- rev.presence
- end
+ def get_path(context)
+ context[:request].params['path'] || ''
+ end
- def find_readme_file(repository, path, rev)
- (repository.entries(path, rev) || []).find { |f| f.name =~ /README((\.).*)?/i }
- end
+ def get_rev(context)
+ rev = context[:request].params['rev']
+ rev.presence
+ end
- def get_formatted_text(repository, file, rev)
- raw_readme_text = Redmine::CodesetUtil.to_utf8_by_setting repository.cat(file.path, rev)
+ def find_readme_file(repository, path, rev)
+ (repository.entries(path, rev) || []).find { |f| f.name =~ /README((\.).*)?/i }
+ end
- if redmine_file? file
- formatter_name = Redmine::WikiFormatting.format_names.find { |name| name =~ /markdown/i }
- Redmine::WikiFormatting.formatter_for(formatter_name).new(raw_readme_text).to_html
- elsif github_file? file
- RedmineGitHosting::MarkdownRenderer.to_html raw_readme_text
- else
- GitHub::Markup.render(file.path, raw_readme_text).gsub("\n", '
')
+ def get_formatted_text(repository, file, rev)
+ raw_readme_text = Redmine::CodesetUtil.to_utf8_by_setting repository.cat(file.path, rev)
+
+ if redmine_file? file
+ formatter_name = Redmine::WikiFormatting.format_names.find { |name| name =~ /markdown/i }
+ Redmine::WikiFormatting.formatter_for(formatter_name).new(raw_readme_text).to_html
+ elsif github_file? file
+ RedmineGitHosting::MarkdownRenderer.to_html raw_readme_text
+ else
+ GitHub::Markup.render(file.path, raw_readme_text).gsub("\n", '
')
+ end
end
- end
- def redmine_file?(file)
- %w[.txt].include? File.extname(file.path)
- end
+ def redmine_file?(file)
+ %w[.txt].include? File.extname(file.path)
+ end
- def github_file?(file)
- %w[.markdown .mdown .mkdn .md].include? File.extname(file.path)
+ def github_file?(file)
+ %w[.markdown .mdown .mkdn .md].include? File.extname(file.path)
+ end
end
end
end
diff --git a/lib/redmine_git_hosting/journal_logger.rb b/lib/redmine_git_hosting/journal_logger.rb
index b1ed8f63a..5bcaa8488 100644
--- a/lib/redmine_git_hosting/journal_logger.rb
+++ b/lib/redmine_git_hosting/journal_logger.rb
@@ -36,5 +36,8 @@ def msg2str(msg)
end
end
end
+ else
+ module JournalLogger
+ end
end
end