-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored boot time / on demand asset generation to occur at build time
refs [ONC-662](https://linear.app/ghost/issue/ONC-662/fix-file-write-issues-in-ghost-application-related-to-asset-generation) Refactored the generation of the following assets: - `comment-counts.js` - `member-attribution.js` - `admin-auth` To occur at build time instead of at boot time or on demand `cards` are still built on demand as these assets need to be re-generated when a theme changes - we utilise the existing asset minification system for this, except we only execute the middleware responsible for this when a request is requesting a card asset This also reverts the changes made in [#21857](#21857) as these changes are no longer needed (because the assets are now generated at build time)
- Loading branch information
Showing
18 changed files
with
89 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
68 changes: 0 additions & 68 deletions
68
ghost/core/core/frontend/services/assets-minification/AdminAuthAssets.js
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
ghost/core/core/frontend/services/assets-minification/CommentCountsAssets.js
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
ghost/core/core/frontend/services/assets-minification/MemberAttributionAssets.js
This file was deleted.
Oops, something went wrong.
13 changes: 2 additions & 11 deletions
13
ghost/core/core/frontend/services/assets-minification/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
const AdminAuthAssets = require('./AdminAuthAssets'); | ||
const CardAssets = require('./CardAssets'); | ||
const CommentCountsAssets = require('./CommentCountsAssets'); | ||
const MemberAttributionAssets = require('./MemberAttributionAssets'); | ||
|
||
const adminAuthAssets = new AdminAuthAssets(); | ||
const cardAssets = new CardAssets(); | ||
const commentCountsAssets = new CommentCountsAssets(); | ||
const memberAttributionAssets = new MemberAttributionAssets(); | ||
|
||
module.exports = { | ||
adminAuthAssets, | ||
cardAssets, | ||
commentCountsAssets, | ||
memberAttributionAssets | ||
}; | ||
cardAssets | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
ghost/core/core/server/web/admin/middleware/serve-admin-auth-frame-file.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const path = require('node:path'); | ||
const fs = require('node:fs/promises'); | ||
|
||
function createServeAuthFrameFileMw(config, urlUtils) { | ||
const placeholders = { | ||
'{{SITE_ORIGIN}}': new URL(urlUtils.getSiteUrl()).origin | ||
}; | ||
|
||
return function serveAuthFrameFileMw(req, res, next) { | ||
const filename = path.parse(req.url).base; | ||
let basePath = path.join(config.get('paths').publicFilePath, 'admin-auth'); | ||
let filePath; | ||
|
||
if (filename === '') { | ||
filePath = path.join(basePath, 'index.html'); | ||
} else { | ||
filePath = path.join(basePath, filename); | ||
} | ||
|
||
fs.readFile(filePath).then((data) => { | ||
let dataString = data.toString(); | ||
|
||
for (const [key, value] of Object.entries(placeholders)) { | ||
dataString = dataString.replace(key, value); | ||
} | ||
|
||
res.end(dataString); | ||
}).catch((err) => { | ||
next(err); // TODO | ||
}); | ||
}; | ||
} | ||
|
||
module.exports = createServeAuthFrameFileMw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.