mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-10 14:09:08 -06:00
better tag display
This commit is contained in:
@@ -111,7 +111,7 @@ def hidden(id):
|
||||
# Handled within request
|
||||
tags = request.args.get('tags') or 'trap'
|
||||
try:
|
||||
page = int(request.args.get('page') or 1) - 1
|
||||
page = int(request.args.get('page') or 1)
|
||||
except (TypeError, ValueError):
|
||||
return '\"page\" parameter must be Integer.<br>Invalid \"page\" parameter: \"{}\"'.format(request.args.get('page'))
|
||||
# Handled within building
|
||||
@@ -124,8 +124,14 @@ def hidden(id):
|
||||
showfull = boolparse(request.args.get('showfull'))
|
||||
showtags = boolparse(request.args.get('showtags'))
|
||||
# Request, Parse & Build Data
|
||||
data = trap(tags, page, count, base64, showfull)
|
||||
return render_template('hidden.html', title='Gelbooru', data=data, base64=base64, showfull=showfull, showtags=showtags)
|
||||
data = trap(tags, page-1, count, base64, showfull)
|
||||
# Handling for limiters
|
||||
if base64:
|
||||
if showfull:
|
||||
count = min(25, count)
|
||||
else:
|
||||
count = min(50, count)
|
||||
return render_template('hidden.html', title='Gelbooru Browser', data=data, tags=tags, page=page, count=count, base64=base64, showfull=showfull, showtags=showtags)
|
||||
|
||||
def base64ify(url):
|
||||
return base64.b64encode(requests.get(url).content).decode()
|
||||
@@ -140,12 +146,17 @@ def trap(tags, page, count, base64, showfull):
|
||||
parse = xmltodict.parse(response)
|
||||
build = []
|
||||
|
||||
try:
|
||||
parse['posts']['post']
|
||||
except KeyError:
|
||||
return build
|
||||
|
||||
for index, element in enumerate(parse['posts']['post'][:count]):
|
||||
temp = {
|
||||
'index' : str(index + 1),
|
||||
'real_url' : element['@file_url'],
|
||||
'sample_url' : element['@preview_url'],
|
||||
'tags' : element['@tags']
|
||||
'tags' : list(filter(lambda x : x != '', [tag.strip() for tag in element['@tags'].split(' ')]))
|
||||
}
|
||||
if base64:
|
||||
if not showfull:
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
.resize-font {
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.pad-tag {
|
||||
margin: 0.10rem;
|
||||
}
|
||||
</style>
|
||||
{% endblock head %}
|
||||
{% block body %}
|
||||
@@ -27,7 +31,7 @@
|
||||
<div class="field">
|
||||
<label for="tags">Tags</label>
|
||||
<p class="control has-icons-left">
|
||||
<input class="input" type="search" name="tags" />
|
||||
<input class="input" type="search" name="tags" value="{{ tags }}""/>
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-search"></i>
|
||||
</span>
|
||||
@@ -37,23 +41,32 @@
|
||||
<div class="field">
|
||||
<label for="count">Count</label>
|
||||
<p class="control has-icons-left">
|
||||
<input class="input" type="number" min="0" max="1000" name="count" value="50" />
|
||||
<input class="input" type="number" min="0" max="1000" name="count" value="{{ count or 50}}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-equals"></i>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="page">Page</label>
|
||||
<p class="control has-icons-left">
|
||||
<input class="input" type="number" min="0" max="1000" name="page" value="{{ page or 0 }}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-flask"></i>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="base64">Use base64 encoding?</label>
|
||||
<input type="checkbox" name="base64" value="true" />
|
||||
<input type="checkbox" name="base64" value="true" {% if base64 %}checked{% endif %}/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="showsample">Show fullsize (instead of thumbnail image)?</label>
|
||||
<input type="checkbox" name="showfull" value="true"/>
|
||||
<input type="checkbox" name="showfull" value="true" {% if showfull %}checked{% endif %}/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="showtags">Show tags of image?</label>
|
||||
<input type="checkbox" name="showtags" value="true" />
|
||||
<input type="checkbox" name="showtags" value="true" {% if showtags %}checked{% endif %}/>
|
||||
</div>
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-4">
|
||||
@@ -97,7 +110,11 @@
|
||||
{% if showtags %}
|
||||
<div class="card-content">
|
||||
<div class="content word-break resize-font">
|
||||
{{ image.tags }}
|
||||
{% for tag in image.tags %}
|
||||
<span class="pad-tag tag">
|
||||
{{ tag }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user