From fa904279c38a28fd95af00012b4ebfa354b9e34e Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 1 Aug 2010 20:08:20 -0700 Subject: Supporting per-repo config stuff. --- usr/src/libpiny/lib/Piny/Repo.pm | 44 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'usr/src/libpiny/lib') diff --git a/usr/src/libpiny/lib/Piny/Repo.pm b/usr/src/libpiny/lib/Piny/Repo.pm index 8b2045c..de8501b 100644 --- a/usr/src/libpiny/lib/Piny/Repo.pm +++ b/usr/src/libpiny/lib/Piny/Repo.pm @@ -6,6 +6,7 @@ package Piny::Repo; use Moose; use Moose::Util::TypeConstraints; +use Config::Tiny qw( ); use File::Find qw( find ); use File::Temp qw( ); use IO::Dir qw( ); @@ -162,6 +163,13 @@ has 'apache_config' => , init_arg => undef ); +has 'config' => + ( is => 'ro' + , isa => 'HashRef[Str]' + , lazy_build => 1 + , init_arg => undef + ); + # Public methods sub add_access { @@ -515,13 +523,21 @@ sub _build_ikiwiki_srcdir { sub _build_ikiwiki_url { my ( $s ) = @_; - return Piny::Config->instance->ikiwiki_url . $s->name; + if ( defined $s->config->{"http_url"} ) { + return $s->config->{"http_url"} . $s->name; + } else { + return Piny::Config->instance->ikiwiki_url . $s->name; + }; }; sub _build_ikiwiki_cgiurl { my ( $s ) = @_; - return Piny::Config->instance->ikiwiki_secure_url . "repos/" . $s->name . "/ikiwiki.cgi"; + if ( defined $s->config->{"https_url"} ) { + return $s->config->{"https_url"} . "repos/" . $s->name . "/ikiwiki.cgi"; + } else { + return Piny::Config->instance->ikiwiki_secure_url . "repos/" . $s->name . "/ikiwiki.cgi"; + }; }; sub _build_secure_path { @@ -539,13 +555,21 @@ sub _build_ikiwiki_cgipath { sub _build_ikiwiki_historyurl { my ( $s ) = @_; - return Piny::Config->instance->ikiwiki_secure_url . "cgit/" . $s->name . "/log/[[file]]"; + if ( defined $s->config->{"https_url"} ) { + return $s->config->{"https_url"} . "cgit/" . $s->name . "/log/[[file]]"; + } else { + return Piny::Config->instance->ikiwiki_secure_url . "cgit/" . $s->name . "/log/[[file]]"; + }; }; sub _build_ikiwiki_diffurl { my ( $s ) = @_; - return Piny::Config->instance->ikiwiki_secure_url . "cgit/" . $s->name . "/diff/?id=[[sha1_commit]]"; + if ( defined $s->config->{"https_url"} ) { + return $s->config->{"https_url"} . "cgit/" . $s->name . "/diff/?id=[[sha1_commit]]"; + } else { + return Piny::Config->instance->ikiwiki_secure_url . "cgit/" . $s->name . "/diff/?id=[[sha1_commit]]"; + }; }; sub _build_apache_config { @@ -554,6 +578,18 @@ sub _build_apache_config { return "secure_path . ">\n AuthPAM_Enabled on\n AuthGROUP_Enabled on\n AuthPAM_FallThrough off\n AuthBasicAuthoritative off\n AuthType Basic\n AuthName \"User access to " . $s->name . " repository needed.\"\n Require group " . $s->group->name . "\n\n"; }; +sub _build_config { + my ( $s ) = @_; + + my $c = Config::Tiny->read( $s->path . "/config" ); + + if ( defined $c and defined $c->{"piny"}) { + return $c->{"piny"}; + } else { + return { }; + }; +}; + # Moose boilerplate __PACKAGE__->meta->make_immutable; -- cgit v1.2.3