Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add chapter name and book title to attribution link #2220

Merged
merged 18 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/content/__snapshots__/routes.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ Array [
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -1025,10 +1025,10 @@ Array [
Location: Houston, Texas
</li>
<li>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</li>
<li>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
</li>
</ul>
</li>
Expand Down
5 changes: 5 additions & 0 deletions src/app/content/components/Attribution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { hasOSWebData } from '../guards';
import * as select from '../selectors';
import { Book, BookWithOSWebData, Page } from '../types';
import { findDefaultBookPage, getBookPageUrlAndParams } from '../utils';
import { splitTitleParts } from '../utils/archiveTreeUtils';
import { contentTextStyle } from './Page/PageContent';
import { bookIdsWithSpecialAttributionText, compensateForUTC, getAuthors, getPublishDate, } from './utils/attributionValues';
import { disablePrint } from './utils/disablePrint';
Expand Down Expand Up @@ -153,6 +154,9 @@ class Attribution extends Component<Props> {
...book,
loadOptions: {booksConfig: book.loadOptions.booksConfig},
};

const [, titlePart] = splitTitleParts(introPage.title);
const introPageTitle = `${titlePart} - ${book.title} | OpenStax`;
const introPageUrl = getBookPageUrlAndParams(bookWithoutExplicitVersions, introPage).url;
const currentPageUrl = getBookPageUrlAndParams(bookWithoutExplicitVersions, page).url;

Expand All @@ -174,6 +178,7 @@ class Attribution extends Component<Props> {
bookTitle: book.title,
copyrightHolder: 'OpenStax',
currentPath: currentPageUrl,
introPageTitle,
introPageUrl,
originalMaterialLink: null,
...bookIdsWithSpecialAttributionText[book.id] || {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ exports[`Attribution in browser renders default attribution 1`] = `
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -1207,10 +1207,10 @@ exports[`Attribution in browser renders default attribution 1`] = `
Location: Houston, Texas
</li>
<li>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</li>
<li>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -2568,7 +2568,7 @@ exports[`Attribution in browser renders special licensing and attribution for HS
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -2596,10 +2596,10 @@ exports[`Attribution in browser renders special licensing and attribution for HS
Location: Houston, Texas
</li>
<li>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</li>
<li>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -4273,7 +4273,7 @@ exports[`Attribution in browser renders special licensing and attribution for In
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -4301,10 +4301,10 @@ exports[`Attribution in browser renders special licensing and attribution for In
Location: Houston, Texas
</li>
<li>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</li>
<li>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -5821,7 +5821,7 @@ exports[`Attribution in browser renders special licensing and attribution for St
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -5849,10 +5849,10 @@ exports[`Attribution in browser renders special licensing and attribution for St
Location: Houston, Texas
</li>
<li>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</li>
<li>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/test-page-1\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/test-page-1</a>
</li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4313,7 +4313,7 @@ li[aria-label="Current Page"] .c60 {
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Access for free at <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -4341,10 +4341,10 @@ li[aria-label="Current Page"] .c60 {
Location: Houston, Texas
</li>
<li>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
Book URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/1-introduction-to-science-and-the-realm-of-physics-physical-quantities-and-units</a>
</li>
<li>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/3-test-page-4\\">https://openstax.org/books/book-slug-1/pages/3-test-page-4</a>
Section URL: <a target=\\"_blank\\" href=\\"https://openstax.org/books/book-slug-1/pages/3-test-page-4\\" aria-label=\\"Introduction to Science and the Realm of Physics, Physical Quantities, and Units - Test Book 1 | OpenStax\\">https://openstax.org/books/book-slug-1/pages/3-test-page-4</a>
</li>
</ul>
</li>
Expand Down
6 changes: 3 additions & 3 deletions src/app/messages/en/attributionText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const defaultText = `
If you are redistributing all or part of this book in a digital format,
then you must include on every digital page view the following attribution:
<blockquote>
Access for free at <a target="_blank" href="https://openstax.org{introPageUrl}">https://openstax.org{introPageUrl}</a>
Access for free at <a target="_blank" href="https://openstax.org{introPageUrl}" aria-label="{introPageTitle}">https://openstax.org{introPageUrl}</a>
Copy link
Contributor

@RoyEJohnson RoyEJohnson May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quotes are superfluous, aren't they? Should just be aria-label={introPageTitle} ?
And the interpolation in the href? That works? I'd write

href={`https://openstax.org${introPageUrl}`}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string gets formatted with the useIntl stuff, so it's like how we interpolate in the messages.json file

</blockquote>
</li>
</ul>
Expand Down Expand Up @@ -56,10 +56,10 @@ export const defaultText = `
Location: Houston, Texas
</li>
<li>
Book URL: <a target="_blank" href="https://openstax.org{introPageUrl}">https://openstax.org{introPageUrl}</a>
Book URL: <a target="_blank" href="https://openstax.org{introPageUrl}" aria-label="{introPageTitle}">https://openstax.org{introPageUrl}</a>
</li>
<li>
Section URL: <a target="_blank" href="https://openstax.org{currentPath}">https://openstax.org{currentPath}</a>
Section URL: <a target="_blank" href="https://openstax.org{currentPath}" aria-label="{introPageTitle}">https://openstax.org{currentPath}</a>
</li>
</ul>
</li>
Expand Down
Loading