Skip to content

Commit

Permalink
feat: Add support for new GK Types: pebble, car, playing card, dog
Browse files Browse the repository at this point in the history
  • Loading branch information
kumy committed Jul 21, 2024
1 parent ffc8391 commit c6e6d8c
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 13 deletions.
2 changes: 1 addition & 1 deletion website/app-templates/smarty/blocks/user/details.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="panel panel-default" id="userDetailsPanel">
<div class="panel-heading">
<img id="userDetailsTypeIcon" src="{GK_CDN_IMAGES_URL}/log-icons/2/icon_25.jpg" width="25" height="25" data-gk-type="" />
<img id="userDetailsTypeIcon" src="{GK_CDN_IMAGES_URL}/log-icons/2/icon.svg" width="25px" height="25px" data-gk-type="" />
{$user|userlink nofilter}
<div class="btn-group pull-right" role="group">
{if $f3->get('SESSION.CURRENT_USER') && !$user->isCurrentUser() && $user->email}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function smarty_modifier_gkavatar(Geokret $geokret): string {
*/
public function smarty_modifier_gkicon(Geokret $geokret): string {
return sprintf(
'<img src="%s/log-icons/%s/icon.svg" class="img-fluid w-3" alt="%s" title="%s" data-gk-type="%s" width="25" height="25">',
'<img src="%s/log-icons/%s/icon.svg" class="img-fluid w-3" alt="%s" title="%s" data-gk-type="%s" width="25px" height="25px">',
GK_CDN_IMAGES_URL,
$geokret->type->getTypeId(),
_('GK type icon'),
Expand Down
77 changes: 70 additions & 7 deletions website/app-templates/smarty/help-pages/en/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@
</ol>

<p>Examples of ready GeoKrety</p>
<img src="{GK_CDN_IMAGES_URL}/help/geokret-przyklad-sp2ong_1.jpg" alt="example" width="250" height="188" />
<img src="{GK_CDN_IMAGES_URL}/help/geokret-przyklad-sp2ong_2.jpg" alt="example 2" width="250" height="148" />
<img src="{GK_CDN_IMAGES_URL}/help/geokret-przyklad-dziku.jpg" alt="example" width="250" height="180" />
<img src="{GK_CDN_IMAGES_URL}/help/geokret-przyklad-sp2ong_1.jpg" alt="example" width="250px" height="188px" />
<img src="{GK_CDN_IMAGES_URL}/help/geokret-przyklad-sp2ong_2.jpg" alt="example 2" width="250px" height="148px" />
<img src="{GK_CDN_IMAGES_URL}/help/geokret-przyklad-dziku.jpg" alt="example" width="250px" height="180px" />
<a href="/en/geokrety/GK18270" target="_blank">
<img src="{GK_CDN_IMAGES_URL}/help/GK18270_667566821c2bf.png" alt="example" width="250px" height="180px" />
</a>

</div>
<div class="col-md-5">
Expand Down Expand Up @@ -159,7 +162,7 @@ <h3>A book</h3>
<div class="caption">
<h3>A Human</h3>
<p>
When you want to track yourself and write something like GeoBlog
When you want to track yourself and write something like GeoBlog. <i>(Not collectible)</i>
</p>
</div>
</div>
Expand Down Expand Up @@ -189,14 +192,74 @@ <h3>KretyPost</h3>
</div>
</div>

<div class="col-sm-2">
<div class="thumbnail">
<img src="{GK_CDN_IMAGES_URL}/log-icons/5/icon.svg" alt="" width="100" height="100" />
<div class="caption">
<h3>Pebble</h3>
<p>
A painted small rock.
</p>
</div>
</div>
</div>

<div class="col-sm-2">
<div class="thumbnail">
<img src="{GK_CDN_IMAGES_URL}/log-icons/6/icon.svg" alt="" width="100" height="100" />
<div class="caption">
<h3>Car</h3>
<p>
Stickers for vehicules. <i>(Not collectible)</i>
</p>
</div>
</div>
</div>

<div class="col-sm-2">
<div class="thumbnail">
<img src="{GK_CDN_IMAGES_URL}/log-icons/7/icon.svg" alt="" width="100" height="100" />
<div class="caption">
<h3>Playing card</h3>
<p>
A playing card, for some Geo-Poker games.
</p>
</div>
</div>
</div>

<div class="col-sm-2">
<div class="thumbnail">
<img src="{GK_CDN_IMAGES_URL}/log-icons/8/icon.svg" alt="" width="100" height="100" />
<div class="caption">
<h3>Dog tag</h3>
<p>
A dog tag on your favorite pet. <i>(Not collectible)</i>
</p>
</div>
</div>
</div>

<div class="col-sm-2">
<div class="thumbnail">
<img src="{GK_CDN_IMAGES_URL}/log-icons/9/icon.svg" alt="" width="100" height="100" />
<div class="caption">
<h3>Jigsaw part</h3>
<p>
A Jigsaw part.
</p>
</div>
</div>
</div>

</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<a class="anchor" id="kretypostrules"></a>
<img src="{GK_CDN_IMAGES_URL}/log-icons/4/icon_25.jpg" alt="kretypost icon" />
<img src="{GK_CDN_IMAGES_URL}/log-icons/4/icon.svg" alt="kretypost icon" width="25px" height="25px" />
KretyPost rules
</div>
<div class="panel-body">
Expand Down Expand Up @@ -775,8 +838,8 @@ <h3>How to decode?</h3>
<ul>
<li><a href="https://www.geocaching.com/track/">TravelBugs</a></li>
<li><s><a href="http://www.geocachearmy.com">www.geocachearmy.com</a></s></li>
<li><a href="http://www.geolutins.com">www.geolutins.com</a></li>
<li><a href="https://geotrackable.com">geotrackable.com"</a></li>
<li><s><a href="http://www.geolutins.com">www.geolutins.com</a></s></li>
<li><a href="https://geotrackable.com">geotrackable.com</a></li>
<li><s><a href="http://www.travelertags.com">www.travelertags.com</a></s></li>
<li><a href="http://www.pathtags.com">www.pathtags.com</a></li>
</ul>
Expand Down
9 changes: 7 additions & 2 deletions website/app-templates/smarty/pages/help_api.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@
<p>GeoKrety Types are internaly stored using a <code>small integer</code>. The current mapping is as follow:</p>
<ul>
<li><code>0</code> = Traditional</li>
<li><code>1</code> = A book/CD/DVD…</li>
<li><code>2</code> = A human/pet</li>
<li><code>1</code> = A book</li>
<li><code>2</code> = A human</li>
<li><code>3</code> = A coin</li>
<li><code>4</code> = KretyPost</li>
<li><code>5</code> = Pebble</li>
<li><code>6</code> = Car</li>
<li><code>7</code> = Playing card</li>
<li><code>8</code> = Dog tag/pet</li>
<li><code>9</code> = Jigsaw part</li>
</ul>
<p>Please refer to the <a href="{'help'|alias}#GeoKretytypes">help page</a> for more details about each type.</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions website/app/GeoKrety/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(?Template $template = null) {
'Content-Security-Policy: '
.sprintf('script-src \'nonce-%s\' \'strict-dynamic\'; ', $nonce)
.sprintf('img-src \'self\' data: %s %s https://www.gstatic.com/recaptcha/ https://tile.openstreetmap.org https://cdn.crowdin.com/jipt/images/ https://seccdn.libravatar.org/avatar/ https://crowdin-static.downloads.crowdin.com/avatar/ https://cdn.geokrety.org; ', GK_CDN_SERVER_URL, GK_MINIO_SERVER_URL_EXTERNAL)
.'frame-src https://www.google.com/ https://crowdin.com; '
.'frame-src https://www.google.com/ https://www.youtube.com/ https://crowdin.com/; '
.sprintf('style-src \'self\' \'nonce-%s\'; ', $nonce)
.sprintf('style-src-elem \'self\' \'unsafe-inline\' %s https://cdn.crowdin.com/jipt/jipt.css https://fonts.googleapis.com/css; ', GK_CDN_SERVER_URL)
.'style-src-attr \'self\' \'unsafe-inline\'; '
Expand All @@ -31,7 +31,7 @@ public function __construct(?Template $template = null) {
'Content-Security-Policy: '
.sprintf('script-src \'nonce-%s\' \'strict-dynamic\'; ', $nonce)
.sprintf('img-src \'self\' data: %s %s https://www.gstatic.com/recaptcha/ https://tile.openstreetmap.org https://seccdn.libravatar.org/avatar/ https://cdn.geokrety.org; ', GK_CDN_SERVER_URL, GK_MINIO_SERVER_URL_EXTERNAL)
.'frame-src https://www.google.com/; '
.'frame-src https://www.google.com/ https://www.youtube.com/; '
.sprintf('style-src \'self\' \'nonce-%s\'; ', $nonce)
.sprintf('style-src-elem \'self\' \'unsafe-inline\' %s; ', GK_CDN_SERVER_URL)
.'style-src-attr \'self\' \'unsafe-inline\'; '
Expand Down
15 changes: 15 additions & 0 deletions website/app/GeoKrety/GeokretyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ class GeokretyType {
public const GEOKRETY_TYPE_HUMAN = 2;
public const GEOKRETY_TYPE_COIN = 3;
public const GEOKRETY_TYPE_KRETYPOST = 4;
public const GEOKRETY_TYPE_PEBBLE = 5;
public const GEOKRETY_TYPE_CAR = 6;
public const GEOKRETY_TYPE_PLAYING_CARD = 7;
public const GEOKRETY_TYPE_DOG_TAG = 8;
public const GEOKRETY_TYPE_JIGSAW = 9;

public const GEOKRETY_TYPES = [
self::GEOKRETY_TYPE_TRADITIONAL,
self::GEOKRETY_TYPE_BOOK_CD_DVD,
self::GEOKRETY_TYPE_HUMAN,
self::GEOKRETY_TYPE_COIN,
self::GEOKRETY_TYPE_KRETYPOST,
self::GEOKRETY_TYPE_PEBBLE,
self::GEOKRETY_TYPE_CAR,
self::GEOKRETY_TYPE_PLAYING_CARD,
self::GEOKRETY_TYPE_DOG_TAG,
self::GEOKRETY_TYPE_JIGSAW,
];

private $type;
Expand Down Expand Up @@ -58,6 +68,11 @@ public static function getTypes() {
self::GEOKRETY_TYPE_HUMAN => _('A human'),
self::GEOKRETY_TYPE_COIN => _('A coin'),
self::GEOKRETY_TYPE_KRETYPOST => _('KretyPost'),
self::GEOKRETY_TYPE_PEBBLE => _('A Pebble'),
self::GEOKRETY_TYPE_CAR => _('A car'),
self::GEOKRETY_TYPE_PLAYING_CARD => _('A Playing Card'),
self::GEOKRETY_TYPE_DOG_TAG => _('A dog'),
self::GEOKRETY_TYPE_JIGSAW => _('Jigsaw part'),
];
}
}
60 changes: 60 additions & 0 deletions website/db/migrations/20240720180654_new_gk_types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class NewGkTypes extends AbstractMigration {
public function up(): void {
$this->execute(<<<'EOL'
ALTER TABLE IF EXISTS geokrety.gk_geokrety
DROP CONSTRAINT validate_type;
ALTER TABLE IF EXISTS geokrety.gk_geokrety
ADD CONSTRAINT validate_type CHECK (type = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
EOL);

$this->execute(<<<'EOL'
CREATE FUNCTION geokrety.geokret_manage_type()
RETURNS trigger
LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
IF NEW.type IN (2, 6, 8) THEN
IF NEW.non_collectible IS NULL THEN
NEW.non_collectible := NOW();
END IF;
ELSIF OLD.type IN (2, 6, 8) THEN
NEW.non_collectible := NULL;
END IF;
RETURN NEW;
END;
$BODY$;
EOL);

$this->execute(<<<'EOL'
CREATE OR REPLACE TRIGGER before_45_manage_type
BEFORE INSERT OR UPDATE OF type, non_collectible
ON geokrety.gk_geokrety
FOR EACH ROW
EXECUTE FUNCTION geokrety.geokret_manage_type();
EOL);
}

public function down(): void {
$this->execute(<<<'EOL'
ALTER TABLE IF EXISTS geokrety.gk_geokrety
DROP CONSTRAINT validate_type;
ALTER TABLE IF EXISTS geokrety.gk_geokrety
ADD CONSTRAINT validate_type CHECK (type = ANY (ARRAY[0, 1, 2, 3, 4]));
EOL);
$this->execute('DROP TRIGGER IF EXISTS before_45_manage_type ON geokrety.gk_geokrety');

$this->execute(<<<'EOL'
DROP FUNCTION IF EXISTS geokrety.geokret_manage_type();
EOL);
}
}
Loading

0 comments on commit c6e6d8c

Please sign in to comment.