Skip to content

Commit

Permalink
🔀 Merge epubMetadata branch to deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Nov 2, 2023
2 parents 3e915f8 + 4bafeb3 commit b292599
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 22 deletions.
16 changes: 15 additions & 1 deletion components/IscnRegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@
:placeholder="$t('IscnRegisterForm.placeholder.url')"
/>
</FormField>
<FormField
v-if="type === 'Book'"
:label="$t('IscnRegisterForm.label.isbn')"
>
<TextField
v-model="isbn"
:placeholder="$t('IscnRegisterForm.placeholder.isbn')"
/>
</FormField>
<Divider class="my-[12px]" />
<FormField
:label="$t('IscnRegisterForm.label.type')"
Expand Down Expand Up @@ -594,6 +603,7 @@
<SameAsFieldList
:name="name"
:url-options="contentFingerprintLinks"
:file-records="fileRecords"
:current-list="sameAsList"
@onConfirm="confirmSameAsChange"
/>
Expand Down Expand Up @@ -785,8 +795,10 @@ export default class IscnRegisterForm extends Vue {
tags: string[] = []
sameAs: string[] = []
url: string = ''
isbn: string = ''
license: string = this.licenseOptions[0]
customLicense: string = ''
thumbnailUrl: string = ''
authorName: string = ''
authorUrl: string[] = []
authorWalletAddress: string[] = []
Expand Down Expand Up @@ -990,6 +1002,7 @@ export default class IscnRegisterForm extends Vue {
tagsString: this.tagsString,
sameAs: this.formattedSameAsList,
url: this.url,
isbn: this.isbn,
exifInfo: this.exif.filter(file => file),
license: this.formattedLicense,
ipfsHash: this.ipfsHashList,
Expand All @@ -1005,7 +1018,7 @@ export default class IscnRegisterForm extends Vue {
authorDescriptions: this.authorDescriptions,
contentFingerprints: this.customContentFingerprints,
inLanguage: this.language,
thumbnail: this.epubMetadata.thumbnail,
thumbnailUrl: this.thumbnailUrl,
}
}
Expand Down Expand Up @@ -1091,6 +1104,7 @@ export default class IscnRegisterForm extends Vue {
this.author.name = this.epubMetadata.author;
this.language = this.epubMetadata.language
this.tags = this.epubMetadata.tags
this.thumbnailUrl = this.epubMetadata.thumbnailUrl
if (this.author.name) { this.authors.push(this.author) }
}
Expand Down
27 changes: 15 additions & 12 deletions components/IscnUploadForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ import ePub from 'epubjs';
import { OfflineSigner } from '@cosmjs/proto-signing'
import { IS_CHAIN_UPGRADING, UPLOAD_FILESIZE_MAX, IPFS_VIEW_GATEWAY_URL } from '~/constant'
import { IS_CHAIN_UPGRADING, UPLOAD_FILESIZE_MAX } from '~/constant'
import { logTrackerEvent } from '~/utils/logger'
import { estimateBundlrFilePrice, uploadSingleFileToBundlr } from '~/utils/arweave/v2'
import {
Expand Down Expand Up @@ -566,13 +566,6 @@ export default class UploadForm extends Vue {
}
epubMetadata.ipfsHash = ipfsHash
epubMetadata.thumbnail = {
"@type": "ImageObject",
url: `${IPFS_VIEW_GATEWAY_URL}${ipfsHash}`,
name: `${file.name}_cover`,
description: `${file.name}_cover`,
encodingFormat: "image/jpeg",
};
const reader = new FileReader()
reader.onload = (e) => {
Expand Down Expand Up @@ -670,7 +663,7 @@ export default class UploadForm extends Vue {
this.sentArweaveTransactionHashes.set(ipfsHash, { transactionHash: '', arweaveId });
const metadata = this.epubMetadataList.find((data: any) => data.ipfsHash === ipfsHash)
if (metadata) {
metadata.thumbnail.contentUrl = `https://arweave.net/${arweaveId}`;
metadata.thumbnailUrl = `ar://${arweaveId}`;
}
}
if (!this.arweaveFeeTargetAddress) {
Expand Down Expand Up @@ -747,9 +740,9 @@ export default class UploadForm extends Vue {
if (arweaveId) {
const uploadedData = this.sentArweaveTransactionHashes.get(records.ipfsHash) || {};
this.sentArweaveTransactionHashes.set(records.ipfsHash, { ...uploadedData, arweaveId });
if (tempRecord.fileName === 'cover.jpeg') {
const metadata = this.epubMetadataList.find((file: any) => file.ipfsHash === records.thumbnail.url)
metadata.thumbnail.contentUrl = `https://arweave.net/${arweaveId}`
if (tempRecord.fileName.includes('cover.jpeg')) {
const metadata = this.epubMetadataList.find((file: any) => file.ipfsHash === records.ipfsHash)
metadata.thumbnailUrl = `ar://${arweaveId}`
}
this.$emit('arweaveUploaded', { arweaveId })
this.isOpenSignDialog = false
Expand Down Expand Up @@ -805,6 +798,16 @@ export default class UploadForm extends Vue {
}
const uploadArweaveIdList = Array.from(this.sentArweaveTransactionHashes.values()).map(entry => entry.arweaveId);
this.fileRecords.forEach((record: any, index:number) => {
if (this.sentArweaveTransactionHashes.has(record.ipfsHash)) {
const arweaveId = this.sentArweaveTransactionHashes.get(
record.ipfsHash,
)?.arweaveId
if (arweaveId) {
this.fileRecords[index].arweaveId = `ar://${arweaveId}`
}
}
})
this.$emit('submit', { fileRecords: this.fileRecords, arweaveIds: uploadArweaveIdList, epubMetadata: this.epubMetadataList[0] })
}
Expand Down
60 changes: 52 additions & 8 deletions components/SameAsFieldList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,27 @@
</FormField>

<div class="flex items-center justify-start gap-[8px]">
<FormField :label="$t('IscnRegisterForm.label.fileName')">
<FormField class="w-[200px]" :label="$t('IscnRegisterForm.label.fileName')">
<TextField
v-model="item.filename"
:placeholder="$t('IscnRegisterForm.placeholder.fileName')"
/>
</FormField>
<FormField :label="$t('IscnRegisterForm.label.fileType')">
<FormField class="w-min" :label="$t('IscnRegisterForm.label.fileType')">
<Selector
class="h-[40px] w-[80px]"
:options="sameAsFiletypeOptions"
:placeholder="item.filetype || sameAsFiletypeOptions[0]"
@input="(value) => handleSelectValue({ value, index: i })"
/>
</FormField>
<Label
v-if="item.originFileName"
class="text-medium-gray"
preset="h6"
>
{{ $t('IscnRegisterForm.label.originFile', { name: item.originFileName }) }}
</Label>
</div>
</div>
<div
Expand Down Expand Up @@ -77,6 +84,7 @@ export default class WalletFieldList extends Vue {
readonly urlOptions!: Array<any>
@Prop({ default: () => [] }) readonly currentList!: Array<any>
@Prop({ default: () => [] }) readonly fileRecords!: Array<any>
@Prop(String) readonly name!: string | undefined
sameAsList: any = [{
Expand Down Expand Up @@ -112,20 +120,27 @@ export default class WalletFieldList extends Vue {
id: `${list.url}-${list.filename}`,
filename: list.filename,
filetype: list.filetype || SAME_AS_FILE_TYPES[0],
originFileName: list.originFileName,
}))
} else if (this.formatUrlOptions.length) {
this.sameAsList = this.formatUrlOptions.map((url, index) => ({
url,
id: `${url}-${index}`,
filename: this.formatName,
filetype: SAME_AS_FILE_TYPES[0],
}))
this.sameAsList = this.formatUrlOptions.map((url, index) =>{
const originFile = this.fileRecords.find((file) => (file.arweaveId === url))
const formattedFileType = this.formatFileType(originFile.fileType);
return{
url,
id: `${url}-${index}`,
filename: this.formatName,
filetype: formattedFileType || SAME_AS_FILE_TYPES[0],
originFileName: originFile.fileName,
}
})
} else {
this.sameAsList = [{
url: '',
id: 1,
filename: this.formatName,
filetype: SAME_AS_FILE_TYPES[0],
originFileName:'',
}]
}
}
Expand Down Expand Up @@ -159,5 +174,34 @@ export default class WalletFieldList extends Vue {
this.deleteEmptyField()
this.$emit('onConfirm', this.sameAsList)
}
// eslint-disable-next-line class-methods-use-this
formatFileType(fileType: string) {
let formattedFileType = ''
if (fileType) {
switch (true) {
case fileType.includes('jpg'):
case fileType.includes('jpeg'):
formattedFileType = 'jpg'
break
case fileType.includes('png'):
formattedFileType = 'png'
break
case fileType.includes('audio'):
formattedFileType = 'mp3'
break
case fileType.includes('pdf'):
formattedFileType = 'pdf'
break
case fileType.includes('epub'):
formattedFileType = 'epub'
break
default:
formattedFileType = ''
break
}
}
return formattedFileType
}
}
</script>
3 changes: 3 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@
"IscnRegisterForm.label.emptyFile": "No Content",
"IscnRegisterForm.label.fingerprints": "Content Fingerprints",
"IscnRegisterForm.label.iscn": "ISCN Title",
"IscnRegisterForm.label.isbn": "ISBN",
"IscnRegisterForm.label.license": "License",
"IscnRegisterForm.label.likerID": "LikerID",
"IscnRegisterForm.label.sameAs" : "Same As URLs",
"IscnRegisterForm.label.name": "Name",
"IscnRegisterForm.label.fileName": "File name",
"IscnRegisterForm.label.fileType": "File type",
"IscnRegisterForm.label.originFile": "origin file: {name}",
"IscnRegisterForm.label.numbersProtocol": "Numbers Protocol",
"IscnRegisterForm.label.numbersProtocol.details": "Register your image asset in {link}",
"IscnRegisterForm.label.numbersProtocol.details.link": "Numbers Protocol",
Expand All @@ -234,6 +236,7 @@
"IscnRegisterForm.placeholder.fileName": "File Name (en)",
"IscnRegisterForm.placeholder.fileType": "File Type",
"IscnRegisterForm.placeholder.url": "URL",
"IscnRegisterForm.placeholder.isbn": "ISBN 10/ ISCN 13",
"IscnRegisterForm.placeholder.wallet": "Wallet Address",
"IscnRegisterForm.quitAlertDialog.confirm": "Cancel Registration",
"IscnRegisterForm.quitAlertDialog.content": "Your registration will be cancelled if you leave this page, and the paid fee cannot be refunded.",
Expand Down
3 changes: 2 additions & 1 deletion utils/cosmos/iscn/iscn.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export interface ISCNRegisterPayload {
recordNotes?: string;
memo?: string;
inLanguage?: string;
thumbnail?: any;
thumbnailUrl?: string;
isbn?: string | number;
}
export interface ISCNRecordWithID extends ISCNRecord {
id: string;
Expand Down

0 comments on commit b292599

Please sign in to comment.