diff options
| -rw-r--r-- | www/cgit.css | 52 | ||||
| -rw-r--r-- | www/cgit.js | 108 |
2 files changed, 129 insertions, 31 deletions
diff --git a/www/cgit.css b/www/cgit.css index c3e015f..c0435e0 100644 --- a/www/cgit.css +++ b/www/cgit.css | |||
| @@ -66,6 +66,15 @@ div#cgit table#header td.logo { | |||
| 66 | padding-right: 1rem; | 66 | padding-right: 1rem; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | div#cgit table#header td.logo img { | ||
| 70 | max-height: 75px; | ||
| 71 | max-width: 100%; | ||
| 72 | width: auto; | ||
| 73 | height: auto; | ||
| 74 | border: none; | ||
| 75 | vertical-align: middle; | ||
| 76 | } | ||
| 77 | |||
| 69 | div#cgit table#header td.main { | 78 | div#cgit table#header td.main { |
| 70 | font-size: 1.5rem; | 79 | font-size: 1.5rem; |
| 71 | font-weight: bold; | 80 | font-weight: bold; |
| @@ -87,7 +96,7 @@ div#cgit table#header td.form { | |||
| 87 | div#cgit table#header td.sub { | 96 | div#cgit table#header td.sub { |
| 88 | display: block; | 97 | display: block; |
| 89 | width: 100%; | 98 | width: 100%; |
| 90 | padding-top: 0.25rem; | 99 | padding-top: 0.5rem; |
| 91 | color: var(--color-outline); | 100 | color: var(--color-outline); |
| 92 | font-size: 0.9rem; | 101 | font-size: 0.9rem; |
| 93 | border-top: none; | 102 | border-top: none; |
| @@ -240,6 +249,7 @@ div#cgit table.list th { | |||
| 240 | div#cgit table.list td { | 249 | div#cgit table.list td { |
| 241 | padding: 0.75rem 0.5rem; | 250 | padding: 0.75rem 0.5rem; |
| 242 | vertical-align: middle; | 251 | vertical-align: middle; |
| 252 | white-space: nowrap; | ||
| 243 | } | 253 | } |
| 244 | 254 | ||
| 245 | /* Commit Graph columns */ | 255 | /* Commit Graph columns */ |
| @@ -251,13 +261,13 @@ div#cgit table.list td.commitgraph { | |||
| 251 | 261 | ||
| 252 | /* 7. Diffs and Code */ | 262 | /* 7. Diffs and Code */ |
| 253 | div#cgit table.blob, | 263 | div#cgit table.blob, |
| 264 | div#cgit table.bin-blob, | ||
| 254 | div#cgit table.diff, | 265 | div#cgit table.diff, |
| 255 | div#cgit table.ssdiff { | 266 | div#cgit table.ssdiff { |
| 256 | width: 100%; | 267 | width: 100%; |
| 257 | border: 1px solid var(--color-outline-variant); | 268 | border: 1px solid var(--color-outline-variant); |
| 258 | border-collapse: collapse; | 269 | border-collapse: collapse; |
| 259 | border-radius: 4px; | 270 | border-radius: 4px; |
| 260 | overflow: hidden; | ||
| 261 | margin-top: 1rem; | 271 | margin-top: 1rem; |
| 262 | background: var(--color-surface-container-lowest); | 272 | background: var(--color-surface-container-lowest); |
| 263 | } | 273 | } |
| @@ -295,13 +305,6 @@ div#cgit table.ssdiff td { | |||
| 295 | } | 305 | } |
| 296 | 306 | ||
| 297 | div#cgit table.bin-blob { | 307 | div#cgit table.bin-blob { |
| 298 | width: 100%; | ||
| 299 | border: 1px solid var(--color-outline-variant); | ||
| 300 | border-collapse: collapse; | ||
| 301 | border-radius: 4px; | ||
| 302 | overflow: hidden; | ||
| 303 | margin-top: 1rem; | ||
| 304 | background: var(--color-surface-container-lowest); | ||
| 305 | font-family: monospace; | 308 | font-family: monospace; |
| 306 | font-size: 0.95em; | 309 | font-size: 0.95em; |
| 307 | } | 310 | } |
| @@ -449,6 +452,10 @@ div#cgit div.commit-msg { | |||
| 449 | color: var(--color-on-surface); | 452 | color: var(--color-on-surface); |
| 450 | } | 453 | } |
| 451 | 454 | ||
| 455 | div#cgit div.commit-msg:empty { | ||
| 456 | display: none; | ||
| 457 | } | ||
| 458 | |||
| 452 | /* 10. Footer */ | 459 | /* 10. Footer */ |
| 453 | div#cgit div.footer { | 460 | div#cgit div.footer { |
| 454 | margin-top: auto; | 461 | margin-top: auto; |
| @@ -469,17 +476,8 @@ div#cgit div.error { | |||
| 469 | 476 | ||
| 470 | /* 11. Responsive Adjustments */ | 477 | /* 11. Responsive Adjustments */ |
| 471 | @media only screen and (max-width: 768px) { | 478 | @media only screen and (max-width: 768px) { |
| 472 | div#cgit table#header { | 479 | div#cgit table#header td.logo img { |
| 473 | flex-direction: column; | 480 | max-height: 40px; |
| 474 | align-items: flex-start; | ||
| 475 | } | ||
| 476 | |||
| 477 | div#cgit table#header td.logo, | ||
| 478 | div#cgit table#header td.main, | ||
| 479 | div#cgit table#header td.form { | ||
| 480 | width: 100%; | ||
| 481 | text-align: left; | ||
| 482 | margin-bottom: 0.5rem; | ||
| 483 | } | 481 | } |
| 484 | 482 | ||
| 485 | div#cgit table.tabs { | 483 | div#cgit table.tabs { |
| @@ -503,20 +501,12 @@ div#cgit div.error { | |||
| 503 | overflow-x: auto; | 501 | overflow-x: auto; |
| 504 | } | 502 | } |
| 505 | 503 | ||
| 506 | /* Force tables to scroll on small screens */ | 504 | /* Make div.scrollable is scrollable*/ |
| 507 | div#cgit table.list, | 505 | div#cgit div.scrollable { |
| 508 | div#cgit table.blob, | ||
| 509 | div#cgit table.diff { | ||
| 510 | white-space: nowrap; | ||
| 511 | } | ||
| 512 | |||
| 513 | div#cgit table.bin-blob { | ||
| 514 | white-space: nowrap; | ||
| 515 | display: block; /* Позволяет скроллить саму таблицу */ | ||
| 516 | overflow-x: auto; | 506 | overflow-x: auto; |
| 517 | } | 507 | } |
| 518 | 508 | ||
| 519 | div#cgit table.bin-blob th, | 509 | div#cgit div#cgit table.bin-blob th, |
| 520 | div#cgit table.bin-blob td { | 510 | div#cgit table.bin-blob td { |
| 521 | padding: 0.5rem; | 511 | padding: 0.5rem; |
| 522 | } | 512 | } |
diff --git a/www/cgit.js b/www/cgit.js new file mode 100644 index 0000000..52a8c3c --- /dev/null +++ b/www/cgit.js | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | /* cgit.js: javacript functions for cgit | ||
| 2 | * | ||
| 3 | * Copyright (C) 2006-2018 cgit Development Team <cgit@lists.zx2c4.com> | ||
| 4 | * | ||
| 5 | * Licensed under GNU General Public License v2 | ||
| 6 | * (see COPYING for full license text) | ||
| 7 | */ | ||
| 8 | |||
| 9 | (function () { | ||
| 10 | /* This follows the logic and suffixes used in ui-shared.c */ | ||
| 11 | |||
| 12 | var age_classes = ["age-mins", "age-hours", "age-days", "age-weeks", "age-months", "age-years"]; | ||
| 13 | var age_suffix = ["min.", "hours", "days", "weeks", "months", "years", "years"]; | ||
| 14 | var age_next = [ | ||
| 15 | 60, | ||
| 16 | 3600, | ||
| 17 | 24 * 3600, | ||
| 18 | 7 * 24 * 3600, | ||
| 19 | 30 * 24 * 3600, | ||
| 20 | 365 * 24 * 3600, | ||
| 21 | 365 * 24 * 3600, | ||
| 22 | ]; | ||
| 23 | var age_limit = [ | ||
| 24 | 7200, | ||
| 25 | 24 * 7200, | ||
| 26 | 7 * 24 * 7200, | ||
| 27 | 30 * 24 * 7200, | ||
| 28 | 365 * 25 * 7200, | ||
| 29 | 365 * 25 * 7200, | ||
| 30 | ]; | ||
| 31 | var update_next = [10, 5 * 60, 1800, 24 * 3600, 24 * 3600, 24 * 3600, 24 * 3600]; | ||
| 32 | |||
| 33 | function render_age(e, age) { | ||
| 34 | var t, n; | ||
| 35 | |||
| 36 | for (n = 0; n < age_classes.length; n++) if (age < age_limit[n]) break; | ||
| 37 | |||
| 38 | t = Math.round(age / age_next[n]) + " " + age_suffix[n]; | ||
| 39 | |||
| 40 | if (e.textContent != t) { | ||
| 41 | e.textContent = t; | ||
| 42 | if (n == age_classes.length) n--; | ||
| 43 | if (e.className != age_classes[n]) e.className = age_classes[n]; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | function aging() { | ||
| 48 | var n, | ||
| 49 | next = 24 * 3600, | ||
| 50 | now_ut = Math.round(new Date().getTime() / 1000); | ||
| 51 | |||
| 52 | for (n = 0; n < age_classes.length; n++) { | ||
| 53 | var m, | ||
| 54 | elems = document.getElementsByClassName(age_classes[n]); | ||
| 55 | |||
| 56 | if (elems.length && update_next[n] < next) next = update_next[n]; | ||
| 57 | |||
| 58 | for (m = 0; m < elems.length; m++) { | ||
| 59 | var age = now_ut - elems[m].getAttribute("data-ut"); | ||
| 60 | |||
| 61 | render_age(elems[m], age); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | /* | ||
| 66 | * We only need to come back when the age might have changed. | ||
| 67 | * Eg, if everything is counted in hours already, once per | ||
| 68 | * 5 minutes is accurate enough. | ||
| 69 | */ | ||
| 70 | |||
| 71 | window.setTimeout(aging, next * 1000); | ||
| 72 | } | ||
| 73 | |||
| 74 | function wrap_tables() { | ||
| 75 | const selectors = [ | ||
| 76 | "div#cgit table.list", | ||
| 77 | "div#cgit table.blob", | ||
| 78 | "div#cgit table.bin-blob", | ||
| 79 | "div#cgit table.diff", | ||
| 80 | "div#cgit table.ssdiff", | ||
| 81 | "div#cgit table.commit-info", | ||
| 82 | ]; | ||
| 83 | |||
| 84 | const tables = document.querySelectorAll(selectors.join(", ")); | ||
| 85 | |||
| 86 | tables.forEach((table) => { | ||
| 87 | if (table.parentNode.classList.contains("scrollable")) { | ||
| 88 | return; | ||
| 89 | } | ||
| 90 | |||
| 91 | const wrapper = document.createElement("div"); | ||
| 92 | wrapper.className = "scrollable"; | ||
| 93 | |||
| 94 | table.parentNode.insertBefore(wrapper, table); | ||
| 95 | wrapper.appendChild(table); | ||
| 96 | }); | ||
| 97 | } | ||
| 98 | |||
| 99 | document.addEventListener( | ||
| 100 | "DOMContentLoaded", | ||
| 101 | function () { | ||
| 102 | /* we can do the aging on DOM content load since no layout dependency */ | ||
| 103 | aging(); | ||
| 104 | wrap_tables(); | ||
| 105 | }, | ||
| 106 | false, | ||
| 107 | ); | ||
| 108 | })(); | ||
