unify watchlist item use.

This commit is contained in:
Joe Ardent 2024-04-15 22:45:47 -07:00
parent 7b41e0f91b
commit 67a69ca0d0
5 changed files with 39 additions and 32 deletions

View file

@ -36,15 +36,13 @@ pub fn get_db_pool() -> SqlitePool {
tracing::info!("Connecting to DB at {db_filename}"); tracing::info!("Connecting to DB at {db_filename}");
let plugin = conf.julid_plugin;
let conn_opts = SqliteConnectOptions::new() let conn_opts = SqliteConnectOptions::new()
.foreign_keys(true) .foreign_keys(true)
.journal_mode(SqliteJournalMode::Wal) .journal_mode(SqliteJournalMode::Wal)
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal) .synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
.filename(&db_filename) .filename(&db_filename)
// be sure to have run `make` so that the libjulid extension is built // be sure to have run `make julid` so that the libjulid extension is built
.extension(plugin) .extension(conf.julid_plugin)
.busy_timeout(Duration::from_secs(TIMEOUT)) .busy_timeout(Duration::from_secs(TIMEOUT))
.create_if_missing(true) .create_if_missing(true)
.optimize_on_close(true, None) .optimize_on_close(true, None)

View file

@ -26,13 +26,22 @@
<p>Here are your things to watch:</p> <p>Here are your things to watch:</p>
<div class="watchlist"> <div class="watchlist">
<ul> <table>
<thead>
<tr>
<th>Title</th>
<th>Link</th>
<th>Type</th>
<th>Year</th>
<th>Watching?</th>
</tr>
</thead>
<tbody>
{% for watch in watches %} {% for watch in watches %}
<li><span class="watchtitle">{{watch.title}}</span> -- {% call m::get_or_default(watch.release_date, "when??") {% include "watchlist-item.html" %}
%}
</li>
{% endfor %} {% endfor %}
</ul> </tbody>
</table>
</div> </div>
{% else %} {% else %}
<p> <p>

View file

@ -43,8 +43,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for res in results %} {% for watch in results %}
{% include "watch-search-result.html" %} {% include "watchlist-item.html" %}
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>

View file

@ -1,19 +0,0 @@
<tr id="watchlist-item-{{res.id}}">
<td><span class="watchtitle"><a href="/watch/{{res.id}}">{{res.title}}</a></span></td>
<td><span>
{% match res.metadata_url %}
{% when Some with (mdurl) %}
<a href="{{ mdurl }}">{{ mdurl }}</a>
{% when None %}
{% endmatch %}
</span>
</td>
<td>{{res.kind}}</td>
<td> {% call m::get_or_default(res.release_date, "when??") -%}</td>
<td>
<span id="add-watch-{{res.id}}">
<span hx-get="/watch/status/{{res.id}}" hx-target="this" hx-trigger="load, reveal"
hx-swap="outerHTML">???</span>
</span>
</td>
</tr>

View file

@ -0,0 +1,19 @@
<tr id="watchlist-item-{{watch.id}}">
<td><span class="watchtitle"><a href="/watch/{{watch.id}}">{{watch.title}}</a></span></td>
<td><span>
{% match watch.metadata_url %}
{% when Some with (mdurl) %}
<a href="{{ mdurl }}">{{ mdurl }}</a>
{% when None %}
{% endmatch %}
</span>
</td>
<td>{{watch.kind}}</td>
<td> {% call m::get_or_default(watch.release_date, "when??") -%}</td>
<td>
<span id="add-watch-{{watch.id}}">
<span hx-get="/watch/status/{{watch.id}}" hx-target="this" hx-trigger="load, reveal"
hx-swap="outerHTML">???</span>
</span>
</td>
</tr>