From 5b9d513b60932ab46f2989dbe69663ca0a89d9c3 Mon Sep 17 00:00:00 2001 From: Darin McBride Date: Mon, 15 Dec 2014 21:43:23 -0700 Subject: [PATCH] Add admin UI to set alliance logo. --- lib/Lacuna/Web/Admin.pm | 60 ++++++++++++++++++++++++++++++++++++++ var/www/public/changes.txt | 1 + 2 files changed, 61 insertions(+) diff --git a/lib/Lacuna/Web/Admin.pm b/lib/Lacuna/Web/Admin.pm index cab15edd..49c3d1f4 100644 --- a/lib/Lacuna/Web/Admin.pm +++ b/lib/Lacuna/Web/Admin.pm @@ -11,6 +11,7 @@ use UUID::Tiny ':std'; use Lacuna::Util qw(format_date); use List::Util qw(sum); use Data::Dumper; +use LWP::UserAgent; sub www_send_test_message { my ($self, $request, $id) = @_; @@ -967,6 +968,41 @@ sub www_view_empire { return $self->wrap($out); } +sub www_set_alliance_logo { + my ($self, $request, $id) = @_; + $id ||= $request->param('id'); + my $alliance = Lacuna->db->resultset('Lacuna::DB::Result::Alliance')->find($id); + unless (defined $alliance) { + confess [404, 'Alliance not found.']; + } + my $image = $request->param('logo_url'); + unless (defined $image) { + confess [404, 'Logo URL not supplied' ]; + } + my $out = ''; + + my $full_url = 'https://d16cbq0l6kkf21.cloudfront.net/assets/alliances/' . $image . '.png'; + my $response = LWP::UserAgent->new->head($full_url); + if ($response->is_success) + { + $alliance->image($image); + $alliance->update; + $out .= '

Success

'; + $out .= sprintf('

Successfully updated %s to use %s

', + $alliance->name, $full_url, $image); + } + else + { + $out .= '

Failure

'; + $out .= sprintf('

Could not find an image for %s - has it been delivered yet?

', + $image); + } + $out .= sprintf('

Back to %s

', + $alliance->id, $alliance->name); + return $self->wrap($out); + +} + sub www_view_alliance { my ($self, $request, $id) = @_; $id ||= $request->param('id'); @@ -974,8 +1010,32 @@ sub www_view_alliance { unless (defined $alliance) { confess [404, 'Alliance not found.']; } + my $current_logo_path = $alliance->image; + my $num = 0; + + if ($current_logo_path) + { + ($num) = $current_logo_path =~ /_(\d+)$/; + $current_logo_path = qq["$current_logo_path"]; + } + else + { + $current_logo_path = "not set"; + } + + my $uri = URI->new(Lacuna->config->get('server_url')); + my ($domain) = $uri->authority =~ /^([^.]+)\./; + my $new_logo_path = sprintf("%s/logo_%d_%03d", $domain, $alliance->id, $num + 1); + my $leader = $alliance->leader; my $out = '

Manage Alliance

'; + $out .= ''; $out .= ''; $out .= ''; $out .= sprintf('', diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index c9b87f7f..2daf8204 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -5,6 +5,7 @@ - UI : Reasons for not being able to use a BHG function now always displayed for every task. - Fix: Instead of going via parliament, go via body or star to view_laws. This allows everyone access to passed laws by a station. - UI : No more nagging if you want to spend halls. + - Add: Admin UI to set alliance logo. 3.0907: - Add: Timer added to colony object preventing passage into Neutral Zone. -- 2.51.2
IdNameHomeLast Login
%d%s%s%s