Skip to content

Commit

Permalink
add support for local logos; remove remote logos
Browse files Browse the repository at this point in the history
  • Loading branch information
mm-vasyl committed Sep 12, 2024
1 parent 8d50f64 commit 7120d13
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/preview/dist/js/index_bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/preview/src/components/Previews.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ export default function Previews({ data }) {
<Box className="logos" display="flex" gap="0px" alignItems="center">
<img src="Monks-Logo_Small_White.png" />
{
(pageAds.length > 0 && pageAds[0].client) &&
data.client &&
<Box display="flex" gap="10px" alignItems="center" sx={{marginRight: "10px"}}>
<span>&times;</span>
<img src={pageAds[0].client} />
<img src={data.client} />
</Box>
}
</Box>
Expand Down
13 changes: 13 additions & 0 deletions src/webpack/buildPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ module.exports = async function buildPreview(result, qualities, outputDir) {
))
.filter(ad => ad != undefined)

const client = result[Object.keys(result)[0]]?.settings.data.settings.client

const adsList = {
timestamp: Date.now(),
client: client
? `client.${client.split('.').at(-1)}`
: undefined,
ads: allAds
};

Expand All @@ -136,6 +141,14 @@ module.exports = async function buildPreview(result, qualities, outputDir) {
await fs.copy(path.join(__dirname, `../preview/dist`), outputDir, {
overwrite: true,
});

// copy client logo
if (client) {
console.log("copying client logo...");
await fs.copy(client, path.join(outputDir, `client.${client.split('.').at(-1)}`), {
overwrite: true,
});
}

// write the result to ads.json in the preview dir
console.log(`creating ${outputDir}/data/ads.json`)
Expand Down
9 changes: 8 additions & 1 deletion src/webpack/devServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ ${chalk.grey.bold('-------------------------------------------------------')}

openLocation && open(`${httpLocation}?gsdevtools=true`);

const client = configs[0].settings.data.settings.client
if (client) {
app.get(`/client.${client.split('.').at(-1)}`, (req, res) => {
res.sendFile(configs[0].settings.data.settings.client)
})
}

app.get('/data/ads.json', (req, res) => {
res.json({
isGoogleSpreadsheetBanner: typeof configs[0].settings.data.settings.contentSource !== 'undefined',
client: client ? `client.${client.split('.').at(-1)}` : undefined,
ads: settingsList.map(e => {
const assetName = getNameFromLocation(e.location)
const bundleName = e.data.settings.bundleName || getNameFromLocation(e.location)
Expand All @@ -101,7 +109,6 @@ ${chalk.grey.bold('-------------------------------------------------------')}
},
},
info: e.data.settings.info,
client: e.data.settings.client,
}
})
})
Expand Down
9 changes: 8 additions & 1 deletion src/webpack/devServerParallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ ${chalk.grey.bold('-------------------------------------------------------')}

openLocation && open(httpLocation);

const client = configs[0].settings.data.settings.client
if (client) {
app.get(`/client.${client.split('.').at(-1)}`, (req, res) => {
res.sendFile(configs[0].settings.data.settings.client)
})
}

app.get('/data/ads.json', (req, res) => {
res.json({
isGoogleSpreadsheetBanner: typeof configs[0].settings.data.settings.contentSource !== 'undefined',
client: client ? `client.${client.split('.').at(-1)}` : undefined,
ads: settingsList.map(e => {
const assetName = getNameFromLocation(e.location)
const bundleName = e.data.settings.bundleName || getNameFromLocation(e.location)
Expand All @@ -115,7 +123,6 @@ ${chalk.grey.bold('-------------------------------------------------------')}
},
},
info: e.data.settings.info,
client: e.data.settings.client,
}
})
})
Expand Down

0 comments on commit 7120d13

Please sign in to comment.