Skip to content

Commit d8fed34

Browse files
committed
add roundest pokémon example
1 parent d18954e commit d8fed34

File tree

15 files changed

+244
-0
lines changed

15 files changed

+244
-0
lines changed

examples/official-site/examples/tabs/images/roundest_pokemon_rating.svg

Lines changed: 65 additions & 0 deletions
Loading

examples/official-site/examples/tabs/index.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ select 'Authenticated CRUD', 'CRUD - Authentication', 'sqlite', 'Complete Create
88
select 'Image Gallery', 'image gallery with user uploads', 'sqlite', 'Create an image gallery with user uploads and session management.' union all
99
select 'Developer UI', 'SQLPage developer user interface', 'postgres', 'A web-based interface for managing SQLPage files and database tables.' union all
1010
select 'Corporate Game', 'corporate-conundrum', 'sqlite', 'An interactive multiplayer board game with real-time updates.' union all
11+
select 'Roundest Pokemon', 'roundest_pokemon_rating', 'sqlite', 'Demo app with a distinct non-default design, using custom HTML templates for everything.' union all
1112
select 'Todo Application', 'todo application (PostgreSQL)', 'sqlite', 'A full-featured todo list application with PostgreSQL backend.' union all
1213
select 'MySQL & JSON', 'mysql json handling', 'mysql', 'Learn advanced JSON manipulation in MySQL to build advanced SQLPage applications.' union all
1314
select 'Simple Website', 'simple-website-example', 'sqlite', 'Basic website example with navigation and data management.' union all
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM lovasoa/sqlpage:latest
2+
3+
COPY sqlpage /etc/sqlpage
4+
COPY src /var/www
5+
ENV DATABASE_URL=sqlite:///tmp/pokemon.db?mode=rwc
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Roundest (SQLPage Version)
2+
3+
This is a simple web app that allows you to vote on which Pokemon is the most round.
4+
5+
| Vote UI | Results UI |
6+
| --- | --- |
7+
| ![vote ui screenshot](screenshots/vote.png) | ![results ui](screenshots/results.png) |
8+
9+
It demonstrates how to build an entirely custom web app,
10+
without using any of the pre-built components of SQLPage.
11+
12+
All the custom components are in the [`sqlpage/templates/`](./sqlpage/templates/) folder.
13+
14+
## Running the app
15+
16+
### Using an installed version of SQLPage
17+
18+
```
19+
sqlpage --web-root src
20+
```
21+
22+
### Using Docker
23+
24+
```
25+
docker build -t roundest-sqlpage .
26+
docker run -p 8080:8080 -it roundest-sqlpage
27+
```
131 KB
Loading
122 KB
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE IF NOT EXISTS pokemon (
2+
dex_id INTEGER PRIMARY KEY,
3+
name TEXT NOT NULL,
4+
up_votes INTEGER DEFAULT 0,
5+
down_votes INTEGER DEFAULT 0
6+
);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div
2+
class="container d-flex justify-content-center align-items-center min-vh-75 gap-5"
3+
>
4+
<form action="/vote.sql" method="POST" class="d-flex gap-5">
5+
{{#each_row}}
6+
<div class="text-center">
7+
<input type="hidden" name="option_{{@row_index}}" value="{{dexNumber}}" />
8+
<img
9+
src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{{dexNumber}}.png"
10+
class="img-fluid"
11+
style="width: 256px; height: 256px; image-rendering: pixelated;"
12+
alt="{{name}}"
13+
/>
14+
<div class="mt-3">
15+
<span class="text-secondary fs-5">#{{dexNumber}}</span>
16+
<h2 class="fs-1 fw-bold text-capitalize">{{name}}</h2>
17+
<div class="mt-4">
18+
<button
19+
type="submit"
20+
formaction="/vote.sql?voted={{dexNumber}}"
21+
class="btn btn-primary btn-lg px-4"
22+
>
23+
Vote
24+
</button>
25+
</div>
26+
</div>
27+
</div>
28+
{{/each_row}}
29+
</form>
30+
</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="container py-4">
2+
<div class="row g-4">
3+
{{#each_row}}
4+
<div class="col-12">
5+
<div class="d-flex align-items-center gap-4 p-4 bg-dark bg-opacity-40 rounded shadow">
6+
<div class="fs-3 fw-bold text-secondary" style="width: 2rem">
7+
#{{rank}}
8+
</div>
9+
10+
<img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{{dex_id}}.png" alt="{{name}}" class="img-fluid" style="width: 5rem; height: 5rem" />
11+
12+
<div class="flex-grow-1">
13+
<div class="text-secondary small">#{{dex_id}}</div>
14+
<h2 class="fs-4 fw-semibold text-capitalize text-white">{{name}}</h2>
15+
</div>
16+
17+
<div class="text-end">
18+
<div class="fs-3 fw-bold text-info">
19+
{{win_percentage}}%
20+
</div>
21+
<div class="small text-secondary">
22+
{{up_votes}}W - {{down_votes}}L
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
{{/each_row}}
28+
</div>
29+
</div>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<html lang="en">
2+
<head>
3+
<link rel="stylesheet" href="{{static_path 'sqlpage.css'}}">
4+
</head>
5+
<body class="d-flex flex-column min-vh-100 bg-dark text-white border-top border-info">
6+
<header class="py-3 px-4">
7+
<div class="d-flex align-items-center justify-content-between">
8+
<div class="d-flex align-items-baseline">
9+
<a href="/" class="text-decoration-none text-white">
10+
<h1 class="fw-bold fs-2 mb-0">
11+
round<span class="text-info">est</span>
12+
<span class="text-secondary fw-light ms-2 fs-3">
13+
(SQLPage Version)
14+
</span>
15+
</h1>
16+
</a>
17+
</div>
18+
<nav class="d-flex gap-4">
19+
<a href="/results.sql" class="text-white text-decoration-none fs-5 hover-underline">
20+
Results
21+
</a>
22+
</nav>
23+
</div>
24+
</header>
25+
26+
<main class="flex-grow-1">{{~#each_row~}}{{~/each_row~}}</main>
27+
28+
<footer class="text-center py-2 text-secondary fw-light">
29+
<a
30+
href="https://github.com/t3dotgg/1app5stacks"
31+
target="_blank"
32+
rel="noopener noreferrer"
33+
class="text-secondary"
34+
>
35+
GitHub
36+
</a>
37+
</footer>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)