1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-28 01:30:11 -07:00

Add Brickset set information actions

This commit is contained in:
David Hübner 2017-04-10 16:56:15 +02:00
parent 04a2754425
commit 4e0fa748a6
5 changed files with 138 additions and 3 deletions

View File

@ -0,0 +1,9 @@
<div class="ui six doubling cards">
{% for image in images %}
<div class="card">
<a class="ui bordered fluid image" href="{{ image.imageURL }}" data-lightbox="setImages">
<img src="{{ image.thumbnailURL }}">
</a>
</div>
{% endfor %}
</div>

View File

@ -0,0 +1,30 @@
{% import 'macros/utils.html.twig' as utils %}
{% if instructions|length != 0 %}
<p>
{{ 'set.instructions.text' | trans }}
</p>
<table class="ui celled padded table">
<thead>
<tr>
<th>{{ 'set.instructions.description' | trans }}</th>
<th>{{ 'set.instructions.filesize' | trans }}</th>
<th>{{ 'set.instructions.download' | trans }}</th>
</tr>
</thead>
<tbody>
{% for instruction in instructions %}
<tr>
<td>{{ instruction.description }}</td>
<td>{{ utils.bytesToSize( remoteSize(instruction.uRL)) }}</td>
<td><a href="{{ instruction.uRL }}">{{ remoteFilename(instruction.uRL) }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<h2 class="ui center aligned icon">
<i class="circular warning icon"></i>
</h2>
{% endif %}

View File

@ -0,0 +1,26 @@
<div class="ui comments">
{% for review in reviews %}
<div class="comment">
<a class="avatar">
{#<img src="/images/avatar/small/matt.jpg">#}
</a>
<div class="content">
<div class="header">
<h4>{{ review.title }}</h4>
</div>
<span class="author">{{ review.author }}</span> {{ review.hTML }}
<div class="metadata">
<span class="date">{{ review.datePosted|date("Y.m.d H:m:i")}}</span>
</div>
<div class="text">
{{ review.review|raw }}
</div>
<div>
Overall rating <div class="ui star rating" data-rating="{{ review.overallRating }}" data-max-rating="5"></div>
{#Value for money <div class="ui star rating" data-rating="{{ review.valueForMoney }}" data-max-rating="5"></div>#}
</div>
</div>
</div>
{% endfor %}
</div>

View File

@ -47,4 +47,16 @@ class BricksetManager
return isset($sets[0]) ? $sets[0] : null;
}
public function getSetInstructions($id) {
return $this->bricksetClient->getInstructions($id);
}
public function getSetReviews($id) {
return $this->bricksetClient->getReviews($id);
}
public function getAdditionalImages($id) {
return $this->bricksetClient->getAdditionalImages($id);
}
}

View File

@ -1,7 +1,8 @@
<?php
namespace AppBundle\Controller\Rebrickable;
namespace AppBundle\Controller\Brickset;
use AppBundle\Api\Exception\EmptyResponseException;
use AppBundle\Entity\Rebrickable\Color;
use AppBundle\Entity\Rebrickable\Inventory_Part;
use AppBundle\Entity\Rebrickable\Part;
@ -13,12 +14,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* @Route("/brickset")
* @Route("/brickset/sets")
*/
class SetController extends Controller
{
/**
* @Route("/", name="set_browse")
* @Route("/", name="brickset_browse")
*/
public function browseAction(Request $request)
{
@ -42,4 +43,61 @@ class SetController extends Controller
'sets' => $sets,
]);
}
/**
* @Route("/{id}/instructions", name="brickset_instructions")
*/
public function instructionsAction(Request $request, $id)
{
$instructions = [];
try {
$instructions = $this->get('api.manager.brickset')->getSetInstructions($id);
} catch (EmptyResponseException $e) {
// $this->addFlash('warning', 'No instruction found on Brickset.com');
} catch (\Exception $e) {
$this->addFlash('error', $e->getMessage());
}
return $this->render('brickset/instructions.html.twig',[
'instructions' => $instructions,
]);
}
/**
* @Route("/{id}/reviews", name="brickset_reviews")
*/
public function reviewsAction(Request $request, $id)
{
$reviews = [];
try {
$reviews = $this->get('api.manager.brickset')->getSetReviews($id);
} catch (EmptyResponseException $e) {
// $this->addFlash('warning', 'No review found on Brickset.com');
} catch (\Exception $e) {
$this->addFlash('error', $e->getMessage());
}
return $this->render('brickset/reviews.html.twig',[
'reviews' => $reviews,
]);
}
/**
* @Route("/{id}/images", name="brickset_images")
*/
public function imagesAction(Request $request, $id)
{
$images = [];
try {
$images = $this->get('api.manager.brickset')->getAdditionalImages($id);
} catch (EmptyResponseException $e) {
// $this->addFlash('warning', 'No images found on Brickset.com');
} catch (\Exception $e) {
$this->addFlash('error', $e->getMessage());
}
return $this->render('brickset/images.html.twig',[
'images' => $images,
]);
}
}