Show numeric values in card preview
This commit is contained in:
parent
d90901b4e3
commit
97e3de4e0f
|
@ -16,6 +16,7 @@ export function parseRequest(req: IncomingMessage) {
|
||||||
// Attributes for Manifold card:
|
// Attributes for Manifold card:
|
||||||
question,
|
question,
|
||||||
probability,
|
probability,
|
||||||
|
numericValue,
|
||||||
metadata,
|
metadata,
|
||||||
creatorName,
|
creatorName,
|
||||||
creatorUsername,
|
creatorUsername,
|
||||||
|
@ -71,6 +72,7 @@ export function parseRequest(req: IncomingMessage) {
|
||||||
question:
|
question:
|
||||||
getString(question) || 'Will you create a prediction market on Manifold?',
|
getString(question) || 'Will you create a prediction market on Manifold?',
|
||||||
probability: getString(probability),
|
probability: getString(probability),
|
||||||
|
numericValue: getString(numericValue) || '',
|
||||||
metadata: getString(metadata) || 'Jan 1 • M$ 123 pool',
|
metadata: getString(metadata) || 'Jan 1 • M$ 123 pool',
|
||||||
creatorName: getString(creatorName) || 'Manifold Markets',
|
creatorName: getString(creatorName) || 'Manifold Markets',
|
||||||
creatorUsername: getString(creatorUsername) || 'ManifoldMarkets',
|
creatorUsername: getString(creatorUsername) || 'ManifoldMarkets',
|
||||||
|
|
|
@ -91,6 +91,7 @@ export function getHtml(parsedReq: ParsedRequest) {
|
||||||
creatorName,
|
creatorName,
|
||||||
creatorUsername,
|
creatorUsername,
|
||||||
creatorAvatarUrl,
|
creatorAvatarUrl,
|
||||||
|
numericValue,
|
||||||
} = parsedReq
|
} = parsedReq
|
||||||
const MAX_QUESTION_CHARS = 100
|
const MAX_QUESTION_CHARS = 100
|
||||||
const truncatedQuestion =
|
const truncatedQuestion =
|
||||||
|
@ -147,8 +148,14 @@ export function getHtml(parsedReq: ParsedRequest) {
|
||||||
<div class="text-indigo-700 text-6xl leading-tight">
|
<div class="text-indigo-700 text-6xl leading-tight">
|
||||||
${truncatedQuestion}
|
${truncatedQuestion}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col text-primary">
|
<div class="flex flex-col text-primary text-center">
|
||||||
<div class="text-8xl">${probability}</div>
|
<div class="text-8xl">${probability}</div>
|
||||||
|
<span class='text-blue-400'>
|
||||||
|
<div class="text-8xl ">${
|
||||||
|
numericValue !== '' && probability === '' ? numericValue : ''
|
||||||
|
}</div>
|
||||||
|
<div class="text-4xl">${numericValue !== '' ? 'expected' : ''}</div>
|
||||||
|
</span>
|
||||||
<div class="text-4xl">${probability !== '' ? 'chance' : ''}</div>
|
<div class="text-4xl">${probability !== '' ? 'chance' : ''}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,6 +14,7 @@ export interface ParsedRequest {
|
||||||
// Attributes for Manifold card:
|
// Attributes for Manifold card:
|
||||||
question: string
|
question: string
|
||||||
probability: string
|
probability: string
|
||||||
|
numericValue: string
|
||||||
metadata: string
|
metadata: string
|
||||||
creatorName: string
|
creatorName: string
|
||||||
creatorUsername: string
|
creatorUsername: string
|
||||||
|
|
|
@ -9,6 +9,7 @@ export type OgCardProps = {
|
||||||
creatorName: string
|
creatorName: string
|
||||||
creatorUsername: string
|
creatorUsername: string
|
||||||
creatorAvatarUrl?: string
|
creatorAvatarUrl?: string
|
||||||
|
numericValue?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildCardUrl(props: OgCardProps, challenge?: Challenge) {
|
function buildCardUrl(props: OgCardProps, challenge?: Challenge) {
|
||||||
|
@ -25,6 +26,12 @@ function buildCardUrl(props: OgCardProps, challenge?: Challenge) {
|
||||||
props.probability === undefined
|
props.probability === undefined
|
||||||
? ''
|
? ''
|
||||||
: `&probability=${encodeURIComponent(props.probability ?? '')}`
|
: `&probability=${encodeURIComponent(props.probability ?? '')}`
|
||||||
|
|
||||||
|
const numericValueParam =
|
||||||
|
props.numericValue === undefined
|
||||||
|
? ''
|
||||||
|
: `&numericValue=${encodeURIComponent(props.numericValue ?? '')}`
|
||||||
|
|
||||||
const creatorAvatarUrlParam =
|
const creatorAvatarUrlParam =
|
||||||
props.creatorAvatarUrl === undefined
|
props.creatorAvatarUrl === undefined
|
||||||
? ''
|
? ''
|
||||||
|
@ -41,6 +48,7 @@ function buildCardUrl(props: OgCardProps, challenge?: Challenge) {
|
||||||
`https://manifold-og-image.vercel.app/m.png` +
|
`https://manifold-og-image.vercel.app/m.png` +
|
||||||
`?question=${encodeURIComponent(props.question)}` +
|
`?question=${encodeURIComponent(props.question)}` +
|
||||||
probabilityParam +
|
probabilityParam +
|
||||||
|
numericValueParam +
|
||||||
`&metadata=${encodeURIComponent(props.metadata)}` +
|
`&metadata=${encodeURIComponent(props.metadata)}` +
|
||||||
`&creatorName=${encodeURIComponent(props.creatorName)}` +
|
`&creatorName=${encodeURIComponent(props.creatorName)}` +
|
||||||
creatorAvatarUrlParam +
|
creatorAvatarUrlParam +
|
||||||
|
|
|
@ -2,6 +2,8 @@ import { Contract } from 'common/contract'
|
||||||
import { getBinaryProbPercent } from 'web/lib/firebase/contracts'
|
import { getBinaryProbPercent } from 'web/lib/firebase/contracts'
|
||||||
import { richTextToString } from 'common/util/parse'
|
import { richTextToString } from 'common/util/parse'
|
||||||
import { contractTextDetails } from 'web/components/contract/contract-details'
|
import { contractTextDetails } from 'web/components/contract/contract-details'
|
||||||
|
import { getFormattedMappedValue } from 'common/pseudo-numeric'
|
||||||
|
import { getProbability } from 'common/calculate'
|
||||||
|
|
||||||
export const getOpenGraphProps = (contract: Contract) => {
|
export const getOpenGraphProps = (contract: Contract) => {
|
||||||
const {
|
const {
|
||||||
|
@ -16,6 +18,11 @@ export const getOpenGraphProps = (contract: Contract) => {
|
||||||
const probPercent =
|
const probPercent =
|
||||||
outcomeType === 'BINARY' ? getBinaryProbPercent(contract) : undefined
|
outcomeType === 'BINARY' ? getBinaryProbPercent(contract) : undefined
|
||||||
|
|
||||||
|
const numericValue =
|
||||||
|
outcomeType === 'PSEUDO_NUMERIC'
|
||||||
|
? getFormattedMappedValue(contract)(getProbability(contract))
|
||||||
|
: undefined
|
||||||
|
|
||||||
const stringDesc = typeof desc === 'string' ? desc : richTextToString(desc)
|
const stringDesc = typeof desc === 'string' ? desc : richTextToString(desc)
|
||||||
|
|
||||||
const description = resolution
|
const description = resolution
|
||||||
|
@ -32,5 +39,6 @@ export const getOpenGraphProps = (contract: Contract) => {
|
||||||
creatorUsername,
|
creatorUsername,
|
||||||
creatorAvatarUrl,
|
creatorAvatarUrl,
|
||||||
description,
|
description,
|
||||||
|
numericValue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user