]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Base.pm
682896c7dfd508e7f0ee0a345e9f09b9df10b3cc
1 package Gruntmaster
::Page
::Base
;
7 use File
::Slurp qw
/read_file/;
8 use HTML
::Template
::Compiled
;
10 ##################################################
13 use Gruntmaster
::Data
();
17 my $ua = LWP
::UserAgent
->new;
21 my ($self, $name, $title) = @_;
23 Gruntmaster
::Data
->export_to_level(1, $caller);
24 List
::Util
->export_to_level(1, $caller, qw
/sum/);
27 *{"${caller}::strftime"} = \
&POSIX
::strftime
;
28 *{"${caller}::NAME"} = sub () { $name };
29 *{"${caller}::TITLE"} = sub () { $title };
30 *{"${caller}::debug"} = sub {
31 local $Log::Log4perl
::caller_depth
= $Log::Log4perl
::caller_depth
+ 1;
32 $_[0]->{'psgix.logger'}->({qw
/level debug message/ => $_[1]})
34 *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain'], [ @_ ] ] };
35 *{"${caller}::purge"} = sub {
36 return unless $ENV{PURGE_HOST
};
37 my $req = HTTP
::Request
->new(PURGE
=> "http://$ENV{PURGE_HOST}$_[0]");
42 ##################################################
44 my %orig_header_templates = (
47 <title>TITLE_GOES_HERE</title>
48 <meta charset="utf-8">
49 <meta name="viewport" content="width=device-width, initial-scale=1.0">
51 <link rel="stylesheet" href="/css/cosmo" id="stylesheet">
52 <script src="/js" type="text/javascript"></script>
54 <nav class="navbar navbar-default navbar-static-top" role="navigation">
55 <div class="container-fluid">
56 <div class="navbar-header">
57 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
58 <a class="navbar-brand" href="/">Gruntmaster 6000</a>
61 <div class="collapse navbar-collapse">
62 <ul class="nav navbar-nav">
63 <li><a href="/pb/">Problems</a>
64 <li><a href="/ct/">Contests</a>
65 <li><a href="/account">Account</a>
68 <ul class="nav navbar-nav navbar-right">
69 <li><a class="dropdown-toggle" data-toggle="dropdown"> Theme <span class="caret"></span></a>
71 <ul class="dropdown-menu" role="menu">
72 <li><a href="#" id="theme_slate">Gunmetal gray</a>
73 <li><a href="#" id="theme_cyborg">Black</a>
74 <li><a href="#" id="theme_cerulean">White</a>
75 <li><a href="#" id="theme_cosmo">Metro</a>
78 <li><a href="/log/">Job log</a>
84 <div class="container-fluid">
86 <div class="logo logo-mindcoding center-block"></div>
88 <h1 id="title">TITLE_GOES_HERE</h1>
89 <div id="result"></div>
95 my %orig_footer_templates = (
101 <h3>Official sponsors</h3>
102 <div class="logo logo-yardi"></div>
107 <div class="col-md-6 column text-center">
108 <a class="logo logo-hermes" href="http://www.societatea-hermes.ro"></a>
111 <div class="col-md-6 column text-center">
112 <a class="logo logo-facebook" href="http://www.facebook.com/mindcodingcluj"></a>
117 <a href="http://cs.ubbcluj.ro" class="logo logo-csf"></a>
118 <a href="http://www.uniunea.ro" class="logo logo-usr"></a>
119 <a href="http://www.coscj.ro" class="logo logo-cos"></a>
120 <a href="http://www.cluj2015.ro/romana" class="logo logo-eyc"></a>
121 <h3> Media Partners </h3>
122 <a href="http://www.clujlife.com" class="logo logo-clujlife"></a>
123 <a href="http://www.vinsieu.ro/eveniment/cluj/cluj-napoca/alte-evenimente/mindcoding/88970/e.html" class="logo logo-vinsieu"></a>
124 <a href="http://www.welcome2cluj.com" class="logo logo-welcome2cluj"></a>
130 sub patch_templates
{
132 return %{$_[0]} unless -d
$root;
133 my ($templates, $name) = @_;
134 my %out = %$templates;
135 for (<$root/$name.*>) {
137 $out{$1} = read_file
$_
143 my %header_templates = patch_templates \
%orig_header_templates, 'header';
144 my %footer_templates = patch_templates \
%orig_footer_templates, 'footer';
147 my ($language, $title) = @_;
148 $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger;
152 $footer_templates{$_[0]};
156 my ($templates, $name, $title) = @_;
158 my %out = patch_templates
$templates, $name;
159 $out{$_} = header
($_, $title) . $out{$_} for keys %out;
160 $out{$_} .= footer
$_ for keys %out;
165 ##################################################
170 my ($self, $lang, @args) = @_;
172 $templates{$self} = { cook_templates
$self->TEMPLATES, $self->NAME => $self->TITLE } unless exists $templates{$self};
174 my $htc = HTML
::Template
::Compiled
->new(scalarref
=> \
$templates{$self}{$lang}, default_escape
=> 'HTML',);
175 $self->_generate($htc, $lang, @args);
176 my $out = $htc->output;
177 utf8
::downgrade
($out);
178 [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language', 'X-Forever' => 1], [ $out ] ]
184 [ map { [ $_, 1, 'text/html', undef, undef, $_, undef ]} keys $_[0]->TEMPLATES ]
This page took 0.069472 seconds and 4 git commands to generate.