Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: move all helpers into a helpers folder
This hopefully avoids the LGTM warning that "import click" and "import .click" are the same.
- Loading branch information
Showing
12 changed files
with
74 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import click | ||
import flask | ||
import requests | ||
import urllib | ||
|
||
from .click import click_additional_options | ||
from ..app import app | ||
|
||
_frontend_url = None | ||
|
||
|
||
@click_additional_options | ||
@click.option( | ||
"--frontend-url", | ||
help="Frontend URL (this server).", | ||
default="https://bananas.openttd.org", | ||
show_default=True, | ||
metavar="URL", | ||
) | ||
def click_frontend_url(frontend_url): | ||
global _frontend_url | ||
_frontend_url = frontend_url | ||
|
||
|
||
def template(*args, **kwargs): | ||
if "message" in kwargs: | ||
kwargs.setdefault("messages", []).append(kwargs["message"]) | ||
|
||
response = flask.make_response(flask.render_template(*args, **kwargs)) | ||
response.headers["Content-Security-Policy"] = "default-src 'self'" | ||
return response | ||
|
||
|
||
def external_url_for(*args, **kwargs): | ||
return _frontend_url + flask.url_for(*args, **kwargs) | ||
|
||
|
||
def redirect(*args, **kwargs): | ||
return flask.redirect(flask.url_for(*args, **kwargs)) | ||
|
||
|
||
def not_found(): | ||
flask.abort(404) | ||
|
||
|
||
def api_error(): | ||
flask.abort(500) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters