Masterserver show privs and js autoload
authorproller <proller@github.com>
Mon, 4 Nov 2013 00:55:35 +0000 (04:55 +0400)
committerproller <proller@github.com>
Mon, 4 Nov 2013 00:56:39 +0000 (04:56 +0400)
src/serverlist.cpp
util/master/README.md
util/master/index.html
util/master/list.js
util/master/master.cgi
util/master/servers.jst
util/master/style.css

index fb5bc9c87d6b21e32cd7a6a089561b40020cc8eb..fa2ddad1579d35d12434e01ed7cb94ef17d5b2e0 100644 (file)
@@ -222,6 +222,7 @@ void sendAnnounce(std::string action, const std::vector<std::string> & clients_n
 
        if(server["action"] == "start") {
                server["dedicated"]     = g_settings->get("server_dedicated");
+               server["privs"]         = g_settings->get("default_privs");
                server["rollback"]      = g_settings->getBool("enable_rollback_recording");
                server["liquid_finite"] = g_settings->getBool("liquid_finite");
                server["mapgen"]        = g_settings->get("mg_name");
index 4730dc26977c8e505edf4b40674df53950d7d0fc..232986deb9a830f2d57f9608d43655eb1c89f2f2 100644 (file)
@@ -17,8 +17,18 @@ Then install doT.js and it's dependencies:
     $ cd doT
     $ npm install
 
+Or by npm:
+    $ npm install dot commander mkdirp
+
 And finally compile the template:
     $ cd ~/minetest/util/master
     $ ~/code/doT/bin/dot-packer -s . -d .
+or
+    $ ./node_modules/dot/bin/dot-packer -s . -d .
+
 
+Embending to any page
+----------------------
 
+<script>var master = {root: 'http://servers.minetest.net/', limit:10, clients_min:1, no_flags:1, no_ping:1, no_uptime:1};</script>
+<script src="http://servers.minetest.net/list.js"></script>
index 339ebe565bc6700fc94036f2cc26fa2eb7b7a617..48a973eac90f9a4e2a9f74d4522cce2636313015 100644 (file)
@@ -3,13 +3,9 @@
 <head>
        <meta charset="utf-8">
        <title>Minetest server list</title>
-       <link rel="stylesheet" href="style.css" />
-       <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
-       <script src="servers.js"></script>
-       <script src="list.js"></script>
 </head>
 <body>
        <div id="server_list"></div>
 </body>
 </html>
-
+<script src="list.js"></script>
index ee4568e249f1a26cffcaee70746a271d7423a250..a47111342d8ea85efa886a8c48a12b5694932f89 100644 (file)
@@ -35,7 +35,7 @@ function addressString(server) {
        var str = '<span'
        if (shortStr.length > 25) {
                shortStr = shortStr.substr(0, 23) + "&hellip;";
-               str += ' class="tooltip" title="' + addrStr + '"'
+               str += ' class="mts_tooltip" title="' + addrStr + '"'
        }
        if (server.port != 30000)
                shortStr += ':' + server.port;
@@ -48,14 +48,14 @@ function tooltipString(str, maxLen) {
        var ret = '<span';
        if (shortStr.length > maxLen) {
                shortStr = shortStr.substr(0, maxLen - 2) + "&hellip;";
-               ret += ' class="tooltip" title="' + str + '"';
+               ret += ' class="mts_tooltip" title="' + str + '"';
        }
        return ret + '>' + shortStr + '</span>';
 }
 
 function hoverList(name, list) {
        if (!list || list.length == 0) return '';
-       var str = '<div class="hover_list">'
+       var str = '<div class="mts_hover_list">'
        str += name + '(' + list.length + ')<br />';
        for (var i in list) {
                str += escapeHTML(list[i]) + '<br />';
@@ -72,9 +72,19 @@ function get() {
        jQuery.getJSON(master.url, draw);
 }
 
-if (!master.no_refresh) {
-       setInterval(get, 60 * 1000);
+function loaded(){
+       if (!master.no_refresh) {
+               setInterval(get, 60 * 1000);
+       }
+       get();
 }
 
-get();
+// https://github.com/pyrsmk/toast
+this.toast=function(){var e=document,t=e.getElementsByTagName("head")[0],n=this.setTimeout,r="createElement",i="appendChild",s="addEventListener",o="onreadystatechange",u="styleSheet",a=10,f=0,l=function(){--f},c,h=function(e,r,i,s){if(!t)n(function(){h(e)},a);else if(e.length){c=-1;while(i=e[++c]){if((s=typeof i)=="function"){r=function(){return i(),!0};break}if(s=="string")p(i);else if(i.pop){p(i[0]),r=i[1];break}}d(r,Array.prototype.slice.call(e,c+1))}},p=function(n,s){++f,/\.css$/.test(n)?(s=e[r]("link"),s.rel=u,s.href=n,t[i](s),v(s)):(s=e[r]("script"),s.src=n,t[i](s),s[o]===null?s[o]=m:s.onload=l)},d=function(e,t){if(!f)if(!e||e()){h(t);return}n(function(){d(e,t)},a)},v=function(e){if(e.sheet||e[u]){l();return}n(function(){v(e)},a)},m=function(){/ded|co/.test(this.readyState)&&l()};h(arguments)};
 
+toast('style.css', 'servers.js', function() {
+       if (typeof(jQuery)!='undefined')
+               loaded();
+       else
+               toast('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', loaded);
+});
index 6dbf83fca03b127a398f41ccab21f0d3e76a8b54..f48816c5db47f3d0c547dd388c398b3040bfca53 100755 (executable)
@@ -241,7 +241,7 @@ sub request (;$) {
             $param->{clients_top} = $old->{clients_top} if $old->{clients_top} > $param->{clients};
             $param->{clients_top} ||= $param->{clients} || 0;
             # params reported once on start, must be same as src/serverlist.cpp:~221 if(server["action"] == "start") { ...
-            for (qw(dedicated rollback liquid_finite mapgen mods)) {
+            for (qw(dedicated rollback liquid_finite mapgen mods privs)) {
                 $param->{$_} ||= $old->{$_} if $old->{$_} and !($param->{action} ~~ 'start');
             }
             $param->{pop_n} = $old->{pop_n} + 1;
index ff17c2d109235bb614829166643d64bee51c5c47..5031f083d642fbb9712cdb009ebc2f60aae27182 100644 (file)
                        {{=addressString(server)}}
                </td>{{?}}
                {{? !master.no_clients}}
-               <td class="clients{{? server.clients_list && server.clients_list.length > 0}} hover_list_text{{?}}">
+               <td class="clients{{? server.clients_list && server.clients_list.length > 0}} mts_hover_list_text{{?}}">
                        {{=server.clients}}/{{=server.clients_max}} {{=server.clients_top}}
                        {{=hoverList("Clients", server.clients_list)}}
                </td>{{?}}
                {{? !master.no_version}}
-               <td class="version{{? server.mods && server.mods.length > 0}} hover_list_text{{?}}">
+               <td class="version{{? server.mods && server.mods.length > 0}} mts_hover_list_text{{?}}">
                        {{=escapeHTML(server.version)}}, {{=escapeHTML(server.gameid)}},&nbsp;
                        {{=escapeHTML(server.mapgen || '?')}}
                        {{=hoverList("Mods", server.mods)}}
@@ -47,7 +47,7 @@
                        {{=tooltipString(server.description, 50)}}
                </td>{{?}}
                {{? !master.no_flags}}
-               <td class="flags">
+               <td class="flags" {{? server.privs}}title="{{=escapeHTML(server.privs)}}"{{?}}>
                        {{=server.creative ? 'Cre ' : ''}}
                        {{=server.dedicated ? 'Ded ' : ''}}
                        {{=server.damage ? 'Dmg ' : ''}}
index 47d58029bc89f88294ee8123cf1ab1c2fd00cf9f..76a4f998d1d78c99cee9c4ded8784c1831f84e80 100644 (file)
@@ -11,7 +11,7 @@
        border: 1px solid gray;
 }
 
-.hover_list{
+.mts_hover_list{
        visibility: hidden;
        border: gray solid 1px;
        position: absolute;
        padding: 0.5em;
 }
 
-td:hover .hover_list {
+td:hover .mts_hover_list {
        visibility: visible;
 }
 
-.hover_list_text, .tooltip {
+.mts_hover_list_text, .mts_tooltip {
        text-decoration: underline;
        text-decoration-style: dashed;
 }
-