Skip to content

Commit

Permalink
Add plugin projects (#13)
Browse files Browse the repository at this point in the history
* Add plugin projects

* Add images for readme
  • Loading branch information
lowlighter committed Dec 8, 2020
1 parent 4a31248 commit 1d11145
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 24 deletions.
Binary file added .github/readme/imgs/project_create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/readme/imgs/project_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/readme/imgs/project_track_progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
token: ${{ secrets.METRICS_TOKEN }}
repositories: 1
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Terminal template
Expand All @@ -43,7 +42,6 @@ jobs:
token: ${{ secrets.METRICS_TOKEN }}
repositories: 1
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: PageSpeed plugin
Expand All @@ -55,7 +53,6 @@ jobs:
plugin_pagespeed: yes
plugin_pagespeed_token: ${{ secrets.PAGESPEED_TOKEN }}
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Music plugin (playlist - apple)
Expand All @@ -67,7 +64,6 @@ jobs:
plugin_music: yes
plugin_music_playlist: ${{ secrets.MUSIC_PLAYLIST_APPLE }}
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Music plugin (playlist - spotify)
Expand All @@ -79,7 +75,6 @@ jobs:
plugin_music: yes
plugin_music_playlist: ${{ secrets.MUSIC_PLAYLIST_SPOTIFY }}
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Music plugin (recent - spotify)
Expand All @@ -92,7 +87,6 @@ jobs:
plugin_music_provider: spotify
plugin_music_token: ${{ secrets.SPOTIFY_TOKENS }}
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Posts plugin (dev.to)
Expand All @@ -104,7 +98,6 @@ jobs:
plugin_posts: yes
plugin_posts_source: dev.to
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Isocalendar plugin
Expand All @@ -115,7 +108,6 @@ jobs:
repositories: 1
plugin_isocalendar: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Isocalendar plugin (full year)
Expand All @@ -127,7 +119,6 @@ jobs:
plugin_isocalendar: yes
plugin_isocalendar_duration: full-year
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Habits plugin
Expand All @@ -138,7 +129,6 @@ jobs:
repositories: 1
plugin_habits: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Languages plugin
Expand All @@ -149,7 +139,6 @@ jobs:
repositories: 1
plugin_languages: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Follow-up plugin
Expand All @@ -160,7 +149,6 @@ jobs:
repositories: 1
plugin_followup: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Lines plugin
Expand All @@ -171,7 +159,6 @@ jobs:
repositories: 1
plugin_lines: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Traffic plugin
Expand All @@ -182,7 +169,6 @@ jobs:
repositories: 1
plugin_traffic: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Gists plugin
Expand All @@ -193,7 +179,6 @@ jobs:
repositories: 1
plugin_gists: yes
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Topics plugin (stars)
Expand All @@ -205,7 +190,6 @@ jobs:
plugin_topics: yes
plugin_topics_sort: stars
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Topics plugin (activity)
Expand All @@ -217,7 +201,6 @@ jobs:
plugin_topics: yes
plugin_topics_sort: activity
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Topics plugin (starred)
Expand All @@ -229,7 +212,6 @@ jobs:
plugin_topics: yes
plugin_topics_sort: starred
plugins_errors_fatal: yes
verify: yes
dryrun: yes

- name: Topics plugin (random)
Expand All @@ -241,5 +223,4 @@ jobs:
plugin_topics: yes
plugin_topics_sort: random
plugins_errors_fatal: yes
verify: yes
dryrun: yes
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ inputs:
description: Number of starred topics to display
default: 15

# Projects plugins
# Display active projects
plugin_projects:
description: Display active projects
default: no

# Limit the number of projects displayed
# Between 1 and 100
plugin_projects_limit:
description: Number of active projects to display
default: 4

# Enable debug mode
# Be sure to put all secrets in your repository secrets before to avoid any leaks !
debug:
Expand Down
24 changes: 21 additions & 3 deletions action/dist/index.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions action/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
isocalendar:{enabled:bool(core.getInput("plugin_isocalendar"))},
gists:{enabled:bool(core.getInput("plugin_gists"))},
topics:{enabled:bool(core.getInput("plugin_topics"))},
projects:{enabled:bool(core.getInput("projects"))},
}
let q = Object.fromEntries(Object.entries(plugins).filter(([key, plugin]) => plugin.enabled).map(([key]) => [key, true]))
console.log(`Plugins enabled | ${Object.entries(plugins).filter(([key, plugin]) => plugin.enabled).map(([key]) => key).join(", ")}`)
Expand Down Expand Up @@ -123,6 +124,12 @@
console.log(`Topics sort mode | ${q["topics.sort"]}`)
console.log(`Topics limit | ${q["topics.limit"]}`)
}
//Projects
if (plugins.projects.enabled) {
for (const option of ["limit"])
q[`projects.${option}`] = core.getInput(`plugin_projects_${option}`) || null
console.log(`Projects limit | ${q["projects.limit"]}`)
}

//Repositories to use
const repositories = Number(core.getInput("repositories")) || 100
Expand Down
3 changes: 3 additions & 0 deletions settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
},
"topics":{ "//":"Topics plugin",
"enabled":false, "//":"Enable or disable starred topics display"
},
"projects":{ "//":"Projects plugin",
"enabled":false, "//":"Enable or disable personal projects display"
}
}
}
2 changes: 2 additions & 0 deletions src/plugins/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import music from "./music/index.mjs"
import pagespeed from "./pagespeed/index.mjs"
import posts from "./posts/index.mjs"
import projects from "./projects/index.mjs"
import selfskip from "./selfskip/index.mjs"
import topics from "./topics/index.mjs"
import traffic from "./traffic/index.mjs"
Expand All @@ -25,6 +26,7 @@
music,
pagespeed,
posts,
projects,
selfskip,
topics,
traffic,
Expand Down
58 changes: 58 additions & 0 deletions src/plugins/projects/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//Setup
export default async function ({login, graphql, q}, {enabled = false} = {}) {
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
if ((!enabled)||(!q.projects))
return null
//Parameters override
let {"projects.limit":limit = 4} = q
//Limit
limit = Math.max(1, Math.min(100, Number(limit)))
//Retrieve contribution calendar from graphql api
const {user:{projects}} = await graphql(`
query Projects {
user(login: "${login}") {
projects(last: ${limit}, states: OPEN, orderBy: {field: UPDATED_AT, direction: DESC}) {
totalCount
nodes {
name
updatedAt
progress {
doneCount
inProgressCount
todoCount
enabled
}
}
}
}
}
`
)
//Iterate through projects and format them
const list = []
for (const project of projects.nodes) {
//Format date
const time = (Date.now()-new Date(project.updatedAt).getTime())/(24*60*60*1000)
let updated = project.updatedAt
if (time < 1)
updated = "less than 1 day ago"
else if (time < 30)
updated = `${Math.floor(time)} day${time >= 2 ? "s" : ""} ago`
else
updated = new Date(project.updatedAt).toDateString().substring(4)
//Format progress
const {enabled, todoCount:todo, inProgressCount:doing, doneCount:done} = project.progress
//Append
list.push({name:project.name, updated, progress:{enabled, todo, doing, done, total:todo+doing+done}})
}
//Results
return {list, totalCount:projects.totalCount}
}
//Handle errors
catch (error) {
console.debug(error)
throw {error:{message:`An error occured`}}
}
}
64 changes: 62 additions & 2 deletions src/templates/classic/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1d11145

Please sign in to comment.