-
Notifications
You must be signed in to change notification settings - Fork 140
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
implement sitemap and error handling of seo-bundle #352
base: master
Are you sure you want to change the base?
Changes from all commits
f7841da
42475f6
c1a67a2
482cfc1
32764d2
b566cf7
11714cb
f9fea5e
ae1ba37
99620d1
42081c0
19dea4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block content %} | ||
<h1>Oops! An Error Occurred</h1> | ||
<h2>The server returned a "{{ status_code }} {{ status_text }}".</h2> | ||
<p>If you see this page, it means your sandbox is not correctly set up. | ||
Please see the README file in the sandbox root folder and if you can't figure out | ||
what is wrong, ask us on freenode irc #symfonycmf or the mailinglist [email protected]. | ||
</p> | ||
|
||
<p>If you are seeing this page as the result of an edit in the admin tool, please report what you were doing | ||
to our <a href="https://github.com/symfony-cmf/cmf-sandbox/issues/new">ticket system</a>, | ||
so that we can add means to prevent this issue in the future. But to get things working again | ||
for now, please just <a href="{{ app.request.getSchemeAndHttpHost() }}/reloadfixtures.php">click here</a> | ||
to reload the data fixtures. | ||
</p><p style='color:red;'> | ||
<strong>Detected the following problem</strong>: | ||
{{ exception.getMessage() }} | ||
|
||
<h3>Suggested pages</h3> | ||
<div class="alert alert-info clearfix"> | ||
<p> | ||
This page is rendered by the | ||
<code>SuggestionProviderController</code> | ||
of the CmfSeoBundle. This way, usefull suggestions can be shown to your users. | ||
</p> | ||
|
||
<a class="docref" href="http://symfony.com/doc/current/cmf/bundles/seo/error_pages.html"> | ||
<i class="glyphicon glyphicon-chevron-right"></i>Read about this feature in the CMF documentation. | ||
</a> | ||
</div> | ||
{% for group, list in best_matches if list is not empty %} | ||
<h4>{{ group|capitalize }}</h4> | ||
<ul> | ||
{% for match in list %} | ||
<li><a href="{{ path(match.id) }}">{{ match.content.title }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<h4>No suggestions found</h4> | ||
{% endfor %} | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block content %} | ||
<h1>Sitemap</h1> | ||
<p> | ||
The sitemap feature allows to give an overview of the content. | ||
The content document decides whether it should be displayed on a sitemap or not. | ||
The sitemap of the symfony-cmf sandbox is relatively flat because the content URL structure is flat. | ||
If you have deeper nested content, the sitemap is organized along the nested structure.<br /> | ||
This information is arranged for human users. For search engines, the sitemap also exists in | ||
an <a href="{{ url('cmf_seo_sitemap', {_format: 'xml', sitemap: 'sitemap'}) }}">xml format</a>. | ||
</p> | ||
<ul class="cmf-sitemap"> | ||
{% for url in urls %} | ||
<li{% if url.depth is not null %} class="indent-{{ url.depth }}"{% endif %}> | ||
<a href="{{ url.location }}" title="{{ url.label }}">{{ url.label }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
{% for url in urls %} | ||
<url> | ||
<loc>{{ url.location }}</loc> | ||
{% if url.lastModification %} | ||
<lastmod>{{ url.lastModification }}</lastmod> | ||
{% endif %} | ||
<changefreq>{{ url.changeFrequency }}</changefreq> | ||
{% if url.alternateLocales is defined and url.alternateLocales|length > 0 %} | ||
{% for locale in url.alternateLocales %} | ||
<xhtml:link rel="alternate" hreflang="{{ locale.hrefLocale }}" href="{{ locale.href }}"/> | ||
{% endfor %} | ||
{% endif %} | ||
</url> | ||
{% endfor %} | ||
</urlset> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ framework: | |
twig: | ||
debug: '%kernel.debug%' | ||
strict_variables: '%kernel.debug%' | ||
exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction' | ||
exception_controller: cmf_seo.error.suggestion_provider.controller:listAction | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this also handle encoding? like when i did a json request, do i get back a json error or a html page with error information? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, need to have a look into the code or test it, would be nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose to use the same strategy the TwigBundle uses: Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but this should not have to happen here, right? is an issue of seo-bundle |
||
|
||
# Assetic Configuration | ||
assetic: | ||
|
@@ -113,6 +113,23 @@ cmf_seo: | |
title: 'CMF Sandbox - %%content_title%%' | ||
description: 'The Content Management Framework. %%content_description%%' | ||
alternate_locale: ~ | ||
error: | ||
enable_parent_provider: true | ||
enable_sibling_provider: true | ||
templates: | ||
html: ":error/index.html.twig" | ||
exclusion_rules: | ||
- { path: 'excluded' } | ||
sitemap: | ||
defaults: | ||
default_change_frequency: never | ||
templates: | ||
xml: ':sitemap/index.xml.twig' | ||
html: ':sitemap/index.html.twig' | ||
configurations: | ||
sitemap: ~ | ||
frequent: | ||
default_change_frequency: always | ||
|
||
cmf_menu: | ||
voters: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
use Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent; | ||
use Symfony\Cmf\Bundle\SeoBundle\SeoAwareInterface; | ||
use Symfony\Cmf\Bundle\SeoBundle\Doctrine\Phpcr\SeoMetadata; | ||
use Symfony\Cmf\Bundle\SeoBundle\SitemapAwareInterface; | ||
|
||
/** | ||
* That example class uses the extractors for the creation of the SeoMetadata. | ||
|
@@ -23,7 +24,7 @@ | |
* | ||
* @author Maximilian Berghoff <[email protected]> | ||
*/ | ||
class DemoSeoContent extends StaticContent implements SeoAwareInterface | ||
class DemoSeoContent extends StaticContent implements SeoAwareInterface, SitemapAwareInterface | ||
{ | ||
/** | ||
* @var SeoMetadata | ||
|
@@ -32,6 +33,13 @@ class DemoSeoContent extends StaticContent implements SeoAwareInterface | |
*/ | ||
protected $seoMetadata; | ||
|
||
/** | ||
* @var bool | ||
* | ||
* @PHPCRODM\Field(type="boolean", property="visible_for_sitemap") | ||
*/ | ||
private $isVisibleForSitemap; | ||
|
||
public function __construct() | ||
{ | ||
$this->seoMetadata = new SeoMetadata(); | ||
|
@@ -53,4 +61,25 @@ public function setSeoMetadata($seoMetadata) | |
{ | ||
$this->seoMetadata = $seoMetadata; | ||
} | ||
|
||
/** | ||
* Decision whether a document should be visible | ||
* in sitemap or not. | ||
* | ||
* @param $sitemap | ||
* | ||
* @return bool | ||
*/ | ||
public function isVisibleInSitemap($sitemap) | ||
{ | ||
return $this->isVisibleForSitemap; | ||
} | ||
|
||
/** | ||
* @param bool $isVisibleForSitemap | ||
*/ | ||
public function setIsVisibleForSitemap($isVisibleForSitemap) | ||
{ | ||
$this->isVisibleForSitemap = $isVisibleForSitemap; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,7 @@ | |
* | ||
* @author Maximilian Berghoff <[email protected]> | ||
*/ | ||
class DemoSeoExtractor extends DemoSeoContent implements | ||
TitleReadInterface, | ||
DescriptionReadInterface, | ||
OriginalUrlReadInterface, | ||
KeywordsReadInterface | ||
class DemoSeoExtractor extends DemoSeoContent implements TitleReadInterface, DescriptionReadInterface, OriginalUrlReadInterface, KeywordsReadInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rather disable this fixer and keep this multiline to make it readable. put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh. we should use that everywhere, cause i saw that on seo-bundle yesterday too. from which coding style is that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouter added it in one of the bundles, can't remember which one |
||
{ | ||
/** | ||
* {@inheritdoc} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please include the blue "docref" boxes we use throughout the sandbox: