basic theme

This commit is contained in:
dave 2019-08-19 09:32:32 -07:00
parent 508448229b
commit 3932d5745b
9 changed files with 1548 additions and 141 deletions

View File

@ -92,4 +92,4 @@ todo
* more options than just hard linking (soft link, copy) * more options than just hard linking (soft link, copy)
* support sorting season torrents * support sorting season torrents
* make UI pretty * make UI pretty
* support post-sort webhooks e.g. to tell plex to rescan when we add something * support post-sort webhooks e.g. to tell plex to rescan when we add something - maybe push and email too

1381
assets/styles.css Normal file

File diff suppressed because it is too large Load Diff

View File

@ -139,6 +139,7 @@ class MediaWeb(object):
torrents=self.cache.torrents, torrents=self.cache.torrents,
moves=self.cache.moves, moves=self.cache.moves,
shows=self.cache.data.shows, shows=self.cache.data.shows,
user=cherrypy.request.login,
**kwargs, **kwargs,
**self.get_default_vars()) **self.get_default_vars())
@ -146,11 +147,15 @@ class MediaWeb(object):
return {} return {}
@cherrypy.expose @cherrypy.expose
def index(self, action=None): def index(self):
return self.render("splash.html")
@cherrypy.expose
def home(self, action=None):
if action: if action:
if action == "update": if action == "update":
self.cache.refresh() self.cache.refresh()
raise cherrypy.HTTPRedirect("/") raise cherrypy.HTTPRedirect("/home")
return self.render("index.html", inflight=self.cache.inflight) return self.render("index.html", inflight=self.cache.inflight)
@cherrypy.expose @cherrypy.expose
@ -163,7 +168,7 @@ class MediaWeb(object):
otherdest or dest) otherdest or dest)
client.rpc.core.move_storage([thash], target) client.rpc.core.move_storage([thash], target)
self.cache.refresh() self.cache.refresh()
raise cherrypy.HTTPRedirect("/") raise cherrypy.HTTPRedirect("/home")
return self.render("moveform.html", torrent=torrent, tkey=tkey) return self.render("moveform.html", torrent=torrent, tkey=tkey)
@ -249,7 +254,7 @@ class MediaWeb(object):
else: else:
raise cherrypy.HTTPError(404) raise cherrypy.HTTPError(404)
self.cache.refresh() self.cache.refresh()
raise cherrypy.HTTPRedirect("/") raise cherrypy.HTTPRedirect("/home")
def get_fname(torrent): def get_fname(torrent):
@ -332,7 +337,11 @@ def main():
web = MediaWeb(rpc_cache, tpl, options) web = MediaWeb(rpc_cache, tpl, options)
cherrypy.tree.mount(web, '/', {'/': {'tools.auth_basic.on': True, cherrypy.tree.mount(web, '/', {'/': {'tools.auth_basic.on': True,
'tools.auth_basic.realm': 'mediaweb', 'tools.auth_basic.realm': 'mediaweb',
'tools.auth_basic.checkpassword': validate_password, }}) 'tools.auth_basic.checkpassword': validate_password, },
'/index': {'tools.auth_basic.on': False},
'/static': {'tools.auth_basic.on': False,
'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(APPROOT, 'assets')}})
# General config options # General config options
cherrypy.config.update({ cherrypy.config.update({

9
templates/html.html Normal file
View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Media Sort</title>
<link type="text/css" rel="stylesheet" href="/static/styles.css" media="all" />
</head>
{% block body %}{% endblock %}
</html>

View File

@ -1,15 +1,25 @@
{% extends "page.html" %} {% extends "page.html" %}
{% block toolbar %} {% block toolbar %}
<form action="/" method="post"> <a class="nav-item is-active" href="/home">Home</a>
<input name="action" type="submit" value="refresh"> <a class="nav-item" href="/home">Refresh</a>
{% if inflight %}update in progress...{% else %}<input name="action" type="submit" value="update">{% endif %} {% if inflight %}<span class="nav-item">Scanning in progress...</span>
</form> {% else %}<a class="nav-item" href="/home?action=update">Rescan</a>{% endif %}
<a class="nav-item" href="/home">Blah</a>
<hr />
<a class="nav-item" href="/home">Blah</a>
<a class="nav-item" href="/home">Blah</a>
{% endblock %} {% endblock %}
{% block body %} {% block main %}
<div class="torrents"> <form action="/autosort" method="post">
<h2>Completed</h2> <header class="flex items-center py1 border-bottom">
<form action="/autosort" method="post"> <h1 class="m0">Completed</h1>
{% if inflight %}<a class="btn ml-auto btn-primary rounded-left">Scanning...</a>
{% else %}<a href="/home?action=update" class="btn ml-auto btn-primary rounded-left">Rescan</a>{% endif %}
<input type="submit" value="Autosort selected" class="btn btn-danger rounded-right">
</header>
<section class="flex py2">
<table> <table>
<tr> <tr>
<th></th> <th></th>
@ -24,8 +34,8 @@
<td><input type="checkbox" name="tkeys" value="{{ torid }}"{% if torid in moves %} checked="checked"{% else %} disabled="disabled"{% endif %}/></td> <td><input type="checkbox" name="tkeys" value="{{ torid }}"{% if torid in moves %} checked="checked"{% else %} disabled="disabled"{% endif %}/></td>
<td>{{ torid[0:8] }}</td> <td>{{ torid[0:8] }}</td>
<td> <td>
{{ tor.name }}<br /> <span class="h3">{{ tor.name }}</span><br />
<span class="small">{{ tor.save_path }}</span> <span class="h6">{{ tor.save_path }}</span>
</td> </td>
{% if torid in moves %} {% if torid in moves %}
<td>{{ moves[torid].dest.dir }}</td> <td>{{ moves[torid].dest.dir }}</td>
@ -41,10 +51,12 @@
</tr> </tr>
{% endif %}{% endfor %} {% endif %}{% endfor %}
</table> </table>
<br/> </section>
<input type="submit" value="Autosort selected"> </form>
</form> <header class="flex items-center py1 border-bottom">
<h2>Downloading</h2> <h1 class="m0">Downloading</h1>
</header>
<section class="flex mb3">
<table> <table>
<tr> <tr>
<th>hash</th> <th>hash</th>
@ -76,25 +88,28 @@
</tr> </tr>
{% endif %}{% endfor %} {% endif %}{% endfor %}
</table> </table>
<div class="libraryinfo"> </section>
<details> <header class="flex items-center py1 border-bottom">
<summary>Library information</summary> <h1 class="m0">Library</h1>
<h2>Shows ({{ shows|len }})</h2> </header>
<table> <section class="flex mb3">
<tr> <details>
<th>name</th> <summary>Library information</summary>
<th>path</th> <h2>Shows ({{ shows|len }})</h2>
<th>sorting</th> <table>
</tr> <tr>
{% for show in shows %} <th>name</th>
<tr> <th>path</th>
<td>{{ show.name }}</td> <th>sorting</th>
<td>{{ show.dir }}</td> </tr>
<td>{{ show.mode }}</td> {% for show in shows %}
</tr> <tr>
{% endfor %} <td>{{ show.name }}</td>
</table> <td>{{ show.dir }}</td>
</details> <td>{{ show.mode }}</td>
</div> </tr>
</div> {% endfor %}
</table>
</details>
</section>
{% endblock %} {% endblock %}

View File

@ -1,11 +1,22 @@
{% extends "page.html" %} {% extends "page.html" %}
{% block toolbar %} {% block toolbar %}
<a href="/"><button type="button">Back</button></a> <a class="nav-item is-active" href="/home">Back</a>
{% endblock %} {% endblock %}
{% block body %} {% block main %}
<div class="moveform"> <div class="moveform">
<header class="flex items-center py1 border-bottom">
<h1 class="m0">Move <span class="font-size-smaller">{{ torrent.name }} - {{ torrent.hash }}</span></h1>
</header>
<section class="mb3">
<ul>
{% for f in torrent.files %}
<li>{{ f.path }} - {{ f.size }} B</li> <!-- TODO nice size formatting-->
{% endfor %}
</ul>
</section>
<h2>Move {{ torrent.name }} </h2> <h2>Move {{ torrent.name }} </h2>
<p>{{ torrent.hash }}</p> <p>{{ torrent.hash }}</p>

View File

@ -1,52 +1,22 @@
<!DOCTYPE html> {% extends "html.html" %}
<html lang="en">
<head> {% block body %}
<meta charset="UTF-8"> <body class="flex v100 items-stretch white bg-black">
<title>Media Sort</title> <nav class="p2 overflow-scroll bg-darken-4" style="width:256px">
<style> <h1 class="m0">msort</h1>
html, body { <p class="mt0 gray">media librarian</p>
font-family: arial, sans-serif; {% block toolbar %}{% endblock %}
font-size: 12px; </nav>
} <div class="flex-auto flex flex-column">
#page { <header class="flex items-center x1 bg-darken-2">
margin: 0px auto; <h3 class="h3 m0 px2">{{ user }}</h3>
padding: 0px 15px; <a href="/" class="nav-item ml-auto">Sign Out</a>
max-width: 1000px; </header>
} <main class="flex-auto p3">
td { {% block main %}{% endblock %}
padding: 3px 5px; <hr />
} </main>
td {
border-bottom: 1px solid #666;
}
h2 {
margin-top: 30px;
}
table {
width: 100%;
}
span.small {
font-size: 10px;
color: #999;
}
.right {
float: right;
}
.libraryinfo {
margin-top: 30px;
}
details summary:hover {
cursor: pointer;
}
</style>
</head>
<body>
<div id="page">
<div class="toolbar">
{% block toolbar %}{% endblock %}
</div>
{% block body %}{% endblock %}
</div> </div>
<a name="bottom" /> <a name="bottom" />
</body> </body>
</html> {% endblock %}

View File

@ -1,55 +1,56 @@
{% extends "page.html" %} {% extends "page.html" %}
{% block toolbar %} {% block toolbar %}
<a href="/"><button type="button">Back</button></a> <a class="nav-item is-active" href="/home">Back</a>
{% endblock %} {% endblock %}
{% block body %} {% block main %}
<div class="sortform"> <form action="/sort" method="post">
<h2>Sort {{ torrent.name }} </h2> <div class="col col-12 lg-col-6">
<p>{{ torrent.hash }}</p> <header class="flex items-center py1 border-bottom">
<h1 class="m0">Files <span class="font-size-smaller">{{ torrent.name }} - {{ torrent.hash }}</span></h1>
<fieldset> </header>
<legend>files</legend> <section class="mb3">
<ul> <ul>
{% for f in torrent.files %} {% for f in torrent.files %}
<li>{{ f.path }} - {{ f.size }} B</li> <!-- TODO nice size formatting--> <li>{{ f.path }} - {{ f.size }} B</li> <!-- TODO nice size formatting-->
{% endfor %}
</ul>
</fieldset>
<br/>
<form action="/sort" method="post">
<input type="hidden" name="tkey" value="{{ tkey }}">
<fieldset>
<legend>destination</legend>
<table>
<tr>
<th></th>
<th>show</th>
<th>season</th>
<th>library</th>
<th>score</th>
</tr>
{% for row in matches %}
<tr>
<td>
<input type="radio" name="dest" value="{{row.dest.dir}}" {% if loop.index == 1 %}checked="checked"{%endif %}/>
</td>
<td>{{ row.dest.dir }}</td>
<td>{{ row.subdest }}</td>
<td>{{ row.dest.root }}</td>
<td>{{ row.score }}</td>
</tr>
{% endfor %} {% endfor %}
</table> </ul>
<br /> </section>
<input type="submit" value="Sort"> </div>
<div class="right"> <div class="col col-12 lg-col-6">
{% if score > 0 %}<a href="/sort?tkey={{ tkey }}&score={{ score // 2 }}#bottom">show more (S={{ score }}%)</a>{% endif %} <header class="flex items-center py1 border-bottom">
{{ matches|len }} <h1 class="m0">Destination</h1>
</div> <input type="submit" value="Save" class="btn btn-danger ml-auto rounded">
</fieldset> </header>
</form> <section class="mb3">
</div>
<input type="hidden" name="tkey" value="{{ tkey }}">
<table>
<tr>
<th></th>
<th>show</th>
<th>season</th>
<th>library</th>
<th>score</th>
</tr>
{% for row in matches %}
<tr>
<td>
<input type="radio" name="dest" value="{{row.dest.dir}}" {% if loop.index == 1 %}checked="checked"{%endif %}/>
</td>
<td>{{ row.dest.dir }}</td>
<td>{{ row.subdest }}</td>
<td>{{ row.dest.root }}</td>
<td>{{ row.score }}</td>
</tr>
{% endfor %}
</table>
<br />
<div class="right">
{% if score > 0 %}<a href="/sort?tkey={{ tkey }}&score={{ score // 2 }}#bottom">show more (S={{ score }}%)</a>{% endif %}
{{ matches|len }}
</div>
</section>
</div>
</form>
{% endblock %} {% endblock %}

11
templates/splash.html Normal file
View File

@ -0,0 +1,11 @@
{% extends "html.html" %}
{% block body %}
<body class="flex items-center justify-center v100 white bg-black">
<div class="bg-darken-4 py3 px4 center">
<h1 class="m0">MediaSort</h1>
Unauthenticated &middot; <a href="/home">Login</a>
</div>
<a name="bottom" />
</body>
{% endblock %}