Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.1-beta2 への機能取り込み #5002

Merged
merged 28 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1e947c0
管理者はメンテナンスモードを回避可能に変更
izayoi256 Mar 15, 2021
70813a4
管理画面 商品のタグでの絞り込み
Mar 18, 2021
a2fc583
商品のタグ名による検索
Mar 18, 2021
474486a
管理者ログアウト時にメンテナンス回避トークンを消すよう変更
izayoi256 Mar 23, 2021
c823bc5
メンテナンス回避中のフロント画面にアラートを表示するよう変更
izayoi256 Mar 23, 2021
4b65f08
SEO 商品の構造化データ
Mar 24, 2021
5f319e4
SEO メタタグ設定 (og:type, canonical, og:url, og:site_name)
Mar 22, 2021
7d60e98
構造化データ テストコードの追加
Mar 24, 2021
5b9fa24
SEO 商品詳細ページの og:image, description
Mar 22, 2021
dd42a02
metaタグ テストコード
Mar 26, 2021
0ca3a7d
ref: #4807 sitemap.index, sitemap.xml生成機能追加
tao-s Dec 18, 2020
f703fa0
SitemapController.php のリファクタリング
okazy Mar 26, 2021
3f8fd7f
インストール時、ページ設定「商品詳細ページ」の metatag のデフォルト値を空にする
Mar 29, 2021
fcc5fcd
メッセージ admin.content.page_meta_metatag を不使用 (deprecated) に
Mar 29, 2021
b0f8d15
modify test (mb_substr)
Mar 29, 2021
9e78398
サイトマップの改善
okazy Apr 1, 2021
0775834
Merge branch '4.0' into feature/41beta2
okazy Apr 2, 2021
ad660fe
Merge pull request #77 from okazy/feature/seo-product-detail
okazy Apr 5, 2021
4a7e54f
Merge branch 'feature/41beta2' into feature/seo-structured-data
okazy Apr 5, 2021
3a44190
Merge pull request #79 from okazy/feature/tag-search-front
okazy Apr 5, 2021
57178d4
Merge pull request #81 from okazy/4.1/seo
okazy Apr 5, 2021
d3dde59
Merge pull request #78 from okazy/feature/seo-structured-data
okazy Apr 5, 2021
e1b6c73
Merge branch '4.1-feature' into feature/traverse-maintenance
okazy Apr 5, 2021
33e70c1
Merge pull request #82 from okazy/feature/tag-search-admin
okazy Apr 5, 2021
28bf606
管理画面ログアウト時にログイン画面に遷移する
okazy Apr 5, 2021
e203454
Merge pull request #80 from okazy/feature/traverse-maintenance
okazy Apr 5, 2021
ef3463d
Merge remote-tracking branch 'origin/4.1-beta2' into feature/41beta2
okazy Apr 5, 2021
4e3cf4c
metaタグのテストの Symfony4.4 対応
okazy Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions app/DoctrineMigrations/Version20210401120000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210401120000 extends AbstractMigration
{
public function up(Schema $schema): void
{
// 会員登録完了ページに noindex を設定
$this->addSql("UPDATE dtb_page SET meta_robots = 'noindex' WHERE url = 'entry_activate' AND meta_robots = ''");
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}
1 change: 1 addition & 0 deletions app/config/eccube/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ security:
logout:
path: admin_logout
target: admin_login
success_handler: eccube.security.logout.success_handler
customer:
pattern: ^/
anonymous: true
Expand Down
3 changes: 3 additions & 0 deletions app/config/eccube/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ services:
eccube.security.failure_handler:
class: Eccube\Security\Http\Authentication\EccubeAuthenticationFailureHandler

eccube.security.logout.success_handler:
class: Eccube\Security\Http\Authentication\EccubeLogoutSuccessHandler

# Autowiring can't guess the constructor arguments that are not type-hinted with
# classes (e.g. container parameters) so you must define those arguments explicitly
# Eccube\Command\ListUsersCommand:
Expand Down
22 changes: 22 additions & 0 deletions html/template/default/assets/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css.map

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions html/template/default/assets/scss/project/_11.2.header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -826,3 +826,30 @@ Styleguide 11.2.7
.ec-itemNavAccordion {
display: none;
}

.ec-maintenanceAlert {
background: steelblue;
height: 5rem;
position: fixed;
top: 0;
width: 100%;
color: white;
z-index: 9999;
display: flex;
font-weight: bold;
& > * {
margin: auto;
}
& &__icon {
display: inline-block;
margin-right: 1rem;
width: 20px;
height: 20px;
color: #fff;
fill: #fff;
vertical-align: top;
}
& +* {
margin-top: 5rem;
}
}
20 changes: 13 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Eccube\Kernel;
use Eccube\Service\SystemService;
use Symfony\Component\Debug\Debug;
use Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -62,13 +63,18 @@
$adminPath = env('ECCUBE_ADMIN_ROUTE', 'admin');
$adminPath = '/'.\trim($adminPath, '/').'/';
if (\strpos($pathInfo, $adminPath) !== 0) {
$locale = env('ECCUBE_LOCALE');
$templateCode = env('ECCUBE_TEMPLATE_CODE');
$baseUrl = \htmlspecialchars(\rawurldecode($request->getBaseUrl()), ENT_QUOTES);

header('HTTP/1.1 503 Service Temporarily Unavailable');
require __DIR__.'/maintenance.php';
return;
$maintenanceContents = file_get_contents($maintenanceFile);
$maintenanceToken = explode(':', $maintenanceContents)[1] ?? null;
$tokenInCookie = $request->cookies->get(SystemService::MAINTENANCE_TOKEN_KEY);
if ($tokenInCookie === null || $tokenInCookie !== $maintenanceToken) {
$locale = env('ECCUBE_LOCALE');
$templateCode = env('ECCUBE_TEMPLATE_CODE');
$baseUrl = \htmlspecialchars(\rawurldecode($request->getBaseUrl()), ENT_QUOTES);

header('HTTP/1.1 503 Service Temporarily Unavailable');
require __DIR__.'/maintenance.php';
return;
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/Eccube/Controller/Admin/Content/MaintenanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,16 @@ public function index(Request $request)

if ($form->isSubmitted() && $form->isValid()) {
$changeTo = $request->request->get('maintenance');
$path = $this->container->getParameter('eccube_content_maintenance_file_path');

if ($isMaintenance === false && $changeTo == 'on') {
// 現在メンテナンスモードではない かつ メンテナンスモードを有効 にした場合
// メンテナンスモードを有効にする
file_put_contents($path, null);

$this->systemService->enableMaintenance('', true);
$this->addSuccess('admin.content.maintenance_switch__on_message', 'admin');
} elseif ($isMaintenance && $changeTo == 'off') {
// 現在メンテナンスモード かつ メンテナンスモードを無効 にした場合
// メンテナンスモードを無効にする
unlink($path);
$this->systemService->disableMaintenanceNow('', true);

$this->addSuccess('admin.content.maintenance_switch__off_message', 'admin');
}
Expand Down
159 changes: 159 additions & 0 deletions src/Eccube/Controller/SitemapController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Controller;

use Eccube\Entity\Page;
use Eccube\Repository\CategoryRepository;
use Eccube\Repository\PageRepository;
use Eccube\Repository\ProductRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;

class SitemapController extends AbstractController
{
/**
* @var ProductRepository
*/
private $productRepository;

/**
* @var CategoryRepository
*/
private $categoryRepository;

/**
* @var PageRepository
*/
private $pageRepository;

/**
* @var RouterInterface
*/
private $router;

/**
* SitemapController constructor.
*/
public function __construct(
ProductRepository $productRepository,
CategoryRepository $categoryRepository,
PageRepository $pageRepository,
RouterInterface $router
) {
$this->productRepository = $productRepository;
$this->categoryRepository = $categoryRepository;
$this->pageRepository = $pageRepository;
$this->router = $router;
}

/**
* Output sitemap index
*
* @Route("/sitemap.xml", name="sitemap_xml")
*/
public function index()
{
$qb = $this->pageRepository->createQueryBuilder('p');
$Page = $qb->select('p')
->where("((p.meta_robots not like '%noindex%' and p.meta_robots not like '%none%') or p.meta_robots IS NULL)")
->andWhere('p.id <> 0')
->andWhere('p.MasterPage is null')
->orderBy('p.update_date', 'DESC')
->setMaxResults(1)
->getQuery()
->getSingleResult();

$Product = $this->productRepository->findOneBy(['Status' => 1], ['update_date' => 'DESC']);
$Category = $this->categoryRepository->findOneBy([], ['update_date' => 'DESC']);

return $this->outputXml(
[
'Category' => $Category,
'Product' => $Product,
'Page' => $Page,
],
'sitemap_index.xml.twig'
);
}

/**
* Output sitemap of product categories
*
* @Route("/sitemap_category.xml", name="sitemap_category_xml")
*/
public function category()
{
$Categories = $this->categoryRepository->getList(null, true);

return $this->outputXml(['Categories' => $Categories]);
}

/**
* Output sitemap of products
*
* Output sitemap of products as status is 1
*
* @Route("/sitemap_product.xml", name="sitemap_product_xml")
*/
public function product()
{
$Products = $this->productRepository->findBy(['Status' => 1], ['update_date' => 'DESC']);

return $this->outputXml(['Products' => $Products]);
}

/**
* Output sitemap of pages
*
* Output sitemap of pages without 'noindex' in meta robots.
*
* @Route("/sitemap_page.xml", name="sitemap_page_xml")
*/
public function page()
{
$Pages = $this->pageRepository->getPageList("((p.meta_robots not like '%noindex%' and p.meta_robots not like '%none%') or p.meta_robots IS NULL)");

// URL に変数が含まれる場合は URL の生成ができないためここで除外する
$Pages = array_filter($Pages, function (Page $Page) {
$route = $this->router->getRouteCollection()->get($Page->getUrl());
if (is_null($route)) {
return false;
}
return count($route->compile()->getPathVariables()) < 1;
});

return $this->outputXml(['Pages' => $Pages]);
}

/**
* Output XML response by data.
*
* @param array $data
* @param string $template_name
*
* @return Response
*/
private function outputXml(array $data, $template_name = 'sitemap.xml.twig')
{
$response = new Response();
$response->headers->set('Content-Type', 'application/xml'); //Content-Typeを設定

return $this->render(
$template_name,
$data,
$response
);
}
}
64 changes: 64 additions & 0 deletions src/Eccube/EventListener/MaintenanceListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\EventListener;

use Eccube\Entity;
use Eccube\Request\Context;
use Eccube\Service\SystemService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

class MaintenanceListener implements EventSubscriberInterface
{

/** @var Context */
protected $requestContext;

/** @var SystemService */
protected $systemService;

public function __construct(Context $requestContext, SystemService $systemService)
{
$this->requestContext = $requestContext;
$this->systemService = $systemService;
}

public static function getSubscribedEvents()
{
return [
KernelEvents::RESPONSE => ['onResponse'],
];
}

public function onResponse(FilterResponseEvent $event)
{
$response = $event->getResponse();

if (!$this->systemService->isMaintenanceMode()) {
$response->headers->clearCookie(SystemService::MAINTENANCE_TOKEN_KEY);
return;
}

$user = $this->requestContext->getCurrentUser();
if ($user instanceof Entity\Member && $this->requestContext->isAdmin()) {
$cookie = new Cookie(
SystemService::MAINTENANCE_TOKEN_KEY,
$this->systemService->getMaintenanceToken()
);
$response->headers->setCookie($cookie);
}
}
}