Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/website/package-lock.json
  • Loading branch information
ala-n committed Jan 29, 2025
2 parents d821332 + 10bd546 commit 994d0dd
Show file tree
Hide file tree
Showing 31 changed files with 6,985 additions and 12,913 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ on:
workflow_dispatch:

env:
node-version: 18.x
node-version: 20.x

jobs:
ui-lint-main:
name: Linting ui.apps directory ...
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node v${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
node-version: ${{ env.node-version }}
- name: Install NPM Dependencies
run: npm ci
Expand All @@ -33,10 +35,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node v${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
node-version: ${{ env.node-version }}
- name: Install NPM Dependencies
run: npm ci
Expand Down
52 changes: 43 additions & 9 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,60 @@ on:
workflow_dispatch:

env:
node-version: 18.x
node-version: 20.x

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
actions: read

# Allows only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy-gh-pages:
# Build job
build-site:
name: Build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Use Node v${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
node-version: ${{ env.node-version }}
- name: Install NPM Dependencies
run: npm ci
working-directory: docs/website
- name: Build
run: npm run build
working-directory: docs/website
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
env:
SITE_BASE_URL: ${{ steps.pages.outputs.base_url }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
branch: gh-pages
folder: docs/website/dist
path: ./docs/website/dist

# Deployment job
deploy-site:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-site
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 0 additions & 3 deletions docs/website/.eslintignore

This file was deleted.

41 changes: 0 additions & 41 deletions docs/website/.eslintrc.yml

This file was deleted.

7 changes: 6 additions & 1 deletion docs/website/.stylelintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ rules:
# and could lead to unexpected results
no-invalid-double-slash-comments: true
# Disallow unknown properties
property-no-unknown: true
property-no-unknown:
- true
- ignoreProperties:
- /-webkit-/
- /-moz-/
- box-orient
# Use double colon notation for applicable pseudo-elements
selector-pseudo-element-colon-notation: double
# Disallow unknown pseudo-class selectors
Expand Down
16 changes: 10 additions & 6 deletions docs/website/11ty/htmlmin.transform.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
const {isDev} = require('./env.config');
const htmlmin = require('html-minifier');
const {minify} = require('html-minifier-terser');

const MINIFICATION_CFG = {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
conservativeCollapse: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true
minifyCSS: true,
removeComments: true,
useShortDoctype: true,
ignoreCustomFragments: [
/<%[\s\S]*?%>/,
/<\?[\s\S]*?\?>/
]
};

function minifier(content, outputPath) {
async function minifier(content, outputPath) {
if (!outputPath || !outputPath.endsWith('.html')) return content;
return htmlmin.minify(content, MINIFICATION_CFG);
return await minify(content, MINIFICATION_CFG);
}

module.exports = (config) => {
Expand Down
48 changes: 30 additions & 18 deletions docs/website/11ty/rss.filter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const {JSDOM} = require('jsdom');
const Parser = require('rss-parser');
const parser = new Parser();

const parser = new Parser({defaultRSS: 2.0});
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms));

class EAKRssService {
static META_FETCH_TIMEOUT = 5000;
static DATE_FORMATTER = new Intl.DateTimeFormat('en-US', {
day: 'numeric',
month: 'long',
Expand All @@ -11,41 +14,50 @@ class EAKRssService {

static async load({feed, count, baseUrl, fallback}, callback) {
const items = await EAKRssService.loadFeed(feed);
const result = items
.concat(fallback.items || [])
.slice(0, count)
.map((item) => EAKRssService.parseItems(item, baseUrl, fallback.image));
callback(null, result);
// Load meta for each item
const result = await Promise.all(items.slice(0, count).map(async (item) => {
const meta = await Promise.race([EAKRssService.loadMeta(item.link), timeout(EAKRssService.META_FETCH_TIMEOUT)]);
return Object.assign({}, item, meta || {});
}));
// Add fallback items and limit result
callback(null, result.concat(fallback.items || []).slice(0, count));
}

static async loadFeed(feed) {
try {
const feedContent = await parser.parseURL(feed);
return feedContent.items;
return feedContent.items.map(EAKRssService.parseItem);
} catch {
console.error('Feed fetching error');
}
return [];
}

static parseItems(item, baseUrl, imgFallback) {
static parseItem(item) {
const {title, link, pubDate} = item;
const tags = item.tags || item.categories;
const content = item.contentSnippet || item.content;
const img = item.img || EAKRssService.extractImg(item, baseUrl) || imgFallback;
const date = EAKRssService.DATE_FORMATTER.format(new Date(pubDate));
return {title, link, img, content, date, tags};
return {title, link, date};
}

static extractImg(item, baseUrl) {
static async loadMeta(link) {
const result = {};
try {
const {window} = new JSDOM(item['content:encoded']);
const image = window.document.querySelector('img');
const imageSrc = image.src;
return imageSrc.startsWith('/') ? (baseUrl + imageSrc) : imageSrc;
// Load page content
const content = await (await fetch(link)).text();
// Parse with JSDOM
const {window} = new JSDOM(content);

// Resolve image
const image = window.document.querySelector('meta[property="og:image"]');
if (image) Object.assign(result, {image: image.content});

// Resolve description
const description = window.document.querySelector('meta[property="og:description"]');
if (description) Object.assign(result, {description: description.content});
} catch {
return '';
console.error('Meta fetching error');
}
return result;
}
}

Expand Down
3 changes: 3 additions & 0 deletions docs/website/11ty/site.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const yaml = require('js-yaml');
const content = fs.readFileSync(path.resolve(__dirname, '../views/site.yml'), 'utf8');
const siteConfig = yaml.load(content, {});

// Override the base URL if it's set in the environment
if (process.env['SITE_BASE_URL']) siteConfig.url = process.env['SITE_BASE_URL'];

module.exports = (config) => {
config.addGlobalData('site', siteConfig);
};
Expand Down
15 changes: 15 additions & 0 deletions docs/website/eslint.config.ignore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = [
{
ignores: [
// Common configuration
'eslint.config.js',
'eslint.config.ignore.js',
'webpack.config.js',
// Common directories
'build/**',
'node_modules/**',
// Site output
'/site/dist/**',
]
}
]
13 changes: 13 additions & 0 deletions docs/website/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = [
{
files: ['**/*.ts', '**/*.js'],
linterOptions: {
reportUnusedDisableDirectives: 'warn'
}
},

...require('./eslint.config.ignore'),
...require('@exadel/eslint-config-esl').typescript,
...require('@exadel/eslint-config-esl').recommended,
...require('@exadel/eslint-plugin-esl').recommended
];
Loading

0 comments on commit 994d0dd

Please sign in to comment.