mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Enable reading from the ToC and single-page reading
This commit is contained in:
parent
8bb93e0d6b
commit
262e86c625
12 changed files with 226 additions and 35 deletions
|
@ -92,10 +92,10 @@ Define domain standardebooks.org
|
|||
AddType application/epub+zip .epub
|
||||
AddType application/x-mobi8-ebook .azw3
|
||||
|
||||
<Location ~ ^/ebooks/.+?/dist/.+$>
|
||||
<Location ~ ^/ebooks/.+?/downloads/.+$>
|
||||
# Serve distributables using the "download" dialog instead of opening in-browser
|
||||
# Note: the trailing e in the Header directive is required
|
||||
SetEnvIf Request_URI ^/ebooks/.+?/dist/(.+)$ FILENAME=$1
|
||||
SetEnvIf Request_URI ^/ebooks/.+?/downloads/(.+)$ FILENAME=$1
|
||||
Header set "Content-Disposition" "attachment; filename=%{FILENAME}e"
|
||||
</Location>
|
||||
|
||||
|
@ -115,6 +115,11 @@ Define domain standardebooks.org
|
|||
Header set Access-Control-Allow-Origin "*"
|
||||
</Location>
|
||||
|
||||
# We use a different CSP policy for single-page files because our default one doesn't allow inline images or CSS
|
||||
<Location ~ /text/single-page$>
|
||||
Header set Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline';"
|
||||
</Location>
|
||||
|
||||
# Remove www from requests
|
||||
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
|
||||
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
|
||||
|
@ -159,6 +164,17 @@ Define domain standardebooks.org
|
|||
# Remove trailing slashes
|
||||
RewriteRule ^/(.+?)/$ /$1 [R=301,L]
|
||||
|
||||
# Redirect ToC of XHTML representation of books
|
||||
RewriteRule ^/ebooks/(.+?)/text$ /ebooks/$1/src/epub/toc.xhtml [L]
|
||||
|
||||
# Redirect XHTML representation of books
|
||||
# This has to appear before the next check, so that we can exclude .xhtml endings
|
||||
RewriteRule ^/ebooks/(.+?)/(text|css|images|fonts)(.*) /ebooks/$1/src/epub/$2$3
|
||||
|
||||
# Received: /filename and /filename.xhtml exists in filesystem; Result: rewrite to /filename.xhtml
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.xhtml -f
|
||||
RewriteRule (.*) $1.xhtml
|
||||
|
||||
# Redirect index pages
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}/index.php -f
|
||||
|
@ -188,8 +204,8 @@ Define domain standardebooks.org
|
|||
RewriteRule ^/alices-adventures-in-wonderland.+$ /ebooks/lewis-carroll/alices-adventures-in-wonderland/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/philip-k-dick/short-stories(.+)$ /ebooks/philip-k-dick/short-fiction$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/benjamin-disraeli/sibyl(.+)$ /ebooks/benjamin-disraeli/sybil$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/alices-adventures-in-wonderland/dist/(.+)$ /ebooks/lewis-carroll/alices-adventures-in-wonderland/john-tenniel/dist/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/through-the-looking-glass/dist/(.+)$ /ebooks/lewis-carroll/through-the-looking-glass/john-tenniel/dist/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/alices-adventures-in-wonderland/downloads/(.+)$ /ebooks/lewis-carroll/alices-adventures-in-wonderland/john-tenniel/downloads/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/through-the-looking-glass/downloads/(.+)$ /ebooks/lewis-carroll/through-the-looking-glass/john-tenniel/downloads/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company$ /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company/(.+?)$ /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-g-wells/tales-of-space-and-time(.+)$ /ebooks/h-g-wells/short-fiction$1 [R=301,L]
|
||||
|
@ -211,7 +227,7 @@ Define domain standardebooks.org
|
|||
RewriteRule ^/collections/([^\./]+?)$ /ebooks/index.php?collection=$1 [QSA]
|
||||
|
||||
# Prevent this rule from firing if we're getting a distribution file
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/dist/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/src/.+$
|
||||
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
|
||||
|
||||
|
|
|
@ -91,10 +91,10 @@ Define domain standardebooks.test
|
|||
AddType application/epub+zip .epub
|
||||
AddType application/x-mobi8-ebook .azw3
|
||||
|
||||
<Location ~ ^/ebooks/.+?/dist/.+$>
|
||||
<Location ~ ^/ebooks/.+?/downloads/.+$>
|
||||
# Serve distributables using the "download" dialog instead of opening in-browser
|
||||
# Note: the trailing e in the Header directive is required
|
||||
SetEnvIf Request_URI ^/ebooks/.+?/dist/(.+)$ FILENAME=$1
|
||||
SetEnvIf Request_URI ^/ebooks/.+?/downloads/(.+)$ FILENAME=$1
|
||||
Header set "Content-Disposition" "attachment; filename=%{FILENAME}e"
|
||||
</Location>
|
||||
|
||||
|
@ -114,6 +114,11 @@ Define domain standardebooks.test
|
|||
Header set Access-Control-Allow-Origin "*"
|
||||
</Location>
|
||||
|
||||
# We use a different CSP policy for single-page files because our default one doesn't allow inline images or CSS
|
||||
<Location ~ /text/single-page$>
|
||||
Header set Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline';"
|
||||
</Location>
|
||||
|
||||
# Remove www from requests
|
||||
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
|
||||
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
|
||||
|
@ -158,6 +163,17 @@ Define domain standardebooks.test
|
|||
# Remove trailing slashes
|
||||
RewriteRule ^/(.+?)/$ /$1 [R=301,L]
|
||||
|
||||
# Redirect ToC of XHTML representation of books
|
||||
RewriteRule ^/ebooks/(.+?)/text$ /ebooks/$1/src/epub/toc.xhtml [L]
|
||||
|
||||
# Redirect XHTML representation of books
|
||||
# This has to appear before the next check, so that we can exclude .xhtml endings
|
||||
RewriteRule ^/ebooks/(.+?)/(text|css|images|fonts)(.*) /ebooks/$1/src/epub/$2$3
|
||||
|
||||
# Received: /filename and /filename.xhtml exists in filesystem; Result: rewrite to /filename.xhtml
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.xhtml -f
|
||||
RewriteRule (.*) $1.xhtml
|
||||
|
||||
# Redirect index pages
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}/index.php -f
|
||||
|
@ -187,8 +203,8 @@ Define domain standardebooks.test
|
|||
RewriteRule ^/alices-adventures-in-wonderland.+$ /ebooks/lewis-carroll/alices-adventures-in-wonderland/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/philip-k-dick/short-stories(.+)$ /ebooks/philip-k-dick/short-fiction$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/benjamin-disraeli/sibyl(.+)$ /ebooks/benjamin-disraeli/sybil$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/alices-adventures-in-wonderland/dist/(.+)$ /ebooks/lewis-carroll/alices-adventures-in-wonderland/john-tenniel/dist/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/through-the-looking-glass/dist/(.+)$ /ebooks/lewis-carroll/through-the-looking-glass/john-tenniel/dist/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/alices-adventures-in-wonderland/downloads/(.+)$ /ebooks/lewis-carroll/alices-adventures-in-wonderland/john-tenniel/downloads/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/lewis-carroll/through-the-looking-glass/downloads/(.+)$ /ebooks/lewis-carroll/through-the-looking-glass/john-tenniel/downloads/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company$ /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company/(.+?)$ /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy/$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-g-wells/tales-of-space-and-time(.+)$ /ebooks/h-g-wells/short-fiction$1 [R=301,L]
|
||||
|
@ -210,7 +226,7 @@ Define domain standardebooks.test
|
|||
RewriteRule ^/collections/([^\./]+?)$ /ebooks/index.php?collection=$1 [QSA]
|
||||
|
||||
# Prevent this rule from firing if we're getting a distribution file
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/dist/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/src/.+$
|
||||
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue