migration from showsize tag to showfull tag for simpler use experience

This commit is contained in:
Xevion
2019-06-30 14:05:22 -05:00
parent 0194162deb
commit 6471193e4c
4 changed files with 37 additions and 37 deletions

View File

@@ -121,20 +121,18 @@ def hidden(id):
return '\"count\" parameter must be Integer.<br>Invalid \"count\": \"{}\"'.format(request.args.get('count'))
base64 = boolparse(request.args.get('base64'))
# Handled within Jinja template
print(request.args.get('showsample'))
showsample = boolparse(request.args.get('showsample'), default=True)
showfull = boolparse(request.args.get('showfull'))
showtags = boolparse(request.args.get('showtags'))
# Request, Parse & Build Data
data = trap(tags, page, count, base64, showsample)
print(showsample)
return render_template('hidden.html', title='Gelbooru', data=data, base64=base64, showsample=showsample, showtags=showtags)
data = trap(tags, page, count, base64, showfull)
return render_template('hidden.html', title='Gelbooru', data=data, base64=base64, showfull=showfull, showtags=showtags)
def base64ify(url):
return base64.b64encode(requests.get(url).content).decode()
gelbooru_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&tags={}&pid={}&limit={}"
def trap(tags, page, count, base64, showsample):
def trap(tags, page, count, base64, showfull):
# URL Building & Request
temp = gelbooru_url.format(tags, page, count)
response = requests.get(temp).text
@@ -150,7 +148,7 @@ def trap(tags, page, count, base64, showsample):
'tags' : element['@tags']
}
if base64:
if showsample:
if not showfull:
temp['base64'] = base64ify(temp['sample_url'])
else:
temp['base64'] = base64ify(temp['real_url'])

View File

@@ -45,15 +45,15 @@
</div>
<div class="field">
<label for="base64">Use base64 encoding?</label>
<input type="checkbox" name="base64" />
<input type="checkbox" name="base64" value="true" />
</div>
<div class="field">
<label for="showsample">Show sample (thumbnail image)?</label>
<input type="checkbox" name="showsample" />
<label for="showsample">Show fullsize (instead of thumbnail image)?</label>
<input type="checkbox" name="showfull" value="true"/>
</div>
<div class="field">
<label for="showtags">Show tags of image?</label>
<input type="checkbox" name="showtags" />
<input type="checkbox" name="showtags" value="true" />
</div>
<div class="columns is-centered">
<div class="column is-4">
@@ -85,10 +85,10 @@
{% if base64 %}
<img src="data:image/png;base64,{{ image.base64 }}">
{% else %}
{% if showsample %}
<img src="{{ image.sample_url }}">
{% else %}
{% if showfull %}
<img src="{{ image.real_url }}" alt="{{ image.sample_url }}">
{% else %}
<img src="{{ image.sample_url }}">
{% endif %}
{% endif %}
</figure>

View File

