Add canary ribbon

This adds an obvious ribbon on the corner of the page if it's rendered
on a web server where $LJ::IS_CANARY is 1.
This commit is contained in:
Mark Smith 2022-10-19 10:51:26 +00:00
parent 8d37b0dfbf
commit 9a7b1e6972
7 changed files with 86 additions and 5 deletions

View File

@ -43,10 +43,11 @@ sub new {
# refresh on each page load, because this changes depending on whether you're using HTTP or HTTPS
$context->stash->{site} = {
root => $LJ::SITEROOT,
imgroot => $LJ::IMGPREFIX,
jsroot => $LJ::JSPREFIX,
statroot => $LJ::STATPREFIX,
root => $LJ::SITEROOT,
imgroot => $LJ::IMGPREFIX,
jsroot => $LJ::JSPREFIX,
statroot => $LJ::STATPREFIX,
is_canary => $LJ::IS_CANARY,
};
return $self;

View File

@ -209,6 +209,8 @@ sub make_journal {
stc/jquery/jquery.ui.button.css
stc/jquery/jquery.ui.dialog.css
stc/jquery/jquery.ui.theme.smoothness.css
stc/canary.css
)
);
@ -2424,6 +2426,7 @@ sub Page {
'global_subtitle' => LJ::ehtml( $u->{'journalsubtitle'} ),
'show_control_strip' => LJ::Hooks::run_hook('show_control_strip'),
'head_content' => '',
'is_canary' => $LJ::IS_CANARY,
'data_link' => {},
'data_links_order' => [],
_styleopts => LJ::viewing_style_opts(%$get),

View File

@ -177,6 +177,9 @@
# The expected location for compiled static assets; see bin/build-static.sh
$STATDOCS = "$HOME/build/static";
}
# Set to true if this is a canary server. This causes very visible banner to appear
# on ever page rendered.
$IS_CANARY = 0
1;

View File

@ -33,4 +33,7 @@ the same terms as Perl itself. For a copy of the license, please reference
<li><a href="[% site.root %]/support">[% 'sitescheme.accountlinks.help' | ml %]</a></li>
</ul>
<p>[% 'sitescheme.footer.info' | ml %]</p>
[% IF site.is_canary %]
<div class="canary canary-bottom-right"><span>canary</span></div>
[% END %]
[%- END -%]

60
htdocs/stc/canary.css Normal file
View File

@ -0,0 +1,60 @@
/* from https://codepen.io/nxworld/pen/oLdoWb */
.canary {
width: 150px;
height: 150px;
overflow: hidden;
position: fixed;
z-index: 999;
}
.canary::before,
.canary::after {
position: absolute;
z-index: -1;
content: "";
display: block;
border: 5px solid #2980b9;
}
.canary span {
position: absolute;
display: block;
width: 225px;
padding: 15px 0;
background-color: #3498db;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
color: #fff;
font: 700 18px/1 sans-serif;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
text-transform: uppercase;
text-align: center;
}
/* bottom right*/
.canary-bottom-right {
bottom: -10px;
right: -10px;
}
.canary-bottom-right::before,
.canary-bottom-right::after {
border-bottom-color: transparent;
border-right-color: transparent;
}
.canary-bottom-right::before {
bottom: 0;
left: 0;
}
.canary-bottom-right::after {
top: 0;
right: 0;
}
.canary-bottom-right span {
left: -25px;
bottom: 30px;
transform: rotate(-45deg);
}

View File

@ -35,6 +35,8 @@ the same terms as Perl itself. For a copy of the license, please reference
"js/foundation/foundation/foundation.reveal.js"
"js/skins/jquery.focus-on-reveal.js"
);
dw.need_res( "stc/canary.css" );
-%]
[%- PROCESS block.need_res -%]
[% dw_scheme.res_includes %]
@ -60,6 +62,9 @@ the same terms as Perl itself. For a copy of the license, please reference
<li><a href="[% site.root %]/site/suggest">[% 'sitescheme.footer.suggestion' | ml %]</a></li>
</ul>
<p>[% 'sitescheme.footer.info' | ml %]</p>
[% IF site.is_canary %]
<div class="canary canary-bottom-right"><span>canary</span></div>
[% END %]
[%- END -%]
[%- userpic_class = 'account-links-userpic' -%]

View File

@ -590,6 +590,8 @@ class Page
"Extra tags supplied by the server to go in the <head> section of the output HTML document. Layouts
should include this in the head section if they are writing HTML.";
var readonly bool is_canary "True if this page is being rendered on the canary server.";
var readonly bool show_control_strip
"Whether the control strip will be shown on the current page.";
@ -4020,6 +4022,10 @@ function Page::print_wrapper_start(string{} opts)
}
"""<body class="page-$.view $column_count$column_side $column_multiple $*layout_type $opts{"class"} $logged_in $owner $subscribed $access $community_options $control_strip">\n""";
if ( $.is_canary ) {
"""<div class="canary canary-bottom-right"><span>canary</span></div>\n""";
}
}
function Page::print_wrapper_end()