Skip to content

Commit

Permalink
Sitemap example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksleight committed Feb 26, 2014
1 parent c5993c8 commit 035b4f6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/sitemap/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RewriteEngine On
RewriteRule (.*) app.php?_=$1 [QSA,L]
3 changes: 3 additions & 0 deletions examples/sitemap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sitemap

Example usage of the XML sitemap component.
22 changes: 22 additions & 0 deletions examples/sitemap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
use Coast\App,
Coast\App\Request,
Coast\App\Response,
Coast\Sitemap;

chdir(__DIR__);
require 'vendor/autoload.php';

$app = new App();
$app->add(function(Request $req, Response $res) {
$sitemap = new Sitemap();
$sitemap->add(
new \Coast\Url('http://coastphp.com/'),
new \DateTime(),
Sitemap::CHANGES_WEEKLY,
1
);
return $res->xml($sitemap->xml());
});

$app->execute((new Request())->import())->export();
5 changes: 5 additions & 0 deletions examples/sitemap/vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
// Placeholder autoloader, allows the examples to work from the main library
require '../../lib/Coast.php';
set_include_path(get_include_path() . PATH_SEPARATOR . '../../lib');
spl_autoload_register();

0 comments on commit 035b4f6

Please sign in to comment.