Skip to content

Commit

Permalink
Merge branch 'develop' into MIM-2082-add-backticks-quotemarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenruben authored Nov 27, 2024
2 parents c1c56a1 + a9c995d commit 566fbb3
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 68 deletions.
92 changes: 46 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/styles/_print.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@media print {
@page {
margin-top: 2rem !important;
margin-top: 3rem !important;
}

body {
Expand Down
24 changes: 14 additions & 10 deletions src/main/resources/lib/ssb/rss/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ const dummyReq: Partial<XP.Request> = {
}

export function getRssItemsNews(): string | null {
const mainSubjects: SubjectItem[] = getMainSubjects(dummyReq as XP.Request)
const articles: Array<News> = getArticles(mainSubjects)
const statistics: Array<News> = getStatistics(mainSubjects)
const news: Array<News> = articles.concat(statistics)
const news: NewsItem[] = getNews()
const xml = `<?xml version="1.0" encoding="utf-8"?>
<rssitems count="${news.length}">
${news
.map(
(n: News) => `<rssitem>
(n: NewsItem) => `<rssitem>
<guid isPermalink="false">${n.guid}</guid>
<title>${xmlEscape(n.title)}</title>
<link>${n.link}</link>
Expand All @@ -40,13 +37,20 @@ export function getRssItemsNews(): string | null {
return xml
}

function getArticles(mainSubjects: SubjectItem[]): Array<News> {
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<News> = []
const news: Array<NewsItem> = []
mainSubjects.forEach((mainSubject) => {
const articles: Array<Content<Article>> = query({
start: 0,
Expand Down Expand Up @@ -89,12 +93,12 @@ function getArticles(mainSubjects: SubjectItem[]): Array<News> {
return news
}

function getStatistics(mainSubjects: SubjectItem[]): Array<News> {
function getStatistics(mainSubjects: SubjectItem[]): NewsItem[] {
const statregStatistics: Array<StatisticInListing> = fetchStatisticsWithReleaseToday()
const serverOffsetInMS: number = parseInt(app.config?.['serverOffsetInMs']) || 0
const timeZoneIso: string = getTimeZoneIso(serverOffsetInMS)

const statisticsNews: Array<News> = []
const statisticsNews: NewsItem[] = []
if (statregStatistics.length > 0) {
mainSubjects.forEach((mainSubject) => {
const statistics: Array<Content<Statistics & Statistic>> = query({
Expand Down Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/main/resources/lib/ssb/rss/statkal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ const dummyReq: Partial<XP.Request> = {
}

export function getRssItemsStatkal(): string | null {
const statisticVariants: ContentLight<ReleaseVariant>[] = 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
? `<?xml version="1.0" encoding="utf-8"?>
Expand Down Expand Up @@ -58,6 +54,14 @@ export function getRssItemsStatkal(): string | null {
return xml
}

export function getRssReleasesStatkal(): RssRelease[] {
const statisticVariants: ContentLight<ReleaseVariant>[] = 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<ReleaseVariant>[],
allMainSubjects: SubjectItem[]
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/services/rssNews/rssNews.ts
Original file line number Diff line number Diff line change
@@ -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',
}
}
5 changes: 5 additions & 0 deletions src/main/resources/services/rssNews/rssNews.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<service>
<allow>
<principal>role:system.everyone</principal>
</allow>
</service>
Loading

0 comments on commit 566fbb3

Please sign in to comment.