feat(plugins/lines): add plugin_lines_sections and new features (#1151) [skip ci]

This commit is contained in:
Simon Lecoq
2022-07-26 01:19:34 +02:00
committed by GitHub
parent ae66ccbe6b
commit c2f0cbe2b1
11 changed files with 297 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
"introduction",
"base.activity+community",
"base.repositories",
"lines",
"followup",
"discussions",
"languages",

View File

@@ -28,7 +28,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" d="M2.5 3.5c0-.133.058-.318.282-.55.227-.237.592-.484 1.1-.708C4.899 1.795 6.354 1.5 8 1.5c1.647 0 3.102.295 4.117.742.51.224.874.47 1.101.707.224.233.282.418.282.551 0 .133-.058.318-.282.55-.227.237-.592.484-1.1.708C11.101 5.205 9.646 5.5 8 5.5c-1.647 0-3.102-.295-4.117-.742-.51-.224-.874-.47-1.101-.707-.224-.233-.282-.418-.282-.551zM1 3.5c0-.626.292-1.165.7-1.59.406-.422.956-.767 1.579-1.041C4.525.32 6.195 0 8 0c1.805 0 3.475.32 4.722.869.622.274 1.172.62 1.578 1.04.408.426.7.965.7 1.591v9c0 .626-.292 1.165-.7 1.59-.406.422-.956.767-1.579 1.041C11.476 15.68 9.806 16 8 16c-1.805 0-3.475-.32-4.721-.869-.623-.274-1.173-.62-1.579-1.04-.408-.426-.7-.965-.7-1.591v-9zM2.5 8V5.724c.241.15.503.286.779.407C4.525 6.68 6.195 7 8 7c1.805 0 3.475-.32 4.722-.869.275-.121.537-.257.778-.407V8c0 .133-.058.318-.282.55-.227.237-.592.484-1.1.708C11.101 9.705 9.646 10 8 10c-1.647 0-3.102-.295-4.117-.742-.51-.224-.874-.47-1.101-.707C2.558 8.318 2.5 8.133 2.5 8zm0 2.225V12.5c0 .133.058.318.282.55.227.237.592.484 1.1.708 1.016.447 2.471.742 4.118.742 1.647 0 3.102-.295 4.117-.742.51-.224.874-.47 1.101-.707.224-.233.282-.418.282-.551v-2.275c-.241.15-.503.285-.778.406-1.247.549-2.917.869-4.722.869-1.805 0-3.475-.32-4.721-.869a6.236 6.236 0 01-.779-.406z"></path></svg>
<%= computed.diskUsage %> used
</div>
<% if (plugins.lines) { %>
<% if ((plugins.lines)&&(plugins.lines.sections?.includes("base"))) { %>
<div class="field <%= plugins.lines.error ? 'error' : '' %>">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 1.5a.25.25 0 00-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25V4.664a.25.25 0 00-.073-.177l-2.914-2.914a.25.25 0 00-.177-.073H2.75zM1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0113.25 16H2.75A1.75 1.75 0 011 14.25V1.75zm7 1.5a.75.75 0 01.75.75v1.5h1.5a.75.75 0 010 1.5h-1.5v1.5a.75.75 0 01-1.5 0V7h-1.5a.75.75 0 010-1.5h1.5V4A.75.75 0 018 3.25zm-3 8a.75.75 0 01.75-.75h4.5a.75.75 0 010 1.5h-4.5a.75.75 0 01-.75-.75z"></path></svg>
<% if (plugins.lines.error) { %>

View File

@@ -1 +1,48 @@
<%# Included in base.repositories.ejs %>
<% if ((plugins.lines)&&((plugins.lines.sections.includes("history"))||(plugins.lines.sections.includes("repositories")))) { %>
<section>
<h2 class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 1.5a.25.25 0 00-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25V4.664a.25.25 0 00-.073-.177l-2.914-2.914a.25.25 0 00-.177-.073H2.75zM1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0113.25 16H2.75A1.75 1.75 0 011 14.25V1.75zm7 1.5a.75.75 0 01.75.75v1.5h1.5a.75.75 0 010 1.5h-1.5v1.5a.75.75 0 01-1.5 0V7h-1.5a.75.75 0 010-1.5h1.5V4A.75.75 0 018 3.25zm-3 8a.75.75 0 01.75-.75h4.5a.75.75 0 010 1.5h-4.5a.75.75 0 01-.75-.75z"></path></svg>
Lines of code pushed
</h2>
<% if (plugins.lines.error) { %>
<div class="row">
<section>
<div class="field error">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.343 13.657A8 8 0 1113.657 2.343 8 8 0 012.343 13.657zM6.03 4.97a.75.75 0 00-1.06 1.06L6.94 8 4.97 9.97a.75.75 0 101.06 1.06L8 9.06l1.97 1.97a.75.75 0 101.06-1.06L9.06 8l1.97-1.97a.75.75 0 10-1.06-1.06L8 6.94 6.03 4.97z"></path></svg>
<%= plugins.lines.error.message %>
</div>
</section>
</div>
<% } else { %>
<% if (plugins.lines.sections?.includes("repositories")) { %>
<div class="row">
<section>
<% for (const {handle, added, deleted, changed} of plugins.lines.repos) { %>
<div class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 5.5a2.5 2.5 0 100 5 2.5 2.5 0 000-5zM4 8a4 4 0 118 0 4 4 0 01-8 0z"></path></svg>
<span class="diff-handle"><%= handle %></span>
</div>
<% } %>
</section>
<section>
<% for (const {handle, added, deleted, changed} of plugins.lines.repos) { %>
<div class="field">
<% for (let i = 1; i <= 5; i++) { %>
<div class="diff-box <%= (added+changed+deleted) ? (added+changed)/(added+deleted+2*changed) >= (i === 3 ? 0.5 : i*0.2) ? 'added' : 'deleted' : '' %>"></div>
<% } %>
<div class="diff-stats"><span class="added"><%= `+${f(added+changed)}`.padStart(7) %></span> <span class="deleted"><%= `-${f(deleted+changed)}`.padStart(7) %></span></div>
<span>&nbsp;</span>
</div>
<% } %>
</section>
</div>
<% } %>
<% if ((plugins.lines.sections?.includes("history"))&&(plugins.lines.history)) { %>
<div class="row margin-bottom">
<h3 class="margin-lr-auto">Diff history</h3>
<%- plugins.lines.history %>
</div>
<% } %>
<% } %>
</section>
<% } %>

View File

@@ -853,6 +853,47 @@
fill: currentColor;
}
/* Diff stats */
.diff-handle {
color: #58a6ff;
max-width: 200px;
text-overflow: ellipsis;
overflow: hidden;
}
.large .diff-handle {
max-width: 400px;
}
.diff-box {
display: inline-block;
width: 8px;
height: 8px;
margin-left: 1px;
background-color: rgba(110, 118, 129, 0.4);
border: 1px solid rgba(246, 240, 251, 0.1);
}
.diff-box:first-child {
margin-left: 9px;
}
.diff-box.added {
background-color: rgb(63, 185, 80);
}
.diff-box.deleted {
background-color: rgb(218, 54, 51);
}
.diff-stats {
margin-left: 4px;
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
font-weight: bold;
font-size: 12px;
white-space: pre;
}
.added {
color: rgb(63, 185, 80);
}
.deleted {
color: rgb(218, 54, 51);
}
/* People */
.people {
padding: 0 10px;