mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-17 21:00:09 -07:00
Add download links
This commit is contained in:
parent
bdddd5a7b4
commit
4b0978f58f
@ -25,4 +25,12 @@ $(document).bind('ready ajaxComplete', function(){
|
|||||||
;
|
;
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$('.item-info .download')
|
||||||
|
.popup({
|
||||||
|
popup : $('.download.popup'),
|
||||||
|
on: 'click',
|
||||||
|
inline: true
|
||||||
|
})
|
||||||
|
;
|
||||||
});
|
});
|
@ -1,6 +1,7 @@
|
|||||||
{% extends 'html.html.twig' %}
|
{% extends 'html.html.twig' %}
|
||||||
|
|
||||||
{% import 'macros/elements.html.twig' as elements %}
|
{% import 'macros/elements.html.twig' as elements %}
|
||||||
|
{% import 'macros/blocks.html.twig' as blocks %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="ui fixed inverted menu">
|
<div class="ui fixed inverted menu">
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% import 'macros/elements.html.twig' as elements %}
|
|
||||||
|
|
||||||
{% block title %}#{{ model.number }} - {{ model.name }}{% endblock %}
|
{% block title %}#{{ model.number }} - {{ model.name }}{% endblock %}
|
||||||
|
|
||||||
{% block header %}#{{ model.number }} - {{ model.name }}{% endblock %}
|
{% block header %}#{{ model.number }} - {{ model.name }}{% endblock %}
|
||||||
@ -11,106 +9,107 @@
|
|||||||
<div class="ui grid">
|
<div class="ui grid">
|
||||||
<div class="column ten wide">
|
<div class="column ten wide">
|
||||||
<div id="model-viewer" class="model-container">
|
<div id="model-viewer" class="model-container">
|
||||||
<img src="{{ asset('/images/-1/'~model.number~'.png') | imagine_filter('model_large')}}">
|
{{ blocks.modelImageLarge(model, -1) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column six wide">
|
<div class="column six wide">
|
||||||
<div class="grey">
|
<div class="item-info ui">
|
||||||
<table>
|
<a class="ui download primary button" href="{{ path('model_zip', {number: model.number}) }}">{{ 'model.download'|trans }}</a>
|
||||||
<tr>
|
|
||||||
<th>category</th><td>{{ model.category ? model.category.name }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>model</th><td>{{ model.path }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>author</th><td>{{ model.author.name }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>sets</th><td>{{ sets|length }}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<dl>
|
<table class="ui very basic table">
|
||||||
<dt>keywords:</dt>
|
<tr>
|
||||||
<dd>
|
<td>{{ 'model.category' | trans }}</td><td>{{ model.category ? model.category.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ 'model.author' | trans }}</td><td>{{ model.author.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ 'model.set.count' | trans }}</td><td>{{ sets|length }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ 'model.license' | trans }}</td>
|
||||||
|
<td>
|
||||||
|
{{ blocks.ccal2_license(model.name,model.author.name) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ 'model.keywords' | trans }}</td>
|
||||||
|
<td>
|
||||||
{% for keyword in model.keywords %}
|
{% for keyword in model.keywords %}
|
||||||
<span class="ui label">{{ keyword.name }}</span>
|
<span class="ui label">{{ keyword.name }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dd>
|
</td>
|
||||||
<dt>aliases:</dt>
|
</tr>
|
||||||
<dd>
|
{% if model.aliases|length %}
|
||||||
{% for alias in model.aliases %}
|
<tr>
|
||||||
|
<td>{{ 'model.aliases' | trans }}</td>
|
||||||
|
<td>
|
||||||
|
{% for alias in model.aliases | slice(0,10)%}
|
||||||
<span>{{ alias.number }}</span>{% if not loop.last %},{% endif %}
|
<span>{{ alias.number }}</span>{% if not loop.last %},{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dd>
|
</td>
|
||||||
<dd>Download:</dd>
|
</tr>
|
||||||
<dt><a href="{{ url('media_file', {'path': model.path}) }}">{{ model.number }}</a></dt>
|
{% endif %}
|
||||||
</dl>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4 class="ui horizontal divider header">
|
<div class="ui segment vertical item-info">
|
||||||
Related Models
|
<div class="ui tabular pointing secondary menu">
|
||||||
</h4>
|
<a class="item active" data-tab="subparts"><i class="cubes icon"></i> Subparts ({{ model.subparts|length }})</a>
|
||||||
|
<a class="item" data-tab="related"><i class="cubes icon"></i> Related ({{ related|length }})</a>
|
||||||
|
<a class="item" data-tab="parents"><i class="cubes icon"></i> Parents ({{ model.parents|length }})</a>
|
||||||
<h5 class="ui horizontal divider header">
|
<a class="item" data-tab="sets"><i class="cubes icon"></i> Sets ({{ sets|length }})</a>
|
||||||
Subparts of this model
|
</div>
|
||||||
</h5>
|
<div class="ui vertical segment">
|
||||||
|
|
||||||
|
<div class="ui tab active" data-tab="subparts">
|
||||||
<div class="ui eight column grid">
|
<div class="ui eight column grid">
|
||||||
{% for subpart in model.subparts %}
|
{% for subpart in model.subparts %}
|
||||||
<div class="column">
|
<div class="column">
|
||||||
{{ elements.part(subpart.subpart) }}
|
{{ blocks.part(subpart.subpart) }}
|
||||||
<p>{{ subpart.count }}</p>
|
<p>{{ subpart.count }}</p>
|
||||||
<p style="border-bottom: 2px solid #{{ subpart.color.rgb }}">color: {{ subpart.color.name }}</p>
|
<p style="border-bottom: 2px solid #{{ subpart.color.rgb }}">color: {{ subpart.color.name }}</p>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5 class="ui horizontal divider header">
|
|
||||||
Model is subpart of
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
<div class="ui eight column grid">
|
|
||||||
{% for subpart in model.parents %}
|
|
||||||
<div class="column">
|
|
||||||
{{ elements.part(subpart.parent) }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5 class="ui horizontal divider header">
|
<div class="ui tab" data-tab="related">
|
||||||
Model pairs with
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
<div class="ui eight column grid">
|
<div class="ui eight column grid">
|
||||||
{% for subpart in related %}
|
{% for subpart in related %}
|
||||||
<div class="column">
|
<div class="column">
|
||||||
{{ elements.part(subpart) }}
|
{{ blocks.part(subpart) }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4 class="ui horizontal divider header">
|
<div class="ui tab" data-tab="parents">
|
||||||
<i class="cubes icon"></i> Sets ({{ sets|length }})
|
<div class="ui eight column grid">
|
||||||
</h4>
|
{% for subpart in model.parents %}
|
||||||
|
<div class="column">
|
||||||
|
{{ blocks.part(subpart.parent) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui tab" data-tab="sets">
|
||||||
{% for set in sets %}
|
{% for set in sets %}
|
||||||
<span style="margin: 5px"><a href="{{ url('set_detail', {number:set.number}) }}">{{ set.number }}</a></span>
|
<span style="margin: 5px"><a href="{{ url('set_detail', {number:set.number}) }}">{{ set.number }}</a></span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
modelView = new ModelViewer($('#model-viewer'), '{{ url('media_file', {'path': model.path }) }}');
|
$('#model-viewer').ModelViewer('{{ url('media_file', {'path': model.path }) }}');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,51 +0,0 @@
|
|||||||
{% import 'macros/elements.html.twig' as elements %}
|
|
||||||
|
|
||||||
This set consists of {{ models|length }} unique part models
|
|
||||||
|
|
||||||
{% if regularParts|length > 0 %}
|
|
||||||
<h4 class="ui horizontal divider header">
|
|
||||||
Regular parts
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<div class="ui ten column grid">
|
|
||||||
{% for inventoryPart in regularParts %}
|
|
||||||
{% if inventoryPart.part is defined %}
|
|
||||||
<div class="column">
|
|
||||||
<div class="ui fluid bordered image">
|
|
||||||
<a class="ui right {{ inventoryPart.part.model == null ? 'black' : 'red'}} circular label">{{ inventoryPart.quantity }}</a>
|
|
||||||
<a href="{{ path('reb_part_detail', {number: inventoryPart.part.number}) }}">
|
|
||||||
<div class="image load">
|
|
||||||
<img src="{{ asset('resources/images/unknown_image.png') }}" data-src="{{ inventoryPart.part.number|partImage(inventoryPart.color.id)| imagine_filter('rebrickable_part_min') }}" class="transition visible">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="border-bottom: #{{ inventoryPart.color.rgb }} 5px solid" class="ui bottom attached label">{{ inventoryPart.part.number }}</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if spareParts|length > 0 %}
|
|
||||||
<h4 class="ui horizontal divider header">
|
|
||||||
Spare parts
|
|
||||||
</h4>
|
|
||||||
<div class="ui ten column grid">
|
|
||||||
{% for inventoryPart in spareParts %}
|
|
||||||
{% if inventoryPart.part is defined %}
|
|
||||||
<div class="column">
|
|
||||||
<div class="ui fluid bordered image">
|
|
||||||
<a class="ui right {{ inventoryPart.part.model == null ? 'black' : 'red'}} circular label">{{ inventoryPart.quantity }}</a>
|
|
||||||
<a href="{{ path('reb_part_detail', {number: inventoryPart.part.number}) }}">
|
|
||||||
<div class="image load">
|
|
||||||
<img src="{{ asset('resources/images/unknown_image.png') }}" data-src="{{ inventoryPart.part.number|partImage(inventoryPart.color.id)| imagine_filter('rebrickable_part_min') }}" class="transition visible">
|
|
||||||
</div>
|
|
||||||
<div style="border-bottom: #{{ inventoryPart.color.rgb }} 5px solid" class="ui bottom attached label">{{ inventoryPart.part.number }}</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
@ -1,48 +0,0 @@
|
|||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
{% set count = 0 %}
|
|
||||||
|
|
||||||
<div class="ui ten column grid">
|
|
||||||
{% for model in models %}
|
|
||||||
<div class="column">
|
|
||||||
<div class="ui bordered fluid image">
|
|
||||||
<a href="{{ url('model_detail', {'number': model['model'].number})}}">
|
|
||||||
<div class="image load">
|
|
||||||
<img src="{{ asset('resources/images/unknown_image.png') }}" data-src="{{ asset('/images/-1/'~model['model'].number~'.png') | imagine_filter('model_min') }}" class="transition visible">
|
|
||||||
</div>
|
|
||||||
<div class="ui bottom attached label {% if model['model'].parts|length == 0 %}black{% endif %}">{{ model['model'].number }}</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% for color in model['colors'] %}
|
|
||||||
{% set count = count + color['quantity'] %}
|
|
||||||
<div style="border-bottom: 4px solid #{{ color['color'].rgb }}">{{ color['quantity'] }} {{ color['color'].name }}</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="ui ten column grid">
|
|
||||||
{% for model in spareModels %}
|
|
||||||
<div class="column">
|
|
||||||
<div class="ui bordered fluid image">
|
|
||||||
<a href="{{ url('model_detail', {'number': model['model'].number})}}">
|
|
||||||
<div class="image load">
|
|
||||||
<img src="{{ asset('resources/images/unknown_image.png') }}" data-src="{{ asset('/images/-1/'~model['model'].number~'.png') | imagine_filter('model_min') }}" class="transition visible">
|
|
||||||
</div>
|
|
||||||
<div class="ui bottom attached label {% if model['model'].parts|length == 0 %}black{% endif %}">{{ model['model'].number }}</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% for color in model['colors'] %}
|
|
||||||
{% set count = count + color['quantity'] %}
|
|
||||||
<div style="border-bottom: 4px solid #{{ color['color'].rgb }}">{{ color['quantity'] }} {{ color['color'].name }}</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>{{ set.partCount }}</p>
|
|
||||||
<p>{{ count }} models</p>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -64,6 +64,23 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<a class="ui download primary button">{{ 'set.download'|trans }}</a>
|
||||||
|
<div class="ui download flowing popup bottom center transition hidden">
|
||||||
|
<div class="ui two column divided center aligned grid">
|
||||||
|
<div class="column">
|
||||||
|
<h4 class="ui header">{{ 'set.download.sorted' }}</h4>
|
||||||
|
<p>{{ 'set.download.sorted.text' | trans }}</p>
|
||||||
|
<a class="ui button" href="{{ path('set_zip', {number: set.number, sorted: true }) }}" download>Download ZIP</a>
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
<h4 class="ui header">{{ 'set.download.unsorted' }}</h4>
|
||||||
|
<p>{{ 'set.download.unsorted.text' | trans }}</p>
|
||||||
|
<a class="ui button" href="{{ path('set_zip', {number: set.number, sorted: false }) }}" download>Download ZIP</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,12 +6,10 @@ use AppBundle\Entity\LDraw\Model;
|
|||||||
use AppBundle\Entity\Rebrickable\Part;
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
use AppBundle\Form\Filter\Model\ModelFilterType;
|
use AppBundle\Form\Filter\Model\ModelFilterType;
|
||||||
use Doctrine\ORM\Query\AST\ConditionalTerm;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part controller.
|
* Part controller.
|
||||||
@ -66,10 +64,10 @@ class ModelController extends Controller
|
|||||||
/** @var Model $model */
|
/** @var Model $model */
|
||||||
if ($model = $this->get('repository.ldraw.model')->findOneByNumber($number)) {
|
if ($model = $this->get('repository.ldraw.model')->findOneByNumber($number)) {
|
||||||
try {
|
try {
|
||||||
$rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null;
|
$rbParts = $model != null ? $this->get('repository.rebrickable.part')->findAllByModel($model) : null;
|
||||||
$sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null;
|
$sets = $model != null ? $this->get('repository.rebrickable.set')->findAllByModel($model) : null;
|
||||||
|
|
||||||
$related = $em->getRepository(Model::class)->findAllRelatedModels($model->getNumber());
|
$related = $this->get('repository.ldraw.model')->findAllRelatedModels($model->getNumber());
|
||||||
|
|
||||||
return $this->render('model/detail.html.twig', [
|
return $this->render('model/detail.html.twig', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
@ -86,20 +84,11 @@ class ModelController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{number}/download", name="model_download")
|
* @Route("/{number}/zip", name="model_zip")
|
||||||
* @Method("GET")
|
* @Method("GET")
|
||||||
*/
|
*/
|
||||||
public function downloadAction(Model $model)
|
public function zipAction(Model $model)
|
||||||
{
|
{
|
||||||
$zip = $this->get('service.zip')->create($model);
|
$zip = $this->get('service.zip')->createFromModel($model);
|
||||||
|
|
||||||
dump($zip);
|
|
||||||
|
|
||||||
$response = new Response(file_get_contents($zip));
|
|
||||||
$response->headers->set('Content-Type', 'application/zip');
|
|
||||||
$response->headers->set('Content-Disposition', 'attachment;filename="' . basename($zip) . '"');
|
|
||||||
$response->headers->set('Content-length', filesize($zip));
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user