mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 01:52:02 -04:00
Fix permissions on OPDS feeds
This commit is contained in:
parent
6252cff1e5
commit
ffa3ab8a74
3 changed files with 20 additions and 11 deletions
|
@ -20,17 +20,23 @@ class OpdsFeed{
|
||||||
}
|
}
|
||||||
|
|
||||||
private function Sha1Entries(string $xmlString): string{
|
private function Sha1Entries(string $xmlString): string{
|
||||||
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', $xmlString));
|
try{
|
||||||
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
|
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', $xmlString));
|
||||||
$xml->registerXPathNamespace('schema', 'http://schema.org/');
|
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
|
||||||
$entries = $xml->xpath('/feed/entry') ?? [];
|
$xml->registerXPathNamespace('schema', 'http://schema.org/');
|
||||||
|
$entries = $xml->xpath('/feed/entry') ?? [];
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach($entries as $entry){
|
foreach($entries as $entry){
|
||||||
$output .= $entry->asXml();
|
$output .= $entry->asXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
return sha1(preg_replace('/\s/ius', '', $output));
|
||||||
|
}
|
||||||
|
catch(Exception $ex){
|
||||||
|
// Invalid XML
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return sha1(preg_replace('/\s/ius', '', $output));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Save(string $filename): void{
|
public function Save(string $filename): void{
|
||||||
|
|
|
@ -227,7 +227,10 @@ if [ "${verbose}" = "true" ]; then
|
||||||
printf "Rebuilding OPDS catalog ... "
|
printf "Rebuilding OPDS catalog ... "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bash -c "php \"${scriptsDir}\"/generate-opds.php --webroot \"${webRoot}\" --weburl \"${webUrl}\""
|
php "${scriptsDir}/generate-opds.php" --webroot "${webRoot}" --weburl "${webUrl}"
|
||||||
|
|
||||||
|
sudo chown se:committers /standardebooks.org/web/www/opds/*.xml
|
||||||
|
sudo chmod 664 /standardebooks.org/web/www/opds/*.xml
|
||||||
|
|
||||||
if [ "${verbose}" = "true" ]; then
|
if [ "${verbose}" = "true" ]; then
|
||||||
printf "Done.\n"
|
printf "Done.\n"
|
||||||
|
|
|
@ -14,7 +14,7 @@ if(!isset($isCrawlable)){
|
||||||
|
|
||||||
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||||
?>
|
?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:schema="http://schema.org/" xmlns:fh="http://purl.org/syndication/history/1.0">
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:schema="http://schema.org/"<? if($isCrawlable){ ?> xmlns:fh="http://purl.org/syndication/history/1.0"<? } ?>>
|
||||||
<id><?= $id ?></id>
|
<id><?= $id ?></id>
|
||||||
<link href="<?= $url ?>" rel="self" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
|
<link href="<?= $url ?>" rel="self" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
|
||||||
<link href="<?= SITE_URL ?>/opds" rel="start" type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
|
<link href="<?= SITE_URL ?>/opds" rel="start" type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue