Skip to content

Commit 968be4f

Browse files
committed
Add Banners
1 parent 368fc0f commit 968be4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+24896
-1190
lines changed

.vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"datatables",
1818
"Disqus",
1919
"DOCSEARCH",
20+
"dompurify",
2021
"dropoverlay",
2122
"easymde",
2223
"favicons",
@@ -31,6 +32,7 @@
3132
"Luxon",
3233
"Navbars",
3334
"navigations",
35+
"nodenext",
3436
"nouislider",
3537
"offcanvas",
3638
"outdir",

build/build-partials.ts

-20
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,6 @@ const init = async () => {
8787
replacementContentIsFile: false
8888
});
8989

90-
// Delete TopAlertBanner.html
91-
await fs.rm(path.join(destinationHbs, 'TopAlertBanner.html'));
92-
await fs.rm(path.join(destinationAstro, 'TopAlertBanner.html'));
93-
94-
// cshtml files
95-
await updateContent({
96-
destination: destinationCshtml,
97-
targetFile: 'TopAlertBanner.html',
98-
targetFileDestination: destinationCshtml,
99-
targetFileContentToReplace: 'topNoticeText = ""',
100-
replaceWithContent: 'AlertText.html',
101-
replacementContentIsFile: true,
102-
replacementTemplate: 'topNoticeText = "{0}"'
103-
});
104-
105-
// Delete AlertText.html
106-
await fs.rm(path.join(destinationHbs, 'AlertText.html'));
107-
await fs.rm(path.join(destinationCshtml, 'AlertText.html'));
108-
await fs.rm(path.join(destinationAstro, 'AlertText.html'));
109-
11090
// Update file extensions and casing of names
11191
const filesHbs = await fs.readdir(destinationHbs);
11292
const filesCshtml = await fs.readdir(destinationCshtml);

build/build-portal.ts build/build-repository.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
#!/usr/bin/env ts-node
22

33
/*!
4-
* Script to build additional assets for portal.
4+
* Script to build additional assets for a repository.
55
* Copyright 2020-2024 Chocolatey Software
66
* Licensed under Apache License (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
77
*/
88

99
import * as esbuild from 'esbuild';
1010
import { purgeCss } from './functions/purge-css';
11-
import { repositoryConfig } from './data/repository-config';
11+
import { repository } from './functions/determine-repository';
1212

