From cdf027540bbecf7fb80b6fa091be1f27cb3d5dc3 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 25 May 2023 22:42:20 -0500 Subject: [PATCH] minor updates --- onyx-pkg.ini | 2 +- src/app.onyx | 5 ++++- www/static/vendor/highlight.min.js | 2 +- www/templates/pages/homepage.html | 6 ++++++ www/templates/pages/news.html | 10 +--------- www/templates/partials/news_listing.html | 10 ++++++++++ 6 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 www/templates/partials/news_listing.html diff --git a/onyx-pkg.ini b/onyx-pkg.ini index 4960205..40ec349 100644 --- a/onyx-pkg.ini +++ b/onyx-pkg.ini @@ -18,7 +18,7 @@ library= [dependencies] git://onyxlang.io/repo/http-server=0.2.1 -git://onyxlang.io/repo/otmp=0.0.9 +git://onyxlang.io/repo/otmp=0.0.12 [dependency_folders] git://onyxlang.io/repo/http-server=http-server diff --git a/src/app.onyx b/src/app.onyx index 49408c5..a312e59 100644 --- a/src/app.onyx +++ b/src/app.onyx @@ -25,7 +25,10 @@ reg: otmp.TemplateRegistry; } @route.{.GET, "/"} -(req: &Req, res: &Res) => res->render("pages/homepage", null); +(req: &Req, res: &Res) { + articles := iter.as_iter(news_articles->get() ?? .[])->take(2)->collect(); + res->render("pages/homepage", &.{ articles = articles }); +} @route.{.GET, "/ovmwasm"} (req: &Req, res: &Res) => res->render("pages/ovmwasm", null); diff --git a/www/static/vendor/highlight.min.js b/www/static/vendor/highlight.min.js index 5f9e666..c0dfe57 100644 --- a/www/static/vendor/highlight.min.js +++ b/www/static/vendor/highlight.min.js @@ -2574,7 +2574,7 @@ var hljs = (function () { aliases: [ "onyx "], keywords: { keyword: [ - "package", "struct", "enum", "use", "global", "macro", + "package", "struct", "union", "enum", "use", "global", "macro", "if", "elseif", "else", "where", "interface", "for", "while", "do", "switch", "case", diff --git a/www/templates/pages/homepage.html b/www/templates/pages/homepage.html index 2da5be2..7932430 100644 --- a/www/templates/pages/homepage.html +++ b/www/templates/pages/homepage.html @@ -64,6 +64,12 @@ factorial :: (n: i32) -> i32 { +
+

Recent News

+ {% partial "partials/news_listing" %} +
+ + {{endblock}} {{extends "pages/normal_page"}} diff --git a/www/templates/pages/news.html b/www/templates/pages/news.html index 1f7ba15..8842dfc 100644 --- a/www/templates/pages/news.html +++ b/www/templates/pages/news.html @@ -6,15 +6,7 @@

News

-{{ foreach $article in $articles }} -
-

{% $article.name %}

-

{% $article.date %}

-

- {% $article.description %} -

-
-{{ endforeach }} +{% partial "partials/news_listing" %} {{endblock}} diff --git a/www/templates/partials/news_listing.html b/www/templates/partials/news_listing.html new file mode 100644 index 0000000..2ed80be --- /dev/null +++ b/www/templates/partials/news_listing.html @@ -0,0 +1,10 @@ + +{{ foreach $article in $articles }} +
+

{% $article.name %}

+

{% $article.date %}

+

+ {% $article.description %} +

+
+{{ endforeach }} -- 2.25.1