Compare commits
No commits in common. "edaf4583a0f01f16e2cfcd0ab38d3b74a18fe0ea" and "34d1088d9dd3bc2623e06190def1e822f640269f" have entirely different histories.
edaf4583a0
...
34d1088d9d
3
.gitignore
vendored
3
.gitignore
vendored
@ -27,5 +27,4 @@ dummy/
|
||||
htmlcov/
|
||||
.coverage
|
||||
.coverage.*
|
||||
*,cover
|
||||
tmp/
|
||||
*,cover
|
||||
@ -3,13 +3,10 @@
|
||||
All notable change notes in this project will be documented in this file.
|
||||
|
||||
## [0.1.0-2] - 2023-04-09
|
||||
|
||||
### Changed
|
||||
|
||||
- `docker-compose.yml`: Changed the volume path for the `init.sql` file:
|
||||
- From: `./schema.sql:/docker-entrypoint-initdb.d/schema.sql`
|
||||
- To: `./init.sql:/docker-entrypoint-initdb.d/init.sql`
|
||||
|
||||
### Removed
|
||||
|
||||
- `docker/schema.sql`: The file has been removed. The schema configuration has been moved to the `init.sql` file.
|
||||
|
||||
12
Makefile
12
Makefile
@ -81,6 +81,8 @@ pg-docs:
|
||||
# Generate or recreate SQLC queries.
|
||||
sqlc:
|
||||
cd $(CORE_DIR) && sqlc generate
|
||||
make gomock
|
||||
|
||||
|
||||
.PHONY: test
|
||||
# Test all files and generate coverage file.
|
||||
@ -118,16 +120,16 @@ tidy:
|
||||
.PHONY: build-linux
|
||||
# Build and generate linux executable.
|
||||
build-linux:
|
||||
cd $(CORE_DIR) && go mod tidy
|
||||
cd $(CORE_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./tmp/$(MOD_NAME) ./cmd/.
|
||||
|
||||
|
||||
cd $(CORE_DIR) && make tidy
|
||||
cd $(CORE_DIR) && make remove-debug
|
||||
cd $(CORE_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./tmp/arena ./cmd/.
|
||||
|
||||
.PHONY: pack-docker
|
||||
# Run docker build for pack binary and assets to Docker container.
|
||||
pack-docker:
|
||||
make test
|
||||
make build-linux
|
||||
cd $(CORE_DIR) && docker build -t $(MOD_NAME):${version} -t $(MOD_NAME):latest .
|
||||
docker build -t $(MOD_NAME):${version} -t $(MOD_NAME):latest .
|
||||
|
||||
.PHONY: remove-debug
|
||||
# Remove all debug entries for reduce size binary.
|
||||
|
||||
16
README.md
16
README.md
@ -1,20 +1,20 @@
|
||||
# Rating Orama
|
||||
|
||||
Rating Orama is a web application for displaying TV show ratings and statistics.
|
||||
Rating Orama is a web application for displaying TV show ratings and statistics.
|
||||
It is composed of 2 main parts:
|
||||
|
||||
1. **Core**: Written in Go and Fiber, responsible for orchestrating everything
|
||||
and displaying the data using a template engine.
|
||||
2. **Database**: PostgreSQL for storing data.
|
||||
1. **Core**: Written in Go and Fiber, responsible for orchestrating everything
|
||||
and displaying the data using a template engine.
|
||||
3. **Database**: PostgreSQL for storing data.
|
||||
|
||||
## Running the project
|
||||
|
||||
There are two ways to run the project: launching each part individually or
|
||||
building the Dockerfile and running it using Docker Compose. Here's an example
|
||||
There are two ways to run the project: launching each part individually or
|
||||
building the Dockerfile and running it using Docker Compose. Here's an example
|
||||
of the `docker-compose.yml` file for the latter option:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
core:
|
||||
@ -49,5 +49,5 @@ volumes:
|
||||
|
||||
## Contributions
|
||||
|
||||
If you have ideas for improvements or bug fixes, feel free to contribute! To do
|
||||
If you have ideas for improvements or bug fixes, feel free to contribute! To do
|
||||
so, simply clone the repository, create a new branch, and submit a pull request.
|
||||
|
||||
@ -2,16 +2,4 @@ DRIVERNAME=pgx
|
||||
MIGRATE=true
|
||||
DATASOURCE=postgresql://developer:secret@localhost:5432/db?sslmode=disable
|
||||
ASYMMETRICKEY=
|
||||
DURATION=
|
||||
|
||||
# scraper
|
||||
TITLE_SELECTOR=
|
||||
SEASON_SELECTOR=
|
||||
EPISODE_CARD_SELECTOR=
|
||||
SEASON_EPISODE_AND_TITLE_SELECTOR=
|
||||
RELEASED_DATE_SELECTOR=
|
||||
PLOT_SELECTOR=
|
||||
STAR_RATING_SELECTOR=
|
||||
VOTE_COUNT_SELECTOR=
|
||||
IMDB_EPISODES_URL=
|
||||
VISIT_URL=
|
||||
DURATION=
|
||||
@ -2,6 +2,7 @@ FROM alpine:3.20
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ../tmp/rating-orama .
|
||||
COPY ./database ./database
|
||||
COPY ./tmp/rating .
|
||||
|
||||
CMD ["/app/rating-orama"]
|
||||
CMD ["/app/rating"]
|
||||
@ -5,16 +5,14 @@ import (
|
||||
"encoding/gob"
|
||||
"gopher-toolbox/db"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/template/html/v2"
|
||||
"github.com/zepyrshut/rating-orama/internal/app"
|
||||
"github.com/zepyrshut/rating-orama/internal/handlers"
|
||||
"github.com/zepyrshut/rating-orama/internal/repository"
|
||||
)
|
||||
|
||||
const version = "0.2.1-beta.20250128-24"
|
||||
const version = "0.2.0-beta.20241116-4"
|
||||
const appName = "rating-orama"
|
||||
|
||||
func init() {
|
||||
@ -24,18 +22,11 @@ func init() {
|
||||
//go:embed database/migrations
|
||||
var database embed.FS
|
||||
|
||||
//go:embed templates
|
||||
var templates embed.FS
|
||||
|
||||
func main() {
|
||||
engine := html.NewFileSystem(http.FS(templates), ".gotmpl")
|
||||
engine.Directory = "templates"
|
||||
|
||||
app := app.NewExtendedApp(appName, version, ".env")
|
||||
app.Migrate(database)
|
||||
f := fiber.New(fiber.Config{
|
||||
AppName: appName,
|
||||
Views: engine,
|
||||
})
|
||||
|
||||
pgxPool := db.NewPGXPool(app.Database.DataSource)
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
func router(h *handlers.Handlers, r *fiber.App) {
|
||||
|
||||
r.Get("/", h.GetIndex)
|
||||
r.Get("/tvshow", h.GetTVShow)
|
||||
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
<div class="flex flex-col justify-center min-h-screen">
|
||||
<form class="max-w-md mx-auto w-full" action="/tvshow" method="get">
|
||||
<label for="default-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Buscar</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="lucide lucide-search">
|
||||
<circle cx="11" cy="11" r="8" />
|
||||
<path d="m21 21-4.3-4.3" />
|
||||
</svg>
|
||||
</div>
|
||||
<input type="search" id="default-search"
|
||||
class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
placeholder="IMDb ID" required
|
||||
name="ttid"
|
||||
/>
|
||||
<button type="submit"
|
||||
class="text-white absolute end-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -1,17 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{{ .Title }}</title>
|
||||
<script src="https://unpkg.com/@tailwindcss/browser@4"></script>
|
||||
</head>
|
||||
|
||||
<body class="min-h-screen bg-slate-50">
|
||||
|
||||
{{ embed }}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -1,51 +0,0 @@
|
||||
|
||||
<footer class="bg-slate-200" aria-label="Site Footer">
|
||||
<ul class="mt-12 flex justify-center gap-6 p-12">
|
||||
<li>
|
||||
<a
|
||||
class="text-slate-700 transition hover:text-slate-700/75"
|
||||
href="https://www.instagram.com/modelektor/"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Instagram</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-instagram"><rect width="20" height="20" x="2" y="2" rx="5" ry="5"/><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"/><line x1="17.5" x2="17.51" y1="6.5" y2="6.5"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a
|
||||
class="text-slate-700 transition hover:text-slate-700/75"
|
||||
href="https://github.com/zepyrshut"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">GitHub</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a
|
||||
class="text-slate-700 transition hover:text-slate-700/75"
|
||||
href="https://pedroperez.dev/"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Website</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-globe"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
class="text-slate-700 transition hover:text-slate-700/75"
|
||||
href="https://github.com/zepyrshut/rating-orama"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Source</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-code-xml"><path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</footer>
|
||||
@ -1,334 +0,0 @@
|
||||
<div class="flex flex-col items-center gap-4 mb-8 p-2">
|
||||
<!-- Card header -->
|
||||
<div class="flex flex-col items-center mt-4 bg-white p-4 rounded-lg shadow-md w-1/2">
|
||||
<div class="flex flex-col items-center space-y-4 w-full">
|
||||
<!-- Title section -->
|
||||
<div class="text-center">
|
||||
<h1 class="text-3xl font-bold text-gray-800">{{ .tvshow.Name }}</h1>
|
||||
<div class="mt-1 flex items-center justify-center space-x-2">
|
||||
<a href="https://www.imdb.com/title/{{ .tvshow.TtImdb }}" target="_blank"
|
||||
class="text-amber-500 hover:text-amber-600 flex items-center space-x-1">
|
||||
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
|
||||
</svg>
|
||||
<span class="font-semibold text-sm">{{ .tvshow.TtImdb }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ratings section -->
|
||||
<div class="grid grid-cols-2 gap-4 w-full">
|
||||
<div class="bg-gray-50 rounded-lg p-2 text-center">
|
||||
<span class="text-xs text-gray-500 uppercase">Average</span>
|
||||
<div class="text-2xl font-bold text-gray-800">{{ printf "%.2f" .avg_rating_show }}</div>
|
||||
</div>
|
||||
<div class="bg-gray-50 rounded-lg p-2 text-center">
|
||||
<span class="text-xs text-gray-500 uppercase">Median</span>
|
||||
<div class="text-2xl font-bold text-gray-800">{{ printf "%.2f" .median_rating_show }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stats section -->
|
||||
<div class="flex justify-around w-full px-3 py-2 bg-gray-50 rounded-lg">
|
||||
<div class="text-center">
|
||||
<span class="text-xs text-gray-500">Vote count</span>
|
||||
<div class="text-lg font-bold text-gray-800">{{ .total_vote_count }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<span class="text-xs text-gray-500">Times searched</span>
|
||||
<div class="text-lg font-bold text-gray-800">{{ .tvshow.Popularity }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="w-4/5 mx-6">
|
||||
|
||||
|
||||
<h2 class="mb-6 text-center text-2xl font-bold">Seasons overall</h2>
|
||||
<canvas id="seasons"></canvas>
|
||||
</div>
|
||||
<div class="w-4/5">
|
||||
|
||||
<h2 class="mb-6 text-center text-2xl font-bold">Season <span id="seasonNumber">1</span></h2>
|
||||
<div id="seasonButtons" class="mb-4 flex flex-wrap items-center justify-center gap-2"></div>
|
||||
<canvas id="episodes"></canvas>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{{ template "partials/footer" . }}
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.js"
|
||||
integrity="sha512-ZwR1/gSZM3ai6vCdI+LVF1zSq/5HznD3ZSTk7kajkaj4D292NLuduDCO1c/NT8Id+jE58KYLKT7hXnbtryGmMg=="
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script type="module">
|
||||
|
||||
const episodes = JSON.parse("{{ .episodes }}")
|
||||
|
||||
function groupEpisodesBySeason(episodes) {
|
||||
const seasons = {};
|
||||
episodes.forEach(episode => {
|
||||
if (!seasons[episode.season]) {
|
||||
seasons[episode.season] = {
|
||||
number: episode.season,
|
||||
episodes: [],
|
||||
avg_rating: 0,
|
||||
median_rating: 0,
|
||||
votes: 0
|
||||
};
|
||||
}
|
||||
seasons[episode.season].episodes.push({
|
||||
number: episode.episode,
|
||||
title: episode.name,
|
||||
avg_rating: episode.avg_rating,
|
||||
votes: episode.vote_count,
|
||||
aired: episode.released
|
||||
});
|
||||
});
|
||||
|
||||
Object.values(seasons).forEach(season => {
|
||||
const ratings = season.episodes.map(ep => ep.avg_rating);
|
||||
season.avg_rating = ratings.reduce((a, b) => a + b, 0) / ratings.length;
|
||||
season.median_rating = ratings.sort((a, b) => a - b)[Math.floor(ratings.length / 2)];
|
||||
season.votes = season.episodes.reduce((sum, ep) => sum + ep.votes, 0);
|
||||
});
|
||||
|
||||
return {
|
||||
seasons: Object.values(seasons).sort((a, b) => a.number - b.number)
|
||||
};
|
||||
}
|
||||
|
||||
function createSeasonButtons() {
|
||||
const maxSeason = Math.max(...episodes.map(ep => ep.season));
|
||||
const buttonContainer = document.getElementById('seasonButtons');
|
||||
const seasonNumberSpan = document.getElementById('seasonNumber');
|
||||
|
||||
for (let i = 1; i <= maxSeason; i++) {
|
||||
const button = document.createElement('button');
|
||||
button.textContent = `S${i}`;
|
||||
button.className = 'rounded-md border-2 border-black px-4 py-2 font-semibold transition-colors duration-200 hover:bg-black hover:text-white';
|
||||
if (i === 1) button.classList.add('bg-black', 'text-white');
|
||||
|
||||
button.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
buttonContainer.querySelectorAll('button').forEach(btn => {
|
||||
btn.classList.remove('bg-black', 'text-white');
|
||||
btn.classList.add('text-black');
|
||||
});
|
||||
|
||||
button.classList.remove('text-black');
|
||||
button.classList.add('bg-black', 'text-white');
|
||||
|
||||
seasonNumberSpan.textContent = i;
|
||||
|
||||
const formattedData = groupEpisodesBySeason(episodes);
|
||||
loadSpecificSeason(formattedData, i);
|
||||
});
|
||||
|
||||
buttonContainer.appendChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const formattedData = groupEpisodesBySeason(episodes);
|
||||
initCharts(formattedData);
|
||||
createSeasonButtons();
|
||||
});
|
||||
|
||||
function loadSeason(seasonNumber) {
|
||||
const formattedData = groupEpisodesBySeason(episodes);
|
||||
loadSpecificSeason(formattedData, seasonNumber);
|
||||
}
|
||||
|
||||
function initCharts(tvShowParsed) {
|
||||
new EpisodeChart(tvShowParsed, "episodes", 0);
|
||||
new SeasonsChart(tvShowParsed, "seasons");
|
||||
}
|
||||
|
||||
function loadSpecificSeason(tvShowParsed, seasonId) {
|
||||
// Guardamos la posición actual del scroll
|
||||
const currentScroll = window.scrollY;
|
||||
|
||||
new EpisodeChart(tvShowParsed, "episodes", seasonId - 1);
|
||||
|
||||
// Restauramos la posición del scroll
|
||||
window.scrollTo(0, currentScroll);
|
||||
}
|
||||
|
||||
|
||||
let chartInstance;
|
||||
class SeasonsChart {
|
||||
constructor(tvShowParsed, canvasId) {
|
||||
this.tvShowParsed = tvShowParsed;
|
||||
this.canvasId = canvasId;
|
||||
this.createChart();
|
||||
}
|
||||
|
||||
createChart() {
|
||||
const seasons = this.tvShowParsed.seasons;
|
||||
const labels = seasons.map((season) => `Season ${season.number}`);
|
||||
const averageRating = seasons.map((season) => season.avg_rating);
|
||||
const medianRating = seasons.map((season) => season.median_rating);
|
||||
const votes = seasons.map((season) => season.votes);
|
||||
const title = "Seasons"
|
||||
const ctx = document.getElementById(this.canvasId);
|
||||
|
||||
new Chart(ctx, {
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: "Average rating",
|
||||
data: averageRating,
|
||||
backgroundColor: "rgba(75, 192, 192, 0.5)",
|
||||
borderColor: "rgba(75, 192, 192, 1)",
|
||||
borderWidth: 1,
|
||||
Range: 10,
|
||||
yAxisID: "y-axis-ratings",
|
||||
},
|
||||
{
|
||||
label: "Median rating",
|
||||
data: medianRating,
|
||||
backgroundColor: "rgba(255, 206, 86, 0.5)",
|
||||
borderColor: "rgba(255, 206, 86, 1)",
|
||||
borderWidth: 1,
|
||||
Range: 10,
|
||||
yAxisID: "y-axis-ratings",
|
||||
|
||||
},
|
||||
{
|
||||
label: "Votes",
|
||||
data: votes,
|
||||
type: "line",
|
||||
tension: 0.4,
|
||||
fill: false,
|
||||
borderColor: "rgba(255, 99, 132, 1)",
|
||||
borderWidth: 2,
|
||||
yAxisID: "y-axis-votes",
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
animation: {
|
||||
duration: 0,
|
||||
},
|
||||
y: {
|
||||
stacked: true,
|
||||
},
|
||||
scales: {
|
||||
"y-axis-ratings": {
|
||||
min: 0,
|
||||
max: 10,
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "left",
|
||||
beginAtZero: true,
|
||||
},
|
||||
"y-axis-votes": {
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "right",
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: title,
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class EpisodeChart {
|
||||
constructor(tvShowParsed, canvasId, seasonId) {
|
||||
this.tvShowParsed = tvShowParsed;
|
||||
this.canvasId = canvasId;
|
||||
this.seasonId = seasonId;
|
||||
this.createChart();
|
||||
}
|
||||
|
||||
createChart() {
|
||||
if (chartInstance) {
|
||||
chartInstance.destroy();
|
||||
}
|
||||
|
||||
const episodes = this.tvShowParsed.seasons[this.seasonId].episodes;
|
||||
const labels = episodes.map((episode) => `Ep. ${episode.number}`);
|
||||
const ratings = episodes.map((episode) => episode.avg_rating);
|
||||
const votes = episodes.map((episode) => episode.votes);
|
||||
const title = `Episodes of season ${this.seasonId + 1}`
|
||||
const ctx = document.getElementById(this.canvasId);
|
||||
|
||||
chartInstance = new Chart(ctx, {
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: "Average rating",
|
||||
data: ratings,
|
||||
backgroundColor: "rgba(75, 192, 192, 0.5)",
|
||||
borderColor: "rgba(75, 192, 192, 1)",
|
||||
borderWidth: 1,
|
||||
Range: 10,
|
||||
yAxisID: "y-axis-ratings",
|
||||
},
|
||||
{
|
||||
label: "Votes",
|
||||
data: votes,
|
||||
type: "line",
|
||||
tension: 0.4,
|
||||
fill: false,
|
||||
borderColor: "rgba(255, 99, 132, 1)",
|
||||
borderWidth: 2,
|
||||
yAxisID: "y-axis-votes",
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
animation: {
|
||||
duration: 0,
|
||||
},
|
||||
scales: {
|
||||
"y-axis-ratings": {
|
||||
min: 0,
|
||||
max: 10,
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "left",
|
||||
beginAtZero: true,
|
||||
},
|
||||
"y-axis-votes": {
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "right",
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
title: function (context) {
|
||||
const index = context[0].dataIndex;
|
||||
const episode = episodes[index];
|
||||
return `${episode.title} (${episode.aired.split("T")[0]})`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -1,6 +1,6 @@
|
||||
module github.com/zepyrshut/rating-orama
|
||||
|
||||
go 1.23.5
|
||||
go 1.23.2
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.10.0
|
||||
@ -18,8 +18,6 @@ require (
|
||||
github.com/antchfx/xpath v1.3.2 // indirect
|
||||
github.com/go-sql-driver/mysql v1.5.0 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gofiber/template v1.8.3 // indirect
|
||||
github.com/gofiber/utils v1.1.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
@ -47,7 +45,6 @@ require (
|
||||
|
||||
require (
|
||||
github.com/gocolly/colly v1.2.0
|
||||
github.com/gofiber/template/html/v2 v2.1.3
|
||||
github.com/golang-migrate/migrate/v4 v4.18.1 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
|
||||
10
core/go.sum
10
core/go.sum
@ -45,12 +45,6 @@ github.com/gocolly/colly v1.2.0 h1:qRz9YAn8FIH0qzgNUw+HT9UN7wm1oF9OBAilwEWpyrI=
|
||||
github.com/gocolly/colly v1.2.0/go.mod h1:Hof5T3ZswNVsOHYmba1u03W65HDWgpV5HifSuueE0EA=
|
||||
github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
|
||||
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
|
||||
github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc=
|
||||
github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
|
||||
github.com/gofiber/template/html/v2 v2.1.3 h1:n1LYBtmr9C0V/k/3qBblXyMxV5B0o/gpb6dFLp8ea+o=
|
||||
github.com/gofiber/template/html/v2 v2.1.3/go.mod h1:U5Fxgc5KpyujU9OqKzy6Kn6Qup6Tm7zdsISR+VpnHRE=
|
||||
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
|
||||
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-migrate/migrate/v4 v4.18.1 h1:JML/k+t4tpHCpQTCAD62Nu43NUFzHY4CV3uAuvHGC+Y=
|
||||
@ -125,8 +119,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg=
|
||||
github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
@ -11,12 +10,6 @@ import (
|
||||
"github.com/zepyrshut/rating-orama/internal/sqlc"
|
||||
)
|
||||
|
||||
func (hq *Handlers) GetIndex(c *fiber.Ctx) error {
|
||||
return c.Render("index", fiber.Map{
|
||||
"Title": "Rating Orama",
|
||||
}, "layouts/main")
|
||||
}
|
||||
|
||||
func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
|
||||
ttShowID := c.Query("ttid")
|
||||
|
||||
@ -27,9 +20,8 @@ func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
|
||||
var title string
|
||||
var scraperEpisodes []scraper.Episode
|
||||
var sqlcEpisodes []sqlc.Episode
|
||||
var totalVoteCount int32
|
||||
|
||||
sqlcTvShow, err := hq.queries.CheckTVShowExists(c.Context(), ttShowID)
|
||||
tvShow, err := hq.queries.CheckTVShowExists(c.Context(), ttShowID)
|
||||
if err != nil {
|
||||
title, scraperEpisodes = scraper.ScrapeEpisodes(ttShowID)
|
||||
//TODO: make transactional
|
||||
@ -50,61 +42,26 @@ func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
|
||||
slog.Error("failed to create episodes", "ttid", ttShowID, "error", err)
|
||||
return c.SendStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
sqlcEpisodes = append(sqlcEpisodes, sqlcEpisode)
|
||||
}
|
||||
|
||||
slog.Info("scraped seasons", "ttid", ttShowID, "title", title)
|
||||
} else {
|
||||
title = sqlcTvShow.Name
|
||||
sqlcEpisodes, err = hq.queries.GetEpisodes(c.Context(), sqlcTvShow.ID)
|
||||
title = tvShow.Name
|
||||
sqlcEpisodes, err = hq.queries.GetEpisodes(c.Context(), tvShow.ID)
|
||||
if err != nil {
|
||||
slog.Error("failed to get episodes", "ttid", ttShowID, "error", err)
|
||||
return c.SendStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, episode := range sqlcEpisodes {
|
||||
totalVoteCount += episode.VoteCount
|
||||
}
|
||||
|
||||
hq.queries.IncreasePopularity(c.Context(), ttShowID)
|
||||
slog.Info("tv show exists", "ttid", ttShowID, "title", sqlcTvShow.Name)
|
||||
slog.Info("tv show exists", "ttid", ttShowID, "title", tvShow.Name)
|
||||
}
|
||||
|
||||
episodesJSON, err := json.Marshal(sqlcEpisodes)
|
||||
if err != nil {
|
||||
slog.Error("failed to marshal episodes", "ttid", ttShowID, "error", err)
|
||||
return c.SendStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// calculate avg rating for the show
|
||||
avgRatingShow, err := hq.queries.TvShowAverageRating(c.Context(), sqlcTvShow.ID)
|
||||
if err != nil {
|
||||
slog.Error("failed to calculate avg rating for the show", "ttid", ttShowID, "error", err)
|
||||
return c.SendStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
medianRatingShow, err := hq.queries.TvShowMedianRating(c.Context(), sqlcTvShow.ID)
|
||||
if err != nil {
|
||||
slog.Error("failed to calculate median rating for the show", "ttid", ttShowID, "error", err)
|
||||
return c.SendStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
seasongAvgRatings, err := hq.queries.SeasonAverageRating(c.Context(), sqlc.SeasonAverageRatingParams{
|
||||
TvShowID: sqlcTvShow.ID,
|
||||
return c.JSON(fiber.Map{
|
||||
"popularity": tvShow.Popularity,
|
||||
"title": title,
|
||||
"seasons": sqlcEpisodes,
|
||||
})
|
||||
|
||||
seasonMedianRatings, err := hq.queries.SeasonMedianRating(c.Context(), sqlc.SeasonMedianRatingParams{
|
||||
TvShowID: sqlcTvShow.ID,
|
||||
})
|
||||
|
||||
return c.Render("tvshow", fiber.Map{
|
||||
"Title": sqlcTvShow.Name,
|
||||
"tvshow": sqlcTvShow,
|
||||
"episodes": string(episodesJSON),
|
||||
"avg_rating_show": avgRatingShow,
|
||||
"median_rating_show": medianRatingShow,
|
||||
"season_avg_ratings": seasongAvgRatings,
|
||||
"season_median_ratings": seasonMedianRatings,
|
||||
"total_vote_count": totalVoteCount,
|
||||
}, "layouts/main")
|
||||
}
|
||||
|
||||
@ -9,7 +9,8 @@ sql:
|
||||
out: "./internal/sqlc"
|
||||
sql_package: "pgx/v5"
|
||||
emit_interface: true
|
||||
emit_empty_slices: true
|
||||
emit_json_tags: true
|
||||
emit_empty_slices: true
|
||||
emit_json_tags: true
|
||||
rename:
|
||||
uuid: "UUID"
|
||||
|
||||
101
core/views/charts.html
Normal file
101
core/views/charts.html
Normal file
@ -0,0 +1,101 @@
|
||||
{{template "partials/header" .}}
|
||||
|
||||
<div class="flex w-full flex-col items-center">
|
||||
<h1 class="mb-6 text-3xl font-bold">{{ .TvShow.Title }}</h1>
|
||||
|
||||
<div class="mb-6 rounded-lg bg-white p-6 shadow-md">
|
||||
<div class="mb-4 text-center">
|
||||
<span class="text-gray-600">IMDb ID:</span>
|
||||
<span class="font-semibold text-gray-800">{{ .TvShow.ShowID }}</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-8">
|
||||
<ul class="space-y-2">
|
||||
<li>
|
||||
<span class="text-gray-600">Title:</span>
|
||||
<span class="font-semibold text-gray-800">{{ .TvShow.Title }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<span class="text-gray-600">Runtime:</span>
|
||||
<span class="font-semibold text-gray-800"
|
||||
>{{ .TvShow.Runtime }} min</span
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<span class="text-gray-600">Seasons:</span>
|
||||
<span class="font-semibold text-gray-800">{{len .TvShow.Seasons }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="space-y-2">
|
||||
<li>
|
||||
<span class="text-gray-600">Total votes:</span>
|
||||
<span class="font-semibold text-gray-800">{{ .TvShow.Votes }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<span class="text-gray-600">Average rating:</span>
|
||||
<span class="font-semibold text-gray-800"
|
||||
>{{printf "%.2f" .TvShow.AvgRating }}</span
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<span class="text-gray-600">Median rating:</span>
|
||||
<span class="font-semibold text-gray-800"
|
||||
>{{printf "%.2f" .TvShow.MedianRating }}</span
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-6 w-2/3">
|
||||
<h2 class="mb-6 text-center text-2xl font-bold">Seasons overall</h2>
|
||||
<canvas id="seasons"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="mb-6 w-2/3">
|
||||
<div x-data="{ selectedSeasonNumber: 1}">
|
||||
<h2 class="mb-6 text-center text-2xl font-bold">
|
||||
Season <span x-text="selectedSeasonNumber"></span>
|
||||
</h2>
|
||||
<canvas id="episodes"></canvas>
|
||||
<div class="mt-4 flex items-center justify-center space-x-2">
|
||||
{{ range .TvShow.Seasons }}
|
||||
<button
|
||||
class="rounded-md border-2 border-black px-4 py-2 font-semibold text-black hover:bg-black hover:text-white"
|
||||
:class="selectedSeasonNumber === {{ .Number }} ? 'bg-black text-white' : 'text-black'"
|
||||
x-on:click="selectedSeasonNumber = {{ .Number }}; loadSeason({{ .Number }})"
|
||||
>
|
||||
S{{ .Number }}
|
||||
</button>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "partials/footer" .}}
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.2.1/chart.umd.js"
|
||||
integrity="sha512-vCUbejtS+HcWYtDHRF2T5B0BKwVG/CLeuew5uT2AiX4SJ2Wff52+kfgONvtdATqkqQMC9Ye5K+Td0OTaz+P7cw=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
<script type="module">
|
||||
import { initCharts, loadSpecificSeason } from "/js/components/charts.js";
|
||||
|
||||
let tvShow = "{{ .TvShowJSON }}";
|
||||
let tvShowParsed = JSON.parse(tvShow);
|
||||
|
||||
function loadSeason(season) {
|
||||
const currentScrollY = window.scrollY;
|
||||
loadSpecificSeason(tvShowParsed, season);
|
||||
window.scrollTo(0, currentScrollY);
|
||||
}
|
||||
|
||||
window.loadSeason = loadSeason;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
initCharts(tvShowParsed);
|
||||
});
|
||||
</script>
|
||||
1
core/views/css/index.css
Normal file
1
core/views/css/index.css
Normal file
File diff suppressed because one or more lines are too long
55
core/views/index.html
Normal file
55
core/views/index.html
Normal file
@ -0,0 +1,55 @@
|
||||
{{template "partials/header" .}}
|
||||
<div class="flex min-h-screen flex-col items-center justify-center">
|
||||
<h1 class="mb-6 text-3xl font-bold">Rating Orama</h1>
|
||||
<div class="w-full max-w-md">
|
||||
<form x-data="search" @submit.prevent="submit" class="flex items-center gap-3" >
|
||||
<input
|
||||
x-model="ttID"
|
||||
class="rounded-md border-2 border-black bg-white px-4 py-2 w-11/12"
|
||||
id="search"
|
||||
name="search"
|
||||
type="text"
|
||||
placeholder="tt0903747"
|
||||
required
|
||||
/>
|
||||
<button
|
||||
:disabled="isLoading"
|
||||
class="rounded-md border-2 border-black bg-white px-4 py-2 font-bold text-black w-2/12"
|
||||
type="submit"
|
||||
:class="isLoading ? '' : 'hover:bg-black hover:text-white'"
|
||||
>
|
||||
<div class="flex items-center justify-center">
|
||||
<template x-if="isLoading">
|
||||
<div role="status">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-6 w-6 animate-spin fill-black text-white"
|
||||
aria-hidden="true"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">Cargando...</span>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="!isLoading" class="lorem">
|
||||
<span>Go!</span>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</button>
|
||||
</form>
|
||||
<p class="mt-2">
|
||||
Please input <span class="font-bold">tt id</span> from IDMb
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
178
core/views/js/components/charts.js
Normal file
178
core/views/js/components/charts.js
Normal file
@ -0,0 +1,178 @@
|
||||
export function initCharts(tvShowParsed) {
|
||||
new EpisodeChart(tvShowParsed, "episodes", 0);
|
||||
new SeasonsChart(tvShowParsed, "seasons");
|
||||
}
|
||||
|
||||
export function loadSpecificSeason(tvShowParsed, seasonId) {
|
||||
new EpisodeChart(tvShowParsed, "episodes", seasonId - 1);
|
||||
}
|
||||
|
||||
let chartInstance;
|
||||
|
||||
class SeasonsChart {
|
||||
constructor(tvShowParsed, canvasId) {
|
||||
this.tvShowParsed = tvShowParsed;
|
||||
this.canvasId = canvasId;
|
||||
this.createChart();
|
||||
}
|
||||
|
||||
createChart() {
|
||||
const seasons = this.tvShowParsed.seasons;
|
||||
const labels = seasons.map((season) => `Season ${season.number}`);
|
||||
const averageRating = seasons.map((season) => season.avg_rating);
|
||||
const medianRating = seasons.map((season) => season.median_rating);
|
||||
const votes = seasons.map((season) => season.votes);
|
||||
const title = "Seasons"
|
||||
const ctx = document.getElementById(this.canvasId);
|
||||
|
||||
new Chart(ctx, {
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: "Average rating",
|
||||
data: averageRating,
|
||||
backgroundColor: "rgba(75, 192, 192, 0.5)",
|
||||
borderColor: "rgba(75, 192, 192, 1)",
|
||||
borderWidth: 1,
|
||||
Range: 10,
|
||||
yAxisID: "y-axis-ratings",
|
||||
},
|
||||
{
|
||||
label: "Median rating",
|
||||
data: medianRating,
|
||||
backgroundColor: "rgba(255, 206, 86, 0.5)",
|
||||
borderColor: "rgba(255, 206, 86, 1)",
|
||||
borderWidth: 1,
|
||||
Range: 10,
|
||||
yAxisID: "y-axis-ratings",
|
||||
|
||||
},
|
||||
{
|
||||
label: "Votes",
|
||||
data: votes,
|
||||
type: "line",
|
||||
tension: 0.4,
|
||||
fill: false,
|
||||
borderColor: "rgba(255, 99, 132, 1)",
|
||||
borderWidth: 2,
|
||||
yAxisID: "y-axis-votes",
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
animation: {
|
||||
duration: 0,
|
||||
},
|
||||
y: {
|
||||
stacked: true,
|
||||
},
|
||||
scales: {
|
||||
"y-axis-ratings": {
|
||||
min: 0,
|
||||
max: 10,
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "left",
|
||||
beginAtZero: true,
|
||||
},
|
||||
"y-axis-votes": {
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "right",
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: title,
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class EpisodeChart {
|
||||
constructor(tvShowParsed, canvasId, seasonId) {
|
||||
this.tvShowParsed = tvShowParsed;
|
||||
this.canvasId = canvasId;
|
||||
this.seasonId = seasonId;
|
||||
this.createChart();
|
||||
}
|
||||
|
||||
createChart() {
|
||||
if (chartInstance) {
|
||||
chartInstance.destroy();
|
||||
}
|
||||
|
||||
const episodes = this.tvShowParsed.seasons[this.seasonId].episodes;
|
||||
const labels = episodes.map((episode) => `Ep. ${episode.number}`);
|
||||
const ratings = episodes.map((episode) => episode.avg_rating);
|
||||
const votes = episodes.map((episode) => episode.votes);
|
||||
const title = `Episodes of season ${this.seasonId + 1}`
|
||||
const ctx = document.getElementById(this.canvasId);
|
||||
|
||||
chartInstance = new Chart(ctx, {
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: "Average rating",
|
||||
data: ratings,
|
||||
backgroundColor: "rgba(75, 192, 192, 0.5)",
|
||||
borderColor: "rgba(75, 192, 192, 1)",
|
||||
borderWidth: 1,
|
||||
Range: 10,
|
||||
yAxisID: "y-axis-ratings",
|
||||
},
|
||||
{
|
||||
label: "Votes",
|
||||
data: votes,
|
||||
type: "line",
|
||||
tension: 0.4,
|
||||
fill: false,
|
||||
borderColor: "rgba(255, 99, 132, 1)",
|
||||
borderWidth: 2,
|
||||
yAxisID: "y-axis-votes",
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
animation: {
|
||||
duration: 0,
|
||||
},
|
||||
scales: {
|
||||
"y-axis-ratings": {
|
||||
min: 0,
|
||||
max: 10,
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "left",
|
||||
beginAtZero: true,
|
||||
},
|
||||
"y-axis-votes": {
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "right",
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
title: function (context) {
|
||||
const index = context[0].dataIndex;
|
||||
const episode = episodes[index];
|
||||
return `${episode.title} (${episode.aired.split("T")[0]})`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
19
core/views/js/components/search.js
Normal file
19
core/views/js/components/search.js
Normal file
@ -0,0 +1,19 @@
|
||||
export function search() {
|
||||
return {
|
||||
url: '/tv-show?id=',
|
||||
ttID: '',
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
submit() {
|
||||
this.isLoading = true;
|
||||
fetch(this.url+this.ttID).then(response => {
|
||||
if (response.ok) {
|
||||
window.location.href = this.url+this.ttID;
|
||||
} else {
|
||||
this.isLoading = false;
|
||||
this.isError = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
8
core/views/js/main.js
Normal file
8
core/views/js/main.js
Normal file
@ -0,0 +1,8 @@
|
||||
import Alpine from "https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/module.esm.js";
|
||||
import { search } from "./components/search.js";
|
||||
|
||||
window.Alpine = Alpine;
|
||||
|
||||
Alpine.data('search', search)
|
||||
|
||||
Alpine.start();
|
||||
16
core/views/layouts/main.html
Normal file
16
core/views/layouts/main.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link type="image/svg+xml" href="/vite.svg" rel="icon" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="/css/index.css" rel="stylesheet" />
|
||||
<title>Rating Orama</title>
|
||||
{{block "css" .}} {{end}}
|
||||
</head>
|
||||
<body class="min-h-screen bg-gray-100">
|
||||
{{embed}}
|
||||
|
||||
<script type="module" src="/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
96
core/views/partials/footer.html
Normal file
96
core/views/partials/footer.html
Normal file
@ -0,0 +1,96 @@
|
||||
<footer class="bg-gray-200" aria-label="Site Footer">
|
||||
<ul class="mt-12 flex justify-center gap-6 p-12">
|
||||
<li>
|
||||
<a
|
||||
class="text-gray-700 transition hover:text-gray-700/75"
|
||||
href="https://www.instagram.com/zepyrshut/"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Instagram</span>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M12.315 2c2.43 0 2.784.013 3.808.06 1.064.049 1.791.218 2.427.465a4.902 4.902 0 011.772 1.153 4.902 4.902 0 011.153 1.772c.247.636.416 1.363.465 2.427.048 1.067.06 1.407.06 4.123v.08c0 2.643-.012 2.987-.06 4.043-.049 1.064-.218 1.791-.465 2.427a4.902 4.902 0 01-1.153 1.772 4.902 4.902 0 01-1.772 1.153c-.636.247-1.363.416-2.427.465-1.067.048-1.407.06-4.123.06h-.08c-2.643 0-2.987-.012-4.043-.06-1.064-.049-1.791-.218-2.427-.465a4.902 4.902 0 01-1.772-1.153 4.902 4.902 0 01-1.153-1.772c-.247-.636-.416-1.363-.465-2.427-.047-1.024-.06-1.379-.06-3.808v-.63c0-2.43.013-2.784.06-3.808.049-1.064.218-1.791.465-2.427a4.902 4.902 0 011.153-1.772A4.902 4.902 0 015.45 2.525c.636-.247 1.363-.416 2.427-.465C8.901 2.013 9.256 2 11.685 2h.63zm-.081 1.802h-.468c-2.456 0-2.784.011-3.807.058-.975.045-1.504.207-1.857.344-.467.182-.8.398-1.15.748-.35.35-.566.683-.748 1.15-.137.353-.3.882-.344 1.857-.047 1.023-.058 1.351-.058 3.807v.468c0 2.456.011 2.784.058 3.807.045.975.207 1.504.344 1.857.182.466.399.8.748 1.15.35.35.683.566 1.15.748.353.137.882.3 1.857.344 1.054.048 1.37.058 4.041.058h.08c2.597 0 2.917-.01 3.96-.058.976-.045 1.505-.207 1.858-.344.466-.182.8-.398 1.15-.748.35-.35.566-.683.748-1.15.137-.353.3-.882.344-1.857.048-1.055.058-1.37.058-4.041v-.08c0-2.597-.01-2.917-.058-3.96-.045-.976-.207-1.505-.344-1.858a3.097 3.097 0 00-.748-1.15 3.098 3.098 0 00-1.15-.748c-.353-.137-.882-.3-1.857-.344-1.023-.047-1.351-.058-3.807-.058zM12 6.865a5.135 5.135 0 110 10.27 5.135 5.135 0 010-10.27zm0 1.802a3.333 3.333 0 100 6.666 3.333 3.333 0 000-6.666zm5.338-3.205a1.2 1.2 0 110 2.4 1.2 1.2 0 010-2.4z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a
|
||||
class="text-gray-700 transition hover:text-gray-700/75"
|
||||
href="https://github.com/zepyrshut"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">GitHub</span>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a
|
||||
class="text-gray-700 transition hover:text-gray-700/75"
|
||||
href="https://pedroperez.dev/"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Website</span>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
class="text-gray-700 transition hover:text-gray-700/75"
|
||||
href="https://github.com/zepyrshut/rating-orama"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Source</span>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</footer>
|
||||
3
core/views/partials/header.html
Normal file
3
core/views/partials/header.html
Normal file
@ -0,0 +1,3 @@
|
||||
<p class="mb-6 bg-yellow-400">
|
||||
Work in progress - API 0.1.0 / Harvester 0.1.0 / Views 0.1.0 <a href="mailto:hola@pedroperez.dev" class="text-blue-800">Have you found any bugs or is it not working with a specific tv show?</a>
|
||||
</p>
|
||||
@ -1,31 +1,28 @@
|
||||
version: "3"
|
||||
version: '3'
|
||||
|
||||
// TODO: update docker-compose
|
||||
services:
|
||||
core:
|
||||
container_name: rating-orama
|
||||
image: rating-orama:latest
|
||||
container_name: core-ratingorama
|
||||
image: core:0.1.0
|
||||
environment:
|
||||
DRIVERNAME: pgx
|
||||
DATASOURCE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable
|
||||
MIGRATE: true
|
||||
DATASOURCE: ${DATASOURCE}
|
||||
HARVESTER_API: ${HARVESTER_API}
|
||||
IS_PRODUCTION: ${IS_PRODUCTION}
|
||||
ports:
|
||||
- "8086:8080"
|
||||
networks:
|
||||
- ratingorama
|
||||
db:
|
||||
container_name: db-ratingorama
|
||||
image: postgres:16.4-alpine3.20
|
||||
image: postgres:15.2-alpine
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
volumes:
|
||||
- ratingorama_data:/var/lib/postgresql/data
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/schema.sql
|
||||
- ./data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- ratingorama
|
||||
|
||||
networks:
|
||||
ratingorama:
|
||||
|
||||
volumes:
|
||||
ratingorama_data:
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@ -7,18 +7,22 @@
|
||||
<title>Inicio</title>
|
||||
</head>
|
||||
|
||||
<body class="min-h-screen bg-slate-50 p-2">
|
||||
|
||||
|
||||
|
||||
<body class="min-h-screen bg-gray-100">
|
||||
<p class="mb-6 bg-yellow-400">
|
||||
Work in progress - API 0.1.0 / Harvester 0.1.0 / Views 0.1.0
|
||||
<a class="text-blue-800" href="mailto:hola@pedroperez.dev"
|
||||
>Have you found any bugs or is it not working with a specific tv
|
||||
show?</a
|
||||
>
|
||||
</p>
|
||||
|
||||
<div class="flex w-full flex-col items-center mt-6">
|
||||
<h1 class="mb-6 text-4xl font-bold">Breaking Bad</h1>
|
||||
<div class="flex w-full flex-col items-center">
|
||||
<h1 class="mb-6 text-3xl font-bold">Breaking Bad</h1>
|
||||
|
||||
<div class="mb-6 rounded-lg bg-white p-6 shadow-sm border border-gray-200">
|
||||
<div class="mb-6 rounded-lg bg-white p-6 shadow-md">
|
||||
<div class="mb-4 text-center">
|
||||
<span class="text-gray-600">IMDb ID: </span>
|
||||
<span class="font-semibold text-gray-800">tt0903747</span>
|
||||
<span class="text-gray-600">IMDb ID:</span>
|
||||
<span class="font-semibold text-gray-800">0903747</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-8">
|
||||
@ -111,12 +115,23 @@
|
||||
<li>
|
||||
<a
|
||||
class="text-gray-700 transition hover:text-gray-700/75"
|
||||
href="https://www.instagram.com/modelektor/"
|
||||
href="https://www.instagram.com/zepyrshut/"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Instagram</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-instagram"><rect width="20" height="20" x="2" y="2" rx="5" ry="5"/><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"/><line x1="17.5" x2="17.51" y1="6.5" y2="6.5"/></svg>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M12.315 2c2.43 0 2.784.013 3.808.06 1.064.049 1.791.218 2.427.465a4.902 4.902 0 011.772 1.153 4.902 4.902 0 011.153 1.772c.247.636.416 1.363.465 2.427.048 1.067.06 1.407.06 4.123v.08c0 2.643-.012 2.987-.06 4.043-.049 1.064-.218 1.791-.465 2.427a4.902 4.902 0 01-1.153 1.772 4.902 4.902 0 01-1.772 1.153c-.636.247-1.363.416-2.427.465-1.067.048-1.407.06-4.123.06h-.08c-2.643 0-2.987-.012-4.043-.06-1.064-.049-1.791-.218-2.427-.465a4.902 4.902 0 01-1.772-1.153 4.902 4.902 0 01-1.153-1.772c-.247-.636-.416-1.363-.465-2.427-.047-1.024-.06-1.379-.06-3.808v-.63c0-2.43.013-2.784.06-3.808.049-1.064.218-1.791.465-2.427a4.902 4.902 0 011.153-1.772A4.902 4.902 0 015.45 2.525c.636-.247 1.363-.416 2.427-.465C8.901 2.013 9.256 2 11.685 2h.63zm-.081 1.802h-.468c-2.456 0-2.784.011-3.807.058-.975.045-1.504.207-1.857.344-.467.182-.8.398-1.15.748-.35.35-.566.683-.748 1.15-.137.353-.3.882-.344 1.857-.047 1.023-.058 1.351-.058 3.807v.468c0 2.456.011 2.784.058 3.807.045.975.207 1.504.344 1.857.182.466.399.8.748 1.15.35.35.683.566 1.15.748.353.137.882.3 1.857.344 1.054.048 1.37.058 4.041.058h.08c2.597 0 2.917-.01 3.96-.058.976-.045 1.505-.207 1.858-.344.466-.182.8-.398 1.15-.748.35-.35.566-.683.748-1.15.137-.353.3-.882.344-1.857.048-1.055.058-1.37.058-4.041v-.08c0-2.597-.01-2.917-.058-3.96-.045-.976-.207-1.505-.344-1.858a3.097 3.097 0 00-.748-1.15 3.098 3.098 0 00-1.15-.748c-.353-.137-.882-.3-1.857-.344-1.023-.047-1.351-.058-3.807-.058zM12 6.865a5.135 5.135 0 110 10.27 5.135 5.135 0 010-10.27zm0 1.802a3.333 3.333 0 100 6.666 3.333 3.333 0 000-6.666zm5.338-3.205a1.2 1.2 0 110 2.4 1.2 1.2 0 010-2.4z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@ -128,7 +143,18 @@
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">GitHub</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@ -140,7 +166,19 @@
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Website</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-globe"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -151,7 +189,19 @@
|
||||
target="_blank"
|
||||
>
|
||||
<span class="sr-only">Source</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-code-xml"><path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/></svg>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@ -165,10 +215,7 @@
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
<script type="module">
|
||||
import {
|
||||
initCharts,
|
||||
loadSpecificSeason,
|
||||
} from "./src/components/charts.js";
|
||||
import { initCharts, loadSpecificSeason } from "./src/components/charts.js";
|
||||
import { data } from "./src/data/breaking-bad.js";
|
||||
|
||||
const tvShowParsed = data;
|
||||
|
||||
@ -1,43 +1,80 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="./src/styles/index.css" rel="stylesheet" />
|
||||
<title>Inicio</title>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="./src/styles/index.css" rel="stylesheet" />
|
||||
<title>Inicio</title>
|
||||
</head>
|
||||
|
||||
<body class="min-h-screen bg-slate-50 p-2">
|
||||
|
||||
<body class="min-h-screen bg-gray-100">
|
||||
<p class="mb-6 bg-yellow-400">
|
||||
Work in progress - API 0.1.0 / Harvester 0.1.0 / Views 0.1.0
|
||||
<a class="text-blue-800" href="mailto:hola@pedroperez.dev"
|
||||
>Have you found any bugs or is it not working with a specific tv
|
||||
show?</a
|
||||
>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div class="flex min-h-screen flex-col items-center justify-center">
|
||||
<h1 class="mb-6 text-3xl font-bold">Rating Orama</h1>
|
||||
|
||||
|
||||
<div class="flex flex-col justify-center min-h-screen">
|
||||
<form class="max-w-md mx-auto w-full">
|
||||
<label for="default-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Buscar</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="lucide lucide-search">
|
||||
<circle cx="11" cy="11" r="8" />
|
||||
<path d="m21 21-4.3-4.3" />
|
||||
</svg>
|
||||
</div>
|
||||
<input type="search" id="default-search"
|
||||
class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
placeholder="IMDb ID" required />
|
||||
<button type="submit"
|
||||
class="text-white absolute end-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Search</button>
|
||||
<div class="w-full max-w-md">
|
||||
<form x-data="search" @submit.prevent="submit" class="flex items-center gap-3" >
|
||||
<input
|
||||
x-model="ttID"
|
||||
class="rounded-md border-2 border-black bg-white px-4 py-2 w-11/12"
|
||||
id="search"
|
||||
name="search"
|
||||
type="text"
|
||||
placeholder="tt0903747"
|
||||
required
|
||||
/>
|
||||
<button
|
||||
:disabled="isLoading"
|
||||
class="rounded-md border-2 border-black bg-white px-4 py-2 font-bold text-black w-2/12"
|
||||
type="submit"
|
||||
:class="isLoading ? '' : 'hover:bg-black hover:text-white'"
|
||||
>
|
||||
<div class="flex items-center justify-center">
|
||||
<template x-if="isLoading">
|
||||
<div role="status">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-6 w-6 animate-spin fill-black text-white"
|
||||
aria-hidden="true"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">Cargando...</span>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="!isLoading" class="lorem">
|
||||
<span>Go!</span>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</button>
|
||||
</form>
|
||||
<p class="mt-2">
|
||||
Please input <span class="font-bold">tt id</span> from IDMb
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script src="./src/main.js" type="module"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<script src="./src/main.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -8,16 +8,18 @@
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"format": "prettier --write ."
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-plugin-organize-attributes": "^1.0.0",
|
||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||
"standard": "^17.1.2",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^6.0.11"
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.21",
|
||||
"prettier": "^2.8.7",
|
||||
"prettier-plugin-organize-attributes": "^0.0.5",
|
||||
"prettier-plugin-tailwindcss": "^0.2.7",
|
||||
"standard": "^17.0.0",
|
||||
"tailwindcss": "^3.3.1",
|
||||
"vite": "^4.2.1"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
@ -25,8 +27,5 @@
|
||||
"dist",
|
||||
"*.config.js"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
4419
views-dev/pnpm-lock.yaml
generated
4419
views-dev/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
6
views-dev/postcss.config.cjs
Normal file
6
views-dev/postcss.config.cjs
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {}
|
||||
}
|
||||
}
|
||||
@ -1 +1,3 @@
|
||||
@import "tailwindcss";
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@ -5,5 +5,7 @@ module.exports = {
|
||||
theme: {
|
||||
extend: {}
|
||||
},
|
||||
|
||||
plugins: [require('@tailwindcss/forms')({
|
||||
strategy: 'class'
|
||||
})]
|
||||
}
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
plugins: [
|
||||
tailwindcss()
|
||||
]
|
||||
base: './'
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user