diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a097b..5f9aec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## 0.3.3 + +- Feature: add `filter` option for series preset `RankSeriesRulePresetICPC` +- Change: `contest.link` has been removed. Use `contest.refLinks` to declare all related external links + ## 0.3.2 - Feature: add `remarks` field diff --git a/README.md b/README.md index 6771053..49949b2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Standard Ranklist (srk) is a json format to describe many kinds of ranklists lik With srk, most of programming contest ranklists can be described in a standard format. It's easy to customize display style with different renderers and share everywhere. -Version: `0.3.2` +Version: `0.3.3` ## Files diff --git a/demo.json b/demo.json index 8bf592d..cff2c2d 100644 --- a/demo.json +++ b/demo.json @@ -1,6 +1,6 @@ { "type": "general", - "version": "0.3.2", + "version": "0.3.3", "remarks": "This is a demo ranklist.", "contributors": [ "bLue (https://example.com/)" @@ -16,7 +16,12 @@ 1, "h" ], - "link": "https://icpc.baylor.edu/scoreboard/" + "refLinks": [ + { + "title": "Original Ranklist", + "link": "https://icpc.baylor.edu/scoreboard/" + } + ] }, "problems": [ { diff --git a/demo.ts b/demo.ts index c06635d..4eeb0f7 100644 --- a/demo.ts +++ b/demo.ts @@ -2,17 +2,20 @@ import * as srk from '.'; const ranklist: srk.Ranklist = { type: 'general', - version: '0.3.2', + version: '0.3.3', remarks: 'This is a demo ranklist.', - contributors: [ - "bLue (https://example.com/)" - ], + contributors: ['bLue (https://example.com/)'], contest: { title: 'ACM ICPC World Finals 2018', startAt: '2018-04-19T17:00:00+08:00', duration: [5, 'h'], frozenDuration: [1, 'h'], - link: 'https://icpc.baylor.edu/scoreboard/', + refLinks: [ + { + title: 'Original Ranklist', + link: 'https://icpc.baylor.edu/scoreboard/', + }, + ], }, problems: [ { @@ -65,7 +68,7 @@ const ranklist: srk.Ranklist = { }, }, }, - } + }, ], rows: [ { diff --git a/index.d.ts b/index.d.ts index 47407d3..a2d0a2e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,7 @@ Copyright (c) algoUX. All rights reserved. ***************************************************************************** */ export type Type = 'general'; -export type Version = '0.3.2'; +export type Version = '0.3.3'; //#region common @@ -29,6 +29,23 @@ export type TimeUnit = 'ms' | 's' | 'min' | 'h' | 'd'; */ export type TimeDuration = [number, TimeUnit]; +/** + * i18n string set. + * @example + * { "en-US": 'English', "zh-CN": '中文', fallback: 'English' } + */ +export type I18NStringSet = { + /** The fallback string if renderer cannot determine the language to use. */ + fallback: string; + /** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */ + [key: string]: string; +}; + +/** + * Text (i18n supported). + */ +export type Text = string | I18NStringSet; + /** URL. */ export type Link = string; @@ -39,7 +56,7 @@ export type Link = string; */ export interface LinkWithTitle { link: Link; - title: string; + title: Text; } /** Base64 string. */ @@ -100,23 +117,6 @@ export interface Style { backgroundColor?: ThemeColor; } -/** - * i18n string set. - * @example - * { "en-US": 'English', "zh-CN": '中文', fallback: 'English' } - */ -export type I18NStringSet = { - /** The fallback string if renderer cannot determine the language to use. */ - fallback: string; - /** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */ - [key: string]: string; -}; - -/** - * Text (i18n supported). - */ -export type Text = string | I18NStringSet; - /** * Contributor field. The email and url are optional. * @example @@ -298,12 +298,6 @@ export interface Contest { /** Banner image. */ banner?: Image | ImageWithLink; - /** - * The link to view original contest. - * @defaultValue Ignored by renderer. - */ - link?: Link; - /** * Reference links of contest. * @defaultValue Ignored by renderer. @@ -436,6 +430,26 @@ export interface RankSeriesRulePresetICPC { */ noTied?: boolean; }; + + /** + * Use filter to determine users to be included. + * Only if the user matches all filter options, it will be included as denominator. + */ + filter?: { + byUserFields?: { + /** + * The field name of `user` to be filtered. + * @example 'organization' + */ + field: keyof User; + + /** + * The field match rule (RegExp constructor string) of `user` to be filtered. + * @example 'SDUT' + */ + rule: string; + }[]; + }, }; } diff --git a/package.json b/package.json index 517cfe9..642180d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@algoux/standard-ranklist", - "version": "0.3.2", + "version": "0.3.3", "description": "Standard Ranklist", "types": "index.d.ts", "scripts": {