1313
const init = async () => {
14-
console.log('🚀 Compiling and minifying Portal JS...');
15-
const repository = repositoryConfig.portal;
14+
console.log('🚀 Compiling and minifying repository JS...');
1615

1716
await esbuild.build({
18-
entryPoints: [`${repository.js}src/*.js`],
17+
entryPoints: [`${repository.js}src/banners/*.js`],
1918
target: 'es2015',
2019
bundle: true,
2120
outdir: repository.js,
2221
minify: true,
2322
outExtension: { '.js': '.min.js' }
2423
}).then(async () => {
25-
console.log('✅ Portal JS compiled and minified');
24+
console.log('✅ Repository JS compiled and minified');
2625

2726
// PurgeCSS
2827
await purgeCss({

build/choco-theme.ts

+6-21
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,12 @@
77
*/
88

99
import * as fs from 'fs/promises';
10-
import * as process from 'process';
10+
import { repository } from './functions/determine-repository';
1111
import { repositoryConfig } from './data/repository-config';
1212
import { purgeCss } from './functions/purge-css';
1313
import { updateContent } from './functions/update-content';
1414

15-
// Process args
16-
const params: Record<string, string> = {};
17-
process.argv.slice(2).forEach(val => {
18-
const [key, value] = val.split('=');
19-
20-
if (key.startsWith('--')) {
21-
params[key.slice(2)] = value;
22-
}
23-
});
24-
25-
// Determine repository information
26-
let repository = repositoryConfig.default;
27-
if (params.repository && repositoryConfig[params.repository]) {
28-
repository = repositoryConfig[params.repository];
29-
console.log('Using repository information:', repository);
30-
}
15+
console.log('Using repository information:', repository);
3116

3217
// Determine source CSS name
3318
let sourceCss: string;
@@ -67,7 +52,7 @@ const copyTheme = async ({
6752

6853
const init = async () => {
6954
try {
70-
const containsValidation = repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.community.name;
55+
const containsValidation = repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.community.name || repository.name === repositoryConfig.hub.name;
7156

7257
// Define arrays for parallel tasks
7358
const parallelTasksInitial = [
@@ -200,7 +185,7 @@ const init = async () => {
200185
}
201186

202187
// ESLint and tsconfig - needed if repository contains it's own assets along with choco-theme
203-
if (repository.name === repositoryConfig.portal.name) {
188+
if (repository.playwright || repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.hub.name) {
204189
parallelTasksInitial.push(
205190
{
206191
task: '.eslintrc.js',
@@ -254,7 +239,7 @@ const init = async () => {
254239

255240
// Change CSS content
256241
// Font Awesome
257-
if (repository.name === repositoryConfig.portal.name || repository.language === 'astro') {
242+
if (repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.hub.name || repository.language === 'astro') {
258243
console.log('🚀 Updating Font Awesome font path...');
259244
await updateContent({
260245
destination: repository.css,
@@ -294,7 +279,7 @@ const init = async () => {
294279
}
295280

296281
// PurgeCSS
297-
if (repository.name !== repositoryConfig.portal.name) {
282+
if (repository.name !== repositoryConfig.portal.name && repository.name !== repositoryConfig.hub.name) {
298283
await purgeCss({
299284
source: `${repository.css}${repository.name}.min.css`,
300285
repository: repository

build/data/preview-config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ export const folderMapping: FolderMapping = {
5555
isStatiq: true,
5656
isAstro: false
5757
},
58+
'--hub': {
59+
folder: 'admin-portal',
60+
protocol: 'https',
61+
port: 44362,
62+
isStatiq: false,
63+
isAstro: false,
64+
root: '/source/AdminPortal'
65+
},
5866
'--org': {
5967
folder: 'chocolatey.org',
6068
port: 5081,

build/data/repository-config.ts

+28
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const defaultRepositoryConfig = {
4545
'::-webkit-scrollbar-thumb',
4646
/^fa-(check|triangle-exclamation|info|xmark)/,
4747
/^text-bg-(info|warning|danger|success)/,
48+
/^text-bg-(blue|pink|purple|green|red|yellow|orange)/,
49+
/^alert-(blue|pink|purple|green|red|yellow|orange)/,
4850
/^data-bs-popper/
4951
]
5052
},
@@ -119,6 +121,16 @@ export const repositoryConfig: Record<string, RepositoryConfig> = {
119121
...defaultRepositoryConfig,
120122
name: 'fest'
121123
},
124+
hub: {
125+
...defaultRepositoryConfig,
126+
name: 'hub',
127+
favicons: 'wwwroot/',
128+
css: 'wwwroot/css/',
129+
js: 'wwwroot/js/',
130+
fontAwesome: 'wwwroot/fonts/fontawesome-free/',
131+
images: 'wwwroot/images/global-shared/',
132+
partials: 'Pages/Global/'
133+
},
122134
org: {
123135
...defaultRepositoryConfig,
124136
name: 'org',
@@ -186,6 +198,22 @@ repositoryConfig.community.purgeCss = {
186198
]
187199
};
188200

201+
// Merge purgeCss section into the hub configuration
202+
repositoryConfig.hub.purgeCss = {
203+
content: [
204+
`${repositoryConfig.hub.js}*.js`,
205+
'Areas/**/*.cshtml',
206+
'Pages/**/*.cshtml'
207+
],
208+
safelist: [
209+
...defaultRepositoryConfig.purgeCss.safelist,
210+
/^bg-(secondary|danger|success)/,
211+
/^callout-(danger|success)/,
212+
/^form-check-input-(blue|pink|purple|green|red|yellow|orange)/,
213+
/^spinner-grow/
214+
]
215+
};
216+
189217
// Merge purgeCss section into the org configuration
190218
repositoryConfig.org.purgeCss = {
191219
content: [
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env ts-node
2+
3+
/*!
4+
* Determines the repository to use based on the provided parameters.
5+
* Copyright 2020-2024 Chocolatey Software
6+
* Licensed under Apache License (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
7+
*/
8+
9+
import * as process from 'process';
10+
import { repositoryConfig } from '../data/repository-config';
11+
12+
// Process args
13+
const params: Record<string, string> = {};
14+
process.argv.slice(2).forEach(val => {
15+
const [key, value] = val.split('=');
16+
17+
if (key.startsWith('--')) {
18+
params[key.slice(2)] = value;
19+
}
20+
});
21+
22+
// Determine repository information
23+
let repository = repositoryConfig.default;
24+
if (params.repository && repositoryConfig[params.repository]) {
25+
repository = repositoryConfig[params.repository];
26+
}
27+
28+
export { repository };

0 commit comments

Comments
 (0)