Skip to content

Commit

Permalink
Display contributors in plugin info page ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Sep 17, 2015
1 parent 96285a8 commit 0cc7ef1
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/views/settings/authors.html.haml
@@ -0,0 +1,4 @@
%div{ style: 'height: 50%;' }
%ul{ class: 'authors-list' }
- @authors.each do |author|
%li= mail_to author.email, author.name
41 changes: 41 additions & 0 deletions assets/javascripts/plugin.js
@@ -0,0 +1,41 @@
// Bind links on Dialog box
function initModalBox() {
$('#ajax-modal').dialog({
resizable: false,
autoOpen: false,
height: 'auto',
width: 'auto',
modal: true,
hide: {
effect: "fade",
duration: 500
},
buttons: {
Ok: function(){$(this).dialog('close');}
}
});

$('.modal-box').each(function() {
$(this).on('click', function() {
var title = $(this).html();
$.get($(this).attr('href'), function(data){
$('#ajax-modal').html(data);
$('#ajax-modal').dialog('option', 'title', title);
$('#ajax-modal').dialog('open');
});
return false;
});
});
}

function enhanceAuthorsUrlForPlugin(plugin_name) {
var link = $('#plugin-' + plugin_name + ' > td.author > a');
if (link.length) {
link.addClass('modal-box');
initModalBox();
}
}

$(document).ready(function() {
enhanceAuthorsUrlForPlugin('redmine_git_hosting');
});
6 changes: 6 additions & 0 deletions assets/stylesheets/application.css
Expand Up @@ -53,6 +53,12 @@ PLUGIN SETTINGS
margin-top: 15px;
}

.authors-list {
columns: 2;
-webkit-columns: 2;
-moz-columns: 2;
}


/*
REPOSITORY EDIT
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -36,6 +36,7 @@
# Enable Redirector for Go Lang repositories
get 'go/:repo_path', repo_path: /([^\/]+\/)*?[^\/]+/, to: 'go_redirector#index'

get 'settings/plugin/:id/authors', to: 'settings#authors', as: 'plugin_authors'
get 'settings/plugin/:id/install_gitolite_hooks', to: 'settings#install_gitolite_hooks', as: 'install_gitolite_hooks'

# Enable SmartHTTP Grack support
Expand Down
6 changes: 3 additions & 3 deletions init.rb
Expand Up @@ -6,11 +6,11 @@

Redmine::Plugin.register :redmine_git_hosting do
name 'Redmine Git Hosting Plugin'
author 'Eric Bishop, Pedro Algarvio, Christian Käser, Zsolt Parragi, Yunsang Choi, Joshua Hogendorn, Jan Schulz-Hofen, John Kubiatowicz, Nicolas Rodriguez and others'
author 'A lot of people! A big thank to them for their contribution!'
description 'Enables Redmine to control hosting of Git repositories through Gitolite'
version '1.1-devel'
url 'https://github.com/jbox-web/redmine_git_hosting'
author_url 'https://github.com/jbox-web'
url 'http://redmine-git-hosting.io/'
author_url '/settings/plugin/redmine_git_hosting/authors'

settings({ partial: 'settings/redmine_git_hosting', default: RedmineGitHosting.settings })
end
Expand Down
1 change: 1 addition & 0 deletions lib/redmine_git_hosting/hooks/add_plugin_icon.rb
Expand Up @@ -5,6 +5,7 @@ class AddPluginIcon < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context = {})
header = ''
header << stylesheet_link_tag(:application, plugin: 'redmine_git_hosting') + "\n"
header << javascript_include_tag(:plugin, plugin: 'redmine_git_hosting') + "\n"
header
end

Expand Down
13 changes: 9 additions & 4 deletions lib/redmine_git_hosting/patches/settings_controller_patch.rb
Expand Up @@ -19,12 +19,17 @@ def self.included(base)

module InstanceMethods

def authors
@plugin = Redmine::Plugin.find(params[:id])
return render_404 unless @plugin.id == :redmine_git_hosting
@authors = RedmineGitHosting.authors
render layout: false
end


def install_gitolite_hooks
@plugin = Redmine::Plugin.find(params[:id])
unless @plugin.id == :redmine_git_hosting
render_404
return
end
return render_404 unless @plugin.id == :redmine_git_hosting
@gitolite_checks = RedmineGitHosting::Config.install_hooks!
end

Expand Down
22 changes: 22 additions & 0 deletions lib/redmine_git_hosting/plugin_author.rb
@@ -0,0 +1,22 @@
module RedmineGitHosting
class PluginAuthor

attr_reader :author


def initialize(author)
@author = author
end


def name
RedmineGitHosting::Utils::Git.author_name(author)
end


def email
RedmineGitHosting::Utils::Git.author_email(author).downcase
end

end
end
16 changes: 16 additions & 0 deletions lib/redmine_git_hosting/redmine_plugin_loader.rb
Expand Up @@ -22,6 +22,16 @@ def autoloaded_paths
end


def authors
load_authors_file
end


def authors_file
plugin_dir('AUTHORS')
end


def settings
default_settings.merge(local_settings)
end
Expand Down Expand Up @@ -108,6 +118,12 @@ def load_setting_file(file)
end


def load_authors_file
return [] unless File.exists?(authors_file)
File.read(authors_file).split("\n").map { |a| RedmineGitHosting::PluginAuthor.new(a) }
end


def hook_file?(file)
File.dirname(file) == plugin_hooks_dir.to_s
end
Expand Down

0 comments on commit 0cc7ef1

Please sign in to comment.