Browse Source

use relative path for file path_entries

master
cinnaboot 7 years ago
parent
commit
caad659d80
  1. 2
      video_metadata/static/style.css
  2. 2
      video_metadata/templates/file_listing/index.html
  3. 8
      video_metadata/views/file_listing.py

2
video_metadata/static/style.css

@ -18,6 +18,6 @@ nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; }
input { color: #333; background-color: #eee; } input { color: #333; background-color: #eee; }
input.danger { color: #cc2f2e; } input.danger { color: #cc2f2e; }
.debug { background: lightgrey; padding: 1em; overflow: auto; border: 1px solid darkgrey } .debug { background: lightgrey; padding: 1em; overflow: auto; border: 1px solid darkgrey }
.search_result { max-width: 400px; padding: 1em; background: aquamarine; } .search_result { max-width: 400px; margin-bottom: 1em; padding: 1em; background: lightblue; border: 1px solid blue }
.arrow_submit { width: 3em; font-weight: bold; } .arrow_submit { width: 3em; font-weight: bold; }
.content li { list-style: ' - '; } .content li { list-style: ' - '; }

2
video_metadata/templates/file_listing/index.html

@ -14,7 +14,7 @@
<form action="{{ url_for('tmdb.query_movie') }}" method="post"> <form action="{{ url_for('tmdb.query_movie') }}" method="post">
<span>{{ path.base_name }}</span> <span>{{ path.base_name }}</span>
<input type="hidden" name="base_name" value="{{ path.base_name }}" /> <input type="hidden" name="base_name" value="{{ path.base_name }}" />
<input type="hidden" name="full_path" value="{{ path.full_path }}" /> <input type="hidden" name="rel_path" value="{{ path.rel_path }}" />
<input class="arrow_submit" type="submit" value="->" /> <input class="arrow_submit" type="submit" value="->" />
</form> </form>
{% endif %} {% endif %}

8
video_metadata/views/file_listing.py

@ -1,4 +1,5 @@
import os import os
import re
import yaml import yaml
from flask import Blueprint, current_app, render_template from flask import Blueprint, current_app, render_template
@ -12,7 +13,7 @@ bp = Blueprint('file_listing', __name__)
class path_entry: class path_entry:
def __init__(self): def __init__(self):
self.base_name = '' self.base_name = ''
self.full_path = '' self.rel_path = ''
self.file_extension = '' self.file_extension = ''
self.is_dir = False self.is_dir = False
self.depth = 0 self.depth = 0
@ -38,14 +39,13 @@ def index():
def getPathInfo(entry, depth=0): def getPathInfo(entry, depth=0):
if not entry.name.startswith('.') and not entry.is_symlink(): if not entry.name.startswith('.') and not entry.is_symlink():
video_path = current_app.config['MOVIE_DIR']
pe = path_entry() pe = path_entry()
pe.base_name = entry.name pe.base_name = entry.name
pe.path = entry.path pe.rel_path = re.sub(video_path, '', entry.path)
pe.is_dir = entry.is_dir() pe.is_dir = entry.is_dir()
pe.depth = depth pe.depth = depth
# TODO: add relative path for http server root links as 'full_path'
if entry.is_file(): if entry.is_file():
ext = os.path.splitext(entry)[1] ext = os.path.splitext(entry)[1]

Loading…
Cancel
Save