Código fuente wiki de Juegoteca

Última modificación por dFa el 2024/09/07 14:00

Mostrar los últimos autores
1 Colección ordenada alfabéticamente tanto de juegos físicos como digitales de todos los sistemas.
2
3
4 {{groovy}}
5 // Conectar a la base de datos
6 def db = groovy.sql.Sql.newInstance('jdbc:mysql://10.100.200.31:8285/games', 'root', 'xwiki', 'com.mysql.jdbc.Driver')
7
8 // Iniciar tabla HTML
9 def table = """
10 {{html}}
11 <style>
12 table {
13 border-collapse: collapse;
14 width: 100%;
15 font-family: Arial, sans-serif;
16 }
17 th, td {
18 border: 1px solid #ddd;
19 padding: 8px;
20 }
21 th {
22 background-color: #f2f2f2;
23 font-weight: bold;
24 text-align: center;
25 }
26 tr:nth-child(even) {
27 background-color: #f9f9f9;
28 }
29 tr:hover {
30 background-color: #f1f1f1;
31 }
32 img {
33 width: 111px; /* Ajusta el ancho de la imagen */
34 height: 151px; /* Ajusta la altura de la imagen */
35 object-fit: cover; /* Mantiene la relación de aspecto y recorta si es necesario */
36 }
37 </style>
38 <table>
39 <thead>
40 <tr>
41 <th>TITULO</th>
42 <th>SISTEMA</th>
43 <th>COMPLETADO</th>
44 <th>CARATULA</th>
45 </tr>
46 </thead>
47 <tbody>
48 """
49
50 // Recorrer las filas de la tabla de la base de datos y añadirlas a la tabla HTML
51 db.eachRow('SELECT * FROM games_list order by titulo asc;') { row ->
52 table += """
53 <tr>
54 <td>${row.titulo}</td>
55 <td>${row.sistema}</td>
56 <td>${row.estado}</td>
57 <td><img src='/images_wiki/${row.caratula}' style='width: 112px; height: 154px;'/></td>
58 </tr>
59 """
60 }
61
62 // Cerrar la tabla HTML
63 table += """
64 </tbody>
65 </table>
66 {{/html}}
67 """
68
69 // Usar out.print para renderizar la tabla como HTML
70 out.print(table)
71
72 {{/groovy}}