@@ -330,7 +330,7 @@ It&apos;s maxmimum value is <code>1000</code>.</p>
<p>The <code>count</code> parameter specifies how many images will load on the page at once.<br>
It is recommended you do not exceed <code>100</code>, as most images will not load past this.<br>
When <code>base64</code> is enabled, count is automatically set back to <code>25</code> to stop server load, unless <code>showsample</code> is enabled, where it will be set to <code>50</code>.</p>
When <code>base64</code> is enabled, count is automatically set back to <code>50</code> to stop server load, unless <code>showfull</code> is enabled, where it will be set to <code>25</code>.</p>
<h5 class="mume-header" id="example-1">Example</h5>
<ul>
@@ -348,33 +348,34 @@ will load <code>50</code> images using <code>base64</code> encoding.</p>
</li>
</ul>
<hr>
<h4 class="mume-header" id="showsample-parameter"><code>showsample</code> parameter</h4>
<h4 class="mume-header" id="showfull-parameter"><code>showfull</code> parameter</h4>
<h5 class="mume-header" id="type-2">Type</h5>
<p>The <code>showsample</code> parameter is a boolean.<br>
<p>The <code>showfull</code> parameter is a boolean.<br>
As usual, it expects some form of <code>True</code>, <code>False</code>, <code>0</code>, or <code>1</code>.<br>
The parameter is not case sensitive.<br>
<code>showsample</code> defaults to <code>True</code> if not specified.</p>
<code>showfull</code> defaults to <code>False</code> if not specified.</p>
<h5 class="mume-header" id="description-2">Description</h5>
<p>The <code>showsample</code> parameter is very simple.<br>
<p>The <code>showfull</code> parameter is very simple.<br>
This requests that the page load with high quality images instead of the default thumbnail quality image.<br>
The Gelbooru API provides multiple links for any given image, one of which is a link for the thumnbail.<br>
The Gelbooru site staff prefer that sites like mine link to the thumbnail image, of which this parameter does. The thumnbail image is of significantly lower quality, but it lowers loading time for both you, as well as reduce load on the Gelbooru CDN. Out of respect for them, we ask that this parameter be kept on, as to view the full high quality version of the image, you need but click on the image itself.</p>
<h5 class="mume-header" id="example-2">Example</h5>
<ul>
<li>
<p><code>/hidden?showsample=True</code><br>
shows all images in thumbnail quality</p>
</li>
<li>
<p><code>/hidden?showsample=False</code><br>
<p><code>/hidden?showfull=True</code><br>
shows all images in high quality</p>
</li>
<li>
<p><code>hidden/showsample=0&amp;base64=True</code><br>
shows all images in high quality using <code>base64</code> encoding</p>
<p><code>/hidden?showfull=False</code><br>
shows all images in thumbnail quality</p>
</li>
<li>
<p><code>hidden/showfull=0&amp;base64=True</code><br>
shows all images in thumnbnail quality using <code>base64</code> encoding</p>
</li>
</ul>
<hr>

View File

@@ -78,7 +78,7 @@ It's maxmimum value is `1000`.
The `count` parameter specifies how many images will load on the page at once.
It is recommended you do not exceed `100`, as most images will not load past this.
When `base64` is enabled, count is automatically set back to `25` to stop server load, unless `showsample` is enabled, where it will be set to `50`.
When `base64` is enabled, count is automatically set back to `50` to stop server load, unless `showfull` is enabled, where it will be set to `25`.
##### Example
@@ -93,31 +93,32 @@ will load `50` images using `base64` encoding.
---
#### `showsample` parameter
#### `showfull` parameter
##### Type
The `showsample` parameter is a boolean.
The `showfull` parameter is a boolean.
As usual, it expects some form of `True`, `False`, `0`, or `1`.
The parameter is not case sensitive.
`showsample` defaults to `True` if not specified.
`showfull` defaults to `False` if not specified.
##### Description
The `showsample` parameter is very simple.
The `showfull` parameter is very simple.
This requests that the page load with high quality images instead of the default thumbnail quality image.
The Gelbooru API provides multiple links for any given image, one of which is a link for the thumnbail.
The Gelbooru site staff prefer that sites like mine link to the thumbnail image, of which this parameter does. The thumnbail image is of significantly lower quality, but it lowers loading time for both you, as well as reduce load on the Gelbooru CDN. Out of respect for them, we ask that this parameter be kept on, as to view the full high quality version of the image, you need but click on the image itself.
##### Example
* `/hidden?showsample=True`
shows all images in thumbnail quality
* `/hidden?showsample=False`
* `/hidden?showfull=True`
shows all images in high quality
* `hidden/showsample=0&base64=True`
shows all images in high quality using `base64` encoding
* `/hidden?showfull=False`
shows all images in thumbnail quality
* `hidden/showfull=0&base64=True`
shows all images in thumnbnail quality using `base64` encoding
---