Sign in to follow this  
Keenan

Stats.xml

Recommended Posts

Just a little thing I did up that might help server admins use the stats.xml that is generated by their server.

 

Fair warning, I probably don't have the time to offer in-depth support on this, but if anything goes wrong - please use the Github issue tracker.

 

https://github.com/xorith/wurmstats

 

Install will depend greatly on your setup, but essentially:

1) Ensure that stats.xml is readable from the Internet - you have to sort this out, but I might add some support for this later

2) Put stats.php on your web server (must support PHP obviously), change $pathToStats to your public stats.xml file. (Why? Because cross-domain security can be a fickle yet needed mistress.)

3) Put the entire html folder in your web root somewhere. I prefer the clone and link method, but anything will do. So long as the css and js subfolders are not changed.

4) Test! If you see a Error 500, that means your stats path in stats.php is wrong - check the console (F12 usually) and see what the error says.

 

If your web server and game server are on the same host, you can use stats.php to point to the stats.xml file directly without making it public.

  • Like 3

Share this post


Link to post
Share on other sites

Do you have a sample of the output??  What type of stats are displayed?

Share this post


Link to post
Share on other sites

I updated it a bit. Added a loading animation, made errors visible so it's easier to debug, and made mobile work spiffy too.

 

Essentially though, the css/html that comes with is more of a stock thing. The idea was to wrap that XML file into something that someone could easily build on/modify. That's primarily why I went with Knockout.js - I knew I could pretty easily create data binds, which are ways to tell an HTML tag what it should say. That means if you want an entirely different look, you just need to follow the example I included and it should work nicely.

 

If someone wants to fork/use this to build WordPress plugins, etc - by all means. If anything it was a nice distraction and it always helps to stay brushed up on some things :)

  • Like 1

Share this post


Link to post
Share on other sites

hey Keenan

Citadel told me i need this functions

Knockout.js
Moment.js
Jquery

 

where can i get them and where shall i upload it?

 

Thank you

Eject

Share this post


Link to post
Share on other sites
1 hour ago, Eject said:

hey Keenan

Citadel told me i need this functions

Knockout.js
Moment.js
Jquery

 

where can i get them and where shall i upload it?

 

Thank you

Eject

 

I probably wasn't very clear about it in the Readme on the repo - Everything is included. Those libraries are linked in the HTML file to CDNs (so you don't need to download them). The only two javascript files needed are provided under js/

 

All they should have to do is put the entire html/ folder somewhere.

Essentially, this is how I would do it:

 

git clone https://github.com/xorith/wurmstats.git wurmstats
cd PATH/TO/YOUR/WEBSITE
ln -s /PATH/TO/wurmstats/html wurmstats

This will create a link so if anything changes or is updated, you just go into the original wurmstats folder and do a 'git pull' and boom! Updated. You may want to do this a little differently if you're planning on modding things - maybe just ln -s the html/js folder so you get code updates, but not HTML updates. Either way.

 

Alternatively they can just copy it.

Share this post


Link to post
Share on other sites

thank you keenan

i have all files and folders uploaded and still get this message

 

Status: HTTP 500 Server Error: http://xxxxxxxxxxxxx/stats.xml is not readable.

 

i have no shell access to my webserver, any idea?

 

regards Eject

Share this post


Link to post
Share on other sites

For whatever reason the php file can't read the URL you are providing for stats. 

Share this post


Link to post
Share on other sites

Nice work Keenan. I prefer my wordpress plugin to read and interpret but only because I don't like the default way the wurm stats look hehe. Was very nice of you to take some time and do this for folks though!

Share this post


Link to post
Share on other sites
Just now, Xyp said:

Nice work Keenan. I prefer my wordpress plugin to read and interpret but only because I don't like the default way the wurm stats look hehe. Was very nice of you to take some time and do this for folks though!

 

I was thinking of making a plugin - but the entire purpose is to allow someone to reskin it easily. All you need are the data bindings, which might sound overly complicated - but you could literally copy and paste the "data-bind=" parts into any div, p, span, td, etc and get the same thing :)

 

Share this post


Link to post
Share on other sites

My plugin is public, its just buried in this tools thread from way back in Nov I think.

 

It just basically reads the xml and outputs into list format, so some css for the list and you are set for customizing it.

I should probably update it since I did add the ability for my site to show the pvp players on the connected pvp server. Which is again easy but some people may need that.

 

Edited by Xyp

Share this post


Link to post
Share on other sites

Not even sure if anyone is actually using this, but I've updated a few times since I made this post.

 

Notable changes:

  • Included support for <weather></weather> (This will be coming to WU with the next beta)
  • Included support for detecting offline servers in the server list.
  • Added an auto-refresh option.
  • Switched to using RequireJS and moved all dependencies to loader.js.
  • Added support for timezones and detecting user timezone for a more accurate date representation

 

Essentially, this is now a one-liner with data bindings.

<script data-main="js/loader" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>

That will include the functionality. You can then use the data binding section of the Readme.md (here: https://github.com/xorith/wurmstats#data-binds) and the examples I've included in the original stats.html to build your own usage out.

You can extend on this as well. Perhaps you want/need to truncate server names or whatever - just take a look at Knockout.js and follow some examples on how the data bindings work. 

 

One more thing to note, in your server's wurm.ini file there is a WEB_PATH= line. This is the path where it writes the stats.html and stats.xml files. If you're having issues making your stats.xml readable, this is might help with that.

You should never make your server folder readable by the Internet! Never! Ever! Don't even think about it! Don't do it!

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this