Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to use a static HTML file instead of the hardcoded MUDURL redirect. #1273

Merged
merged 1 commit into from Apr 3, 2019

Conversation

Projects
None yet
3 participants
@grapenut
Copy link
Contributor

grapenut commented Dec 3, 2018

This PR adds a configuration option 'index_html_file' which is commented out by default in mushcnf.dst. Setting the option to the path name of a static HTML file (game/txt/index.html by default) allows the game to use it as the default response for HTTP requests instead of the hardcoded redirect to MUDURL. If the option is blank or the file does not exist, we fall back to the original hardcoded redirect page. This uses the existing fcache_*() functions that are already used to load and serve up files like connect.txt/connect.html. This allows a game administrator to use a nicer redirect page or serve a small index.html for a web client that loads additional assets from the main website.

@grapenut

This comment has been minimized.

Copy link
Contributor Author

grapenut commented Dec 3, 2018

Here is an example in action with a custom index.html that loads the MUSH Portal web client. You can either point your favorite MUSH client to node.grapenut.org:8000 like normal, or point your browser to http://node.grapenut.org:8000 to the get custom index.html that loads all of the web client assets from the public mushportal.com server.

# Static HTML landing page to show when someone accesses the MUSH
# port using a web browser and no http_handler is defined.
# OPTIONAL
# index_html_file txt/index.html

This comment has been minimized.

Copy link
@HarryCordewener

HarryCordewener Dec 3, 2018

Contributor
  • What is the expected documentation if you have both a mudurl and this? I feel documentation could be improved here.
  • The idea of serving up a static page instead of using an http_handler seems an error in logic as-is. If anything, this could serve as a 'default' page when http_handler fails, or something of the like.

This comment has been minimized.

Copy link
@grapenut

grapenut Dec 3, 2018

Author Contributor

This is the same behavior as before. When there is no http_handler to handle requests it builds a hardcoded page and dumps that back on HTTP requests. The only thing that mudurl determines is whether or not that hardcoded page contains a link to mudurl. In this PR we we just dump a static index.html if it's defined, otherwise build the hardcoded page as we normally would.

safe_format(buf, &bp,
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset:iso-8859-1\r\n"
"Pragma: no-cache\r\n"
"Connection: Close\r\n"
"\r\n"
"\r\n");

This comment has been minimized.

Copy link
@HarryCordewener

HarryCordewener Dec 3, 2018

Contributor

Can this be added to a test?

This comment has been minimized.

Copy link
@grapenut

grapenut Dec 3, 2018

Author Contributor

This was not a bug fix. The original code builds the whole page in one function call like this with strings stacked together. I split it into 2 function calls, one for headers and one for the page if needed.

@grapenut grapenut changed the title Serve a static HTML file instead of the hardcoded MUDURL redirect. Option to use a static HTML file instead of the hardcoded MUDURL redirect. Mar 21, 2019

@shawnw shawnw merged commit 8084058 into pennmush:master Apr 3, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.