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