Skip to content

Commit c9961e8

Browse files
authored
Projects plugin : Add new option plugin_projects_descriptions (lowlighter#75)
1 parent 5e0ee81 commit c9961e8

File tree

9 files changed

+48
-6
lines changed

9 files changed

+48
-6
lines changed

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ inputs:
374374
description: Number of active projects to display
375375
default: 4
376376

377+
# Display projects descriptions if enabled
378+
plugin_projects_descriptions:
379+
description: Display projects descriptions
380+
default: no
381+
377382
# Tweets plugin
378383
# Enable it to display recent tweets of the twitter username attached to "user"
379384
plugin_tweets:

source/app/action/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@
210210
info(`Projects ${option}`, q[`projects.${option}`] = input.string(`plugin_projects_${option}`))
211211
for (const option of ["limit"])
212212
info(`Projects ${option}`, q[`projects.${option}`] = input.number(`plugin_projects_${option}`))
213+
for (const option of ["descriptions"])
214+
info(`Projects ${option}`, q[`projects.${option}`] = input.bool(`plugin_projects_${option}`))
213215
}
214216
//Tweets
215217
if (plugins.tweets.enabled) {

source/app/mocks.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
}
211211
//Gists query
212212
if (/^query Gists /.test(query)) {
213-
console.debug(`metrics/compute/mocks > mocking graphql api result > Projects`)
213+
console.debug(`metrics/compute/mocks > mocking graphql api result > Gists`)
214214
return /after: "MOCKED_CURSOR"/m.test(query) ? ({
215215
user:{
216216
gists:{
@@ -258,6 +258,7 @@
258258
{
259259
name:"User-owned project",
260260
updatedAt:`${faker.date.recent()}`,
261+
body:faker.lorem.paragraph(),
261262
progress:{
262263
doneCount:faker.random.number(10),
263264
inProgressCount:faker.random.number(10),
@@ -279,6 +280,7 @@
279280
project:{
280281
name:"Repository project example",
281282
updatedAt:`${faker.date.recent()}`,
283+
body:faker.lorem.paragraph(),
282284
progress:{
283285
doneCount:faker.random.number(10),
284286
inProgressCount:faker.random.number(10),

source/plugins/projects/index.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if ((!enabled)||(!q.projects))
77
return null
88
//Parameters override
9-
let {"projects.limit":limit = 4, "projects.repositories":repositories = ""} = q
9+
let {"projects.limit":limit = 4, "projects.repositories":repositories = "", "projects.descriptions":descriptions = false} = q
1010
//Repositories projects
1111
repositories = decodeURIComponent(repositories ?? "").split(",").map(repository => repository.trim()).filter(repository => /[-\w]+[/][-\w]+[/]projects[/]\d+/.test(repository)) ?? []
1212
//Limit
@@ -41,13 +41,13 @@
4141
//Format progress
4242
const {enabled, todoCount:todo, inProgressCount:doing, doneCount:done} = project.progress
4343
//Append
44-
list.push({name:project.name, updated, progress:{enabled, todo, doing, done, total:todo+doing+done}})
44+
list.push({name:project.name, updated, description:project.body, progress:{enabled, todo, doing, done, total:todo+doing+done}})
4545
}
4646
//Limit
4747
console.debug(`metrics/compute/${login}/plugins > projects > keeping only ${limit} projects`)
4848
list.splice(limit)
4949
//Results
50-
return {list, totalCount:projects.totalCount}
50+
return {list, totalCount:projects.totalCount, descriptions}
5151
}
5252
//Handle errors
5353
catch (error) {

source/queries/projects.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ query Projects {
44
totalCount
55
nodes {
66
name
7+
body
78
updatedAt
89
progress {
910
doneCount

source/queries/projects.repository.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ query RepositoryProject {
33
repository(name: "$repository") {
44
project(number: $id) {
55
name
6+
body
67
updatedAt
78
progress {
89
doneCount

source/templates/classic/partials/projects.ejs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</div>
1414
</section>
1515
<% } else { %>
16-
<section>
17-
<% for (const {name, updated, progress} of plugins.projects.list) { %>
16+
<section class="project">
17+
<% for (const {name, updated, progress, description = ""} of plugins.projects.list) { %>
1818
<div class="row fill-width">
1919
<section>
2020
<div class="field">
@@ -23,6 +23,15 @@
2323
</div>
2424
</section>
2525
</div>
26+
<% if (plugins.projects.descriptions) { %>
27+
<div class="row fill-width">
28+
<section>
29+
<div class="field description">
30+
<%= description %>
31+
</div>
32+
</section>
33+
</div>
34+
<% } %>
2635
<div class="row">
2736
<section>
2837
<div class="field">

source/templates/classic/style.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,22 @@
511511
margin: 0 2px;
512512
}
513513

514+
/* Projects */
515+
.project .description {
516+
overflow: hidden;
517+
text-overflow: ellipsis;
518+
display: block;
519+
width: 420px;
520+
margin-left: 37px;
521+
max-height: 38px;
522+
font-size: 12px;
523+
white-space: normal;
524+
/* May not work in all browsers */
525+
display: -webkit-box;
526+
-webkit-line-clamp: 2;
527+
-webkit-box-orient: vertical;
528+
}
529+
514530
/* Fade animation */
515531
.af {
516532
opacity: 0;

tests/metrics.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@
211211
plugin_projects_repositories:"lowlighter/metrics/projects/1",
212212
plugin_projects_limit:0,
213213
}, {skip:["terminal"]}],
214+
["Projects plugin (descriptions)", {
215+
plugin_projects:true,
216+
plugin_projects_repositories:"lowlighter/metrics/projects/1",
217+
plugin_projects_limit:0,
218+
plugin_projects_descriptions:true,
219+
}, {skip:["terminal"]}],
214220
["Lines plugin (default)", {
215221
base:"repositories",
216222
plugin_lines:true,

0 commit comments

Comments
 (0)