Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { createHash } from 'node:crypto'
import { readFileSync } from 'node:fs'
import type { Campaign, DepositRow, Site, User, Withdrawal } from './db.js'
import { pitFooter } from './pit-footer.js'
import { RING_PLACEHOLDER } from './ring.js'
import { ringFooter } from './ring-footer.js'
import type { PublicEndpoint } from '@profullstack/webhooks'
Expand Down Expand Up @@ -77,7 +76,6 @@ ${RING_PLACEHOLDER}
${o.body}
</main>
${ringFooter()}
${pitFooter()}
</body>
</html>`
}
Expand Down
39 changes: 0 additions & 39 deletions src/pit-footer.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { CoinPay } from '@profullstack/coinpay-onboard'
import { Sealer, Store, type Campaign, type DepositRow, type Site, type User } from './db.js'
import { adPage, advertisePage, depositPage, helpPage, homePage, installScript, inviteLandingPage, invitesPage, mePage, messagePage, pitchPage, publishPage, sitePage, SITE, type Ctx } from './html.js'
import { ACCEPT_MESSAGES, Rewards, type RewardsConfig } from './rewards.js'
import { startPitFooterRefresh } from './pit-footer.js'
import { RING_PLACEHOLDER, ringBar, startRingRefresh } from './ring.js'
import { ringDescriptor, ringFooterScriptHashes, startRingFooterRefresh } from './ring-footer.js'
import { AdNetwork, newApiKey, UserError, type Config } from './service.js'
Expand Down Expand Up @@ -709,7 +708,6 @@ export function serve(options: { port?: number; hostname?: string } = {}) {
})
const trustProxy = (env.ADNETWORK_TRUST_PROXY ?? '1') === '1'
startRingRefresh()
startPitFooterRefresh('ad.network.pit.world')
startRingFooterRefresh()
net.startSweep()
net.hooks.start()
Expand Down
24 changes: 6 additions & 18 deletions test/pit-footer.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { expect, it } from 'bun:test'
import { pitFooter, setPitFooter, startPitFooterRefresh } from "../src/pit-footer.ts"
import { homePage } from "../src/html.ts"
import { homePage } from '../src/html.ts'

it('pit.world footer: nothing until read, then the last thing in <body>, kept on failure', async () => {
expect(setPitFooter('<p>not the footer</p>')).toBe(false)
expect(pitFooter()).toBe('')
const frag = '<style>.pit-foot{}</style><nav class="pit-foot" data-pit-footer>x</nav>'
const stop = startPitFooterRefresh('ad.network', (async (url: string) => {
expect(url).toBe('https://pit.world/snippets/footer.html?site=ad.network')
return new Response(frag)
}) as unknown as typeof fetch)
await new Promise((r) => setTimeout(r, 10))
stop()
it('the universal footer is the only footer on ad.network pages', () => {
const html = homePage({ user: null, csrf: 'x' })
expect(html.match(/data-pit-footer/g)?.length).toBe(1)
expect(html).toMatch(/<\/footer>[\s\S]*data-pit-footer[\s\S]*<\/nav>\s*<\/body>/)
const stop2 = startPitFooterRefresh('ad.network', (async () => { throw new Error('down') }) as unknown as typeof fetch)
await new Promise((r) => setTimeout(r, 10))
stop2()
expect(pitFooter()).toContain('data-pit-footer')
expect(html.match(/<footer/g)?.length).toBe(1)
expect(html).toContain('class="pfs-footer"')
expect(html).not.toContain('data-pit-footer')
expect(html).toMatch(/class="pfs-footer"[\s\S]*<\/footer>\s*<\/body>/)
})
5 changes: 3 additions & 2 deletions test/ring-footer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { expect, it } from 'bun:test'
import { homePage } from '../src/html.ts'
import { ringDescriptor } from '../src/ring-footer.ts'

it('Profullstack ring footer: server-rendered, one footer, before the pit.world footer', () => {
it('Profullstack ring footer: server-rendered as the only footer', () => {
const html = homePage({ user: null, origin: 'https://ad.network.pit.world', csrf: 'x' } as any)
const from = encodeURIComponent('https://ad.network.pit.world/')
expect(html).toContain(`https://rssamplifier.com/ring/profullstack/previous?from=${from}`)
expect(html).toContain(`https://rssamplifier.com/ring/profullstack/next?from=${from}`)
expect(html.match(/<footer/g)?.length).toBe(1)
expect(html).toMatch(/class="pfs-footer"[\s\S]*<\/footer>\s*(<style|<nav class="pit-foot"|<\/body>)/)
expect(html).toMatch(/class="pfs-footer"[\s\S]*<\/footer>\s*<\/body>/)
expect(html).not.toContain('data-pit-footer')
})

it('openwebring descriptor names the ring', () => {
Expand Down
Loading