diff --git a/config/apache/standardebooks.org.conf b/config/apache/standardebooks.org.conf
index 5f25ac53..76670114 100644
--- a/config/apache/standardebooks.org.conf
+++ b/config/apache/standardebooks.org.conf
@@ -159,9 +159,9 @@ Define domain standardebooks.org
RewriteRule ^(.+)$ $1.php [QSA]
# End PHP-FPM configuration
- # Received: /filename and /filename.xml exists in filesystem; Result: rewrite to /filename.xml and end request
+ # Received: /filename and /filename.xml exists in filesystem; Result: rewrite to /filename.xml
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.xml -f
- RewriteRule (.*) $1.xml [L]
+ RewriteRule (.*) $1.xml
# Remove trailing slashes
RewriteRule ^/(.+?)/$ /$1 [R=301,L]
@@ -219,6 +219,10 @@ Define domain standardebooks.org
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/dist/.+$
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/src/.+$
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
+
+ # If we ask for /opds/all?query=xyz, rewrite that to the search page.
+ RewriteCond %{QUERY_STRING} ^query=
+ RewriteRule ^/opds/all.xml$ /opds/search.php [QSA]
diff --git a/config/apache/standardebooks.test.conf b/config/apache/standardebooks.test.conf
index 084d2601..69a3f364 100644
--- a/config/apache/standardebooks.test.conf
+++ b/config/apache/standardebooks.test.conf
@@ -158,9 +158,9 @@ Define domain standardebooks.test
RewriteRule ^(.+)$ $1.php [QSA]
# End PHP-FPM configuration
- # Received: /filename and /filename.xml exists in filesystem; Result: rewrite to /filename.xml and end request
+ # Received: /filename and /filename.xml exists in filesystem; Result: rewrite to /filename.xml
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.xml -f
- RewriteRule (.*) $1.xml [L]
+ RewriteRule (.*) $1.xml
# Remove trailing slashes
RewriteRule ^/(.+?)/$ /$1 [R=301,L]
@@ -218,4 +218,8 @@ Define domain standardebooks.test
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/dist/.+$
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/src/.+$
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
+
+ # If we ask for /opds/all?query=xyz, rewrite that to the search page.
+ RewriteCond %{QUERY_STRING} ^query=
+ RewriteRule ^/opds/all.xml$ /opds/search.php [QSA]
diff --git a/lib/Contributor.php b/lib/Contributor.php
index 7f182b1d..3cd85215 100644
--- a/lib/Contributor.php
+++ b/lib/Contributor.php
@@ -6,13 +6,15 @@ class Contributor{
public $WikipediaUrl;
public $MarcRole;
public $FullName;
+ public $NacoafUrl;
- public function __construct(string $name, string $sortName = null, string $fullName = null, string $wikipediaUrl = null, string $marcRole = null){
+ public function __construct(string $name, string $sortName = null, string $fullName = null, string $wikipediaUrl = null, string $marcRole = null, string $nacoafUrl = null){
$this->Name = str_replace('\'', '’', $name);
$this->UrlName = Formatter::MakeUrlSafe($name);
$this->SortName = $sortName;
$this->FullName = $fullName;
$this->WikipediaUrl = $wikipediaUrl;
$this->MarcRole = $marcRole;
+ $this->NacoafUrl = $nacoafUrl;
}
}
diff --git a/lib/Ebook.php b/lib/Ebook.php
index c34d43e1..ab8c2528 100644
--- a/lib/Ebook.php
+++ b/lib/Ebook.php
@@ -50,6 +50,7 @@ class Ebook{
public $ContributorsHtml;
public $TitleWithCreditsHtml = '';
public $Timestamp;
+ public $ModifiedTimestamp;
public function __construct(string $wwwFilesystemPath){
// First, construct a source repo path from our WWW filesystem path.
@@ -162,6 +163,11 @@ class Ebook{
$this->Timestamp = new DateTime((string)$date[0]);
}
+ $modifiedDate = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]');
+ if($modifiedDate !== false && sizeof($modifiedDate) > 0){
+ $this->ModifiedTimestamp = new DateTime((string)$modifiedDate[0]);
+ }
+
// Get SE tags
foreach($xml->xpath('/package/metadata/meta[@property="se:subject"]') ?: [] as $tag){
$this->Tags[] = new Tag($tag);
@@ -222,7 +228,8 @@ class Ebook{
(string)$contributor,
$this->NullIfEmpty($xml->xpath('/package/metadata/meta[@property="file-as"][@refines="#' . $id . '"]')),
$this->NullIfEmpty($xml->xpath('/package/metadata/meta[@property="se:name.person.full-name"][@refines="#' . $id . '"]')),
- $this->NullIfEmpty($xml->xpath('/package/metadata/meta[@property="se:url.encyclopedia.wikipedia"][@refines="#' . $id . '"]'))
+ $this->NullIfEmpty($xml->xpath('/package/metadata/meta[@property="se:url.encyclopedia.wikipedia"][@refines="#' . $id . '"]')),
+ $this->NullIfEmpty($xml->xpath('/package/metadata/meta[@property="se:url.authority.nacoaf"][@refines="#' . $id . '"]'))
);
// A display-sequence of 0 indicates that we don't want to process this contributor
diff --git a/scripts/generate-opds.php b/scripts/generate-opds.php
index 1dde4c7b..81198676 100755
--- a/scripts/generate-opds.php
+++ b/scripts/generate-opds.php
@@ -42,6 +42,7 @@ print("\n");
+
All Standard Ebooks
Free and liberated ebooks, carefully produced for the true book lover.
= $webUrl ?>/images/logo.png
diff --git a/templates/OpdsEntry.php b/templates/OpdsEntry.php
new file mode 100644
index 00000000..bc4bf47a
--- /dev/null
+++ b/templates/OpdsEntry.php
@@ -0,0 +1,31 @@
+
+ = SITE_URL . $ebook->Url ?>
+ = $ebook->Title ?>
+ foreach($ebook->Authors as $author){ ?>
+
+ = $author->Name ?>
+ if($author->WikipediaUrl !== null){ ?>= $author->WikipediaUrl ?> } ?>
+ if($author->FullName !== null){ ?>= $author->FullName ?> } ?>
+ if($author->NacoafUrl !== null){ ?>= $author->NacoafUrl ?> } ?>
+
+ } ?>
+ = $ebook->Timestamp->format('Y-m-d\TH:i:s\Z') ?>
+ = $ebook->Timestamp->format('Y-m-d\TH:i:s\Z') ?>
+ = $ebook->Language ?>
+ Standard Ebooks
+ foreach($ebook->Sources as $source){ ?>
+ = $source->Url ?>
+ } ?>
+ Public domain in the United States; original content released to the public domain via the Creative Commons CC0 1.0 Universal Public Domain Dedication
+ = htmlspecialchars($ebook->Description, ENT_QUOTES, 'UTF-8') ?>
+ = $ebook->LongDescription ?>
+ foreach($ebook->LocTags as $subject){ ?>
+
+ } ?>
+
+
+
+
+
+
+
diff --git a/www/opds/search.php b/www/opds/search.php
new file mode 100644
index 00000000..824cc1db
--- /dev/null
+++ b/www/opds/search.php
@@ -0,0 +1,39 @@
+
+require_once('Core.php');
+
+$now = new DateTime('now', new DateTimeZone('UTC'));
+
+try{
+ $query = HttpInput::GetString('query', false);
+
+ if($query !== null){
+ $ebooks = Library::Search($query);
+ }
+}
+catch(\Exception $ex){
+ http_response_code(500);
+ include(WEB_ROOT . '/404.php');
+ exit();
+}
+header('Content-type: text/xml');
+print("\n");
+?>
+
+ https://standardebooks.org/opds/all
+
+
+
+
+
+ Standard Ebooks OPDS Search Results
+ Free and liberated ebooks, carefully produced for the true book lover.
+ https://standardebooks.org/images/logo.png
+ = $now->Format('Y-m-d\TH:i:s\Z') ?>
+
+ Standard Ebooks
+ https://standardebooks.org
+
+ foreach($ebooks as $ebook){ ?>
+ = Template::OpdsEntry(['ebook' => $ebook]) ?>
+ } ?>
+