Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #88 from samsonasik/feature/seo
Browse files Browse the repository at this point in the history
implement feature #59 : more seo
  • Loading branch information
samsonasik committed Dec 25, 2014
2 parents a5203f2 + f60867e commit 5ed679e
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/autoload/navigation.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
[
'label' => 'Home',
'route' => 'home',
'priority' => 1.00,
'changefreq' => 'always',
],
[
'label' => 'Contributors',
'route' => 'contributors',
'priority' => 0.80,
'changefreq' => 'weekly',
],
],
],
Expand Down
13 changes: 13 additions & 0 deletions module/Application/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@
],
],
],
'sitemapxml' => [
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => [
'route' => '/sitemapxml',
'defaults' => [
'controller' => 'Application\Controller\Sitemap',
'action' => 'index',
],
],
],
],
],
'service_manager' => [
Expand Down Expand Up @@ -101,6 +111,9 @@
'Application\Controller\Contributors' => 'Application\Factory\Controller\ContributorsControllerFactory',
'Application\Controller\Console' => 'Application\Factory\Controller\ConsoleControllerFactory',
],
'invokables' => [
'Application\Controller\Sitemap' => 'Application\Controller\SitemapController',
],
],
'view_helpers' => [
'factories' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

/**
* Get sitemap page
*/
class SitemapController extends AbstractActionController
{
public function indexAction()
{
$this->getResponse()->getHeaders()->addHeaderLine('Content-Type', 'text/xml');

$viewModel = new ViewModel();
$viewModel->setTerminal(true);

return $viewModel;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace ApplicationTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class SitemapControllerTest extends AbstractHttpControllerTestCase
{
public function setUp()
{
$this->setApplicationConfig(
include dirname(dirname(dirname(dirname(dirname(__DIR__))))).'/config/application.config.php'
);
parent::setUp();
}

public function testGetXmlPage()
{
$this->dispatch('/sitemapxml');
$this->assertResponseStatusCode(200);

$this->assertModuleName('Application');
$this->assertControllerName('Application\Controller\Sitemap');
$this->assertControllerClass('SitemapController');
$this->assertMatchedRouteName('sitemapxml');

$this->assertEquals('Content-Type: text/xml', $this->getResponseHeader('Content-Type')->toString());
}
}
4 changes: 4 additions & 0 deletions module/Application/view/application/sitemap/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php echo $this->navigation('navigation')
->sitemap()
->setServerUrl('http://learnzf2.sitrun-tech.com/')
->setFormatOutput(true);
3 changes: 2 additions & 1 deletion module/Application/view/layout/2columns.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="box-sidebar border-radius">
<h5 class="title">Other demos</h5>
<ul>
<?php foreach ($this->layout()->modules_list as $list) {
<?php if ($this->layout()->modules_list) { foreach ($this->layout()->modules_list as $list) {
if ($list->getModuleName() !== $this->layout()->modulenamespace) {
?>

Expand All @@ -45,6 +45,7 @@
?> </a> </li>

<?php
}
}
}
?>
Expand Down
5 changes: 5 additions & 0 deletions module/Application/view/layout/header.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<?php echo $this->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
->setName('webcrawlers','all')
->setName('spiders','all')
->setName('robots','all')
->setName('keywords', 'ZF2, Zend, Framework, Learn, Tutorial')
->setName('description', 'Real Live ZF2 Examples and tutorial');
?>

<!-- Le styles -->
Expand Down
2 changes: 2 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow: /

0 comments on commit 5ed679e

Please sign in to comment.