Switch to use tags for selecting radar blips

This commit is contained in:
Christian Köberl
2022-05-27 10:42:44 +02:00
committed by Bastian
parent faadd8681d
commit 63a9f5c28e
6 changed files with 39 additions and 38 deletions

View File

@@ -156,26 +156,26 @@ The content should look as follows:
} }
``` ```
### Create different Radars ### Filter with tags / create different Radars
To create different radars with one set of blips put a `radars` entry in your frontmatter: To create different radars with one set of blips put a `tags` entry in your frontmatter:
```yaml ```yaml
--- ---
title: Item title: Item
ring: adopt ring: adopt
quadrant: tools quadrant: tools
radars: [radar-1, radar-2] tags: [radar-1, radar-2]
--- ---
``` ```
Then, to select the blips put a `radar` entry in the `config.json` for generating the site: Then, to select the blips put a `tags` entry in the `config.json` for generating the site:
```json ```json
{ {
"radar": "radar-1", "tags": ["radar-1"],
"quadrants": { "quadrants": {
... ...
``` ```
This will only add blips with the defined radar into the output. This will only add blips with the defined tags into the output.
### Change the index.html ### Change the index.html
To change the index.html, create a public folder in your application and put your `index.html` in it. To change the index.html, create a public folder in your application and put your `index.html` in it.

View File

@@ -120,7 +120,7 @@ var createRadar = function () { return __awaiter(void 0, void 0, void 0, functio
}); }; }); };
exports.createRadar = createRadar; exports.createRadar = createRadar;
var checkAttributes = function (fileName, attributes) { var checkAttributes = function (fileName, attributes) {
var rawConf = fs_1.readFileSync(path.resolve(paths_1.appBuild, "config.json"), "utf-8"); var rawConf = (0, fs_1.readFileSync)(path.resolve(paths_1.appBuild, "config.json"), "utf-8");
var config = JSON.parse(rawConf); var config = JSON.parse(rawConf);
if (!config.rings.includes(attributes.ring)) { if (!config.rings.includes(attributes.ring)) {
throw new Error("Error: ".concat(fileName, " has an illegal value for 'ring' - must be one of ").concat(config.rings)); throw new Error("Error: ".concat(fileName, " has an illegal value for 'ring' - must be one of ").concat(config.rings));
@@ -129,19 +129,25 @@ var checkAttributes = function (fileName, attributes) {
if (!quadrants.includes(attributes.quadrant)) { if (!quadrants.includes(attributes.quadrant)) {
throw new Error("Error: ".concat(fileName, " has an illegal value for 'quadrant' - must be one of ").concat(quadrants)); throw new Error("Error: ".concat(fileName, " has an illegal value for 'quadrant' - must be one of ").concat(quadrants));
} }
if (config.radar && attributes.radars) { if (config.tags) {
if (!attributes.radars.includes(config.radar)) { for (var _i = 0, _a = config.tags; _i < _a.length; _i++) {
var tag = _a[_i];
if (attributes.tags && attributes.tags.includes(tag)) {
return attributes;
}
}
return undefined; return undefined;
} }
} else {
return attributes; return attributes;
}
}; };
var createRevisionsFromFiles = function (fileNames) { var createRevisionsFromFiles = function (fileNames) {
var publicUrl = process.env.PUBLIC_URL; var publicUrl = process.env.PUBLIC_URL;
return Promise.all(fileNames.map(function (fileName) { return Promise.all(fileNames.map(function (fileName) {
return fs_extra_1.readFile(fileName, "utf8").then(function (data) { return (0, fs_extra_1.readFile)(fileName, "utf8").then(function (data) {
var fm = front_matter_1.default(data); var fm = (0, front_matter_1.default)(data);
var html = marked_1.marked(fm.body.replace(/\]\(\//g, "](" + publicUrl + "/")); var html = (0, marked_1.marked)(fm.body.replace(/\]\(\//g, "](".concat(publicUrl, "/")));
html = html.replace(/a href="http/g, 'a target="_blank" rel="noopener noreferrer" href="http'); html = html.replace(/a href="http/g, 'a target="_blank" rel="noopener noreferrer" href="http');
var attributes = checkAttributes(fileName, fm.attributes); var attributes = checkAttributes(fileName, fm.attributes);
if (attributes) { if (attributes) {

View File

@@ -1,28 +1,12 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.assetUrl = exports.isMobileViewport = exports.translate = exports.showEmptyRings = exports.getItemPageNames = exports.rings = exports.quadrants = exports.radarNameShort = exports.radarName = void 0; exports.translate = exports.assetUrl = exports.isMobileViewport = exports.getItemPageNames = exports.radarNameShort = exports.radarName = void 0;
exports.radarName = process.env.REACT_APP_RADAR_NAME || "AOE Technology Radar"; exports.radarName = process.env.REACT_APP_RADAR_NAME || "AOE Technology Radar";
exports.radarNameShort = exports.radarName; exports.radarNameShort = exports.radarName;
exports.quadrants = [
"languages-and-frameworks",
"methods-and-patterns",
"platforms-and-aoe-services",
"tools",
];
exports.rings = ["all", "adopt", "trial", "assess", "hold"];
var getItemPageNames = function (items) { var getItemPageNames = function (items) {
return items.map(function (item) { return item.quadrant + "/" + item.name; }); return items.map(function (item) { return "".concat(item.quadrant, "/").concat(item.name); });
}; };
exports.getItemPageNames = getItemPageNames; exports.getItemPageNames = getItemPageNames;
exports.showEmptyRings = false;
var messages = {
"languages-and-frameworks": "Languages & Frameworks",
"methods-and-patterns": "Methods & Patterns",
"platforms-and-aoe-services": "Platforms & Operations",
tools: "Tools",
};
var translate = function (key) { return messages[key] || "-"; };
exports.translate = translate;
function isMobileViewport() { function isMobileViewport() {
// return false for server side rendering // return false for server side rendering
if (typeof window == "undefined") if (typeof window == "undefined")
@@ -37,3 +21,7 @@ function assetUrl(file) {
return process.env.PUBLIC_URL + "/" + file; return process.env.PUBLIC_URL + "/" + file;
} }
exports.assetUrl = assetUrl; exports.assetUrl = assetUrl;
function translate(config, key) {
return config.quadrants[key] || "-";
}
exports.translate = translate;

View File

@@ -10,6 +10,8 @@ import { radarPath, getAllMarkdownFiles } from "./file";
import { Item, Revision, ItemAttributes, Radar, FlagType } from "../../src/model"; import { Item, Revision, ItemAttributes, Radar, FlagType } from "../../src/model";
import { appBuild } from "../paths"; import { appBuild } from "../paths";
import type { ConfigData } from "../../src/config";
type FMAttributes = ItemAttributes; type FMAttributes = ItemAttributes;
marked.setOptions({ marked.setOptions({
@@ -34,7 +36,7 @@ export const createRadar = async (): Promise<Radar> => {
const checkAttributes = (fileName: string, attributes: FMAttributes) => { const checkAttributes = (fileName: string, attributes: FMAttributes) => {
const rawConf = readFileSync(path.resolve(appBuild, "config.json"), "utf-8"); const rawConf = readFileSync(path.resolve(appBuild, "config.json"), "utf-8");
const config = JSON.parse(rawConf); const config = JSON.parse(rawConf) as ConfigData;
if (!config.rings.includes(attributes.ring)) { if (!config.rings.includes(attributes.ring)) {
throw new Error( throw new Error(
@@ -49,13 +51,17 @@ const checkAttributes = (fileName: string, attributes: FMAttributes) => {
); );
} }
if (config.radar && attributes.radars) { if (config.tags) {
if (!attributes.radars.includes(config.radar)) { for (let tag of config.tags) {
return undefined; if (attributes.tags && attributes.tags.includes(tag)) {
return attributes;
} }
} }
return undefined;
} else {
return attributes;
}
return attributes;
}; };
const createRevisionsFromFiles = (fileNames: string[]) => { const createRevisionsFromFiles = (fileNames: string[]) => {

View File

@@ -1,6 +1,7 @@
import {Item, HomepageOption, QuadrantConfig} from './model'; import {Item, HomepageOption, QuadrantConfig} from './model';
export interface ConfigData { export interface ConfigData {
tags?: string[];
quadrants: { [key: string]: string }; quadrants: { [key: string]: string };
rings: string[]; rings: string[];
showEmptyRings: boolean; showEmptyRings: boolean;

View File

@@ -10,7 +10,7 @@ export type ItemAttributes = {
quadrant: string; quadrant: string;
title: string; title: string;
featured?: boolean; featured?: boolean;
radars?: string[]; tags?: string[];
}; };
export enum FlagType { export enum FlagType {