Skip to content

Commit

Permalink
disable the low res images option
Browse files Browse the repository at this point in the history
  • Loading branch information
mlebkowski committed Jan 31, 2017
1 parent 362dc5e commit 458a862
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
27 changes: 27 additions & 0 deletions _misc/shrink.sh
@@ -0,0 +1,27 @@
#!/bin/bash

main() {
declare path="$1" target=${2:-"shrink"}

mkdir -p "$target"

find "$path" -type f -iname "*.png" -print0 | while IFS= read -r -d $'\0' image; do
local name=$(basename "$image")
printf "Shrinking \e[36m%s\e[0m... " "$image"

local target_url=$(curl --user api:$TINYPNG_API_KEY --data-binary @"$image" -s https://api.tinify.com/shrink | jq -r .output.url)

if [ -z "$target_url" ]; then
echo -e '\e[91m[Error]\e[0m'
continue;
fi

printf "And saving to \e[93m%s\e[0m... " "$target/$name"

curl -Ss "$target_url" > "$target/$name"

printf "\e[92m[Done]\e[0m\n"
done
}

main "$@"
2 changes: 1 addition & 1 deletion cards.html
Expand Up @@ -7,7 +7,7 @@
<a href="#usage">Did you know you can embed those cards on your site? (click to see how!)</a>
</p>
<hr>
<style type="text/css">cb-card { font-size: 42%; float: left }</style>
<style type="text/css">cb-card { font-size: 22%; float: left }</style>
<div id="cards" class=row></div>
<script type="text/javascript">require(['cartoon-battle'], function (getCards) {
getCards(function (cards) {
Expand Down
5 changes: 2 additions & 3 deletions javascript/cartoon-battle/Card.js
@@ -1,4 +1,4 @@
define(['./config', './util', './Rarity', 'settings'], function (config, util, Rarity, Settings) {
define(['./config', './util', './Rarity'], function (config, util, Rarity) {
function Card(value) {
value = value || {};
this.node = util.createFragment('cb-card', [
Expand Down Expand Up @@ -101,8 +101,7 @@ define(['./config', './util', './Rarity', 'settings'], function (config, util, R

this.image = image;

var path = Settings.getValue('high_resolution_images') ? "cards" : "thumbnails";
this.node.querySelector("img").src = config.images_cdn + "deck/" + path + "/" + this.image + ".png";
this.node.querySelector("img").src = config.images_cdn + "deck/cards/" + this.image + ".png";
};

Card.prototype.setAttack = function card__setAttack(attack) {
Expand Down
4 changes: 1 addition & 3 deletions javascript/recipes.js
@@ -1,4 +1,4 @@
/* global define */ define(['cartoon-battle', 'cartoon-battle/util', 'settings'], function (getCards, util, Settings) {
/* global define */ define(['cartoon-battle', 'cartoon-battle/util'], function (getCards, util) {
var table = document.querySelector('table');
var tbody = table.querySelector('tbody');
var input = document.forms.recipes.querySelector('input');
Expand Down Expand Up @@ -41,8 +41,6 @@
return;
}

document.getElementById('resolution_alert').style.display = Settings.getValue('high_resolution_images') ? "none" : "block";

selectedCard = card;
setTitle(card.name);
"function" === typeof ga && ga("send", "event", "recipe", "search", card.name);
Expand Down
8 changes: 0 additions & 8 deletions recipes.html
Expand Up @@ -64,14 +64,6 @@
</form>
</div>

<p class="alert alert-warning" id="resolution_alert" style="display: none;">
I reduced the image sizes to save some bandwidth, and lower the site cost.
Please see my <a href="{{ site.patreon_url }}">Patreon Page</a> and pledge a monthly amount
to keep this site going, and allow me to maintain the highest quality possible for you guys.

<br><br>
You can enable the high resolution images for free, just look at the patreon page for details how to do it.
</p>
<table class="table">
<thead>
<tr>
Expand Down
4 changes: 1 addition & 3 deletions settings.html
@@ -1,10 +1,8 @@
---
title: Settings
weight: 100
---

<form name="settings">
<p class="alert alert-info">The settings are saved automatically</p>
<p class="alert alert-warning">Settings take no effect currently</p>
<fieldset/>
</form>

Expand Down

0 comments on commit 458a862

Please sign in to comment.