Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Mar 25, 2018
0 parents commit 3a20e12
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# v1.0.0, 2018-03-26
* Initial release
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Flextype

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Sitemap Plugin for [Flextype](http://flextype.org/)
![version](https://img.shields.io/badge/version-1.0.0-brightgreen.svg?style=flat-square "Version")
![Flextype](https://img.shields.io/badge/Flextype-0.x-green.svg?style=flat-square "Flextype Version")
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/flextype-plugins/tiny-url/blob/master/LICENSE.txt)

Sitemap plugin provide automatically generated XML sitemap for Flextype.

## Installation
1. Unzip plugin to the folder `/site/plugins/`
2. Go to `/site/config/site.yml` and add plugin name to plugins section.
3. Save your changes.

Example:
```
...
plugins:
- sitemap
```

## Settings

```yaml
enabled: true # or `false` to disable the plugin
```
## License
See [LICENSE](https://github.com/flextype-plugins/sitemap/blob/master/LICENSE)
2 changes: 2 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sitemap: "Sitemap"
sitemap_description: "Sitemap plugin provide automatically generated XML sitemap for Flextype."
2 changes: 2 additions & 0 deletions languages/ru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sitemap: "Sitemap"
sitemap_description: "Sitemap plugin provide automatically generated XML sitemap for Flextype."
38 changes: 38 additions & 0 deletions sitemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
*
* Flextype Sitemap Plugin
*
* @author Romanenko Sergey / Awilum <[email protected]>
* @link http://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Flextype;

use Url;
use Arr;
use Response;
use Request;

if (Url::getUriSegment(0) == 'sitemap.xml') {
Events::addListener('onPageBeforeRender', function () {
Response::status(200);
Request::setHeaders('Content-Type: text/xml; charset=utf-8');

$_pages = Pages::getPages('', false, 'date');

foreach ($_pages as $page) {
if ($page['slug'] !== '404') {
$pages[] = $page;
}
}

include 'views/sitemap.php';

Request::shutdown();
});
}
13 changes: 13 additions & 0 deletions sitemap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Sitemap
version: 1.0.0
description: "Provide automatically generated XML sitemap."
author:
name: Sergey Romanenko
email: [email protected]
url: http://flextype.org
homepage: https://github.com/flextype-plugins/sitemap
bugs: https://github.com/flextype-plugins/sitemap/issues
license: MIT

# Plugin settings
enabled: true
11 changes: 11 additions & 0 deletions views/sitemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($pages as $page) { ?>
<url>
<loc><?php echo $page['url']; ?></loc>
<lastmod><?php echo $page['date']; ?></lastmod>
<changefreq><?php echo $page['changefreq'] ?? '1.0'; ?></changefreq>
<priority>1.0</priority>
</url>
<?php } ?>
</urlset>

0 comments on commit 3a20e12

Please sign in to comment.