mirror of
https://github.com/MeiK2333/github-style.git
synced 2025-10-07 01:54:06 +00:00
Add contributions graph
This commit is contained in:
@@ -55,6 +55,133 @@
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{{ if eq .Site.Params.contributions "post" }}
|
||||
<div class="mt-4 position-relative">
|
||||
<div class="js-yearly-contributions">
|
||||
<div class="position-relative">
|
||||
<h2 class="f4 text-normal mb-2">
|
||||
{{ $scratch := newScratch }}
|
||||
{{ if eq now.Weekday.String "Monday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 1 }}
|
||||
{{ else if eq now.Weekday.String "Tuesday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 2 }}
|
||||
{{ else if eq now.Weekday.String "Wednesday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 3 }}
|
||||
{{ else if eq now.Weekday.String "Thursday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 4 }}
|
||||
{{ else if eq now.Weekday.String "Friday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 5 }}
|
||||
{{ else if eq now.Weekday.String "Saturday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 6 }}
|
||||
{{ else if eq now.Weekday.String "Sunday" }}
|
||||
{{ $scratch.Set "dayOfWeek" 7 }}
|
||||
{{ end }}
|
||||
{{ $dayOfWeek := $scratch.Get "dayOfWeek" }}
|
||||
|
||||
{{ $allDays := add 364 $dayOfWeek }}
|
||||
{{ $startDate := (time (now.Format "2006-01-02")).AddDate 0 0 (int (sub 0 $allDays)) }}
|
||||
{{ $startMonth := 0 }}
|
||||
{{ $monthPos := slice }}
|
||||
{{ $weeks := 53 }}
|
||||
{{ $count := 0 }}
|
||||
|
||||
{{ $mainSections := .Site.Params.mainSections | default (slice "post") }}
|
||||
{{ $section := where .Site.RegularPages "Section" "in" $mainSections }}
|
||||
|
||||
{{ range $section }}
|
||||
{{ $scratch.Add (.PublishDate.Format "2006-01-02") 1 }}
|
||||
{{ if le $startDate .PublishDate }}
|
||||
{{ $count = add $count 1 }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $count }} contributions in the last year
|
||||
</h2>
|
||||
<div class="js-profile-timeline-year-list">
|
||||
<a href="?tab=overview&from=from&to=to" class="js-year-link selected"></a>
|
||||
</div>
|
||||
<div class="border border-gray-dark py-2 graph-before-activity-overview">
|
||||
<div class="js-calendar-graph mx-3 d-flex flex-column flex-items-end flex-xl-items-center overflow-hidden pt-1 is-graph-loading graph-canvas calendar-graph height-full text-center"
|
||||
data-from="{{ $startDate.Format "2006-01-02" }} 00:00:00"
|
||||
data-to="{{ now.Format "2006-01-02" }} 00:00:00" data-org=""
|
||||
data-url="/{{ .Site.Params.github }}">
|
||||
|
||||
<svg width="828" height="128" class="js-calendar-graph-svg">
|
||||
<g transform="translate(10, 20)">
|
||||
{{ range $i, $sequence := (seq $weeks) }}
|
||||
<g transform="translate({{mul $i 16}}, 0)">
|
||||
{{ range $j, $seq := (seq 7) }}
|
||||
|
||||
{{ $date := $startDate.AddDate 0 0 (int (add (mul $i 7) $j)) }}
|
||||
{{ $color := newScratch }}
|
||||
|
||||
{{ if eq $j 0 }}
|
||||
{{ if ne $startMonth $date.Month }}
|
||||
{{ $monthPos = $monthPos | append $i}}
|
||||
{{ $startMonth = $date.Month }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $dateCount := $scratch.Get ($date.Format "2006-01-02") }}
|
||||
{{ if eq $dateCount nil }}
|
||||
{{ $dateCount = 0 }}
|
||||
{{ end }}
|
||||
|
||||
{{ if eq $dateCount 0 }}
|
||||
{{ $color.Set "color" "#ebedf0" }}
|
||||
{{ else if eq $dateCount 1 }}
|
||||
{{ $color.Set "color" "#c6e48b" }}
|
||||
{{ else if eq $dateCount 2 }}
|
||||
{{ $color.Set "color" "#7bc96f" }}
|
||||
{{ else if eq $dateCount 3 }}
|
||||
{{ $color.Set "color" "#239a3b" }}
|
||||
{{ else }}
|
||||
{{ $color.Set "color" "#196127" }}
|
||||
{{ end }}
|
||||
<rect class="day" width="12" height="12" x="{{sub 16 $i}}" y="{{mul 15 $j}}"
|
||||
fill="{{ $color.Get "color" }}" data-count="{{ $dateCount }}"
|
||||
data-date="{{ $date.Format "2006-01-02" }}"></rect>
|
||||
{{ end }}
|
||||
</g>
|
||||
{{ end }}
|
||||
{{ range $index, $element := first 12 $monthPos }}
|
||||
<text x="{{ add (mul 15 $element) 16 }}" y="-9"
|
||||
class="month">{{ (now.AddDate 0 $index 0).Format "Jan" }}</text>
|
||||
{{ end }}
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="8"
|
||||
style="display: none;">Sun</text>
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="25">Mon</text>
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="32"
|
||||
style="display: none;">Tue</text>
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="56">Wed</text>
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="57"
|
||||
style="display: none;">Thu</text>
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="85">Fri</text>
|
||||
<text text-anchor="start" class="wday" dx="-10" dy="81"
|
||||
style="display: none;">Sat</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
<div class="contrib-footer clearfix mt-1 mx-3 px-3 pb-1">
|
||||
<div class="contrib-legend text-gray"
|
||||
title="A summary of pull requests, issues opened, and commits to the default and gh-pages branches.">
|
||||
Less
|
||||
<ul class="legend">
|
||||
<li style="background-color: #ebedf0"></li>
|
||||
<li style="background-color: #c6e48b"></li>
|
||||
<li style="background-color: #7bc96f"></li>
|
||||
<li style="background-color: #239a3b"></li>
|
||||
<li style="background-color: #196127"></li>
|
||||
</ul>
|
||||
More
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
<div id="pinned-items-modal-wrapper"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user