projects
/
plack-app-gruntmaster.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1f887c2
)
Add static mode
author
Marius Gavrilescu
<marius@ieval.ro>
Sat, 21 Mar 2015 17:04:21 +0000
(19:04 +0200)
committer
Marius Gavrilescu
<marius@ieval.ro>
Sat, 21 Mar 2015 17:05:22 +0000
(19:05 +0200)
lib/Plack/App/Gruntmaster.pm
patch
|
blob
|
blame
|
history
lib/Plack/App/Gruntmaster/HTML.pm
patch
|
blob
|
blame
|
history
tmpl/pb_entry.en
patch
|
blob
|
blame
|
history
tmpl/skel.en
patch
|
blob
|
blame
|
history
diff --git
a/lib/Plack/App/Gruntmaster.pm
b/lib/Plack/App/Gruntmaster.pm
index 9284acc1a8b1eae97cd01e579b894d3d4e647481..c9965d08a46894e02b5aa61cdbf89087c28d9000 100644
(file)
--- a/
lib/Plack/App/Gruntmaster.pm
+++ b/
lib/Plack/App/Gruntmaster.pm
@@
-114,10
+114,11
@@
sub dispatch_request{
response_filter {
my ($r) = @_;
return $r if ref $r ne 'Plack::App::Gruntmaster::Response';
response_filter {
my ($r) = @_;
return $r if ref $r ne 'Plack::App::Gruntmaster::Response';
- my @hdrs = ('X-Forever' => 1, 'Cache-Control' => "$privacy, max-age=$r->{maxage}");
- push @hdrs, Vary => 'Authorization' if $privacy eq 'private';
+ my $vary = 'X-Static';
+ $vary .= ', Authorization' if $privacy eq 'private';
+ my @hdrs = ('X-Forever' => 1, 'Cache-Control' => "$privacy, max-age=$r->{maxage}", Vary => $vary);
return [200, ['Content-Type' => 'application/json; charset=utf-8', @hdrs], [encode_json $r->{params}]] if $format eq 'json';
return [200, ['Content-Type' => 'application/json; charset=utf-8', @hdrs], [encode_json $r->{params}]] if $format eq 'json';
- my $ret = render $r->{template}, 'en', title => $r->{title}, %{$r->{params}};
+ my $ret = render $r->{template}, 'en', title => $r->{title}, %{$r->{params}}
, maybe static => $env->{HTTP_X_STATIC} + 1
;
[200, ['Content-Type' => 'text/html; charset=utf-8', @hdrs], [encode 'UTF-8', $ret]]
},
},
[200, ['Content-Type' => 'text/html; charset=utf-8', @hdrs], [encode 'UTF-8', $ret]]
},
},
@@
-182,7
+183,7
@@
sub dispatch_request{
sub (/) { redispatch_to '/index' },
sub (/favicon.ico) { redirect '/static/favicon.ico' },
sub (/) { redispatch_to '/index' },
sub (/favicon.ico) { redirect '/static/favicon.ico' },
- sub (/:article) { [200, ['Content-Type' => 'text/html; charset=utf-8', 'Cache-Control' => 'public, max-age=3600', 'X-Forever' => 1
], [render_article $_{article}, 'en'
]] }
+ sub (/:article) { [200, ['Content-Type' => 'text/html; charset=utf-8', 'Cache-Control' => 'public, max-age=3600', 'X-Forever' => 1
, Vary => 'X-Static'], [render_article $_{article}, 'en', maybe static => $env->{HTTP_X_STATIC}
]] }
},
sub (POST) {
},
sub (POST) {
diff --git
a/lib/Plack/App/Gruntmaster/HTML.pm
b/lib/Plack/App/Gruntmaster/HTML.pm
index 1e0f7889870101de3c74c793ac537e51bfc99b98..3195b623170da4c58059fd9f2cc8fcfe4e31d94b 100644
(file)
--- a/
lib/Plack/App/Gruntmaster/HTML.pm
+++ b/
lib/Plack/App/Gruntmaster/HTML.pm
@@
-50,11
+50,11
@@
sub render {
}
sub render_article {
}
sub render_article {
- my ($art, $lang) = @_;
+ my ($art, $lang
, %args
) = @_;
$lang //= 'en';
my $title = read_file "a/$art.$lang.title";
my $meat = read_file "a/$art.$lang";
$lang //= 'en';
my $title = read_file "a/$art.$lang.title";
my $meat = read_file "a/$art.$lang";
- _render('skel', $lang, title => $title , meat => $meat)
+ _render('skel', $lang, title => $title , meat => $meat
, %args
)
}
sub _render {
}
sub _render {
@@
-66,6
+66,8
@@
sub _render {
$tree->defmap(smap => \%args);
my $process = __PACKAGE__->can("process_$tmpl");
$process->($tree, %args) if $process;
$tree->defmap(smap => \%args);
my $process = __PACKAGE__->can("process_$tmpl");
$process->($tree, %args) if $process;
+ $_->detach for $tree->look_down(static => $args{static} ? 'no' : 'yes');
+ $_->attr('static', undef) for $tree->look_down(sub {$_[0]->attr('static')});
$tree->as_HTML;
}
$tree->as_HTML;
}
diff --git
a/tmpl/pb_entry.en
b/tmpl/pb_entry.en
index 8246c42a605ab78687f29f89d4e4151853877955..6398e631b7617fd5b1f121f71ab446979e76e9fd 100644
(file)
--- a/
tmpl/pb_entry.en
+++ b/
tmpl/pb_entry.en
@@
-16,14
+16,14
@@
<a href="/log/?problem=problem_id" id="job_log">Job log</a><br>
<a href="/sol/problem_id" id="solution" data-toggle="modal" data-target="#solution_modal">Solution</a>
<a href="/log/?problem=problem_id" id="job_log">Job log</a><br>
<a href="/sol/problem_id" id="solution" data-toggle="modal" data-target="#solution_modal">Solution</a>
-<h1>Submit solution</h1>
+<h1
static="no"
>Submit solution</h1>
<div id="nosubmit">
The contest has finished.<br>
To submit solutions to this problem, please visit the problem <a href="/pb/id">outside the contest</a>.
</div>
<div id="nosubmit">
The contest has finished.<br>
To submit solutions to this problem, please visit the problem <a href="/pb/id">outside the contest</a>.
</div>
-<div id="submit">
+<div id="submit"
static="no"
>
<form id="submitform" action="/action/submit" method="POST" enctype="multipart/form-data" role="form">
<input type="hidden" name="problem" value="problem_id">
<input type="hidden" name="contest" value="contest_id">
<form id="submitform" action="/action/submit" method="POST" enctype="multipart/form-data" role="form">
<input type="hidden" name="problem" value="problem_id">
<input type="hidden" name="contest" value="contest_id">
diff --git
a/tmpl/skel.en
b/tmpl/skel.en
index 39b4ddae50435374e95c80aea92ae7e187a0b776..6ae836aea13a969de2a515d7c646938cb78b8867 100644
(file)
--- a/
tmpl/skel.en
+++ b/
tmpl/skel.en
@@
-17,7
+17,7
@@
<li id="nav-ct"><a href="/ct/">Contests</a>
<li id="nav-log"><a href="/log/">Job log</a>
<li id="nav-us"><a href="/us/">Users</a>
<li id="nav-ct"><a href="/ct/">Contests</a>
<li id="nav-log"><a href="/log/">Job log</a>
<li id="nav-us"><a href="/us/">Users</a>
-<li id="nav-account"><a href="/account">Account</a>
+<li id="nav-account"
static="no"
><a href="/account">Account</a>
<li id="nav-contribute"><a href="/contribute">Contribute!</a>
</ul>
<li id="nav-contribute"><a href="/contribute">Contribute!</a>
</ul>
@@
-27,11
+27,13
@@
<div class="container-fluid">
<h1 id="title">TITLE</h1>
<div class="container-fluid">
<h1 id="title">TITLE</h1>
+<div id="static" class="alert alert-info" static="yes">This is a static version of Gruntmaster 6000.</div>
+
<div id="result"></div>
<div id="content">Content goes here</div>
<div id="result"></div>
<div id="content">Content goes here</div>
-<div id="login" class="reqjs"><a href="#">Log in</a></div>
+<div id="login" class="reqjs"
static="no"
><a href="#">Log in</a></div>
<div id="theme-selector" class="reqjs">
Themes:
<div id="theme-selector" class="reqjs">
Themes:
This page took
0.01621 seconds
and
4
git commands to generate.