|
119 | 119 | margin-bottom: 1em; |
120 | 120 | } |
121 | 121 |
|
| 122 | + .avatar { |
| 123 | + border-radius: 50%; |
| 124 | + border-style: solid; |
| 125 | + border-color: rgba(255, 255, 255, 0.75); |
| 126 | + background-clip: padding-box; |
| 127 | + background-color: white; |
| 128 | + border-width: 2px; |
| 129 | + vertical-align: middle; |
| 130 | + transition: .2s; |
| 131 | + } |
| 132 | + |
| 133 | + summary .avatar { |
| 134 | + width: 2em; |
| 135 | + } |
| 136 | + |
| 137 | + li .avatar { |
| 138 | + width: 3.5em; |
| 139 | + } |
| 140 | + |
| 141 | + summary .avatar:hover { |
| 142 | + transform: scale(3); |
| 143 | + } |
| 144 | + |
| 145 | + li .avatar:hover, |
| 146 | + .avatar-hover { |
| 147 | + transform: scale(2); |
| 148 | + } |
| 149 | + |
122 | 150 | /*]]>*/ |
123 | 151 | </style> |
124 | 152 | </head> |
@@ -257,6 +285,53 @@ <h2>Table of Contents</h2> |
257 | 285 | targetElement.innerHTML = heading + fileElements.join(''); |
258 | 286 | } |
259 | 287 |
|
| 288 | + function generateAvatar(profileHref) { |
| 289 | + return `<a href="${profileHref}"><img class="avatar" src="${profileHref}.png"/></a>`; |
| 290 | + } |
| 291 | + |
| 292 | + function generateContributorSection(a, logicalHref) { |
| 293 | + const li = a.parentElement; |
| 294 | + if (li.localName == 'li') { |
| 295 | + const ul = li.parentElement; |
| 296 | + if (ul?.localName == 'ul') { |
| 297 | + const details = ul.parentElement; |
| 298 | + if (details?.localName == 'details') { |
| 299 | + const avatar = toElements(`<span>${generateAvatar(logicalHref)} </span>`)[0]; |
| 300 | + li.insertBefore(avatar, a); |
| 301 | + |
| 302 | + const summary = details.querySelector('summary'); |
| 303 | + if (summary.children.length == 0) { |
| 304 | + summary.innerHTML += ' '; |
| 305 | + } |
| 306 | + summary.innerHTML += generateAvatar(logicalHref); |
| 307 | + |
| 308 | + a.onmouseenter = () => { |
| 309 | + avatar.querySelector('img').classList.add('avatar-hover') |
| 310 | + }; |
| 311 | + a.onmouseleave = () => { |
| 312 | + avatar.querySelector('img').classList.remove('avatar-hover') |
| 313 | + }; |
| 314 | + |
| 315 | + |
| 316 | + // We only need to process the overall contributor section once. |
| 317 | + if (ul.style.listStyleType != 'none') { |
| 318 | + ul.style.listStyleType = 'none'; |
| 319 | + ul.style.paddingLeft = '1em'; |
| 320 | + |
| 321 | + summary.onclick = () => { |
| 322 | + setTimeout(() => { |
| 323 | + const avatars = summary.querySelectorAll('*'); |
| 324 | + for (const avatar of avatars) { |
| 325 | + avatar.style.display = details.open ? 'none' : 'inline-block'; |
| 326 | + } |
| 327 | + }, 10); |
| 328 | + }; |
| 329 | + } |
| 330 | + } |
| 331 | + } |
| 332 | + } |
| 333 | + } |
| 334 | + |
260 | 335 | function generateMarkdown(logicalBaseURL, response) { |
261 | 336 | if (response instanceof Array) { |
262 | 337 | generateFileList(response); |
@@ -314,11 +389,15 @@ <h2>Table of Contents</h2> |
314 | 389 |
|
315 | 390 | const logicalHref = new URL(href, logicalBaseURL); |
316 | 391 | if (!logicalHref.pathname.endsWith('.md')) { |
317 | | - const siteURL = toSiteURL(logicalHref); |
318 | | - if (siteURL != null) { |
319 | | - a.href = siteURL; |
320 | | - } else if (!href.startsWith('http')) { |
321 | | - a.href = new URL(`https://github.com/${org}/${repo}/blob/${branch}/${path}/../${href}`); |
| 392 | + if (/^https:\/\/github.com\/[^\/]+$/.exec(logicalHref.toString())) { |
| 393 | + generateContributorSection(a, logicalHref); |
| 394 | + } else { |
| 395 | + const siteURL = toSiteURL(logicalHref); |
| 396 | + if (siteURL != null) { |
| 397 | + a.href = siteURL; |
| 398 | + } else if (!href.startsWith('http')) { |
| 399 | + a.href = new URL(`https://github.com/${org}/${repo}/blob/${branch}/${path}/../${href}`); |
| 400 | + } |
322 | 401 | } |
323 | 402 | continue; |
324 | 403 | } |
@@ -382,12 +461,10 @@ <h2>Table of Contents</h2> |
382 | 461 |
|
383 | 462 | function generatBreadcrumbPath(crumbPath, segment) { |
384 | 463 | const fullPath = `${org}/${repo}/${branch}${crumbPath}`; |
385 | | - console.log(fullPath); |
386 | 464 |
|
387 | 465 | for (const matcher of specializedBreadcrumpbs) { |
388 | 466 | const match = matcher.pattern.exec(fullPath); |
389 | 467 | if (match != null) { |
390 | | - console.log(match); |
391 | 468 | const replacement = matcher.replacement; |
392 | 469 | return replacement; |
393 | 470 | } |
|
0 commit comments