diff --git a/package-lock.json b/package-lock.json index 78d3a05bb..e85917956 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "date-fns": "~3.6.0", "highcharts-react-official": "~3.2.1", "react-bootstrap": "~2.10.5", - "react-select": "~5.8.2", + "react-select": "~5.8.3", "redux": "~5.0.1", "redux-logger": "~3.0.6", "schema-dts": "^1.1.2", @@ -51,10 +51,10 @@ "@enonic-types/lib-task": "7.14.1", "@enonic-types/lib-value": "7.14.0", "@enonic-types/lib-websocket": "7.14.1", - "@enonic/react-components": "5.0.0", + "@enonic/react-components": "5.0.1", "@enonic/react4xp": "5.0.4", "@enonic/tsup-plugin-manifest": "^0.0.1", - "@eslint/compat": "^1.2.2", + "@eslint/compat": "^1.2.3", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "^9.15.0", "@item-enonic-types/global": "~7.13.1", @@ -76,7 +76,7 @@ "@types/validator": "~13.12.2", "@types/zipcelx": "~1.5.2", "autoprefixer": "~10.4.16", - "axios": "~1.6.0", + "axios": "^1.7.7", "babel-loader": "~9.2.1", "babel-preset-env": "~1.7.0", "browser-sync": "^3.0.3", @@ -95,7 +95,7 @@ "file-loader": "~6.2.0", "glob": "~10.4.1", "highcharts": "~10.3.3", - "husky": "^9.1.6", + "husky": "^9.1.7", "imagesloaded": "~5.0.0", "jest": "~29.7.0", "jquery": "~3.7.1", @@ -108,7 +108,7 @@ "npm-run-all": "~4.1.5", "npm-safe-install": "~1.1.0", "numeral": "~2.0.6", - "postcss": "~8.4.47", + "postcss": "~8.4.49", "postcss-loader": "~8.1.1", "postcss-normalize": "~10.0.1", "prettier": "~3.3.3", @@ -2344,9 +2344,9 @@ "dev": true }, "node_modules/@enonic/react-components": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@enonic/react-components/-/react-components-5.0.0.tgz", - "integrity": "sha512-xZJjVA0RkYmowmSfUokirF7hWeq7TDBOPy/1iocTKRXzr2vxoS9EZRpNdX+lV969Wp39hue1FKED56V1fk7DVQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@enonic/react-components/-/react-components-5.0.1.tgz", + "integrity": "sha512-K4sj3Ui/XSdv3pJnsMbWzm1MIvTQnm0MNCW5NFExTWYC0JkP2EVccNpH/xV1C3rBXyBZcBbSMPy2O+1RKVQtfA==", "dev": true, "dependencies": { "domelementtype": "^2.3.0", @@ -3870,9 +3870,9 @@ } }, "node_modules/@eslint/compat": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.2.tgz", - "integrity": "sha512-jhgiIrsw+tRfcBQ4BFl2C3vCrIUw2trCY0cnDvGZpwTtKCEDmZhAtMfrEUP/KpnwM6PrO0T+Ltm+ccW74olG3Q==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.3.tgz", + "integrity": "sha512-wlZhwlDFxkxIZ571aH0FoK4h4Vwx7P3HJx62Gp8hTc10bfpwT2x0nULuAHmQSJBOWPgPeVf+9YtnD4j50zVHmA==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -7448,12 +7448,12 @@ } }, "node_modules/axios": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.0.tgz", - "integrity": "sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dev": true, "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -12438,9 +12438,9 @@ } }, "node_modules/husky": { - "version": "9.1.6", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.6.tgz", - "integrity": "sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A==", + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", "dev": true, "bin": { "husky": "bin.js" @@ -16809,9 +16809,9 @@ } }, "node_modules/postcss": { - "version": "8.4.47", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", - "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", + "version": "8.4.49", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz", + "integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==", "dev": true, "funding": [ { @@ -16829,7 +16829,7 @@ ], "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.1.0", + "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, "engines": { @@ -17863,9 +17863,9 @@ } }, "node_modules/react-select": { - "version": "5.8.2", - "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.2.tgz", - "integrity": "sha512-a/LkOckoI62710gGPQSQqUp7A10fGbH/ya3/IR49qaq3XoBvwymgD5mJgtiHxBDsutyEQfdKNycWVh8Cg8UCjw==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.3.tgz", + "integrity": "sha512-lVswnIq8/iTj1db7XCG74M/3fbGB6ZaluCzvwPGT5ZOjCdL/k0CLWhEK0vCBLuU5bHTEf6Gj8jtSvi+3v+tO1w==", "dependencies": { "@babel/runtime": "^7.12.0", "@emotion/cache": "^11.4.0", @@ -23573,9 +23573,9 @@ "dev": true }, "@enonic/react-components": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@enonic/react-components/-/react-components-5.0.0.tgz", - "integrity": "sha512-xZJjVA0RkYmowmSfUokirF7hWeq7TDBOPy/1iocTKRXzr2vxoS9EZRpNdX+lV969Wp39hue1FKED56V1fk7DVQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@enonic/react-components/-/react-components-5.0.1.tgz", + "integrity": "sha512-K4sj3Ui/XSdv3pJnsMbWzm1MIvTQnm0MNCW5NFExTWYC0JkP2EVccNpH/xV1C3rBXyBZcBbSMPy2O+1RKVQtfA==", "dev": true, "requires": { "domelementtype": "^2.3.0", @@ -24365,9 +24365,9 @@ "dev": true }, "@eslint/compat": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.2.tgz", - "integrity": "sha512-jhgiIrsw+tRfcBQ4BFl2C3vCrIUw2trCY0cnDvGZpwTtKCEDmZhAtMfrEUP/KpnwM6PrO0T+Ltm+ccW74olG3Q==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.3.tgz", + "integrity": "sha512-wlZhwlDFxkxIZ571aH0FoK4h4Vwx7P3HJx62Gp8hTc10bfpwT2x0nULuAHmQSJBOWPgPeVf+9YtnD4j50zVHmA==", "dev": true, "requires": {} }, @@ -26925,12 +26925,12 @@ } }, "axios": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.0.tgz", - "integrity": "sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dev": true, "requires": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -30726,9 +30726,9 @@ } }, "husky": { - "version": "9.1.6", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.6.tgz", - "integrity": "sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A==", + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", "dev": true }, "hyphenate-style-name": { @@ -33965,13 +33965,13 @@ "dev": true }, "postcss": { - "version": "8.4.47", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", - "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", + "version": "8.4.49", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz", + "integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==", "dev": true, "requires": { "nanoid": "^3.3.7", - "picocolors": "^1.1.0", + "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, @@ -34657,9 +34657,9 @@ } }, "react-select": { - "version": "5.8.2", - "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.2.tgz", - "integrity": "sha512-a/LkOckoI62710gGPQSQqUp7A10fGbH/ya3/IR49qaq3XoBvwymgD5mJgtiHxBDsutyEQfdKNycWVh8Cg8UCjw==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.3.tgz", + "integrity": "sha512-lVswnIq8/iTj1db7XCG74M/3fbGB6ZaluCzvwPGT5ZOjCdL/k0CLWhEK0vCBLuU5bHTEf6Gj8jtSvi+3v+tO1w==", "requires": { "@babel/runtime": "^7.12.0", "@emotion/cache": "^11.4.0", diff --git a/package.json b/package.json index dcb33865e..3358b3979 100644 --- a/package.json +++ b/package.json @@ -62,10 +62,10 @@ "@enonic-types/lib-task": "7.14.1", "@enonic-types/lib-value": "7.14.0", "@enonic-types/lib-websocket": "7.14.1", - "@enonic/react-components": "5.0.0", + "@enonic/react-components": "5.0.1", "@enonic/react4xp": "5.0.4", "@enonic/tsup-plugin-manifest": "^0.0.1", - "@eslint/compat": "^1.2.2", + "@eslint/compat": "^1.2.3", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "^9.15.0", "@item-enonic-types/global": "~7.13.1", @@ -87,7 +87,7 @@ "@types/validator": "~13.12.2", "@types/zipcelx": "~1.5.2", "autoprefixer": "~10.4.16", - "axios": "~1.6.0", + "axios": "^1.7.7", "babel-loader": "~9.2.1", "babel-preset-env": "~1.7.0", "browser-sync": "^3.0.3", @@ -106,7 +106,7 @@ "file-loader": "~6.2.0", "glob": "~10.4.1", "highcharts": "~10.3.3", - "husky": "^9.1.6", + "husky": "^9.1.7", "imagesloaded": "~5.0.0", "jest": "~29.7.0", "jquery": "~3.7.1", @@ -119,7 +119,7 @@ "npm-run-all": "~4.1.5", "npm-safe-install": "~1.1.0", "numeral": "~2.0.6", - "postcss": "~8.4.47", + "postcss": "~8.4.49", "postcss-loader": "~8.1.1", "postcss-normalize": "~10.0.1", "prettier": "~3.3.3", @@ -168,7 +168,7 @@ "date-fns": "~3.6.0", "highcharts-react-official": "~3.2.1", "react-bootstrap": "~2.10.5", - "react-select": "~5.8.2", + "react-select": "~5.8.3", "redux": "~5.0.1", "redux-logger": "~3.0.6", "schema-dts": "^1.1.2", diff --git a/src/main/resources/assets/styles/_print.scss b/src/main/resources/assets/styles/_print.scss index 85f4e10c3..d1719df22 100644 --- a/src/main/resources/assets/styles/_print.scss +++ b/src/main/resources/assets/styles/_print.scss @@ -1,6 +1,6 @@ @media print { @page { - margin-top: 2rem !important; + margin-top: 3rem !important; } body { diff --git a/src/main/resources/lib/ssb/rss/news.ts b/src/main/resources/lib/ssb/rss/news.ts index 05a77646c..f221cb130 100644 --- a/src/main/resources/lib/ssb/rss/news.ts +++ b/src/main/resources/lib/ssb/rss/news.ts @@ -15,15 +15,12 @@ const dummyReq: Partial = { } export function getRssItemsNews(): string | null { - const mainSubjects: SubjectItem[] = getMainSubjects(dummyReq as XP.Request) - const articles: Array = getArticles(mainSubjects) - const statistics: Array = getStatistics(mainSubjects) - const news: Array = articles.concat(statistics) + const news: NewsItem[] = getNews() const xml = ` ${news .map( - (n: News) => ` + (n: NewsItem) => ` ${n.guid} ${xmlEscape(n.title)} ${n.link} @@ -40,13 +37,20 @@ export function getRssItemsNews(): string | null { return xml } -function getArticles(mainSubjects: SubjectItem[]): Array { +export function getNews(): NewsItem[] { + const mainSubjects: SubjectItem[] = getMainSubjects(dummyReq as XP.Request) + const articles: NewsItem[] = getArticles(mainSubjects) + const statistics: NewsItem[] = getStatistics(mainSubjects) + return articles.concat(statistics) +} + +function getArticles(mainSubjects: SubjectItem[]): NewsItem[] { const from: string = subDays(new Date(), 1).toISOString() const to: string = new Date().toISOString() const serverOffsetInMilliSeconds: number = parseInt(app.config?.['serverOffsetInMs']) || 0 const timeZoneIso: string = getTimeZoneIso(serverOffsetInMilliSeconds) - const news: Array = [] + const news: Array = [] mainSubjects.forEach((mainSubject) => { const articles: Array> = query({ start: 0, @@ -89,12 +93,12 @@ function getArticles(mainSubjects: SubjectItem[]): Array { return news } -function getStatistics(mainSubjects: SubjectItem[]): Array { +function getStatistics(mainSubjects: SubjectItem[]): NewsItem[] { const statregStatistics: Array = fetchStatisticsWithReleaseToday() const serverOffsetInMS: number = parseInt(app.config?.['serverOffsetInMs']) || 0 const timeZoneIso: string = getTimeZoneIso(serverOffsetInMS) - const statisticsNews: Array = [] + const statisticsNews: NewsItem[] = [] if (statregStatistics.length > 0) { mainSubjects.forEach((mainSubject) => { const statistics: Array> = query({ @@ -163,7 +167,7 @@ function getLinkByPath(path: string) { return baseUrl + path.substring(site.length) } -interface News { +interface NewsItem { guid: string // _id title: string // displayName link: string // url diff --git a/src/main/resources/lib/ssb/rss/statkal.ts b/src/main/resources/lib/ssb/rss/statkal.ts index 670ff2213..52d1409b7 100644 --- a/src/main/resources/lib/ssb/rss/statkal.ts +++ b/src/main/resources/lib/ssb/rss/statkal.ts @@ -20,11 +20,7 @@ const dummyReq: Partial = { } export function getRssItemsStatkal(): string | null { - const statisticVariants: ContentLight[] = getUpcompingStatisticVariantsFromRepo() - const allMainSubjects: SubjectItem[] = getMainSubjects(dummyReq as XP.Request) - const upcomingVariants: StatkalVariant[] = getUpcomingVariants(statisticVariants, allMainSubjects) - const upcomingReleases: StatkalRelease[] = getUpcomingReleases(statisticVariants) - const rssReleases: RssRelease[] = getRssReleases(upcomingVariants, upcomingReleases) + const rssReleases: RssRelease[] = getRssReleasesStatkal() const xml = rssReleases ? ` @@ -58,6 +54,14 @@ export function getRssItemsStatkal(): string | null { return xml } +export function getRssReleasesStatkal(): RssRelease[] { + const statisticVariants: ContentLight[] = getUpcompingStatisticVariantsFromRepo() + const allMainSubjects: SubjectItem[] = getMainSubjects(dummyReq as XP.Request) + const upcomingVariants: StatkalVariant[] = getUpcomingVariants(statisticVariants, allMainSubjects) + const upcomingReleases: StatkalRelease[] = getUpcomingReleases(statisticVariants) + return getRssReleases(upcomingVariants, upcomingReleases) +} + function getUpcomingVariants( statisticVariants: ContentLight[], allMainSubjects: SubjectItem[] diff --git a/src/main/resources/services/rssNews/rssNews.ts b/src/main/resources/services/rssNews/rssNews.ts new file mode 100644 index 000000000..91498ed99 --- /dev/null +++ b/src/main/resources/services/rssNews/rssNews.ts @@ -0,0 +1,10 @@ +import { getNews, getRssItemsNews } from '/lib/ssb/rss/news' + +export function get(req: XP.Request): XP.Response { + const format: string = req.params.format ?? 'json' + const isXml = format === 'xml' + return { + body: isXml ? getRssItemsNews() : getNews(), + contentType: isXml ? 'text/xml' : 'application/json', + } +} diff --git a/src/main/resources/services/rssNews/rssNews.xml b/src/main/resources/services/rssNews/rssNews.xml new file mode 100644 index 000000000..d18703052 --- /dev/null +++ b/src/main/resources/services/rssNews/rssNews.xml @@ -0,0 +1,5 @@ + + + role:system.everyone + + diff --git a/src/main/resources/services/rssStatkal/rssStatkal.ts b/src/main/resources/services/rssStatkal/rssStatkal.ts new file mode 100644 index 000000000..1c8c01fc4 --- /dev/null +++ b/src/main/resources/services/rssStatkal/rssStatkal.ts @@ -0,0 +1,10 @@ +import { getRssReleasesStatkal, getRssItemsStatkal } from '/lib/ssb/rss/statkal' + +export function get(req: XP.Request): XP.Response { + const format: string = req.params.format ?? 'json' + const isXml = format === 'xml' + return { + body: isXml ? getRssItemsStatkal() : getRssReleasesStatkal(), + contentType: isXml ? 'text/xml' : 'application/json', + } +} diff --git a/src/main/resources/services/rssStatkal/rssStatkal.xml b/src/main/resources/services/rssStatkal/rssStatkal.xml new file mode 100644 index 000000000..d18703052 --- /dev/null +++ b/src/main/resources/services/rssStatkal/rssStatkal.xml @@ -0,0 +1,5 @@ + + + role:system.everyone + +