| 1 | package Smolder::Control::Public; | ||
| 2 | use Smolder::Conf; | ||
| 3 | use base 'Smolder::Control'; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Smolder::Control::Public | ||
| 10 | |||
| 11 | =head1 DESCRIPTION | ||
| 12 | |||
| 13 | Controller module for generic Public screens. | ||
| 14 | |||
| 15 | =cut | ||
| 16 | |||
| 17 | sub setup { | ||
| 18 | my $self = shift; | ||
| 19 | $self->start_mode('welcome'); | ||
| 20 | $self->run_modes( | ||
| 21 | [ | ||
| 22 | qw( | ||
| 23 | welcome | ||
| 24 | developer_tutorial | ||
| 25 | admin_tutorial | ||
| 26 | not_found | ||
| 27 | nav | ||
| 28 | ) | ||
| 29 | ] | ||
| 30 | ); | ||
| 31 | } | ||
| 32 | |||
| 33 | =head1 RUN MODES | ||
| 34 | |||
| 35 | =head2 welcome | ||
| 36 | |||
| 37 | Shows a welcome page using the F<Public/welcome.tmpl> template. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | sub welcome { | ||
| 42 | my $self = shift; | ||
| 43 | if (my $project_id = Smolder::Conf->get('AutoRedirectToProject')) { | ||
| 44 | $self->header_type('redirect'); | ||
| 45 | $self->header_add( -uri => "/app/public_projects/smoke_reports/$project_id" ); | ||
| 46 | return "redirecting"; | ||
| 47 | } | ||
| 48 | else { | ||
| 49 | return $self->tt_process({}); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | =head2 nav | ||
| 54 | |||
| 55 | Return the nav HTML snippet incase we need to update it | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | sub nav { | ||
| 60 | my $self = shift; | ||
| 61 | return $self->tt_process('nav.tmpl', {no_wrapper => 1}); | ||
| 62 | |||
| 63 | } | ||
| 64 | |||
| 65 | =head2 developer_tutorial | ||
| 66 | |||
| 67 | Shows a tutorial for a developer using the F<Public/developer_tutorial.tmpl> template. | ||
| 68 | |||
| 69 | =cut | ||
| 70 | |||
| 71 | sub developer_tutorial { | ||
| 72 | my $self = shift; | ||
| 73 | return $self->tt_process({}); | ||
| 74 | } | ||
| 75 | |||
| 76 | =head2 admin_tutorial | ||
| 77 | |||
| 78 | Shows a tutorial for an admin using the F<Public/admin_tutorial.tmpl> template. | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | sub admin_tutorial { | ||
| 83 | my $self = shift; | ||
| 84 | return $self->tt_process({}); | ||
| 85 | } | ||
| 86 | |||
| 87 | =head2 not_found | ||
| 88 | |||
| 89 | Show the PAGE NOT FOUND error. | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | sub not_found { | ||
| 94 | my $self = shift; | ||
| 95 | return $self->tt_process({}); | ||
| 96 | } | ||
| 97 | |||
| 98 | =head2 error | ||
| 99 | |||
| 100 | Show the INTERNAL SERVER ERROR page. | ||
| 101 | |||
| 102 | =cut | ||
| 103 | |||
| 104 | sub error { | ||
| 105 | my $self = shift; | ||
| 106 | return $self->tt_process({}); | ||
| 107 | } | ||
| 108 | |||
| 109 | 1; |