sitemap generator
This commit is contained in:
parent
3414ec1113
commit
8f26802d22
@ -25,6 +25,7 @@ dirs_mode: 0775
|
||||
csrf_token: "123"
|
||||
password_salt: "456"
|
||||
|
||||
sitemap_dir: /home/user/sitemap
|
||||
uploads_dir: /home/user/files.example.org
|
||||
uploads_path: /uploads
|
||||
files_domain: files.example.org
|
||||
|
60
cron/sitemap.php
Normal file
60
cron/sitemap.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../init.php';
|
||||
require_once 'lib/files.php';
|
||||
|
||||
global $config;
|
||||
|
||||
use samdark\sitemap\Sitemap;
|
||||
|
||||
$db = DB();
|
||||
|
||||
$sitemap = new Sitemap($config['sitemap_dir'].'/sitemap.xml');
|
||||
$addr = 'https://'.$config['domain'];
|
||||
|
||||
$sitemap->addItem("{$addr}/",
|
||||
changeFrequency: Sitemap::WEEKLY);
|
||||
|
||||
// pages
|
||||
$q = $db->query("SELECT short_name FROM pages");
|
||||
while ($row = $db->fetch($q)) {
|
||||
$sitemap->addItem("{$addr}/{$row['short_name']}/",
|
||||
changeFrequency: Sitemap::WEEKLY);
|
||||
}
|
||||
|
||||
// files
|
||||
$sitemap->addItem("{$addr}/files/",
|
||||
changeFrequency: Sitemap::WEEKLY);
|
||||
foreach (FilesCollection::cases() as $fc) {
|
||||
$sitemap->addItem("{$addr}/files/".$fc->value.'/',
|
||||
changeFrequency: Sitemap::MONTHLY);
|
||||
}
|
||||
|
||||
foreach ([FilesCollection::WilliamFriedman, FilesCollection::Baconiana] as $fc) {
|
||||
$q = $db->query("SELECT id FROM {$fc->value}_collection WHERE type=?", FilesItemType::FOLDER);
|
||||
while ($row = $db->fetch($q)) {
|
||||
$sitemap->addItem("{$addr}/files/".$fc->value.'/'.$row['id'].'/',
|
||||
changeFrequency: Sitemap::MONTHLY);
|
||||
}
|
||||
}
|
||||
|
||||
$q = $db->query("SELECT id FROM books WHERE type=? AND external=0", FilesItemType::FOLDER);
|
||||
while ($row = $db->fetch($q)) {
|
||||
$sitemap->addItem("{$addr}/files/".$row['id'].'/',
|
||||
changeFrequency: Sitemap::MONTHLY);
|
||||
}
|
||||
|
||||
// posts
|
||||
//foreach (PostLanguage::cases() as $pl) {
|
||||
// $sitemap->addItem("{$addr}/articles/".($pl != PostLanguage::English ? '?lang='.$pl->value : ''),
|
||||
// changeFrequency: Sitemap::WEEKLY);
|
||||
//
|
||||
// $q = $db->query("SELECT * FROM posts WHERE visible=1");
|
||||
// while ($row = $db->fetch($q)) {
|
||||
// $post = new Post($row);
|
||||
// $sitemap->addItem("{$addr}".$post->getUrl($pl),
|
||||
// changeFrequency: Sitemap::WEEKLY);
|
||||
// }
|
||||
//}
|
||||
|
||||
$sitemap->write();
|
Loading…
x
Reference in New Issue
Block a user