From 1225c698ecd819534c5b0288506121a42c86df6d Mon Sep 17 00:00:00 2001 From: Simon Lecoq <22963968+lowlighter@users.noreply.github.com> Date: Fri, 12 Nov 2021 21:01:11 -0500 Subject: [PATCH] feat(templates/repository, templates/terminal): additional support (#660) --- source/plugins/screenshot/index.mjs | 2 +- source/templates/repository/partials/_.json | 8 ++- .../templates/repository/partials/posts.ejs | 51 ++++++++++++++++ .../repository/partials/screenshot.ejs | 20 +++++++ .../repository/partials/sponsors.ejs | 60 +++++++++++++++++++ .../templates/repository/partials/stock.ejs | 48 +++++++++++++++ source/templates/terminal/partials/_.json | 4 +- .../terminal/partials/isocalendar.ejs | 7 +++ .../terminal/partials/screenshot.ejs | 4 ++ source/templates/terminal/style.css | 16 +++++ 10 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 source/templates/repository/partials/posts.ejs create mode 100644 source/templates/repository/partials/screenshot.ejs create mode 100644 source/templates/repository/partials/sponsors.ejs create mode 100644 source/templates/repository/partials/stock.ejs create mode 100644 source/templates/terminal/partials/isocalendar.ejs create mode 100644 source/templates/terminal/partials/screenshot.ejs diff --git a/source/plugins/screenshot/index.mjs b/source/plugins/screenshot/index.mjs index ef19a733..11533262 100644 --- a/source/plugins/screenshot/index.mjs +++ b/source/plugins/screenshot/index.mjs @@ -32,7 +32,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal await browser.close() //Results - return {image:await screenshot.getBase64Async("image/png"), title, height:screenshot.bitmap.height, width:screenshot.bitmap.width} + return {image:await screenshot.getBase64Async("image/png"), title, height:screenshot.bitmap.height, width:screenshot.bitmap.width, url} } //Handle errors catch (error) { diff --git a/source/templates/repository/partials/_.json b/source/templates/repository/partials/_.json index 617b17d4..67a63c08 100644 --- a/source/templates/repository/partials/_.json +++ b/source/templates/repository/partials/_.json @@ -8,7 +8,11 @@ "stargazers", "people", "activity", + "posts", + "rss", + "screenshot", + "stock", "contributors", - "licenses", - "rss" + "sponsors", + "licenses" ] \ No newline at end of file diff --git a/source/templates/repository/partials/posts.ejs b/source/templates/repository/partials/posts.ejs new file mode 100644 index 00000000..f8e14237 --- /dev/null +++ b/source/templates/repository/partials/posts.ejs @@ -0,0 +1,51 @@ +<% if (plugins.posts) { %> +
+

+ + Recent articles +

+
+
+ <% if (plugins.posts.error) { %> +
+ + <%= plugins.posts.error.message %> +
+ <% } else { %> +
+ + From <%= plugins.posts.source %> +
+
+ <% if (plugins.posts.list.length) { %> + <% for (const {title, description, image, date} of plugins.posts.list) { %> +
+ +
+
+
<%= f.date(new Date(date), {date:true, timeZone:config.timezone?.name}) %>
+ <% if (plugins.posts.covers) { %> +
+ <% } %> +
+
+
<%= title %>
+ <% if (plugins.posts.descriptions) { %> +
<%= description %>
+ <% } %> +
+
+
+ <% } %> + <% } else { %> +
+ + No recent posts +
+ <% } %> +
+ <% } %> +
+
+
+<% } %> \ No newline at end of file diff --git a/source/templates/repository/partials/screenshot.ejs b/source/templates/repository/partials/screenshot.ejs new file mode 100644 index 00000000..4b3b31bb --- /dev/null +++ b/source/templates/repository/partials/screenshot.ejs @@ -0,0 +1,20 @@ +<% if (plugins.screenshot) { %> +
+

+ + <%= plugins.screenshot.title %> +

+
+
+ <% if (plugins.screenshot.error) { %> +
+ + <%= plugins.screenshot.error.message %> +
+ <% } else { %> + + <% } %> +
+
+
+<% } %> diff --git a/source/templates/repository/partials/sponsors.ejs b/source/templates/repository/partials/sponsors.ejs new file mode 100644 index 00000000..415fa791 --- /dev/null +++ b/source/templates/repository/partials/sponsors.ejs @@ -0,0 +1,60 @@ +<% if (plugins.sponsors) { %> +
+

+ + Sponsor me! +

+ <% if (plugins.sponsors.error) { %> +
+
+
+ + <%= plugins.sponsors.error.message %> +
+
+
+ <% } else { %> + <% for (const section of plugins.sponsors.sections) { %> + <% if ((section === "goal")&&(plugins.sponsors.goal)) { %> +
+
+
+ <%= plugins.sponsors.goal.description %> +
+ <% { const width = 440 * (1 + large) %> +
+ + + + + + + +
+ <% } %> +
+ + <% if (plugins.sponsors.count) { %> + <%= plugins.sponsors.count %> sponsor<%= plugins.sponsors.count !== 1 ? "s are" : " is" %> funding <%= user.login %>'s work + <% } %> + + <%= plugins.sponsors.goal.title %> +
+
+ <% for (const user of plugins.sponsors.list) { %><% } %> +
+
+
+ <% } else if (section === "about") { %> +
+
+
+ <%- plugins.sponsors.about %> +
+
+
+ <% } %> + <% } %> + <% } %> +
+<% } %> \ No newline at end of file diff --git a/source/templates/repository/partials/stock.ejs b/source/templates/repository/partials/stock.ejs new file mode 100644 index 00000000..e32acdb4 --- /dev/null +++ b/source/templates/repository/partials/stock.ejs @@ -0,0 +1,48 @@ +<% if (plugins.stock) { %> +
+

+ + Stock prices <%= plugins.stock.symbol ? `for ${plugins.stock.symbol}` : "" %> +

+ <% if (plugins.stock.error) { %> +
+
+
+ + <%= plugins.stock.error.message %> +
+
+
+ <% } else { %> +
+
+
+ + <%= plugins.stock.company %> +
+
+ + Valued at <%= plugins.stock.price.toFixed(2) %> <%= plugins.stock.currency %> +
+
+
+
+ + <%= {"1d":"Today", "5d":"Last five days", "1mo":"Last month", "3mo":"Last trimester", "6mo":"Last semester", "1y":"Last year", "2y":"Last two years", "5y":"Last five years", "10y":"Last ten years", ytd:"Year to date", max:"All-time"}[plugins.stock.duration] %> +
+
+ <% if (plugins.stock.delta > 0) { %> + + <% } else { %> + + <% } %> + <%= f(plugins.stock.delta, {sign:true, fixed:2}) %> <%= plugins.stock.currency %> (<%= f(100*plugins.stock.delta/plugins.stock.price, {sign:true, fixed:2}) %>%) +
+
+
+
+ <%- plugins.stock.chart %> +
+ <% } %> +
+<% } %> \ No newline at end of file diff --git a/source/templates/terminal/partials/_.json b/source/templates/terminal/partials/_.json index ed85d40d..a879be1d 100644 --- a/source/templates/terminal/partials/_.json +++ b/source/templates/terminal/partials/_.json @@ -4,5 +4,7 @@ "base.repositories", "gists", "languages", - "pagespeed" + "pagespeed", + "isocalendar", + "screenshot" ] \ No newline at end of file diff --git a/source/templates/terminal/partials/isocalendar.ejs b/source/templates/terminal/partials/isocalendar.ejs new file mode 100644 index 00000000..2030ec81 --- /dev/null +++ b/source/templates/terminal/partials/isocalendar.ejs @@ -0,0 +1,7 @@ +<% if (plugins.isocalendar) { %> +
<%- meta.$ %> ncal -MB<%= {"half-year":5, "full-year":11}[plugins.isocalendar.duration] %>
<%# -%> +
<%# -%>
<%- plugins.isocalendar.svg %>
+<%= `${plugins.isocalendar.streak.current}`.padStart(5) %> consecutive day<%= s(plugins.isocalendar.streak.current) %> with commits +<%= `~${plugins.isocalendar.average}`.padStart(5) %> commits per day in average +
+<% } %> diff --git a/source/templates/terminal/partials/screenshot.ejs b/source/templates/terminal/partials/screenshot.ejs new file mode 100644 index 00000000..2eb36970 --- /dev/null +++ b/source/templates/terminal/partials/screenshot.ejs @@ -0,0 +1,4 @@ +<% if (plugins.screenshot) { %> +
<%- meta.$ %> wget <%= plugins.screenshot.url %>
<%# -%> +
<%# -%>
+<% } %> diff --git a/source/templates/terminal/style.css b/source/templates/terminal/style.css index 27bcc9f4..d2e60a55 100644 --- a/source/templates/terminal/style.css +++ b/source/templates/terminal/style.css @@ -63,6 +63,22 @@ color: #AE9DA7; } +/* Isocalendar */ + .isocalendar svg { + margin-top: -20px !important; + } + +/* Images */ + .isocalendar svg, .screenshot { + filter: grayscale(1) brightness(.9) opacity(.7); + } + +/* Autosize */ + .autosize { + width: auto; + height: auto; + } + /* Prompt */ .ps1-path { color: #7EDA29;