Commit bb6a181b authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Do not render empty quotes when exporting to Text or HTML

parent bd6446ac
...@@ -77,11 +77,12 @@ export class AnnotationsExporter { ...@@ -77,11 +77,12 @@ export class AnnotationsExporter {
const annotationsAsText = annotations.map((annotation, index) => { const annotationsAsText = annotations.map((annotation, index) => {
const page = pageLabel(annotation); const page = pageLabel(annotation);
const annotationQuote = quote(annotation);
const lines = [ const lines = [
`Created at: ${formatDateTime(new Date(annotation.created))}`, `Created at: ${formatDateTime(new Date(annotation.created))}`,
`Author: ${extractUsername(annotation)}`, `Author: ${extractUsername(annotation)}`,
page ? `Page: ${page}` : undefined, page ? `Page: ${page}` : undefined,
`Quote: "${quote(annotation)}"`, annotationQuote ? `Quote: "${annotationQuote}"` : undefined,
`Comment: ${annotation.text}`, `Comment: ${annotation.text}`,
annotation.tags.length > 0 annotation.tags.length > 0
? `Tags: ${annotation.tags.join(', ')}` ? `Tags: ${annotation.tags.join(', ')}`
...@@ -219,6 +220,8 @@ export class AnnotationsExporter { ...@@ -219,6 +220,8 @@ export class AnnotationsExporter {
<h1>Annotations</h1> <h1>Annotations</h1>
{annotations.map((annotation, index) => { {annotations.map((annotation, index) => {
const page = pageLabel(annotation); const page = pageLabel(annotation);
const annotationQuote = quote(annotation);
return ( return (
<article key={annotation.id}> <article key={annotation.id}>
<h2>Annotation {index + 1}:</h2> <h2>Annotation {index + 1}:</h2>
...@@ -242,14 +245,16 @@ export class AnnotationsExporter { ...@@ -242,14 +245,16 @@ export class AnnotationsExporter {
<td>{page}</td> <td>{page}</td>
</tr> </tr>
)} )}
{annotationQuote && (
<tr> <tr>
<td>Quote:</td> <td>Quote:</td>
<td> <td>
<blockquote style={{ margin: 0 }}> <blockquote style={{ margin: 0 }}>
{quote(annotation)} {annotationQuote}
</blockquote> </blockquote>
</td> </td>
</tr> </tr>
)}
<tr> <tr>
<td>Comment:</td> <td>Comment:</td>
<td>{annotation.text}</td> <td>{annotation.text}</td>
......
...@@ -90,6 +90,7 @@ describe('AnnotationsExporter', () => { ...@@ -90,6 +90,7 @@ describe('AnnotationsExporter', () => {
...baseAnnotation, ...baseAnnotation,
user: 'acct:jane@localhost', user: 'acct:jane@localhost',
tags: ['foo', 'bar'], tags: ['foo', 'bar'],
target: targetWithSelectors(quoteSelector('The quote')),
}, },
{ {
...baseAnnotation, ...baseAnnotation,
...@@ -129,14 +130,13 @@ Tags: tag_1, tag_2 ...@@ -129,14 +130,13 @@ Tags: tag_1, tag_2
Annotation 2: Annotation 2:
Created at: ${formattedNow} Created at: ${formattedNow}
Author: bill Author: bill
Quote: "null"
Comment: Annotation text Comment: Annotation text
Tags: tag_1, tag_2 Tags: tag_1, tag_2
Annotation 3: Annotation 3:
Created at: ${formattedNow} Created at: ${formattedNow}
Author: jane Author: jane
Quote: "null" Quote: "The quote"
Comment: Annotation text Comment: Annotation text
Tags: foo, bar Tags: foo, bar
...@@ -144,7 +144,6 @@ Annotation 4: ...@@ -144,7 +144,6 @@ Annotation 4:
Created at: ${formattedNow} Created at: ${formattedNow}
Author: bill Author: bill
Page: 23 Page: 23
Quote: "null"
Comment: Annotation text Comment: Annotation text
Tags: tag_1, tag_2 Tags: tag_1, tag_2
...@@ -152,7 +151,6 @@ Annotation 5: ...@@ -152,7 +151,6 @@ Annotation 5:
Created at: ${formattedNow} Created at: ${formattedNow}
Author: bill Author: bill
Page: iii Page: iii
Quote: "null"
Comment: Annotation text`, Comment: Annotation text`,
); );
}); });
...@@ -185,7 +183,6 @@ Total replies: 0 ...@@ -185,7 +183,6 @@ Total replies: 0
Annotation 1: Annotation 1:
Created at: ${formattedNow} Created at: ${formattedNow}
Author: John Doe Author: John Doe
Quote: "null"
Comment: Annotation text Comment: Annotation text
Tags: tag_1, tag_2`, Tags: tag_1, tag_2`,
); );
...@@ -273,10 +270,10 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex ...@@ -273,10 +270,10 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...baseAnnotation, ...baseAnnotation,
user: 'acct:jane@localhost', user: 'acct:jane@localhost',
tags: ['foo', 'bar'], tags: ['foo', 'bar'],
target: targetWithSelectors(quoteSelector('The quote')),
}, },
{ {
...baseAnnotation, ...baseAnnotation,
...newReply(),
target: targetWithSelectors( target: targetWithSelectors(
quoteSelector('includes <p>HTML</p> tags'), quoteSelector('includes <p>HTML</p> tags'),
pageSelector(23), pageSelector(23),
...@@ -284,6 +281,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex ...@@ -284,6 +281,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
}, },
{ {
...baseAnnotation, ...baseAnnotation,
...newReply(),
tags: [], tags: [],
target: targetWithSelectors(pageSelector('iii')), target: targetWithSelectors(pageSelector('iii')),
}, },
...@@ -370,7 +368,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex ...@@ -370,7 +368,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
<tr> <tr>
<td>Quote:</td> <td>Quote:</td>
<td> <td>
<blockquote style="margin:0px;"></blockquote> <blockquote style="margin:0px;">The quote</blockquote>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -437,12 +435,6 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex ...@@ -437,12 +435,6 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
<td>Page:</td> <td>Page:</td>
<td>iii</td> <td>iii</td>
</tr> </tr>
<tr>
<td>Quote:</td>
<td>
<blockquote style="margin:0px;"></blockquote>
</td>
</tr>
<tr> <tr>
<td>Comment:</td> <td>Comment:</td>
<td>Annotation text</td> <td>Annotation text</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment