-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from roadiz/develop
New ServiceWorker and fixes.
- Loading branch information
Showing
33 changed files
with
294 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Themes\BaseTheme\Controllers; | ||
|
||
use Doctrine\ORM\QueryBuilder; | ||
use RZ\Roadiz\Core\Entities\NodeType; | ||
use Themes\BaseTheme\BaseThemeApp; | ||
|
||
abstract class AbstractSitemapController extends BaseThemeApp | ||
{ | ||
/** | ||
* @return \IteratorAggregate|array | ||
*/ | ||
protected function getListableNodeSources() | ||
{ | ||
/** @var QueryBuilder $qb */ | ||
$qb = $this->get('em') | ||
->getRepository(NodeType::class) | ||
->createQueryBuilder('nt'); | ||
$qb->andWhere($qb->expr()->notIn('nt.name', ['Link'])) | ||
->andWhere($qb->expr()->eq('nt.reachable', true)); | ||
$nodeTypes = $qb->getQuery()->getResult(); | ||
|
||
/* | ||
* Add your own nodes grouped by their type. | ||
*/ | ||
return $this->get('nodeSourceApi') | ||
->getBy([ | ||
'node.nodeType' => $nodeTypes, | ||
'node.visible' => true, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* Copyright (c) 2017. Rezo Zero | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* Copyright (c) 2019 | ||
* | ||
* BaseTheme | ||
* | ||
* @file SitemapController.php | ||
* @author Bilel Jegham <contact.bileljegham@gmail.com> | ||
*/ | ||
namespace Themes\BaseTheme\Controllers; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* Class ServiceWorkerController | ||
* @package Themes\BaseTheme\Controllers | ||
*/ | ||
class ServiceWorkerController extends AbstractSitemapController | ||
{ | ||
/** | ||
* @param Request $request | ||
* @param string $_locale | ||
* @return Response | ||
*/ | ||
public function serviceWorkerAction( | ||
Request $request, | ||
$_locale = 'fr' | ||
) { | ||
$this->prepareThemeAssignation(null, $this->bindLocaleFromRoute($request, $_locale)); | ||
/* | ||
* Add your own nodes grouped by their type. | ||
*/ | ||
$this->assignation['pages'] = $this->getListableNodeSources(); | ||
|
||
$response = new Response( | ||
trim($this->getTwig()->render('service-worker/sw.js.twig', $this->assignation)), | ||
Response::HTTP_OK, | ||
['content-type' => 'application/javascript'] | ||
); | ||
|
||
$this->makeResponseCachable($request, $response, 60); | ||
return $response; | ||
} | ||
|
||
/** | ||
* @param Request $request | ||
* @param string $_locale | ||
* @return Response | ||
*/ | ||
public function offlineAction( | ||
Request $request, | ||
$_locale = 'fr' | ||
) { | ||
$this->prepareThemeAssignation(null, $this->bindLocaleFromRoute($request, $_locale)); | ||
|
||
$this->assignation['nodeName'] = 'offline-page'; | ||
$this->assignation['nodeTypeName'] = 'offline'; | ||
$this->assignation['title'] = $this->get('translator')->trans('offline.title'); | ||
|
||
$response = $this->render('pages/offline.html.twig', $this->assignation); | ||
|
||
$this->makeResponseCachable($request, $response, 60); | ||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{% spaceless %} | ||
/* --- Pages --- */ | ||
{% for page in pages %} | ||
// Styles for {{ page.node.nodeName }} | ||
/* Styles for {{ page.node.nodeName }} */ | ||
{% endfor %} | ||
{% endspaceless %} | ||
{% endspaceless %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends "bootstrap_4_layout.html.twig" %} | ||
|
||
{%- block widget_attributes -%} | ||
{%- if label and not attr.placeholder %} | ||
{% set attr = attr|merge({placeholder: label|trans}) %} | ||
{% if required %} | ||
{% set attr = attr|merge({placeholder: label|trans ~ '*'}) %} | ||
{% endif %} | ||
{% endif -%} | ||
{{ parent() }} | ||
{%- endblock widget_attributes -%} | ||
|
||
{% block form_row -%} | ||
{%- if compound is defined and compound -%} | ||
{%- set element = 'fieldset' -%} | ||
{%- endif -%} | ||
<{{ element|default('div') }} class="form-group form-{{ name|replace({ '_': '-' }) }}"> | ||
{{- form_label(form) -}} | ||
{{- form_widget(form) -}} | ||
</{{ element|default('div') }}> | ||
{%- endblock form_row %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% extends '@BaseTheme/pages/base.html.twig' %} | ||
|
||
{% block body_attributes %}id="offline-page" data-node-type="offline"{% endblock %} | ||
|
||
|
||
{% block header %} | ||
<header class="page-header"> | ||
<div class="container"> | ||
<h1 class="page-title">{{ title }}</h1> | ||
</div> | ||
</header> | ||
{% endblock %} | ||
|
||
{% block inner_content %} | ||
<div class="container"> | ||
<button onclick="document.location.reload(true)">{% trans %}offline.btn{% endtrans %}</button> | ||
</div> | ||
{% endblock %} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<link href="/themes/BaseTheme/static/css/app.1db76626028c95fa7daf.css" rel="stylesheet"> | ||
<link href="/themes/BaseTheme/static/css/app.b308f0c535294de887b1.css" rel="stylesheet"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<script nomodule defer="defer" src="/themes/BaseTheme/static/js/legacy.vendors~app.aacd4a2958fba0b30a87.js"></script><script nomodule defer="defer" src="/themes/BaseTheme/static/js/legacy.app.108dbabf3405ef91c9bf.js"></script> | ||
<script nomodule defer="defer" src="/themes/BaseTheme/static/js/legacy.vendors~app.aacd4a2958fba0b30a87.js"></script><script nomodule defer="defer" src="/themes/BaseTheme/static/js/legacy.app.bc02d5b4adae0d6fc573.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<script type="module" crossorigin src="/themes/BaseTheme/static/js/modern.vendors~app.7aa4595c5f49d7c1be72.js"></script><script type="module" crossorigin src="/themes/BaseTheme/static/js/modern.app.1db76626028c95fa7daf.js"></script> | ||
<script type="module" crossorigin src="/themes/BaseTheme/static/js/modern.vendors~app.7aa4595c5f49d7c1be72.js"></script><script type="module" crossorigin src="/themes/BaseTheme/static/js/modern.app.b308f0c535294de887b1.js"></script> |
Oops, something went wrong.