diff --git a/RELEASE_PROCEDURE.md b/RELEASE_PROCEDURE.md index e55fde78f..84ce278a0 100644 --- a/RELEASE_PROCEDURE.md +++ b/RELEASE_PROCEDURE.md @@ -56,6 +56,10 @@ Before see How to 1. Update the oeplatform/versions/changelogs/ [`current.md`](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/versions/changelogs/current.md) (see the examples of previous releases) + - Write its `## Highlights`: three to five points for users. The platform's + "What's new" page, linked from the homepage, shows them without the version + number. A release without highlights (usually a patch) keeps the previous + release's highlights there. - Change filename to release version (x_x_x.md) - Copy template to `current.md` - Update version with `bumpversion --allow-dirty [minor|patch]` diff --git a/REUSE.toml b/REUSE.toml index a8ef42252..d8a3764e5 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -3572,6 +3572,7 @@ path = [ "base/templates/base/_instance_stylesheets.html", "base/templates/base/_feedback.html", "base/templates/base/_notice.html", + "base/templates/base/whats_new.html", "theming/stock_tokens.scss", "theming/literal_scan.mjs", ] diff --git a/base/helper.py b/base/helper.py index 17c9a51f9..f262d2290 100644 --- a/base/helper.py +++ b/base/helper.py @@ -24,47 +24,34 @@ SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) -@lru_cache(maxsize=None) -def read_version_changes() -> dict: - """read version and changes from changelog markdown +CHANGELOG_DIR = os.path.join(SITE_ROOT, "..", "versions", "changelogs") +RELEASED_CHANGELOG = re.compile(r"(\d+)_(\d+)_(\d+)\.md") +HIGHLIGHTS = re.compile(r"^## Highlights[ \t]*\n(.*?)(?=^## |\Z)", re.M | re.S) +COMMENT = re.compile(r"", re.S) - We use cache so it can stay in process memory and we dont have to read files - in every request. this only changes on a new release anyway, in which case - the process is restarted. - Returns: - dict: {"version": (major, minor, patch), "changes": changes} - """ - os.path.dirname(os.path.realpath(__file__)) - version_expr = r"^(?P\d+)\.(?P\d+)+\.(?P\d+)$" - markdowner = markdown2.Markdown() +@lru_cache(maxsize=None) +def latest_release_highlights(directory=CHANGELOG_DIR) -> str: + """HTML of the newest released changelog's `## Highlights`, or "". - logger.info("READING VERSION file.") - try: - with open( - os.path.join(SITE_ROOT, "..", "VERSION"), encoding="utf-8" - ) as version_file: - text = version_file.read() - match = re.match(version_expr, text) - if not match: - raise ValueError(text) - major, minor, patch = match.groups() - with open( - os.path.join( - SITE_ROOT, - "..", - "versions/changelogs/%s_%s_%s.md" % (major, minor, patch), - ), - encoding="utf-8", - ) as change_file: - changes = markdowner.convert( - "\n".join(line for line in change_file.readlines()) - ) - except Exception: - logger.error("READING VERSION file.") - # probably because change_file is missing - major, minor, patch, changes = "", "", "", "" - return {"version": (major, minor, patch), "changes": changes} + A released changelog is named `__.md` (`current.md` is + the next release, not yet out). A release without highlights, as a patch + release usually is, is skipped. The version is deliberately not returned: + the platform's pages do not say which release it runs. Cached for the + process: changelogs only change with a release, which restarts it. + """ + released = [] + for name in os.listdir(directory): + match = RELEASED_CHANGELOG.fullmatch(name) + if match: + released.append((tuple(int(part) for part in match.groups()), name)) + for _version, name in sorted(released, reverse=True): + with open(os.path.join(directory, name), encoding="utf-8") as file: + section = HIGHLIGHTS.search(file.read()) + text = COMMENT.sub("", section.group(1)).strip() if section else "" + if text: + return markdown2.markdown(text) + return "" def get_json_content(path, json_id=None): diff --git a/base/static/css/index-style.css b/base/static/css/index-style.css index 1368eb1a5..9acea6a9c 100644 --- a/base/static/css/index-style.css +++ b/base/static/css/index-style.css @@ -114,6 +114,16 @@ padding: 24px 0; } +.index-hero-news { + color: var(--oep-on-strong); +} + +.index-hero-news:hover, +.index-hero-news:focus-visible { + color: var(--oep-on-strong); + text-decoration: underline; +} + .index-hero-btn { display: inline-flex; align-items: center; diff --git a/base/templates/base/index.html b/base/templates/base/index.html index db10fb689..2e190d1dc 100644 --- a/base/templates/base/index.html +++ b/base/templates/base/index.html @@ -46,6 +46,7 @@