diff --git a/README.md b/README.md index 3a825e4..c167b53 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ First install node.js, e.g.: Then install doT.js and its dependencies: - $ npm install dot 'commander@12.0.0' mkdirp + $ npm install dot 'commander@11.1.0' mkdirp And finally compile the template: @@ -32,12 +32,12 @@ Embedding the server list in a page ... ... @@ -46,9 +46,8 @@ Embedding the server list in a page ...
... + - - Setting up the server --------------------- @@ -61,19 +60,16 @@ Setting up the server 2. Install required Python packages: - # You might have to use pip3 if your system defaults to Python 2 - pip install -r requirements.txt + pip3 install -r requirements.txt - 3. If using in production, install uwsgi and it's python plugin: + 3. If using in production, install uwsgi and its python plugin: pacman -S uwsgi uwsgi-plugin-python # OR: - apt-get install uwsgi uwsgi-plugin-python - # OR: - pip install uwsgi + apt-get install uwsgi uwsgi-plugin-python3 4. Configure the server by adding options to `config.py`. - See `config-example.py` for defaults. + See `config-example.py` for defaults. 5. Start the server: @@ -83,8 +79,8 @@ Setting up the server $ # Then configure according to http://flask.pocoo.org/docs/deploying/uwsgi/ 7. (optional) Configure the proxy server, if any. You should make the server - load static files directly from the static directory. Also, `/list` - should be served from `list.json`. Example for nginx: + load static files directly from the static directory. Also, `/list` + should be served from `list.json`. Example for nginx: root /path/to/server/static; rewrite ^/list$ /list.json; @@ -94,35 +90,32 @@ Setting up the server } Setting up the server (Apache version) ---------------------- +-------------------------------------- If you wish to use Apache to host the server list, do steps 1-2, 4, above. Additionally install/enable mod_wsgi and an Apache site config like the following: - # This config assumes you have the server list at DocumentRoot. - # Visitors to the server list in this config would visit http://local.server/ and - # apache would serve up the output from server.py. Static resources would be served - # from http://local.server/static. + # This config assumes you have the server list at DocumentRoot. + # Visitors to the server list in this config would visit http://local.server/ and + # apache would serve up the output from server.py. Static resources would be served + # from http://local.server/static. - # Where are the minetest-server files located? - DocumentRoot /var/games/minetest/serverlist + # Where are the minetest-server files located? + DocumentRoot /var/games/minetest/serverlist - # Serve up server.py at the root of the URL. - WSGIScriptAlias / /var/games/minetest/serverlist/server.py + # Serve up server.py at the root of the URL. + WSGIScriptAlias / /var/games/minetest/serverlist/server.py - # The name of the function that we call when we invoke server.py - WSGICallableObject app + # The name of the function that we call when we invoke server.py + WSGICallableObject app - # These options are necessary to enable Daemon mode. Without this, you'll have strange behavior - # with servers dropping off your list! You can tweak threads as needed. See mod_wsgi documentation. - WSGIProcessGroup minetest-serverlist - WSGIDaemonProcess minetest-serverlist threads=2 + # These options are necessary to enable Daemon mode. Without this, you'll have strange behavior + # with servers dropping off your list! You can tweak threads as needed. See mod_wsgi documentation. + WSGIProcessGroup minetest-serverlist + WSGIDaemonProcess minetest-serverlist threads=2 - - - Require all granted - - - + + Require all granted + License ------- diff --git a/static/list.js b/static/list.js index 3bf05c8..3642a6d 100644 --- a/static/list.js +++ b/static/list.js @@ -1,16 +1,21 @@ var master; -if (!master) master = {}; -if (typeof(master.root) == 'undefined') master.root = window.location.href; -if (!master.output) master.output = '#server_list'; -if (!master.list) master.list = "list"; -if (!master.list_root) master.list_root = master.root; -if (!master.list_url) master.list_url = master.list_root + master.list; +if (!master) + master = {}; +if (!master.root) + master.root = window.location.href; +if (!master.list) + master.list = "list"; +if (!master.list_root) + master.list_root = master.root; +if (!master.list_url) + master.list_url = master.list_root + master.list; master.cached_json = null; // Utility functions used by the templating code function humanTime(seconds) { - if (typeof(seconds) != "number") return '?'; + if (typeof(seconds) != "number") + return '?'; var conv = { y: 31536000, d: 86400, @@ -26,25 +31,25 @@ function humanTime(seconds) { } function escapeHTML(str) { - if(!str) return str; + if (!str) + return str; return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } function addressString(server) { - var isIPv6 = server.address.indexOf(":") != -1; - var addrStr = (isIPv6 ? '[' : '') + - escapeHTML(server.address) + - (isIPv6 ? ']' : ''); + var addrStr = server.address; + if (addrStr.indexOf(':') != -1) + addrStr = '[' + addrStr + ']'; var shortStr = addrStr; addrStr += ':' + server.port; var str = ' 25) { - shortStr = shortStr.substr(0, 23) + "…"; - str += ' title="' + addrStr + '"' + if (shortStr.length > 26) { + shortStr = shortStr.substring(0, 25) + "\u2026"; + str += ' title="' + escapeHTML(addrStr) + '"' } if (server.port != 30000) shortStr += ':' + server.port; - return str + '>' + shortStr + ''; + return str + '>' + escapeHTML(shortStr) + ''; } function tooltipString(str) { @@ -53,30 +58,36 @@ function tooltipString(str) { } function hoverList(name, list) { - if (!list || list.length == 0) return ''; + if (!list || list.length == 0) + return ''; var str = '
' - str += '' + name + ' (' + list.length + ')
'; + str += '' + escapeHTML(name) + ' (' + list.length + ')
'; for (var i in list) { str += escapeHTML(list[i]) + '
'; } return str + '
'; } -function hoverString(name, string) { - if (!string) return ''; +function hoverString(name, str) { + if (!str) + return ''; + if (typeof(str) != 'string') + str = str.toString(); return '
' - + '' + name + ':
' - + escapeHTML(string) + '
' + + '' + escapeHTML(name) + ':
' + + escapeHTML(str) + '
' + '
'; } function constantWidth(str, width) { - return '' + str + ''; + if (typeof(str) != 'string') + str = str.toString(); + return '' + escapeHTML(str) + ''; } // Code that fetches & displays the actual list -function draw(json) { +master.draw = function(json) { if (json == null) return; @@ -95,27 +106,32 @@ function draw(json) { } var html = window.render.servers(json); - jQuery(master.output).html(html); + jQuery('#server_list').html(html); - jQuery('.proto_select', master.output).on('change', function(e) { + jQuery('.proto_select', '#server_list').on('change', function(e) { master.proto_range = e.target.value; - draw(master.cached_json); // re-render + master.draw(master.cached_json); // re-render }); -} +}; -function get() { +master.get = function() { jQuery.getJSON(master.list_url, function(json) { master.cached_json = json; - draw(json); + master.draw(json); }); -} +}; -function loaded(){ - if (!master.no_refresh) { - setInterval(get, 60 * 1000); - } - get(); -} +master.loaded = function() { + if (!master.no_refresh) + setInterval(master.get, 60 * 1000); + master.get(); +}; + +master.showAll = function() { + delete master.min_clients; + delete master.limit; + master.get(); +}; // https://github.com/pyrsmk/toast @@ -123,8 +139,8 @@ this.toast=function(){var e=document,t=e.getElementsByTagName("head")[0],n=this. toast(master.root + 'style.css', master.root + 'servers.js', function() { if (typeof(jQuery) != 'undefined') - return loaded(); + return master.loaded(); else - toast('//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js', loaded); + toast('//ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js', master.loaded); }); diff --git a/static/servers.jst b/static/servers.jst index 5d5e7e6..eb6e34c 100644 --- a/static/servers.jst +++ b/static/servers.jst @@ -16,7 +16,7 @@ {{? !master.no_address}}Address[:Port]{{?}} {{? !master.no_clients}}Players / Max{{? !master.no_avgtop}}
Average / Top{{?}}{{?}} - {{? !master.no_version}}Version, Game[, Mapgen]{{?}} + {{? !master.no_version}}Version, Game, Mapgen{{?}} {{? !master.no_name}}Name{{?}} {{? !master.no_description}}Description{{?}} {{? !master.no_flags}}Flags{{?}} @@ -47,7 +47,7 @@ {{? !master.no_name}} {{? server.url}} - {{=tooltipString(server.name)}} + {{=tooltipString(server.name)}} {{??}} {{=tooltipString(server.name)}} {{?}} @@ -63,8 +63,6 @@ {{=server.damage ? 'Dmg ' : ''}} {{=server.pvp ? 'PvP ' : ''}} {{=server.password ? 'Pwd ' : ''}} - {{=server.rollback ? 'Rol ' : ''}} - {{=server.can_see_far_names ? 'Far ' : ''}} {{?}} {{? !master.no_uptime}} @@ -79,5 +77,5 @@ {{? master.min_clients || master.limit}} - Show more... + Show all... {{?}} diff --git a/static/style.css b/static/style.css index e578499..0599f5a 100644 --- a/static/style.css +++ b/static/style.css @@ -50,7 +50,7 @@ max-width: 32ch; } #server_list td.description { - max-width: 64ch; + max-width: 70ch; } .mts_hover_list {