Ongeki template start

This commit is contained in:
Wanich Keatkajonjumroen 2023-08-28 03:18:56 +09:00
parent d4ea3bc12a
commit 2a52e391d6
4 changed files with 47 additions and 0 deletions

1
core/json.json Normal file
View File

@ -0,0 +1 @@
{'chuni': <module 'titles.chuni' from 'D:\\projects\\artemis\\titles\\chuni\\__init__.py'>, 'cm': <module 'titles.cm' from 'D:\\projects\\artemis\\titles\\cm\\__init__.py'>, 'cxb': <module 'titles.cxb' from 'D:\\projects\\artemis\\titles\\cxb\\__init__.py'>, 'diva': <module 'titles.diva' from 'D:\\projects\\artemis\\titles\\diva\\__init__.py'>, 'idz': <module 'titles.idz' from 'D:\\projects\\artemis\\titles\\idz\\__init__.py'>, 'mai2': <module 'titles.mai2' from 'D:\\projects\\artemis\\titles\\mai2\\__init__.py'>, 'ongeki': <module 'titles.ongeki' from 'D:\\projects\\artemis\\titles\\ongeki\\__init__.py'>, 'pokken': <module 'titles.pokken' from 'D:\\projects\\artemis\\titles\\pokken\\__init__.py'>, 'sao': <module 'titles.sao' from 'D:\\projects\\artemis\\titles\\sao\\__init__.py'>, 'wacca': <module 'titles.wacca' from 'D:\\projects\\artemis\\titles\\wacca\\__init__.py'>}

View File

@ -2,9 +2,11 @@ from titles.ongeki.index import OngekiServlet
from titles.ongeki.const import OngekiConstants from titles.ongeki.const import OngekiConstants
from titles.ongeki.database import OngekiData from titles.ongeki.database import OngekiData
from titles.ongeki.read import OngekiReader from titles.ongeki.read import OngekiReader
from titles.ongeki.frontend import OngekiFrontend
index = OngekiServlet index = OngekiServlet
database = OngekiData database = OngekiData
reader = OngekiReader reader = OngekiReader
frontend = OngekiFrontend
game_codes = [OngekiConstants.GAME_CODE] game_codes = [OngekiConstants.GAME_CODE]
current_schema_version = 5 current_schema_version = 5

40
titles/ongeki/frontend.py Normal file
View File

@ -0,0 +1,40 @@
import yaml
import jinja2
from twisted.web.http import Request
from os import path
from twisted.web.server import Session
from core.frontend import FE_Base, IUserSession
from core.config import CoreConfig
from titles.ongeki.config import OngekiConfig
from titles.ongeki.const import OngekiConstants
from titles.ongeki.database import OngekiData
# from titles.ongeki.read import OngekiReader
class OngekiFrontend(FE_Base):
def __init__(
self, cfg: CoreConfig, environment: jinja2.Environment, cfg_dir: str
) -> None:
super().__init__(cfg, environment)
self.data = OngekiData(cfg)
self.game_cfg = OngekiConfig()
if path.exists(f"{cfg_dir}/{OngekiConstants.CONFIG_NAME}"):
self.game_cfg.update(
yaml.safe_load(open(f"{cfg_dir}/{OngekiConstants.CONFIG_NAME}"))
)
self.nav_name = "O.N.G.E.K.I."
def render_GET(self, request: Request) -> bytes:
template = self.environment.get_template(
"titles/ongeki/frontend/ongeki_index.jinja"
)
sesh: Session = request.getSession()
usr_sesh = IUserSession(sesh)
return template.render(
title=f"{self.core_config.server.name} | {self.nav_name}",
game_list=self.environment.globals["game_list"],
sesh=vars(usr_sesh)
).encode("utf-16")

View File

@ -0,0 +1,4 @@
{% extends "core/frontend/index.jinja" %}
{% block content %}
<h1>O.N.G.E.K.I.</h1>
{% endblock content %}