minimaws: show compatible slots for devices [Vas Crabb]

(nw) Identify Donkey Kong Junior (Japan set F-1) [Corrado Comaselli]
This commit is contained in:
Vas Crabb 2017-08-04 11:39:32 +10:00
parent 0fbad045de
commit 00f6156cbb
4 changed files with 49 additions and 3 deletions

View File

@ -198,6 +198,13 @@ class QueryCursor(object):
'WHERE machine.id IN (SELECT machine FROM devicereference WHERE device = ?)',
(device, ))
def get_compatible_slots(self, device):
return self.dbcurs.execute(
'SELECT machine.shortname AS shortname, machine.description AS description, slot.name AS slot, slotoption.name AS slotoption, sourcefile.filename AS sourcefile ' \
'FROM slotoption JOIN slot ON slotoption.slot = slot.id JOIN machine on slot.machine = machine.id JOIN sourcefile ON machine.sourcefile = sourcefile.id '
'WHERE slotoption.device = ?',
(device, ))
def get_sourcefile_id(self, filename):
return (self.dbcurs.execute('SELECT id FROM sourcefile WHERE filename = ?', (filename, )).fetchone() or (None, ))[0]

View File

@ -19,6 +19,11 @@ ERROR_PAGE = string.Template(
'</html>\n')
SORTABLE_TABLE_EPILOGUE = string.Template(
' </tbody>\n'
'</table>\n'
'<script>make_table_sortable(document.getElementById("${id}"));</script>\n')
MACHINE_PROLOGUE = string.Template(
'<!DOCTYPE html>\n' \
'<html>\n' \
@ -64,6 +69,15 @@ EXCL_MACHINE_ROW = string.Template(
' <td></td>\n' \
' </tr>\n')
COMPATIBLE_SLOT_ROW = string.Template(
' <tr>\n' \
' <td><a href="${machinehref}">${shortname}</a></td>\n' \
' <td><a href="${machinehref}">${description}</a></td>\n' \
' <td>${slot}</td>\n' \
' <td>${slotoption}</td>\n' \
' <td><a href="${sourcehref}">${sourcefile}</a></td>\n' \
' </tr>\n')
SOURCEFILE_PROLOGUE = string.Template(
'<!DOCTYPE html>\n' \

View File

@ -211,6 +211,7 @@ class MachineHandler(QueryPageHandler):
yield htmltmpl.MACHINE_SLOTS_PLACEHOLDER.substitute(
machine=self.js_escape(self.shortname)).encode('utf=8')
# list devices referenced by this system/device
first = True
for name, desc, src in self.dbcurs.get_devices_referenced(id):
if first:
@ -224,8 +225,32 @@ class MachineHandler(QueryPageHandler):
first = False
yield self.machine_row(name, desc, src)
if not first:
yield ' </tbody>\n</table>\n<script>make_table_sortable(document.getElementById("tbl-dev-refs"));</script>\n'.encode('utf-8')
yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-dev-refs').encode('utf-8')
# list slots where this device is an option
first = True
for name, desc, slot, opt, src in self.dbcurs.get_compatible_slots(id):
if (first):
yield \
'<h2>Compatible Slots</h2>\n' \
'<table id="tbl-comp-slots">\n' \
' <thead>\n' \
' <tr><th>Short name</th><th>Description</th><th>Slot</th><th>Choice</th><th>Source file</th></tr>\n' \
' </thead>\n' \
' <tbody>\n'.encode('utf-8')
first = False
yield htmltmpl.COMPATIBLE_SLOT_ROW.substitute(
machinehref=self.machine_href(name),
sourcehref=self.sourcefile_href(src),
shortname=cgi.escape(name),
description=cgi.escape(desc),
sourcefile=cgi.escape(src),
slot=cgi.escape(slot),
slotoption=cgi.escape(opt)).encode('utf-8')
if not first:
yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-comp-slots').encode('utf-8')
# list systems/devices that reference this device
first = True
for name, desc, src in self.dbcurs.get_device_references(id):
if first:
@ -239,7 +264,7 @@ class MachineHandler(QueryPageHandler):
first = False
yield self.machine_row(name, desc, src)
if not first:
yield ' </tbody>\n</table>\n<script>make_table_sortable(document.getElementById("tbl-ref-by"));</script>\n'.encode('utf-8')
yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-ref-by').encode('utf-8')
yield '</html>\n'.encode('utf-8')

View File

@ -3383,7 +3383,7 @@ GAME( 2013, dkongpe, dkong, dkong2b, dkong, dkong_state, 0, ROT
GAME( 1982, dkongjr, 0, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo of America", "Donkey Kong Junior (US set F-2)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, dkongjrj, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo", "Donkey Kong Jr. (Japan)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, dkongjnrj, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo", "Donkey Kong Junior (Japan?)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, dkongjnrj, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo", "Donkey Kong Junior (Japan set F-1)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, dkongjrb, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "bootleg", "Donkey Kong Jr. (bootleg)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, dkongjre, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo of America", "Donkey Kong Junior (E kit)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, dkongjrpb, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "bootleg", "Donkey Kong Junior (P kit, bootleg)", MACHINE_SUPPORTS_SAVE ) // definitely not issued by Nintendo