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
deca184a
Commit
deca184a
authored
Jan 11, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jan 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format dates as YYYY-MM-DD hh:mm when exporting annotations
parent
302d92ea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
annotations-exporter.ts
src/sidebar/services/annotations-exporter.ts
+4
-3
annotations-exporter-test.js
src/sidebar/services/test/annotations-exporter-test.js
+15
-16
No files found.
src/sidebar/services/annotations-exporter.ts
View file @
deca184a
...
...
@@ -10,6 +10,7 @@ import {
import
{
annotationDisplayName
}
from
'../helpers/annotation-user'
;
import
{
stripInternalProperties
}
from
'../helpers/strip-internal-properties'
;
import
{
VersionData
}
from
'../helpers/version-data'
;
import
{
formatDateTime
}
from
'../util/time'
;
export
type
JSONExportContent
=
{
export_date
:
string
;
...
...
@@ -76,7 +77,7 @@ export class AnnotationsExporter {
.
map
((
annotation
,
index
)
=>
{
const
page
=
pageLabel
(
annotation
);
const
lines
=
[
annotation
.
created
,
formatDateTime
(
new
Date
(
annotation
.
created
))
,
`Comment:
${
annotation
.
text
}
`
,
extractUsername
(
annotation
),
`Quote: "
${
quote
(
annotation
)}
"`
,
...
...
@@ -93,7 +94,7 @@ export class AnnotationsExporter {
.
join
(
'
\
n
\
n'
);
return
trimAndDedent
`
${
now
.
toISOString
(
)}
${
formatDateTime
(
now
)}
${
title
}
${
uri
}
Group:
${
groupName
}
...
...
@@ -120,7 +121,7 @@ export class AnnotationsExporter {
const
annotationToRow
=
(
annotation
:
APIAnnotationData
)
=>
[
annotation
.
created
,
formatDateTime
(
new
Date
(
annotation
.
created
))
,
uri
,
groupName
,
isReply
(
annotation
)
?
'Reply'
:
'Annotation'
,
...
...
src/sidebar/services/test/annotations-exporter-test.js
View file @
deca184a
...
...
@@ -3,10 +3,12 @@ import {
newReply
,
publicAnnotation
,
}
from
'../../test/annotation-fixtures'
;
import
{
formatDateTime
}
from
'../../util/time'
;
import
{
AnnotationsExporter
}
from
'../annotations-exporter'
;
describe
(
'AnnotationsExporter'
,
()
=>
{
let
now
;
let
formattedNow
;
let
baseAnnotation
;
let
exporter
;
const
groupName
=
'My group'
;
...
...
@@ -27,6 +29,7 @@ describe('AnnotationsExporter', () => {
beforeEach
(()
=>
{
now
=
new
Date
();
formattedNow
=
formatDateTime
(
now
);
baseAnnotation
=
{
...
newAnnotation
(),
...
publicAnnotation
(),
...
...
@@ -77,7 +80,6 @@ describe('AnnotationsExporter', () => {
});
it
(
'generates text content with provided annotations'
,
()
=>
{
const
isoDate
=
baseAnnotation
.
created
;
const
annotations
=
[
{
...
baseAnnotation
,
...
...
@@ -108,7 +110,7 @@ describe('AnnotationsExporter', () => {
assert
.
equal
(
result
,
`
${
isoDate
}
`
${
formattedNow
}
A special document
http://example.com
Group:
${
groupName
}
...
...
@@ -118,28 +120,28 @@ Total annotations: 5
Total replies: 1
Annotation 1:
${
isoDate
}
${
formattedNow
}
Comment: Annotation text
bill
Quote: "this is the quote"
Tags: tag_1, tag_2
Annotation 2:
${
isoDate
}
${
formattedNow
}
Comment: Annotation text
bill
Quote: "null"
Tags: tag_1, tag_2
Annotation 3:
${
isoDate
}
${
formattedNow
}
Comment: Annotation text
jane
Quote: "null"
Tags: foo, bar
Annotation 4:
${
isoDate
}
${
formattedNow
}
Comment: Annotation text
bill
Quote: "null"
...
...
@@ -147,7 +149,7 @@ Tags: tag_1, tag_2
Page: 23
Annotation 5:
${
isoDate
}
${
formattedNow
}
Comment: Annotation text
bill
Quote: "null"
...
...
@@ -162,7 +164,6 @@ Page: iii`,
display_name
:
'John Doe'
,
},
};
const
isoDate
=
annotation
.
created
;
const
result
=
exporter
.
buildTextExportContent
([
annotation
],
{
displayNamesEnabled
:
true
,
...
...
@@ -172,7 +173,7 @@ Page: iii`,
assert
.
equal
(
result
,
`
${
isoDate
}
`
${
formattedNow
}
A special document
http://example.com
Group:
${
groupName
}
...
...
@@ -182,7 +183,7 @@ Total annotations: 1
Total replies: 0
Annotation 1:
${
isoDate
}
${
formattedNow
}
Comment: Annotation text
John Doe
Quote: "null"
...
...
@@ -200,7 +201,6 @@ Tags: tag_1, tag_2`,
});
it
(
'generates CSV content with expected annotations'
,
()
=>
{
const
isoDate
=
baseAnnotation
.
created
;
const
annotations
=
[
{
...
baseAnnotation
,
...
...
@@ -229,9 +229,9 @@ Tags: tag_1, tag_2`,
assert
.
equal
(
result
,
`Creation Date,URL,Group,Annotation/Reply Type,Quote,User,Body,Tags,Page
${
isoDate
}
,http://example.com,My group,Annotation,,jane,Annotation text,"foo,bar",
${
isoDate
}
,http://example.com,My group,Reply,"includes ""double quotes"", and commas",bill,Annotation text,"tag_1,tag_2",23
${
isoDate
}
,http://example.com,My group,Annotation,,bill,Annotation text,,iii`
,
${
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`
,
);
});
...
...
@@ -242,7 +242,6 @@ ${isoDate},http://example.com,My group,Annotation,,bill,Annotation text,,iii`,
display_name
:
'John Doe'
,
},
};
const
isoDate
=
annotation
.
created
;
const
result
=
exporter
.
buildCSVExportContent
([
annotation
],
{
displayNamesEnabled
:
true
,
...
...
@@ -252,7 +251,7 @@ ${isoDate},http://example.com,My group,Annotation,,bill,Annotation text,,iii`,
assert
.
equal
(
result
,
`Creation Date,URL,Group,Annotation/Reply Type,Quote,User,Body,Tags,Page
${
isoDate
}
,http://example.com,My group,Annotation,,John Doe,Annotation text,"tag_1,tag_2",`
,
${
formattedNow
}
,http://example.com,My group,Annotation,,John Doe,Annotation text,"tag_1,tag_2",`
,
);
});
});
...
...
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