From dd1f1b683413e096010d71e742203c5ab6dbe3c1 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Mon, 15 May 2017 09:10:31 +0300 Subject: [PATCH 1/3] Nicer looking file list (basic table) --- nyaa/routes.py | 2 +- nyaa/templates/view.html | 41 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/nyaa/routes.py b/nyaa/routes.py index e70f993..51a7dd3 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -504,7 +504,7 @@ def view_torrent(torrent_id): files = None if torrent.filelist: - files = utils.flattenDict(json.loads(torrent.filelist.filelist_blob.decode('utf-8'))) + files = json.loads(torrent.filelist.filelist_blob.decode('utf-8')) return flask.render_template('view.html', torrent=torrent, files=files, diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index 6496eb9..26a9636 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -79,20 +79,33 @@
- - - - - - - {%- for key, value in files.items() %} - - - - - {%- endfor %} - -
PathSize
{{ key }}{{ value | filesizeformat(True) }}
+ + + + + + + {%- for key, value in files.items() recursive %} + {%- if value is iterable %} + {%- if loop.depth0 is greaterthan 0 %} + + + + {{ loop(value.items()) }} + + {%- else %} + + + + + {%- endif %} + {%- endfor %} +
PathSize
+ {%- else %} +
+ {%- endif %} + {{ key }}
+ {{ key }}{{ value | filesizeformat(True) }}
{% elif files %} From bd1a9f5cf40d4341abba8ec4d6da1eda04cab31c Mon Sep 17 00:00:00 2001 From: sharkykh Date: Mon, 15 May 2017 09:34:22 +0300 Subject: [PATCH 2/3] Reformat --- nyaa/templates/view.html | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index 26a9636..a77f7a2 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -86,24 +86,17 @@ {%- for key, value in files.items() recursive %} + {%- if value is iterable %} - {%- if loop.depth0 is greaterthan 0 %} - - - {%- else %} - - - {%- endif %} - {{ key }} - {{ loop(value.items()) }} - + + {{ key }} + {{ loop(value.items()) }} {%- else %} - - - {{ key }} - {{ value | filesizeformat(True) }} - + + {{ key }} + {{ value | filesizeformat(True) }} {%- endif %} + {%- endfor %} From 6be5326f45c42f6ca906ecf6ef08fecac4ea9506 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Mon, 15 May 2017 09:37:02 +0300 Subject: [PATCH 3/3] Reformat code some more --- nyaa/templates/view.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index a77f7a2..969a95e 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -86,17 +86,17 @@ {%- for key, value in files.items() recursive %} - + {%- if value is iterable %} - - {{ key }} - {{ loop(value.items()) }} + + {{ key }} + {{ loop(value.items()) }} {%- else %} - - {{ key }} - {{ value | filesizeformat(True) }} + + {{ key }} + {{ value | filesizeformat(True) }} {%- endif %} - + {%- endfor %}