$(function(){
- const nav = $('nav')[0];
+ const nav = q('nav');
nav.classList.add('hidden-xs');
- $('#title')[0].insertAdjacentHTML('beforebegin', '<div class="text-center visible-xs-block">Tap title to toggle menu</div>');
+ q('#title').insertAdjacentHTML('beforebegin', '<div class="text-center visible-xs-block">Tap title to toggle menu</div>');
- $('#title').on('click', () => nav.classList.toggle('hidden-xs'));
+ $('#title,#logo').on('click', () => nav.classList.toggle('hidden-xs'));
});
us: /^\/us\//,
account: /^\/account$/,
contribute: /^\/contribute$/,
+ about: /^\/about$/,
};
$(function(){
const path = location.pathname;
for (const nav in NAVS)
if(path.match(NAVS[nav]))
- $('#nav-' + nav)[0].classList.add('active');
+ q('#nav-' + nav).classList.add('active');
});
document.body.classList.add('transition-color');
setTimeout(() => document.body.classList.remove('transition-color'), 1000);
}
- $('link[title]').each(e => e.disabled = true);
- $('link[title="' + name + '"]')[0].disabled = false;
+ q('html').className = name;
localStorage.setItem("theme", name);
+ $(function() {
+ if(name == 'slate' || name == 'cyborg')
+ $('img').each(e => e.setAttribute('src', e.getAttribute('src').replace('logos/light', 'logos/dark')));
+ else
+ $('img').each(e => e.setAttribute('src', e.getAttribute('src').replace('logos/dark', 'logos/light')));
+ });
}
$(function() {
'<li><a role="button" data-theme="cyborg">Black</a>' +
'<li><a role="button" data-theme="slate">Grey</a>' +
'<li><a role="button" data-theme="readable">White</a></ul>';
- const sidebar = $('#sidebar')[0];
+ const sidebar = q('#sidebar');
sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
$('#themes a').on('click', e => set_style(e.target.dataset.theme, true));
});
use Digest::SHA qw/sha256_base64/;
use IO::Compress::Gzip qw/gzip/;
use File::Slurp qw/read_file write_file edit_file_lines/;
+use SVG::SpriteMaker;
use File::Which;
use List::Util qw/first/;
mkdir 'static';
mkdir 'static/css';
mkdir 'static/js';
+mkdir 'static/logos';
sub gzip_file {
my ($file) = @_;
gzip_file $file
}
+sub sprite_name {
+ my ($name) = $_[0] =~ m,/(.*)\.svg,;
+ "logo-$name"
+}
+
+sub make_logos {
+ my @logos = <logos/*>;
+ my $logos = make_sprite \&sprite_name, @logos;
+ my @logos_light;
+ for (<logos/*>) {
+ my $light = s/logos/logos-light/r;
+ push @logos_light, -f $light ? $light : $_;
+ }
+ my $logos_light = make_sprite \&sprite_name, @logos_light;
+
+ write_gzfile 'static/logos/dark.svg', $logos->render;
+ write_gzfile 'static/logos/light.svg', $logos_light->render;
+}
+
sub read_css_into_blocks {
my ($file) = @_;
my (@blocks, $block);
\@blocks
}
-my $default_theme = 'cyborg';
++my $default_theme = 'slate';
+
+ sub theme_prefix {
+ my ($theme, $decl, $default) = @_;
+ return $decl if $theme eq $default_theme || !$decl;
+ return '' if $decl eq $default;
+
+ $default =~ s/[^{]*{\n//;
+ $default =~ s/\n}[^}]*//;
+ $decl =~ s/^$_$//m for split "\n", $default;
+ $decl =~ s/\n+/\n/g;
+
+ my $prefix = "html.$theme";
+ my ($first_line) = $decl =~ /([^{]*){/;
+ $first_line =~ s/(,\s+)/$1 $prefix /g;
+ $first_line = "$prefix $first_line";
+ $decl =~ s/([^{]*){/$first_line\{/;
+ $decl
+ }
+
sub make_css {
- my %css;
- $css{common} .= read_file $_ for <css/*.css>;
+ my $css = join '', map { read_file $_ } <css/*.css>;
- my (%themes, $rndtheme);
+ my (%themes);
for (<css/themes/*>) {
- ($rndtheme) = m,themes/(.*)\.css,;
- $themes{$rndtheme} = read_css_into_blocks $_;
+ my ($theme) = m,themes/(.*)\.css,;
+ $themes{$theme} = read_css_into_blocks $_;
}
+ my @themes = sort grep { $_ ne $default_theme } keys %themes;
while (grep { scalar @$_ } values %themes) {
my %blocks = map { $_ => (shift @{$themes{$_}}) // '' } keys %themes;
- if (grep { $_ ne $blocks{$rndtheme} } values %blocks) {
- $css{$_} .= $blocks{$_} for keys %themes;
- } else {
- $css{common} .= $blocks{$rndtheme};
- }
+ $css .= $blocks{$default_theme};
+ $css .= theme_prefix $_, $blocks{$_}, $blocks{$default_theme} for @themes
}
- write_gzfile "static/css/$_.css", minify $css{$_} for keys %css
+ write_gzfile "static/css/all.css", minify $css
}
sub make_js {
system 'cp', '-rp', 'js', 'static/';
}
- my $css_mtime = -M 'static/css/slate.css' // 0;
+my $sprite_mtime = -M 'static/logos/dark.svg' // 0;
+for (<logos/*>, <logos-light/*>) {
+ if (!$sprite_mtime || $sprite_mtime > -M) {
+ make_logos;
+ last
+ }
+}
+
+ my $css_mtime = -M 'static/css/all.css' // 0;
for (<css/*>, <css/themes/*>) {
if (!$css_mtime || $css_mtime > -M) {
make_css;
return unless $file;
my $hash = sha256_base64 scalar read_file $file;
s/integrity=".*"/integrity="sha256-$hash="/;
-} 'tmpl/skel.en'
+} 'tmpl/skel.en';
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link href="/static/css/common.css" rel="stylesheet" integrity="x">
- <link href="/static/css/cyborg.css" title="cyborg" rel="alternate stylesheet" integrity="x">
- <link href="/static/css/slate.css" title="slate" rel="stylesheet" integrity="x">
- <link href="/static/css/readable.css" title="readable" rel="alternate stylesheet" integrity="x">
+<link href="/static/favicon.png" rel="shortcut icon">
+ <link href="/static/css/all.css" rel="stylesheet" integrity="x">
<script src="/static/js/all.js" type="text/javascript" async defer integrity="x"></script>
<body>
<div class="container-fluid">
<nav role="navigation">
<ul class="nav nav-pills nav-justified">
-<li id="nav-home"><a href="/">Gruntmaster 6000</a>
+<li id="nav-home"><a href="/">Home</a>
<li id="nav-pb"><a href="/pb/">Problems</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" static="no"><a href="/account">Account</a>
+<li id="nav-about"><a href="/about">About / Help</a>
<li id="nav-contribute"><a href="/contribute">Contribute!</a>
</ul>
</nav>
+<img id="logo" class="center-block" src="/static/logos/dark.svg#logo-mindcoding" width="600px" height="152px">
+
<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="static" class="alert alert-info" static="yes">This is a static version of MindCoding, useful when the <a class="alert-link" href="https://mindcoding.ro/">regular version</a> is overloaded.</div>
<div id="result"></div>
<main id="content">Content goes here</main>
+<div id="webchat"><a href="http://webchat.oftc.net/?channels=%23mindcoding" target="_blank">Webchat</a></div>
+
+<div id="sponsors">
+</div>
+
<footer>
-Dilmom: Why don't you call your product the Gruntmaster 6000?<br>
-Dilbert: What kind of product do you see when you imagine a Gruntmaster 6000?<br>
-Dilmom: Well, it's a stripped-down version of the Gruntmaster 9000, of course. But it's software-upgradeable.
+<div class="row">
+<div class="col-md-6 text-center">
+<a href="http://www.societatea-hermes.ro"><img src="/static/logos/dark.svg#logo-hermes" alt="Societatea Hermes" width="164px" height="100px"></a>
+</div>
+
+<div class="col-md-6 text-center">
+<a href="http://www.facebook.com/mindcodingcluj"><img src="/static/logos/dark.svg#logo-facebook" alt="MindCoding Facebook page" width="100px" height="100px"></a>
+</div>
+</div>
</footer>