Add games.parent_appid (schema v9), parse appinfo parent links, show addons and parent game in the card, and add import_steam.py --refresh-parents for existing databases.
This commit is contained in:
1 parent
376a2ee7a0
commit
528fcb7474
18 files changed
+135
-11
No files matched your search
@@ -1300,6 +1300,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
try:
|
||||
r = con.execute("""
|
||||
SELECT g.appid, g.name, g.type, g.release_date, g.metacritic, g.review_pct,
|
||||
g.parent_appid,
|
||||
g.estimated_hours, g.hltb_main, g.hltb_extra, g.hltb_complete,
|
||||
COALESCE(p.minutes,0) minutes, p.last_played,
|
||||
COALESCE(i.installed,0) installed, i.size_bytes,
|
||||
@@ -1331,6 +1332,22 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"SELECT key, value FROM attributes WHERE appid=? ORDER BY key", (appid,))]
|
||||
item["attributes"] = attrs
|
||||
item["similar"] = reco.similar_games(con, appid, limit=6)
|
||||
item["addons"] = [
|
||||
{"appid": row["appid"], "name": row["name"], "type": row["type"]}
|
||||
for row in con.execute(
|
||||
"""SELECT appid, name, type FROM games
|
||||
WHERE parent_appid = ? ORDER BY type, name""", (appid,))
|
||||
]
|
||||
item["parent"] = None
|
||||
if r["parent_appid"]:
|
||||
parent = con.execute(
|
||||
"SELECT appid, name, type FROM games WHERE appid = ?",
|
||||
(r["parent_appid"],)).fetchone()
|
||||
if parent:
|
||||
item["parent"] = {
|
||||
"appid": parent["appid"], "name": parent["name"],
|
||||
"type": parent["type"],
|
||||
}
|
||||
self._json(item)
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
@@ -1559,6 +1559,17 @@ function renderModal(g) {
|
||||
const attrs = (g.attributes || []).length
|
||||
? `<div class="chip-row">${g.attributes.map((a) => `<span class="genre">${esc(a.key)}: ${esc(a.value)}</span>`).join("")}</div>`
|
||||
: "";
|
||||
const addons = (g.addons || []).length
|
||||
? `<div class="addons-block">
|
||||
<h3>Дополнения (${g.addons.length})</h3>
|
||||
<div class="chip-row">
|
||||
${g.addons.map((a) => `<button class="genre addon" type="button" data-appid="${a.appid}" title="${esc(a.type || "")}">${esc(a.name)}</button>`).join("")}
|
||||
</div>
|
||||
</div>`
|
||||
: "";
|
||||
const parentLink = g.parent
|
||||
? `<div class="parent-link muted">Часть игры <button class="link" type="button" data-appid="${g.parent.appid}">${esc(g.parent.name)}</button></div>`
|
||||
: "";
|
||||
const similar = (g.similar || []).length
|
||||
? `<div class="similar-block">
|
||||
<h3>Похожие в библиотеке</h3>
|
||||
@@ -1597,6 +1608,8 @@ function renderModal(g) {
|
||||
${about ? `<details class="about-block"><summary>Полное описание</summary><p class="modal-desc about">${esc(about.slice(0, 2400))}${about.length > 2400 ? "…" : ""}</p></details>` : ""}
|
||||
${tags ? `<div class="chip-row">${tags}</div>` : ""}
|
||||
<div id="achievementsBlock" class="achievements-block hidden"></div>
|
||||
${parentLink}
|
||||
${addons}
|
||||
${similar}
|
||||
${attrs}
|
||||
<form class="personal" id="personalForm">
|
||||
@@ -1627,6 +1640,11 @@ function renderModal(g) {
|
||||
});
|
||||
}
|
||||
bindCards($("#modalBody"));
|
||||
$("#modalBody").querySelectorAll(
|
||||
".addons-block button[data-appid], .parent-link button[data-appid]"
|
||||
).forEach((button) => {
|
||||
button.addEventListener("click", () => openGame(button.dataset.appid));
|
||||
});
|
||||
$("#personalForm").addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
|
||||
@@ -1091,6 +1091,12 @@ html[data-theme="light"] .game-table tbody tr:hover { background: rgba(23, 32, 5
|
||||
.ach-text b { font-size: 13px; font-weight: 600; }
|
||||
.ach-text span { font-size: 12px; }
|
||||
|
||||
.addons-block { margin: 4px 0 18px; padding-top: 16px; border-top: 1px solid var(--border); }
|
||||
.addons-block h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
|
||||
button.addon { cursor: pointer; font: inherit; }
|
||||
button.addon:hover { border-color: var(--accent); color: var(--text); }
|
||||
.parent-link { margin: 0 0 14px; font-size: 13px; }
|
||||
|
||||
.similar-block { margin: 4px 0 18px; padding-top: 16px; border-top: 1px solid var(--border); }
|
||||
.similar-block h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
|
||||
.similar-row {
|
||||
|
||||
Reference in new issue
Block a user