Add support for languages details for repository template

This commit is contained in:
lowlighter
2021-02-09 18:50:57 +01:00
parent b80eecc3f5
commit a202469d99

View File

@@ -1,6 +1,9 @@
<% if (plugins.languages) { %> <% if (plugins.languages) { %>
<section class="column"> <section class="column">
<h3>Most used languages</h3> <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="M1.5 2.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v8.5a.25.25 0 01-.25.25h-6.5a.75.75 0 00-.53.22L4.5 14.44v-2.19a.75.75 0 00-.75-.75h-2a.25.25 0 01-.25-.25v-8.5zM1.75 1A1.75 1.75 0 000 2.75v8.5C0 12.216.784 13 1.75 13H3v1.543a1.457 1.457 0 002.487 1.03L8.061 13h6.189A1.75 1.75 0 0016 11.25v-8.5A1.75 1.75 0 0014.25 1H1.75zm5.03 3.47a.75.75 0 010 1.06L5.31 7l1.47 1.47a.75.75 0 01-1.06 1.06l-2-2a.75.75 0 010-1.06l2-2a.75.75 0 011.06 0zm2.44 0a.75.75 0 000 1.06L10.69 7 9.22 8.47a.75.75 0 001.06 1.06l2-2a.75.75 0 000-1.06l-2-2a.75.75 0 00-1.06 0z"></path></svg>
Most used languages
</h2>
<% if (plugins.languages.error) { %> <% if (plugins.languages.error) { %>
<section> <section>
<div class="field error"> <div class="field error">
@@ -18,14 +21,35 @@
<rect mask="url(#languages-bar)" x="<%= x*460 %>" y="0" width="<%= value*460 %>" height="8" fill="<%= color %>"/> <rect mask="url(#languages-bar)" x="<%= x*460 %>" y="0" width="<%= value*460 %>" height="8" fill="<%= color %>"/>
<% } %> <% } %>
</svg> </svg>
<div class="field center horizontal-wrap fill-width"> <% if (plugins.languages.details?.length) { %>
<% for (const {name, value, color} of plugins.languages.favorites) { %> <div class="row fill-width">
<div class="field center no-wrap language"> <% for (const row of [0, 1]) { %>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill="<%= color %>" fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8z"></path></svg> <section>
<%= name %> <% for (const {name, value, color, size} of plugins.languages.favorites.filter((_, i) => i%2 === row)) { %>
</div> <div class="field language details">
<% } %> <div class="field">
</div> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill="<%= color %>" fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8z"></path></svg>
<%= name %>
</div>
<small>
<% if (plugins.languages.details.includes("bytes-size")) { %> <div><%= f.bytes(size) %></div><% } %>
<% if (plugins.languages.details.includes("percentage")) { %> <div><%= f.percentage(value) %></div><% } %>
</small>
</div>
<% } %>
</section>
<% } %>
</div>
<% } else { %>
<div class="field center horizontal-wrap fill-width">
<% for (const {name, value, color} of plugins.languages.favorites) { %>
<div class="field center no-wrap language">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill="<%= color %>" fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8z"></path></svg>
<%= name %>
</div>
<% } %>
</div>
<% } %>
<% } %> <% } %>
</section> </section>
<% } %> <% } %>