From 68f7e426e8fa4e34d7517fd81198efc064d863ae Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Thu, 2 Nov 2023 23:46:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9A=B8=20=20Provide=20additional=20in?= =?UTF-8?q?formation=20for=20sameAs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 3 +- components/IscnUploadForm.vue | 25 ++++++++------ components/SameAsFieldList.vue | 60 ++++++++++++++++++++++++++++----- locales/en.json | 1 + utils/cosmos/iscn/iscn.type.ts | 2 +- 5 files changed, 70 insertions(+), 21 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index d818b144..51a97ccf 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -594,6 +594,7 @@ @@ -1005,7 +1006,7 @@ export default class IscnRegisterForm extends Vue { authorDescriptions: this.authorDescriptions, contentFingerprints: this.customContentFingerprints, inLanguage: this.language, - thumbnail: this.epubMetadata.thumbnail, + thumbnailUrl: this.epubMetadata?.thumbnailUrl, } } diff --git a/components/IscnUploadForm.vue b/components/IscnUploadForm.vue index bdc8c72e..507431ff 100644 --- a/components/IscnUploadForm.vue +++ b/components/IscnUploadForm.vue @@ -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 { @@ -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) => { @@ -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) { @@ -748,8 +741,8 @@ export default class UploadForm extends Vue { 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}` + const metadata = this.epubMetadataList.find((file: any) => file.ipfsHash === records.ipfsHash) + metadata.thumbnailUrl = `ar://${arweaveId}` } this.$emit('arweaveUploaded', { arweaveId }) this.isOpenSignDialog = false @@ -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] }) } diff --git a/components/SameAsFieldList.vue b/components/SameAsFieldList.vue index ce882d65..243d09d8 100644 --- a/components/SameAsFieldList.vue +++ b/components/SameAsFieldList.vue @@ -16,13 +16,13 @@
- + - + +
@Prop({ default: () => [] }) readonly currentList!: Array + @Prop({ default: () => [] }) readonly fileRecords!: Array @Prop(String) readonly name!: string | undefined sameAsList: any = [{ @@ -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:'', }] } } @@ -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 + } } diff --git a/locales/en.json b/locales/en.json index 8eed747d..3b57682b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -216,6 +216,7 @@ "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", diff --git a/utils/cosmos/iscn/iscn.type.ts b/utils/cosmos/iscn/iscn.type.ts index 377bdffa..42bd0afa 100644 --- a/utils/cosmos/iscn/iscn.type.ts +++ b/utils/cosmos/iscn/iscn.type.ts @@ -25,7 +25,7 @@ export interface ISCNRegisterPayload { recordNotes?: string; memo?: string; inLanguage?: string; - thumbnail?: any; + thumbnailUrl?: string; } export interface ISCNRecordWithID extends ISCNRecord { id: string; From 4bafeb3140a67d310c8fb812faf3bb9fbc9e7d41 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Fri, 3 Nov 2023 00:05:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Add=20ISBN=20field=20for=20Book?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 15 ++++++++++++++- components/IscnUploadForm.vue | 2 +- locales/en.json | 2 ++ utils/cosmos/iscn/iscn.type.ts | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index 51a97ccf..101629b9 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -355,6 +355,15 @@ :placeholder="$t('IscnRegisterForm.placeholder.url')" /> + + + file), license: this.formattedLicense, ipfsHash: this.ipfsHashList, @@ -1006,7 +1018,7 @@ export default class IscnRegisterForm extends Vue { authorDescriptions: this.authorDescriptions, contentFingerprints: this.customContentFingerprints, inLanguage: this.language, - thumbnailUrl: this.epubMetadata?.thumbnailUrl, + thumbnailUrl: this.thumbnailUrl, } } @@ -1092,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) } } diff --git a/components/IscnUploadForm.vue b/components/IscnUploadForm.vue index 507431ff..bd0e3af9 100644 --- a/components/IscnUploadForm.vue +++ b/components/IscnUploadForm.vue @@ -740,7 +740,7 @@ 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') { + if (tempRecord.fileName.includes('cover.jpeg')) { const metadata = this.epubMetadataList.find((file: any) => file.ipfsHash === records.ipfsHash) metadata.thumbnailUrl = `ar://${arweaveId}` } diff --git a/locales/en.json b/locales/en.json index 3b57682b..57f36a82 100644 --- a/locales/en.json +++ b/locales/en.json @@ -210,6 +210,7 @@ "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", @@ -235,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.", diff --git a/utils/cosmos/iscn/iscn.type.ts b/utils/cosmos/iscn/iscn.type.ts index 42bd0afa..8f36b25b 100644 --- a/utils/cosmos/iscn/iscn.type.ts +++ b/utils/cosmos/iscn/iscn.type.ts @@ -26,6 +26,7 @@ export interface ISCNRegisterPayload { memo?: string; inLanguage?: string; thumbnailUrl?: string; + isbn?: string | number; } export interface ISCNRecordWithID extends ISCNRecord { id: string;