From 243c535dd2efc9d8126aa6c153292d8253239dd9 Mon Sep 17 00:00:00 2001
From: "Steinar H. Gunderson"
Date: Sun, 28 Jun 2015 02:10:55 +0200
Subject: [PATCH] Make engine URL, move source and similar values dynamic
instead of hard-coding them in the HTML.
Also change 'id' to 'engine' in a long-standing cleanup, and remove the unused author information.
---
config.pm | 6 ++++++
remoteglot.pl | 24 +++++++++++++++------
www/css/remoteglot.css | 3 +++
www/index.html | 9 ++++----
www/js/remoteglot.js | 49 +++++++++++++++++++++++++++++++++++++-----
5 files changed, 75 insertions(+), 16 deletions(-)
diff --git a/config.pm b/config.pm
index 3a57206..77fa74e 100644
--- a/config.pm
+++ b/config.pm
@@ -66,6 +66,12 @@ our @masters = (
# you probably need specific prior permission to use this.
our $tb_serial_key = undef;
+# Credits to show in the footer.
+our $engine_url = "http://www.stockfishchess.org/";
+our $engine_details = undef; # For hardware.
+our $move_source = "FICS";
+our $move_source_url = "http://www.freechess.org/";
+
# Postgres configuration.
our $dbistr = "dbi:Pg:dbname=remoteglot";
our $dbiuser = undef;
diff --git a/remoteglot.pl b/remoteglot.pl
index 5a5d4c5..d4a0d73 100755
--- a/remoteglot.pl
+++ b/remoteglot.pl
@@ -482,10 +482,9 @@ sub parse_ids {
my ($engine, @x) = @_;
while (scalar @x > 0) {
- if ($x[0] =~ /^(name|author)$/) {
- my $key = shift @x;
+ if ($x[0] eq 'name') {
my $value = join(' ', @x);
- $engine->{'id'}{$key} = $value;
+ $engine->{'id'}{'author'} = $value;
last;
}
@@ -738,10 +737,23 @@ sub output_json {
my $json = {};
$json->{'position'} = $pos_calculating->to_json_hash();
- $json->{'id'} = $engine->{'id'};
+ $json->{'engine'} = $engine->{'id'};
+ if (defined($remoteglotconf::engine_url)) {
+ $json->{'engine'}{'url'} = $remoteglotconf::engine_url;
+ }
+ if (defined($remoteglotconf::engine_details)) {
+ $json->{'engine'}{'details'} = $remoteglotconf::engine_details;
+ }
+ if (defined($remoteglotconf::move_source)) {
+ $json->{'move_source'} = $remoteglotconf::move_source;
+ }
+ if (defined($remoteglotconf::move_source_url)) {
+ $json->{'move_source_url'} = $remoteglotconf::move_source_url;
+ }
$json->{'score'} = long_score($info, $pos_calculating, '');
$json->{'short_score'} = short_score($info, $pos_calculating, '');
$json->{'plot_score'} = plot_score($info, $pos_calculating, '');
+ $json->{'using_lomonosov'} = defined($remoteglotconf::tb_serial_key);
$json->{'nodes'} = $info->{'nodes'};
$json->{'nps'} = $info->{'nps'};
@@ -875,7 +887,7 @@ sub output_json {
my $new_depth = $json->{'depth'} // 0;
my $new_nodes = $json->{'nodes'} // 0;
if (!defined($old_engine) ||
- $old_engine ne $json->{'id'}{'name'} ||
+ $old_engine ne $json->{'engine'}{'name'} ||
$new_depth > $old_depth ||
($new_depth == $old_depth && $new_nodes >= $old_nodes)) {
atomic_set_contents($filename, $encoded);
@@ -884,7 +896,7 @@ sub output_json {
$dbh->do('DELETE FROM scores WHERE id=?', undef, $id);
$dbh->do('INSERT INTO scores (id, plot_score, short_score, engine, depth, nodes) VALUES (?,?,?,?,?,?)', undef,
$id, $json->{'plot_score'}, $json->{'short_score'},
- $json->{'id'}{'name'}, $new_depth, $new_nodes);
+ $json->{'engine'}{'name'}, $new_depth, $new_nodes);
$dbh->commit;
}
}
diff --git a/www/css/remoteglot.css b/www/css/remoteglot.css
index 21a3a85..09b6b08 100644
--- a/www/css/remoteglot.css
+++ b/www/css/remoteglot.css
@@ -178,6 +178,9 @@ a.move:hover {
#linenav {
display: none;
}
+#lomonosov {
+ display: none;
+}
#games {
font-size: smaller;
diff --git a/www/index.html b/www/index.html
index 3c1eb85..72b017e 100644
--- a/www/index.html
+++ b/www/index.html
@@ -70,14 +70,13 @@
remoteglot
© 2007–2015 Steinar H. Gunderson.
- Chess analysis by Stockfish (main analysis: 20x2.3GHz Haswell-EP,
- multi-PV search: 16x2.4GHz Haswell-EP).
- Moves provided by FIDE.
- Hosting and multi-PV analysis hardware by Studentersamfundet i Trondhjem.
+ Chess analysis by Stockfish.
+
+ Hosting and additional analysis hardware by Studentersamfundet i Trondhjem.
JavaScript chessboard powered by chessboard.js
and chess.js.
Ding sound by Aiwha (CC-BY-3.0).
- 7-man Lomonosov tablebase lookup by ChessOK.
+ 7-man Lomonosov tablebase lookup by ChessOK.
diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js
index 0462252..673fd12 100644
--- a/www/js/remoteglot.js
+++ b/www/js/remoteglot.js
@@ -771,6 +771,50 @@ var update_board = function(current_data, display_data) {
headline = 'Analysis';
}
+ // Credits, where applicable. Note that we don't want the footer to change a lot
+ // when e.g. viewing history, so if any of these changed during the game,
+ // use the current one still.
+ if (current_data['using_lomonosov']) {
+ $("#lomonosov").show();
+ } else {
+ $("#lomonosov").hide();
+ }
+
+ // Credits: The engine name/version.
+ if (current_data['engine'] && current_data['engine']['name'] !== null) {
+ $("#engineid").text(current_data['engine']['name']);
+ }
+
+ // Credits: The engine URL.
+ if (current_data['engine'] && current_data['engine']['url']) {
+ $("#engineid").attr("href", current_data['engine']['url']);
+ } else {
+ $("#engineid").removeAttr("href");
+ }
+
+ // Credits: Engine details.
+ if (current_data['engine'] && current_data['engine']['details']) {
+ $("#enginedetails").text(" (" + current_data['engine']['details'] + ")");
+ } else {
+ $("#enginedetails").text("");
+ }
+
+ // Credits: Move source, possibly with URL.
+ if (current_data['move_source'] && current_data['move_source_url']) {
+ $("#movesource").text("Moves provided by ");
+ var movesource_a = document.createElement("a");
+ movesource_a.setAttribute("href", current_data['move_source_url']);
+ var movesource_text = document.createTextNode(current_data['move_source']);
+ movesource_a.appendChild(movesource_text);
+ var movesource_period = document.createTextNode(".");
+ document.getElementById("movesource").appendChild(movesource_a);
+ document.getElementById("movesource").appendChild(movesource_period);
+ } else if (current_data['move_source']) {
+ $("#movesource").text("Moves provided by " + current_data['move_source'] + ".");
+ } else {
+ $("#movesource").text("");
+ }
+
var last_move;
if (display_data) {
// Displaying some non-current position, pick out the last move
@@ -839,11 +883,6 @@ var update_board = function(current_data, display_data) {
update_clock();
- // The engine id.
- if (data['id'] && data['id']['name'] !== null) {
- $("#engineid").text(data['id']['name']);
- }
-
// The score.
if (data['score'] !== null) {
$("#score").text(data['score']);
--
2.39.2