Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
7002a1d1
Commit
7002a1d1
authored
Jan 12, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jan 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rearrange fields in annotations exports to follow the same pattern as annotation cards
parent
d93b8b3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
38 deletions
+38
-38
annotations-exporter.tsx
src/sidebar/services/annotations-exporter.tsx
+10
-10
annotations-exporter-test.js
src/sidebar/services/test/annotations-exporter-test.js
+28
-28
No files found.
src/sidebar/services/annotations-exporter.tsx
View file @
7002a1d1
...
...
@@ -79,13 +79,13 @@ export class AnnotationsExporter {
const
page
=
pageLabel
(
annotation
);
const
lines
=
[
`Created at:
${
formatDateTime
(
new
Date
(
annotation
.
created
))}
`
,
`
Comment:
${
annotation
.
text
}
`
,
extractUsername
(
annotation
)
,
`
Author:
${
extractUsername
(
annotation
)
}
`
,
page
?
`Page:
${
page
}
`
:
undefined
,
`Quote: "
${
quote
(
annotation
)}
"`
,
`Comment:
${
annotation
.
text
}
`
,
annotation
.
tags
.
length
>
0
?
`Tags:
${
annotation
.
tags
.
join
(
', '
)}
`
:
undefined
,
page
?
`Page:
${
page
}
`
:
undefined
,
].
filter
(
Boolean
);
return
trimAndDedent
`
...
...
@@ -122,28 +122,28 @@ export class AnnotationsExporter {
const
annotationToRow
=
(
annotation
:
APIAnnotationData
)
=>
[
formatDateTime
(
new
Date
(
annotation
.
created
)),
extractUsername
(
annotation
),
pageLabel
(
annotation
)
??
''
,
uri
,
groupName
,
isReply
(
annotation
)
?
'Reply'
:
'Annotation'
,
quote
(
annotation
)
??
''
,
extractUsername
(
annotation
),
annotation
.
text
,
annotation
.
tags
.
join
(
','
),
pageLabel
(
annotation
)
??
''
,
]
.
map
(
escapeCSVValue
)
.
join
(
','
);
const
headers
=
[
'Created at'
,
'Author'
,
'Page'
,
'URL'
,
'Group'
,
'Annotation/Reply Type'
,
'Quote'
,
'User'
,
'Comment'
,
'Tags'
,
'Page'
,
].
join
(
','
);
const
annotationsContent
=
annotations
.
map
(
anno
=>
annotationToRow
(
anno
))
...
...
@@ -228,15 +228,15 @@ export class AnnotationsExporter {
{
formatDateTime
(
new
Date
(
annotation
.
created
))
}
</
time
>
</
p
>
<
p
>
Comment:
{
annotation
.
text
}
</
p
>
<
p
>
{
extractUsername
(
annotation
)
}
</
p
>
<
p
>
Author:
{
extractUsername
(
annotation
)
}
</
p
>
{
page
&&
<
p
>
Page:
{
page
}
</
p
>
}
<
p
>
Quote:
<
blockquote
>
{
quote
(
annotation
)
}
</
blockquote
>
</
p
>
<
p
>
Comment:
{
annotation
.
text
}
</
p
>
{
annotation
.
tags
.
length
>
0
&&
(
<
p
>
Tags:
{
annotation
.
tags
.
join
(
', '
)
}
</
p
>
)
}
{
page
&&
<
p
>
Page:
{
page
}
</
p
>
}
</
article
>
);
})
}
...
...
src/sidebar/services/test/annotations-exporter-test.js
View file @
7002a1d1
...
...
@@ -121,39 +121,39 @@ Total replies: 1
Annotation 1:
Created at:
${
formattedNow
}
Comment: Annotation text
bill
Author: bill
Quote: "this is the quote"
Comment: Annotation text
Tags: tag_1, tag_2
Annotation 2:
Created at:
${
formattedNow
}
Comment: Annotation text
bill
Author: bill
Quote: "null"
Comment: Annotation text
Tags: tag_1, tag_2
Annotation 3:
Created at:
${
formattedNow
}
Comment: Annotation text
jane
Author: jane
Quote: "null"
Comment: Annotation text
Tags: foo, bar
Annotation 4:
Created at:
${
formattedNow
}
Comment: Annotation text
bill
Author: bill
Page: 23
Quote: "null"
Comment: Annotation text
Tags: tag_1, tag_2
Page: 23
Annotation 5:
Created at:
${
formattedNow
}
Comment: Annotation text
bill
Author: bill
Page: iii
Quote: "null"
Page: iii
`
,
Comment: Annotation text
`
,
);
});
...
...
@@ -184,9 +184,9 @@ Total replies: 0
Annotation 1:
Created at:
${
formattedNow
}
Comment: Annotation text
John Doe
Author: John Doe
Quote: "null"
Comment: Annotation text
Tags: tag_1, tag_2`
,
);
});
...
...
@@ -229,10 +229,10 @@ Tags: tag_1, tag_2`,
assert
.
equal
(
result
,
`Created at,
URL,Group,Annotation/Reply Type,Quote,User,Comment,Tags,Page
${
formattedNow
}
,
http://example.com,My group,Annotation,,jane,Annotation text,"foo,bar",
${
formattedNow
}
,
http://example.com,My group,Reply,"includes ""double quotes"", and commas",bill,Annotation text,"tag_1,tag_2",23
${
formattedNow
}
,
http://example.com,My group,Annotation,,bill,Annotation text,,iii
`
,
`Created at,
Author,Page,URL,Group,Annotation/Reply Type,Quote,Comment,Tags
${
formattedNow
}
,
jane,,http://example.com,My group,Annotation,,Annotation text,"foo,bar"
${
formattedNow
}
,
bill,23,http://example.com,My group,Reply,"includes ""double quotes"", and commas",Annotation text,"tag_1,tag_2"
${
formattedNow
}
,
bill,iii,http://example.com,My group,Annotation,,Annotation text,
`
,
);
});
...
...
@@ -252,8 +252,8 @@ ${formattedNow},http://example.com,My group,Annotation,,bill,Annotation text,,ii
assert
.
equal
(
result
,
`Created at,
URL,Group,Annotation/Reply Type,Quote,User,Comment,Tags,Page
${
formattedNow
}
,
http://example.com,My group,Annotation,,John Doe,Annotation text,"tag_1,tag_2",
`
,
`Created at,
Author,Page,URL,Group,Annotation/Reply Type,Quote,Comment,Tags
${
formattedNow
}
,
John Doe,,http://example.com,My group,Annotation,,Annotation text,"tag_1,tag_2"
`
,
);
});
});
...
...
@@ -359,12 +359,12 @@ ${formattedNow},http://example.com,My group,Annotation,,John Doe,Annotation text
Created at:
<time datetime="
${
isoDate
}
">
${
formattedNow
}
</time>
</p>
<p>Comment: Annotation text</p>
<p>jane</p>
<p>Author: jane</p>
<p>
Quote:
<blockquote></blockquote>
</p>
<p>Comment: Annotation text</p>
<p>Tags: foo, bar</p>
</article>
<article>
...
...
@@ -373,14 +373,14 @@ ${formattedNow},http://example.com,My group,Annotation,,John Doe,Annotation text
Created at:
<time datetime="
${
isoDate
}
">
${
formattedNow
}
</time>
</p>
<p>
Comment: Annotation text
</p>
<p>
bill
</p>
<p>
Author: bill
</p>
<p>
Page: 23
</p>
<p>
Quote:
<blockquote>includes <p>HTML</p> tags</blockquote>
</p>
<p>Comment: Annotation text</p>
<p>Tags: tag_1, tag_2</p>
<p>Page: 23</p>
</article>
<article>
<h2>Annotation 3:</h2>
...
...
@@ -388,13 +388,13 @@ ${formattedNow},http://example.com,My group,Annotation,,John Doe,Annotation text
Created at:
<time datetime="
${
isoDate
}
">
${
formattedNow
}
</time>
</p>
<p>
Comment: Annotation text
</p>
<p>
bill
</p>
<p>
Author: bill
</p>
<p>
Page: iii
</p>
<p>
Quote:
<blockquote></blockquote>
</p>
<p>
Page: iii
</p>
<p>
Comment: Annotation text
</p>
</article>
</section>
</body>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment