Skip to content

Commit

Permalink
Improved NFT format for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
macterra committed Nov 19, 2023
1 parent 8e4cd19 commit d8f9006
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 8 additions & 3 deletions nft.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<title>
<%= nft.title %>
<%= nft.title %> by <%= creator.name %>
</title>

<meta property="og:title" content="<%= nft.title %>" />
Expand All @@ -15,6 +15,8 @@
<meta name="twitter:site" content="@artxmarket" />
<meta name="twitter:title" content="<%= nft.title %>" />

<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
body {
font-family: Roboto, Helvetica, Arial, sans-serif;
Expand All @@ -39,6 +41,9 @@
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
flex-wrap: wrap;
}
Expand Down Expand Up @@ -148,7 +153,7 @@
Collected:
</td>
<td>
<%= asset.updated %>
<%= nft.collected %>
</td>
</tr>
<tr>
Expand All @@ -169,7 +174,7 @@
Minted:
</td>
<td>
<%= asset.created %>
<%= nft.minted %>
</td>
</tr>
<tr>
Expand Down
9 changes: 9 additions & 0 deletions xidb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const agent = require('./agent');
const admin = require('./admin');
const archiver = require('./archiver');
const lnbits = require('./lnbits');
const dateFns = require('date-fns');

async function waitForArchiver() {
let isReady = false;
Expand Down Expand Up @@ -519,6 +520,14 @@ function saveNft(xid, config = realConfig) {
assetData.owner.link = `${config.link}/profile/${assetData.owner.xid}`;
assetData.creator.link = `${config.link}/profile/${assetData.creator.xid}`;

const formatTime = (timestamp) => {
const date = new Date(timestamp);
return dateFns.format(date, "yyyy-MM-dd HH:mm:ss");
};

assetData.nft.minted = formatTime(assetData.asset.created);
assetData.nft.collected = formatTime(assetData.asset.updated);

const templatePath = path.join(config.data, 'nft.ejs');
const template = fs.readFileSync(templatePath, 'utf8');
const html = ejs.render(template, assetData);
Expand Down
6 changes: 5 additions & 1 deletion xidb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ describe('saveNft', () => {
const mockCollectionXid = 'mockCollectionXid';
const mockOwnerXid = 'mockOwnerXid';
const mockCreatorXid = 'mockCreatorXid';
const mockTimestamp = new Date().toISOString();

const mockNftData = {
xid: mockNftXid,
asset: { owner: mockOwnerXid },
asset: { owner: mockOwnerXid, created: mockTimestamp, updated: mockTimestamp },
nft: { token: mockTokenXid, title: 'mockNftTitle' }
};

Expand Down Expand Up @@ -219,6 +220,7 @@ describe('saveNft', () => {
xid: mockNftXid,
asset: {
owner: mockOwnerData.xid,
created: expect.any(String),
updated: expect.any(String),
},
nft: {
Expand All @@ -227,6 +229,8 @@ describe('saveNft', () => {
preview: `${config.link}${mockTokenData.file.path}`,
image: '../mockPreviewImage',
link: `${config.link}/nft/${mockNftXid}`,
minted: expect.any(String),
collected: expect.any(String),
},
owner: {
...mockOwnerData,
Expand Down

0 comments on commit d8f9006

Please sign in to comment.