diff --git a/src/main.rs b/src/main.rs index ed8420c..c0de8d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,12 +39,20 @@ fn index( use plurify::Plurify; #[derive(Serialize)] #[serde(crate = "rocket::serde")] + struct Scrape { + leechers: usize, + peers: usize, + seeders: usize, + } + #[derive(Serialize)] + #[serde(crate = "rocket::serde")] struct Row { created: Option, + files: String, indexed: String, magnet: String, + scrape: Option, size: String, - files: String, torrent: Torrent, } let (total, torrents) = storage @@ -69,6 +77,7 @@ fn index( .map(|t| t.format(&meta.format_time).to_string()), indexed: torrent.time.format(&meta.format_time).to_string(), magnet: format::magnet(&torrent.info_hash, meta.trackers.as_ref()), + scrape: None, // @TODO size: format::bytes(torrent.size), files: torrent.files.as_ref().map_or("1 file".into(), |f| { let l = f.len(); diff --git a/static/theme/default.css b/static/theme/default.css index 25ea3fb..1b72f72 100644 --- a/static/theme/default.css +++ b/static/theme/default.css @@ -15,9 +15,17 @@ transition: opacity .2s ease-in-out; } +:root { + --accent: #96d9a1; + --background: #282b3c; + --default: #ccc; + --item: #34384f; +} + + body { - background: #282b3c; - color: #ccc; + background: var(--background); + color: var(--default); font-family: Sans-serif; font-size: 13px; } @@ -25,7 +33,7 @@ body { a, a:visited, a:active { - color: #96d9a1; + color: var(--accent); text-decoration: none; opacity: .9; } @@ -40,7 +48,7 @@ h1 { } h2 { - color: #ccc; + color: var(--default); font-size: 14px; } @@ -59,12 +67,12 @@ header > a, header > a:active, header > a:hover, header > a:visited { - color: #ccc; + color: var(--default); font-size: 20px; } header::first-letter { - color: #96d9a1; + color: var(--accent); } header > div { @@ -82,7 +90,7 @@ main { /* pagination */ main > a { - background: #34384f; + background: var(--item); border-radius: 3px; float: right; margin-left: 8px; @@ -92,7 +100,7 @@ main > a { /* item row */ main > div { - background-color: #34384f; + background-color: var(--item); border-radius: 3px; margin: 8px 0; padding: 24px; @@ -122,6 +130,7 @@ main > div > div > ul > li { main > div > div > ul > li > span { color: white; + display: inline-block; font-size: smaller; opacity: 0.7; } @@ -135,9 +144,42 @@ main > div > div > ul > li:not(:last-child)::after { margin: 0 6px; } -main > div > div > a > svg { +main > div > div > ul > li > span.leechers { + background-image: url('leechers.svg'); + background-position: left center; + background-repeat: no-repeat; + padding-left: 16px; +} + +main > div > div > ul > li > span.peers { + background-image: url('peers.svg'); + background-position: left center; + background-repeat: no-repeat; + padding-left: 16px; +} + +main > div > div > ul > li > span.seeders { + background-image: url('seeders.svg'); + background-position: left center; + background-repeat: no-repeat; + padding-left: 16px; +} + +/* control actions */ +main > div > div > div { float: right; - vertical-align: middle; +} + +main > div > div > div > a { + background-position: center; + background-repeat: no-repeat; + display: inline-block; + height: 16px; + width: 16px; +} + +main > div > div > div > a.magnet { + background-image: url('magnet.svg'); } /* pagination info */ @@ -147,6 +189,6 @@ main > span { } footer { - margin: 16px auto 24px; + margin: 16px auto 36px; text-align: center; } \ No newline at end of file diff --git a/static/theme/leechers.svg b/static/theme/leechers.svg new file mode 100644 index 0000000..84b49ff --- /dev/null +++ b/static/theme/leechers.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/static/theme/magnet.svg b/static/theme/magnet.svg new file mode 100644 index 0000000..215871a --- /dev/null +++ b/static/theme/magnet.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/static/theme/peers.svg b/static/theme/peers.svg new file mode 100644 index 0000000..407990b --- /dev/null +++ b/static/theme/peers.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/static/theme/seeders.svg b/static/theme/seeders.svg new file mode 100644 index 0000000..4e45db0 --- /dev/null +++ b/static/theme/seeders.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/templates/index.html.tera b/templates/index.html.tera index 8b4ea08..712ce5f 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -1,32 +1,33 @@ {% extends "layout/default" %} {% block content %} -{% if rows %} - {% for row in rows %} -
- -

{{ row.torrent.name }}

- {% if row.torrent.comment %}

{{ row.torrent.comment }}

{% endif %} + {% if rows %} + {% for row in rows %}
-
    -
  • {{ row.indexed }}
  • - {% if row.created %}
  • ({{ row.created }})
  • {% endif %} - {% if row.size %}
  • {{ row.size }}
  • {% endif %} -
  • {{ row.files }}
  • -
- - - - - + +

{{ row.torrent.name }}

+ {% if row.torrent.comment %}

{{ row.torrent.comment }}

{% endif %} +
+
    +
  • {{ row.indexed }}
  • + {% if row.created %}
  • ({{ row.created }})
  • {% endif %} + {% if row.size %}
  • {{ row.size }}
  • {% endif %} +
  • {{ row.files }}
  • + {% if row.scrape %} +
  • {{ row.scrape.seeders }}
  • +
  • {{ row.scrape.seeders }}
  • +
  • {{ row.scrape.seeders }}
  • + {% endif %} +
+
+ +
+
-
- {% endfor %} -{% else %} -
- Nothing. -
-{% endif %} -{% if next %}Next{% endif %} -{% if back %}Back{% endif %} -{{ pagination_totals }} + {% endfor %} + {% else %} +
Nothing.
+ {% endif %} + {% if next %}Next{% endif %} + {% if back %}Back{% endif %} + {{ pagination_totals }} {% endblock content %} \ No newline at end of file