Plugin markdown update (#211)
This commit is contained in:
@@ -68,7 +68,7 @@
|
|||||||
console.debug(`metrics/compute/${login} > markdown render`)
|
console.debug(`metrics/compute/${login} > markdown render`)
|
||||||
let source = image
|
let source = image
|
||||||
try {
|
try {
|
||||||
let template = q.markdown
|
let template = `${q.markdown}`.replace(/\n/g, "")
|
||||||
if (!/^https:/.test(template)) {
|
if (!/^https:/.test(template)) {
|
||||||
const {data:{default_branch:branch, full_name:repo}} = await rest.repos.get({owner:login, repo:q.repo||login})
|
const {data:{default_branch:branch, full_name:repo}} = await rest.repos.get({owner:login, repo:q.repo||login})
|
||||||
console.debug(`metrics/compute/${login} > on ${repo} with default branch ${branch}`)
|
console.debug(`metrics/compute/${login} > on ${repo} with default branch ${branch}`)
|
||||||
|
|||||||
@@ -12,16 +12,19 @@
|
|||||||
//Retrieve posts
|
//Retrieve posts
|
||||||
console.debug(`metrics/compute/${login}/plugins > posts > processing with source ${source}`)
|
console.debug(`metrics/compute/${login}/plugins > posts > processing with source ${source}`)
|
||||||
let posts = null
|
let posts = null
|
||||||
|
let link = null
|
||||||
switch (source) {
|
switch (source) {
|
||||||
//Dev.to
|
//Dev.to
|
||||||
case "dev.to":{
|
case "dev.to":{
|
||||||
console.debug(`metrics/compute/${login}/plugins > posts > querying api`)
|
console.debug(`metrics/compute/${login}/plugins > posts > querying api`)
|
||||||
posts = (await imports.axios.get(`https://dev.to/api/articles?username=${user}&state=fresh`)).data.map(({title, description, published_at:date, cover_image:image}) => ({title, description, date, image}))
|
posts = (await imports.axios.get(`https://dev.to/api/articles?username=${user}&state=fresh`)).data.map(({title, description, published_at:date, cover_image:image, url:link}) => ({title, description, date, image, link}))
|
||||||
|
link = `https://dev.to/${user}`
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
//Hashnode
|
//Hashnode
|
||||||
case "hashnode":{
|
case "hashnode":{
|
||||||
posts = (await imports.axios.post("https://api.hashnode.com", {query:queries.posts.hashnode({user})}, {headers:{"Content-type":"application/json"}})).data.data.user.publication.posts.map(({title, brief:description, dateAdded:date, coverImage:image}) => ({title, description, date, image}))
|
posts = (await imports.axios.post("https://api.hashnode.com", {query:queries.posts.hashnode({user})}, {headers:{"Content-type":"application/json"}})).data.data.user.publication.posts.map(({title, brief:description, dateAdded:date, coverImage:image, slug}) => ({title, description, date, image, link:`https://hashnode.com/post/${slug}`}))
|
||||||
|
link = `https://hashnode.com/@${user}`
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
//Unsupported
|
//Unsupported
|
||||||
@@ -42,7 +45,7 @@
|
|||||||
posts = await Promise.all(posts.map(async({image, ...post}) => ({image:await imports.imgb64(image, {width:144, height:-1}), ...post})))
|
posts = await Promise.all(posts.map(async({image, ...post}) => ({image:await imports.imgb64(image, {width:144, height:-1}), ...post})))
|
||||||
}
|
}
|
||||||
//Results
|
//Results
|
||||||
return {source, descriptions, covers, list:posts}
|
return {source, link, descriptions, covers, list:posts}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unhandled error
|
//Unhandled error
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
query PostsHashnode {
|
query PostsHashnode {
|
||||||
user(username: "$user"){
|
user(username: "$user"){
|
||||||
publication{
|
publication{
|
||||||
posts(page: 1) {
|
posts(page: 0) {
|
||||||
|
slug
|
||||||
title
|
title
|
||||||
brief
|
brief
|
||||||
coverImage
|
coverImage
|
||||||
|
|||||||
@@ -46,11 +46,17 @@
|
|||||||
//Medias
|
//Medias
|
||||||
if (tweet.attachments)
|
if (tweet.attachments)
|
||||||
tweet.attachments = await Promise.all(tweet.attachments.media_keys.filter(key => medias.get(key)).map(key => medias.get(key)).map(async url => ({image:await imports.imgb64(url, {height:-1, width:450})})))
|
tweet.attachments = await Promise.all(tweet.attachments.media_keys.filter(key => medias.get(key)).map(key => medias.get(key)).map(async url => ({image:await imports.imgb64(url, {height:-1, width:450})})))
|
||||||
else if (linked) {
|
if (linked) {
|
||||||
const {result:{ogImage, ogSiteName:website, ogTitle:title, ogDescription:description}} = await imports.opengraph({url:linked})
|
const {result:{ogImage, ogSiteName:website, ogTitle:title, ogDescription:description}} = await imports.opengraph({url:linked})
|
||||||
const image = await imports.imgb64(ogImage?.url, {height:-1, width:450, fallback:false})
|
const image = await imports.imgb64(ogImage?.url, {height:-1, width:450, fallback:false})
|
||||||
if (image)
|
if (image) {
|
||||||
tweet.attachments = [{image, title, description, website}]
|
if (tweet.attachments)
|
||||||
|
tweet.attachments.unshift([{image, title, description, website}])
|
||||||
|
else
|
||||||
|
tweet.attachments = [{image, title, description, website}]
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tweet.text = `${tweet.text}\n${linked}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -68,7 +74,7 @@
|
|||||||
//Line breaks
|
//Line breaks
|
||||||
.replace(/\n/g, "<br/>")
|
.replace(/\n/g, "<br/>")
|
||||||
//Links
|
//Links
|
||||||
.replace(new RegExp(`${tweet.urls.size ? "" : "noop^"}(${[...tweet.urls.keys()].map(url => `(?:${url})`).join("|")})`, "gi"), (_, url) => `<span class="link">${tweet.urls.get(url)}</span>`), {"&":true})
|
.replace(new RegExp(`${tweet.urls.size ? "" : "noop^"}(${[...tweet.urls.keys()].map(url => `(?:${url})`).join("|")})`, "gi"), (_, url) => `<a href="${url}" class="link">${tweet.urls.get(url)}</a>`), {"&":true})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
//Result
|
//Result
|
||||||
|
|||||||
@@ -20,28 +20,16 @@ I contributed to `{{ REPOSITORIES_CONTRIBUTED_TO }}` repositories and made `{{ C
|
|||||||
|
|
||||||
## 🧩 Markdown plugins
|
## 🧩 Markdown plugins
|
||||||
|
|
||||||
Most of plugins from SVG templates can be reused directly by including image source in markdown, but some have them have their own **markdown** version which includes hyperlinks.
|
Most of plugins from SVG templates can be reused directly by including image source in markdown, but some have them have their own **markdown** version which includes hyperlinks and reduce image overhead.
|
||||||
|
|
||||||
### 📰 Recent activity
|
See [compatibility matrix](https://github.com/lowlighter/metrics#-templateplugin-compatibily-matrix) for more informations.
|
||||||
|
|
||||||
<%- await include(`partials/activity.ejs`) %>
|
<%- await include(`partials/activity.ejs`) %>
|
||||||
|
|
||||||
### ✒️ Recent posts
|
<%- await include(`partials/posts.ejs`) %>
|
||||||
|
|
||||||
*Coming soon*
|
|
||||||
|
|
||||||
### 🗼 Rss feed
|
|
||||||
|
|
||||||
<%- await include(`partials/rss.ejs`) %>
|
<%- await include(`partials/rss.ejs`) %>
|
||||||
|
|
||||||
### 🐤 Latest tweets
|
<%- await include(`partials/tweets.ejs`) %>
|
||||||
|
|
||||||
*Coming soon*
|
|
||||||
|
|
||||||
### 🌇 GitHub Skyline 3D calendar
|
|
||||||
|
|
||||||
*Coming soon*
|
|
||||||
|
|
||||||
### 📌 Starred topics
|
|
||||||
|
|
||||||
<%- await include(`partials/topics.ejs`) %>
|
<%- await include(`partials/topics.ejs`) %>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<%_ } else if (plugins.activity.events.length) { _%>
|
<%_ } else if (plugins.activity.events.length) { _%>
|
||||||
<%_ for (const {actor, type, repo, timestamp, ...event} of plugins.activity.events) { _%>
|
<%_ for (const {actor, type, repo, timestamp, ...event} of plugins.activity.events) { _%>
|
||||||
<%_ if (type === "comment") { _%>
|
<%_ if (type === "comment") { _%>
|
||||||
* 💬 Commented on [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/<%= {issue:"issues", pr:"pulls", commit:"commit"}[event.on] %>/<%= event.number %>) from [<%= repo %>](https://github.com/<%= repo %>)
|
* 💬 Commented on [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/<%= {issue:"issues", pr:"pull", commit:"commit"}[event.on] %>/<%= event.number %>) from [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
<%_ } else if (type === "member") { _%>
|
<%_ } else if (type === "member") { _%>
|
||||||
* 💼 Added [<%= event.user %>](https://github.com/<%= event.user %>) as collaborator in [<%= repo %>](https://github.com/<%= repo %>)
|
* 💼 Added [<%= event.user %>](https://github.com/<%= event.user %>) as collaborator in [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
<%_ } else if (type === "star") { _%>
|
<%_ } else if (type === "star") { _%>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<%_ } else if (type === "issue") { _%>
|
<%_ } else if (type === "issue") { _%>
|
||||||
* #️⃣ <%- event.action === "opened" ? "Opened" : event.action === "reopened" ? "Reopened" : "Closed" %> [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/issues/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
* #️⃣ <%- event.action === "opened" ? "Opened" : event.action === "reopened" ? "Reopened" : "Closed" %> [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/issues/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
<%_ } else if (type === "pr") { _%>
|
<%_ } else if (type === "pr") { _%>
|
||||||
* 🔃 <%- event.action === "opened" ? "Opened" : "Merged" %> [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/pulls/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
* 🔃 <%- event.action === "opened" ? "Opened" : "Merged" %> [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/pull/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
* <%= event.files.changed %> file<%= s(event.files.changed) %> changed `++<%= event.lines.added %> --<%= event.lines.deleted%>`
|
* <%= event.files.changed %> file<%= s(event.files.changed) %> changed `++<%= event.lines.added %> --<%= event.lines.deleted%>`
|
||||||
<%_ } else if (type === "wiki") { _%>
|
<%_ } else if (type === "wiki") { _%>
|
||||||
* 📝 Updated <%= event.pages.length %> wiki page<%= s(event.pages.length) %> in [<%= repo %>](https://github.com/<%= repo %>/wiki)
|
* 📝 Updated <%= event.pages.length %> wiki page<%= s(event.pages.length) %> in [<%= repo %>](https://github.com/<%= repo %>/wiki)
|
||||||
@@ -32,12 +32,15 @@
|
|||||||
<%_ } else if (type === "public") { _%>
|
<%_ } else if (type === "public") { _%>
|
||||||
* 🚀 Made [<%= repo %>](https://github.com/<%= repo %>) public
|
* 🚀 Made [<%= repo %>](https://github.com/<%= repo %>) public
|
||||||
<%_ } else if (type === "review") { _%>
|
<%_ } else if (type === "review") { _%>
|
||||||
* 🔍 Reviewed [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/pulls/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
* 🔍 Reviewed [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/pull/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
<%_ } else if (type === "ref/create") { _%>
|
<%_ } else if (type === "ref/create") { _%>
|
||||||
* ⏺️ Created new <%= event.ref.type %> `<%= event.ref.name %>` in [<%= repo %>](https://github.com/<%= repo %>)
|
* ⏺️ Created new <%= event.ref.type %> `<%= event.ref.name %>` in [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
<%_ } else if (type === "ref/create") { _%>
|
<%_ } else if (type === "ref/create") { _%>
|
||||||
* 🚮 Deleted <%= event.ref.type %> `<%= event.ref.name %>` from [<%= repo %>](https://github.com/<%= repo %>)
|
* 🚮 Deleted <%= event.ref.type %> `<%= event.ref.name %>` from [<%= repo %>](https://github.com/<%= repo %>)
|
||||||
<%_ } _%>
|
<%_ } _%>
|
||||||
|
<%_ if (plugins.activity.timestamps) { _%>
|
||||||
|
* *On <%= f.date(timestamp, {timeStyle:"short", dateStyle:"short"}) %>*
|
||||||
|
<%_ } _%>
|
||||||
<%_ } _%>
|
<%_ } _%>
|
||||||
<%_ } else { _%>
|
<%_ } else { _%>
|
||||||
No recent activity
|
No recent activity
|
||||||
|
|||||||
35
source/templates/markdown/partials/posts.ejs
Normal file
35
source/templates/markdown/partials/posts.ejs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<%_ if (plugins.posts) { _%>
|
||||||
|
**[✒️ Recent posts from <%= plugins.posts?.source %>](<%= plugins.posts?.link %>)**
|
||||||
|
<%_ if (plugins.posts.error) { _%>
|
||||||
|
<%= plugins.posts.error.message _%>
|
||||||
|
<%_ } else if ((plugins.posts.list.length)&&(plugins.posts.descriptions)||(plugins.posts.covers)) { _%>
|
||||||
|
<%_ for (const {title, date, link, description = "", image} of plugins.posts.list) { _%>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<%_ if (plugins.posts.covers) { _%>
|
||||||
|
<td rowspan="2" width="280">
|
||||||
|
<img src="<%= image %>" alt="" width="280">
|
||||||
|
</td>
|
||||||
|
<%_ } _%>
|
||||||
|
<th>
|
||||||
|
<a href="<%= link %>"><%= title.trim() %></a>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= description %>
|
||||||
|
<br>
|
||||||
|
<i>Published on <%= f.date(new Date(date), {dateStyle:"short"}) %></i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<%_ } _%>
|
||||||
|
<%_ } else if (plugins.posts.list.length) { _%>
|
||||||
|
<%_ for (const {title, date, link} of plugins.posts.list) { _%>
|
||||||
|
* [<%= title.trim() %>](<%= link %>)
|
||||||
|
* *Published on <%= f.date(new Date(date), {dateStyle:"short"}) %>*
|
||||||
|
<%_ } _%>
|
||||||
|
<%_ } else { _%>
|
||||||
|
No recent posts
|
||||||
|
<%_ } _%>
|
||||||
|
<%_ } _%>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<%_ } else if (plugins.rss.feed.length) { _%>
|
<%_ } else if (plugins.rss.feed.length) { _%>
|
||||||
<%_ for (const {title, link, date} of plugins.rss.feed) { _%>
|
<%_ for (const {title, link, date} of plugins.rss.feed) { _%>
|
||||||
* [<%= title %>](<%= link %>)
|
* [<%= title %>](<%= link %>)
|
||||||
* Published on <%= f.date(new Date(date), {dateStyle:"short"}) %>
|
* *Published on <%= f.date(new Date(date), {dateStyle:"short"}) %>*
|
||||||
<%_ } _%>
|
<%_ } _%>
|
||||||
<%_ } else { _%>
|
<%_ } else { _%>
|
||||||
Empty RSS feed
|
Empty RSS feed
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
* <img src="<%= icon %>" width="24" height="24" alt=""> [<%= name %>](https://github.com/topics/<%= name.toLocaleLowerCase().replace(/ /g, "-") %>)
|
* <img src="<%= icon %>" width="24" height="24" alt=""> [<%= name %>](https://github.com/topics/<%= name.toLocaleLowerCase().replace(/ /g, "-") %>)
|
||||||
<%_ } _%>
|
<%_ } _%>
|
||||||
<%_ } else { _%>
|
<%_ } else { _%>
|
||||||
Empty RSS feed
|
No starred topics
|
||||||
<%_ } _%>
|
<%_ } _%>
|
||||||
<%_ } _%>
|
<%_ } _%>
|
||||||
21
source/templates/markdown/partials/tweets.ejs
Normal file
21
source/templates/markdown/partials/tweets.ejs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<%_ if (plugins.tweets) { _%>
|
||||||
|
**[🐤 Latest tweets from @<%= plugins.tweets.username %>](https://twitter.com/<%= plugins.tweets.username %>)**
|
||||||
|
<%_ if (plugins.tweets.error) { _%>
|
||||||
|
<%= plugins.tweets.error.message _%>
|
||||||
|
<%_ } else if (plugins.tweets.list.length) { _%>
|
||||||
|
<%_ for (const {text, createdAt, attachments} of plugins.tweets.list) { _%>
|
||||||
|
> <%- text %>
|
||||||
|
<%_ if (attachments) { _%>
|
||||||
|
<%_ for (const {image, title, description, website} of attachments) { _%>
|
||||||
|
>
|
||||||
|
> <a href="<%= website %>"><img src="<%= image %>" alt="<%= title %>" height="200"></a>
|
||||||
|
<%_ } _%>
|
||||||
|
<%_ } _%>
|
||||||
|
>
|
||||||
|
> *<%= createdAt %>*
|
||||||
|
|
||||||
|
<%_ } _%>
|
||||||
|
<%_ } else { _%>
|
||||||
|
No recent tweets
|
||||||
|
<%_ } _%>
|
||||||
|
<%_ } _%>
|
||||||
Reference in New Issue
Block a user