• Print

Author Topic: New MOTD Generator System  (Read 12 times)

0 Members and 1 Guest are viewing this topic.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
New MOTD Generator System
« on: December 13, 2015, 01:34:19 am »
Hey everyone,

After some discussion about what to do with ulx_motd.txt and our workshop installation a few weeks back, I think it was Mr. President that had the idea of just having some minimal configuration and setup, then have the default MOTD be generated on the fly. So, I started work on implementing this.

Then I may have gotten a teensy bit carried away. :P

I've just committed all of my latest code for MOTD generation to a new branch, and I'd love to have some testing and feedback for whatever you guys feel is necessary:
https://github.com/TeamUlysses/ulx/tree/motd-generator

The general idea is this:
 - ulx_showmotd can be disabled, or set to a URL- This functionality has not changed whatsoever.
 - Otherwise, instead of sending ulx_motd.txt, some configuration data is sent to the client, and the client will generate the HTML to be displayed.
 - These configuration settings include content and some general font/color styling.
 - Content generation is mostly static (what they put in is what will display), except for two special types: one that lists workshop/regular addons installed, and another that can list all of the users in specified group(s).
 - Users with customized HTML in ulx_motd.txt must now find a place to host their HTML file (Likely possible with fastDL, but I'm not sure), or use the new HTML generator.
 - All settings can be configured within XGUI and saved/previewed on the fly. As with all XGUI things, settings are automatically propagated to all admins as necessary, no "refresh" is needed.

Everything is currently complete and ready to go, except that only the style settings are currently editable in XGUI. The content settings will take only a little bit more work to implement, and I expect to have it done in the next few days, time permitting.

---

Below is everything you may (or may not) want to know about it without having to fire up Gmod. Again, I'd love feedback for any part of this, especially design, layout, and wording changes for the default content.

Here's my mockup for the HTML and basic design, which is fairly close to the final result:
https://dl.dropboxusercontent.com/u/3804211/motd.html

Here's the initial settings for the generator:
Code: [Select]
; These settings describe the default configuration and text to be shown on the MOTD. This only applies if ulx showMotd is set to 1.
; All style configuration is set, and the values must be valid CSS.
; Under info, you may have as many sections as you like. Valid types include "text", "ordered_list", "list".
; Special type "mods" will automatically list workshop and regular addons in an unordered list.
; Special type "admins" will automatically list all users within the groups specified in contents.
; For an example of all of these items, please see the default file generated in ulx\lua\data.lua

"info"
{
"description" "Welcome to our server. Enjoy your stay!"
{
"title" "About This Server"
"type" "text"
"contents"
{
"This server is running ULX."
"To edit this default MOTD, open XGUI->Settings->Server->ULX MOTD, or edit data\ulx\motd.txt."
}
}
{
"title" "Rules"
"type" "ordered_list"
"contents"
{
"DON'T MESS WITH OTHER PLAYERS' STUFF. If they want help, they'll ask!"
"Don't spam."
"Have fun."
}
}
{
"title" "Reporting Rulebreakers"
"type" "list"
"contents"
{
"Contact an available admin on this server and let them know."
"Use @ before typing a chat message to send it to admins."
"If no admin is available, note the players name and the current time, then let an admin know as soon as they are available."
}
}
{
"title" "Installed Addons"
"type" "mods"
}
{
"title" "Our Admins"
"type" "admins"
"contents"
{
"superadmin"
"admin"
}
}
}
"style"
{
"borders"
{
"border_color" "#000000"
"border_thickness" "2px"
}
"colors"
{
"background_color" "#dddddd"
"header_color" "#82a0c8"
"header_text_color" "#ffffff"
"section_text_color" "#000000"
"text_color" "#000000"
}
"fonts"
{
"server_name"
{
"family" "Impact"
"size" "32px"
"weight" "normal"
}
"subtitle"
{
"family" "Impact"
"size" "20px"
"weight" "normal"
}
"section_title"
{
"family" "Impact"
"size" "26px"
"weight" "normal"
}
"regular"
{
"family" "Tahoma"
"size" "12px"
"weight" "normal"
}
}
}

Here's the actual rendered result using the above default file on my server:
https://dl.dropboxusercontent.com/u/3804211/motd_generated.html

Here's a list of fonts and font weights I've provided for the XGUI editor to give users some options they can start working with:
Code: [Select]
local fontWeights = { "normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900", "lighter", "bolder" }
local commonFonts = { "Arial", "Arial Black", "Calibri", "Candara", "Cambria", "Consolas", "Courier New", "Fraklin Gothic Medium", "Futura", "Georgia", "Helvetica", "Impact", "Lucida Console", "Segoe UI", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana" }

And some screenshots of the XGUI settings:
http://ulyssesmod.net/xgui/motd_generator_1.png
http://ulyssesmod.net/xgui/motd_generator_2.png
http://ulyssesmod.net/xgui/motd_generator_3.png

Here's some relevant code bits as well, if you're interested:
Core templates and renderer: https://github.com/TeamUlysses/ulx/blob/motd-generator/lua/ulx/modules/cl/motdmenu.lua#L51-L242
Code that grabs the list of addons/admins to be displayed: https://github.com/TeamUlysses/ulx/blob/motd-generator/lua/ulx/modules/sh/menus.lua#L41-L91
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: New MOTD Generator System
« Reply #1 on: December 13, 2015, 06:25:40 am »
No Comic Sans? Come on!

Nice work, Stickly. You will make many server owners very happy. :)

Hopefully people won't find this too complicated... but the auto-generating portions mean that most people probably won't bother to change it.

I made a quick change which escapes '<' and '>' in the user content. I think that should stop any HTML injection.
Experiencing God's grace one day at a time.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: New MOTD Generator System
« Reply #2 on: December 14, 2015, 06:50:03 am »
I definitely agree with sanitizing user input- but for this, should we even bother? It would be nice for formatting to be available if needed, so a user could add and other stuff as needed. If they decide to do really complicated stuff and break the style or something.. well, they should be making their own webpage. :P Also, I think I'll add an extra permission to give access to the motd generator, so that access can be limited as much as possible to prevent vandalizing. What do you think?

And Comic Sans MS didn't work on Awesomium (assuming I typed it in right), otherwise it totally would have been on that list.  ;D
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

  • Print