pokken: add frontend stub
This commit is contained in:
parent
bf6c7d39f5
commit
68e25b9c5e
@ -71,8 +71,9 @@ class FrontendServlet(resource.Resource):
|
||||
game_fe = game_mod.frontend(cfg, self.environment, config_dir)
|
||||
self.game_list.append({"url": game_dir, "name": game_fe.nav_name})
|
||||
fe_game.putChild(game_dir.encode(), game_fe)
|
||||
except:
|
||||
raise
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to import frontend from {game_dir} because {e}")
|
||||
|
||||
self.environment.globals["game_list"] = self.game_list
|
||||
self.putChild(b"gate", FE_Gate(cfg, self.environment))
|
||||
|
@ -1,8 +1,10 @@
|
||||
from titles.pokken.index import PokkenServlet
|
||||
from titles.pokken.const import PokkenConstants
|
||||
from titles.pokken.database import PokkenData
|
||||
from .index import PokkenServlet
|
||||
from .const import PokkenConstants
|
||||
from .database import PokkenData
|
||||
from .frontend import PokkenFrontend
|
||||
|
||||
index = PokkenServlet
|
||||
database = PokkenData
|
||||
game_codes = [PokkenConstants.GAME_CODE]
|
||||
current_schema_version = 1
|
||||
frontend = PokkenFrontend
|
||||
|
33
titles/pokken/frontend.py
Normal file
33
titles/pokken/frontend.py
Normal file
@ -0,0 +1,33 @@
|
||||
import yaml
|
||||
import jinja2
|
||||
from twisted.web.http import Request
|
||||
from os import path
|
||||
|
||||
from core.frontend import FE_Base
|
||||
from core.config import CoreConfig
|
||||
from .database import PokkenData
|
||||
from .config import PokkenConfig
|
||||
from .const import PokkenConstants
|
||||
|
||||
|
||||
class PokkenFrontend(FE_Base):
|
||||
def __init__(
|
||||
self, cfg: CoreConfig, environment: jinja2.Environment, cfg_dir: str
|
||||
) -> None:
|
||||
super().__init__(cfg, environment)
|
||||
self.data = PokkenData(cfg)
|
||||
self.game_cfg = PokkenConfig()
|
||||
if path.exists(f"{cfg_dir}/{PokkenConstants.CONFIG_NAME}"):
|
||||
self.game_cfg.update(
|
||||
yaml.safe_load(open(f"{cfg_dir}/{PokkenConstants.CONFIG_NAME}"))
|
||||
)
|
||||
self.nav_name = "Pokken"
|
||||
|
||||
def render_GET(self, request: Request) -> bytes:
|
||||
template = self.environment.get_template(
|
||||
"titles/pokken/frontend/pokken_index.jinja"
|
||||
)
|
||||
return template.render(
|
||||
title=f"{self.core_config.server.name} | {self.nav_name}",
|
||||
game_list=self.environment.globals["game_list"],
|
||||
).encode("utf-16")
|
4
titles/pokken/frontend/pokken_index.jinja
Normal file
4
titles/pokken/frontend/pokken_index.jinja
Normal file
@ -0,0 +1,4 @@
|
||||
{% extends "core/frontend/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>Pokken</h1>
|
||||
{% endblock content %}
|
Loading…
Reference in New Issue
Block a user