patx/gitman
(#5) Added a lot of stuff because i was bored
open (created by vextoly on Nov 3 at 8:13PM)
vextoly/gitman into patx/gitman
branch main into branch main
Add browser file editing, BSD licenses, preferences with time zones, and a seperate password page.
Comments
Diff
Base 5a613ad7390953e0795167e67a60aebbb881313b to branch main 490cf3553558137f1b268517d93af087f98ef1de
diff --git a/app.py b/app.py
index 0531e79..fd88f82 100644
--- a/app.py
+++ b/app.py
@@ -18,6 +18,7 @@ import sys
import threading
import time
import tempfile
+import zoneinfo
from socketserver import ThreadingMixIn
from pathlib import Path, PurePosixPath
from urllib.parse import parse_qsl, quote, unquote, urlencode, urlparse
@@ -151,6 +152,100 @@ NULL_REV = "null"
NULL_NODE = "0" * 40
EMPTY_TREE_NODE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
README_CANDIDATES = ("README.md", "README.rst", "README.txt", "README")
+LICENSE_FILE_CANDIDATES = ("LICENSE.md", "LICENSE.txt", "LICENSE", "LICENCE.md", "LICENCE.txt", "LICENCE")
+BSD_DISCLAIMER = (
+ "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" "
+ "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE "
+ "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE "
+ "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE "
+ "FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL "
+ "DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR "
+ "SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER "
+ "CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, "
+ "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE "
+ "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+)
+BSD_PERMISSION_FEE = (
+ "Permission to use, copy, modify, and/or distribute this software for any "
+ "purpose with or without fee is hereby granted."
+)
+BSD_FEE_WARRANTY = (
+ "THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH "
+ "REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY "
+ "AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, "
+ "INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM "
+ "LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR "
+ "OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR "
+ "PERFORMANCE OF THIS SOFTWARE."
+)
+BSD_REDISTRIBUTION_CONDITIONS = (
+ "Redistribution and use in source and binary forms, with or without "
+ "modification, are permitted provided that the following conditions are met:\n"
+ "\n"
+ "1. Redistributions of source code must retain the above copyright notice, "
+ "this list of conditions and the following disclaimer.\n"
+ "\n"
+ "2. Redistributions in binary form must reproduce the above copyright notice, "
+ "this list of conditions and the following disclaimer in the documentation "
+ "and/or other materials provided with the distribution."
+)
+LICENSE_TEXTS = {
+ "bsd-0": BSD_PERMISSION_FEE + "\n\n" + BSD_FEE_WARRANTY,
+ "bsd-1": (
+ "Copyright (c) {year}, {holder}\n\n"
+ + BSD_PERMISSION_FEE
+ + "\n\n"
+ + BSD_FEE_WARRANTY
+ ),
+ "bsd-2": (
+ "BSD 2-Clause License\n\n"
+ "Copyright (c) {year}, {holder}\n\n"
+ + BSD_REDISTRIBUTION_CONDITIONS
+ + "\n\n"
+ + BSD_DISCLAIMER
+ ),
+ "bsd-3": (
+ "BSD 3-Clause License\n\n"
+ "Copyright (c) {year}, {holder}\n\n"
+ + BSD_REDISTRIBUTION_CONDITIONS
+ + "\n\n"
+ "3. Neither the name of the copyright holder nor the names of its "
+ "contributors may be used to endorse or promote products derived from "
+ "this software without specific prior written permission.\n\n"
+ + BSD_DISCLAIMER
+ ),
+ "bsd-4": (
+ "BSD 4-Clause License (Original BSD License)\n\n"
+ "Copyright (c) {year}, {holder}. All rights reserved.\n\n"
+ "Redistribution and use in source and binary forms, with or without "
+ "modification, are permitted provided that the following conditions are met:\n"
+ "\n"
+ "1. Redistributions of source code must retain the above copyright notice, "
+ "this list of conditions and the following disclaimer.\n"
+ "\n"
+ "2. Redistributions in binary form must reproduce the above copyright notice, "
+ "this list of conditions and the following disclaimer in the documentation "
+ "and/or other materials provided with the distribution.\n"
+ "\n"
+ "3. All advertising materials mentioning features or use of this software "
+ "must display the following acknowledgement: This product includes software "
+ "developed by {holder}.\n"
+ "\n"
+ "4. Neither the name of the copyright holder nor the names of its "
+ "contributors may be used to endorse or promote products derived from "
+ "this software without specific prior written permission.\n"
+ "\n"
+ + BSD_DISCLAIMER
+ ),
+}
+LICENSE_LABELS = {
+ "": "None/Custom",
+ "bsd-0": "BSD 0-Clause",
+ "bsd-1": "BSD 1-Clause",
+ "bsd-2": "BSD 2-Clause",
+ "bsd-3": "BSD 3-Clause",
+ "bsd-4": "BSD 4-Clause",
+}
MARKDOWN_EXTENSIONS = ("extra", "sane_lists")
MARKDOWN_TAGS = {
"a",
@@ -241,8 +336,8 @@ CSP_HEADER = (
"form-action 'self'; "
"object-src 'none'; "
"img-src 'self' data: http: https:; "
- "style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; "
- "script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com"
+ "style-src 'self' 'unsafe-inline'; "
+ "script-src 'self' 'unsafe-inline'"
)
REPO_INDEX_THREADS = set()
REPO_INDEX_LOCK = threading.Lock()
@@ -355,6 +450,7 @@ def init_db():
display_name TEXT NOT NULL DEFAULT '',
bio TEXT NOT NULL DEFAULT '',
website TEXT NOT NULL DEFAULT '',
+ timezone TEXT NOT NULL DEFAULT 'UTC',
created_at TEXT NOT NULL
);
@@ -547,6 +643,7 @@ def ensure_user_profile_columns(conn):
"display_name": "ALTER TABLE users ADD COLUMN display_name TEXT NOT NULL DEFAULT ''",
"bio": "ALTER TABLE users ADD COLUMN bio TEXT NOT NULL DEFAULT ''",
"website": "ALTER TABLE users ADD COLUMN website TEXT NOT NULL DEFAULT ''",
+ "timezone": "ALTER TABLE users ADD COLUMN timezone TEXT NOT NULL DEFAULT 'UTC'",
}
for name, ddl in profile_columns.items():
if name not in columns:
@@ -1019,6 +1116,7 @@ def render(template_name, **context):
context.setdefault("error", None)
context.setdefault("notice", None)
context.setdefault("csrf_field", csrf_field)
+ context.setdefault("format_datetime", format_datetime)
context.setdefault("render_markdown", render_markdown)
context.setdefault("render_markdown_links", render_markdown_links)
context.setdefault("render_mentions", render_mentions)
@@ -1093,6 +1191,49 @@ def request_per_page(default):
return parse_bounded_int(request.query.get("per_page"), default, minimum=1, maximum=MAX_PAGE_SIZE)
+def available_timezone_choices():
+ try:
+ zones = sorted(zoneinfo.available_timezones())
+ except Exception:
+ zones = []
+ if not zones:
+ zones = ["UTC"]
+ elif "UTC" not in zones:
+ zones = ["UTC", *zones]
+ return zones
+
+
+def user_timezone_name(user):
+ try:
+ name = (user["timezone"] or "").strip() if user else ""
+ except (IndexError, KeyError):
+ name = ""
+ if not name:
+ return "UTC"
+ try:
+ zoneinfo.ZoneInfo(name)
+ except (zoneinfo.ZoneInfoNotFoundError, ValueError, KeyError):
+ return "UTC"
+ return name
+
+
+def format_datetime(value):
+ """Render a stored UTC timestamp in the signed-in user's time zone."""
+ if not value:
+ return ""
+ text = str(value).strip()
+ if text.endswith("Z"):
+ text = text[:-1] + "+00:00"
+ try:
+ parsed = dt.datetime.fromisoformat(text)
+ except ValueError:
+ return str(value)
+ if parsed.tzinfo is None:
+ parsed = parsed.replace(tzinfo=dt.UTC)
+ zone = zoneinfo.ZoneInfo(user_timezone_name(current_user()))
+ return parsed.astimezone(zone).strftime("%Y-%m-%d %H:%M")
+
+
def page_offset(page, per_page):
return (page - 1) * per_page
@@ -2057,6 +2198,90 @@ def fork_repository(owner, source_repo, name, description):
raise
+def default_branch_name(path):
+ completed = run_git(["symbolic-ref", "--short", "HEAD"], cwd=path, check=False)
+ name = completed.stdout.strip() if completed.returncode == 0 else ""
+ return name or "main"
+
+
+def license_text_for_choice(license_choice, holder):
+ template = LICENSE_TEXTS.get(license_choice)
+ if not template:
+ return None
+ return template.format(year=dt.datetime.now(dt.UTC).year, holder=holder)
+
+
+def repo_branch_exists(path, branch):
+ return (
+ run_git(["show-ref", "--verify", "--quiet", f"refs/heads/{branch}"], cwd=path, check=False).returncode == 0
+ )
+
+
+def commit_file_to_repo(repo, path, file_path, content, message, user, branch=None):
+ """Commit text file content to a bare repository through a temporary working clone."""
+ file_path = clean_repo_path(file_path)
+ if branch is None:
+ branch = default_branch_name(path)
+ branch_exists = repo_branch_exists(path, branch)
+
+ with tempfile.TemporaryDirectory(prefix="gitman-edit-") as tempdir:
+ work_path = Path(tempdir) / "work"
+ clone = run_git(["clone", str(path), str(work_path)], check=False, timeout=60)
+ if clone.returncode != 0:
+ raise GitCommandError(clone.stderr.strip() or "Unable to clone repository.", clone.returncode)
+
+ run_git(["config", "user.name", user["username"]], cwd=work_path)
+ run_git(["config", "user.email", f"{user['username']}@gitman.local"], cwd=work_path)
+
+ head_exists = run_git(["rev-parse", "--verify", "HEAD"], cwd=work_path, check=False).returncode == 0
+ if head_exists:
+ checkout = run_git(["checkout", "-B", branch, f"origin/{branch}"], cwd=work_path, check=False, timeout=30)
+ if checkout.returncode != 0:
+ checkout = run_git(["checkout", branch], cwd=work_path, check=False, timeout=30)
+ if checkout.returncode != 0:
+ raise GitCommandError(checkout.stderr.strip() or "Unable to check out the branch.", checkout.returncode)
+ else:
+ run_git(["symbolic-ref", "HEAD", f"refs/heads/{branch}"], cwd=work_path)
+
+ target = work_path / file_path
+ target.parent.mkdir(parents=True, exist_ok=True)
+ target.write_text(content, encoding="utf-8")
+ run_git(["add", "--", file_path], cwd=work_path)
+ commit = run_git(["commit", "-m", message, "--", file_path], cwd=work_path, check=False, timeout=30)
+ if commit.returncode != 0:
+ raise GitCommandError(commit.stderr.strip() or "Unable to commit the file.", commit.returncode)
+ node = run_git(["rev-parse", "HEAD"], cwd=work_path).stdout.strip()
+
+ with repo_import_lock(repo):
+ prepare_repo_for_receive(path)
+ push = run_git(
+ ["push", "origin", f"HEAD:refs/heads/{branch}"],
+ cwd=work_path,
+ check=False,
+ timeout=60,
+ )
+ if push.returncode != 0:
+ raise GitCommandError(
+ push.stderr.strip() or "Unable to update the branch. It may have changed; try again.",
+ push.returncode,
+ )
+ return node
+
+
+def license_file_for_repo(path, revision="HEAD"):
+ if not revision or is_null_revision(revision):
+ return None
+ completed = run_git(["ls-tree", "-r", "--name-only", revision], cwd=path, check=False)
+ if completed.returncode != 0:
+ return None
+ by_lower = {name.lower(): name for name in completed.stdout.splitlines() if name.strip()}
+ for candidate in LICENSE_FILE_CANDIDATES:
+ actual = by_lower.get(candidate.lower())
+ if actual:
+ return actual
+ return None
+
+
def run_git_import(args, cwd=None, check=True):
git_config = {"pack.threads": GIT_IMPORT_PACK_THREADS}
try:
@@ -4631,6 +4856,7 @@ def repo_active_tab(repo):
("branches", "/branches"),
("issues", "/issues"),
("pulls", "/pulls"),
+ ("license", "/license"),
("settings", "/settings"),
):
if current_path == base_path + suffix or current_path.startswith(base_path + suffix + "/"):
@@ -5064,9 +5290,47 @@ def edit_profile():
return render("edit_profile.tpl", profile=values, error=str(exc))
[email protected]("/settings/password")
[email protected]("/settings/preferences", method=["GET", "POST"])
+def preferences():
+ user = require_login()
+ timezone_choices = available_timezone_choices()
+ if request.method == "GET":
+ return render(
+ "preferences.tpl",
+ profile=user,
+ timezone_choices=timezone_choices,
+ current_timezone=user_timezone_name(user),
+ )
+
+ timezone = (request.forms.get("timezone") or "").strip()
+ if timezone not in timezone_choices:
+ response.status = 400
+ return render(
+ "preferences.tpl",
+ profile=user,
+ timezone_choices=timezone_choices,
+ current_timezone=user_timezone_name(user),
+ error="Choose a valid time zone.",
+ )
+ with db_connect() as conn:
+ conn.execute("UPDATE users SET timezone = ? WHERE id = ?", (timezone, user["id"]))
+ refreshed = get_user_by_id(user["id"])
+ request.environ["gitman.user"] = refreshed
+ return render(
+ "preferences.tpl",
+ profile=refreshed,
+ timezone_choices=timezone_choices,
+ current_timezone=timezone,
+ notice="Preferences saved.",
+ )
+
+
[email protected]("/settings/password", method=["GET", "POST"])
def change_password():
user = require_login()
+ if request.method == "GET":
+ return render("password_page.tpl")
+
identifier = str(user["id"])
if rate_limit_blocked("password-change", identifier):
return too_many_requests_response()
@@ -5075,7 +5339,7 @@ def change_password():
confirmation = request.forms.get("confirm_password", "")
def invalid(message, status=400):
response.status = status
- return render_user_profile(user, password_error=message)
+ return render("password_page.tpl", error=message)
if len(current) > 1024 or not verify_password(current, user["password_hash"]):
record_auth_failure("password-change", identifier)
return invalid("Current password is incorrect.")
@@ -5097,23 +5361,52 @@ def change_password():
refreshed = get_user_by_id(user["id"])
request.environ["gitman.user"] = refreshed
login_user(refreshed)
- return render_user_profile(refreshed, notice="Password changed. Other browser sessions are signed out.")
+ return render("password_page.tpl", notice="Password changed. Other browser sessions are signed out.")
@app.route("/new", method=["GET", "POST"])
def new_repo():
user = require_login()
+ license_choices = list(LICENSE_LABELS.items())
if request.method == "GET":
- return render("new_repo.tpl")
+ return render("new_repo.tpl", license_choices=license_choices)
repo_name_raw = request.forms.get("name", "")
description = request.forms.get("description", "").strip()[:500]
+ license_choice = request.forms.get("license", "")
+ if license_choice not in LICENSE_LABELS:
+ license_choice = ""
try:
repo_name = normalize_slug(repo_name_raw, "Repository name")
create_repository(user, repo_name, description)
+ if license_choice in LICENSE_TEXTS:
+ repo = get_repo(user["username"], repo_name)
+ if repo:
+ try:
+ license_text = license_text_for_choice(
+ license_choice, user["display_name"] or user["username"]
+ )
+ commit_file_to_repo(
+ repo,
+ repo_path(user["username"], repo_name),
+ "LICENSE",
+ license_text,
+ "Add LICENSE",
+ user,
+ branch="main",
+ )
+ except GitCommandError:
+ pass
redirect(f"/{user['username']}/{repo_name}")
except (ValueError, GitCommandError) as exc:
- return render("new_repo.tpl", error=str(exc), name=repo_name_raw, description=description)
+ return render(
+ "new_repo.tpl",
+ error=str(exc),
+ name=repo_name_raw,
+ description=description,
+ license_choices=license_choices,
+ selected_license=license_choice,
+ )
@app.route("/<username>")
@@ -5449,6 +5742,88 @@ def repo_raw(owner, repo_name, file_path):
return HTTPResponse(content, content_type=content_type)
[email protected]("/<owner>/<repo_name>/license")
+def repo_license(owner, repo_name):
+ repo = get_repo(owner, repo_name)
+ if not repo:
+ abort(404, "Repository not found.")
+ path = repo_path(owner, repo_name)
+ selected_ref = selected_repo_ref(path)
+ revision = ref_revision(selected_ref)
+ license_name = license_file_for_repo(path, revision=revision)
+ license_text = None
+ license_html = None
+ if license_name:
+ try:
+ license_text = git_cat(path, license_name, revision=revision)
+ except GitCommandError:
+ license_text = None
+ license_text, _truncated = truncate_text_for_render(license_text or "", label="License preview")
+ if license_text and is_markdown_file(license_name):
+ license_html = render_markdown(license_text)
+ return render(
+ "license.tpl",
+ repo=repo,
+ license_name=license_name,
+ license_text=license_text,
+ license_html=license_html,
+ **repo_page_context(repo, path, selected_ref=selected_ref),
+ )
+
+
[email protected]("/<owner>/<repo_name>/edit/<file_path:path>", method=["GET", "POST"])
+def repo_edit_file(owner, repo_name, file_path):
+ user = require_login()
+ repo = get_repo(owner, repo_name)
+ if not repo:
+ abort(404, "Repository not found.")
+ if not user_can_maintain_repo(user, repo):
+ abort(403, "Only the repository owner or contributors can edit files.")
+ file_path = clean_repo_path(file_path)
+ path = repo_path(owner, repo_name)
+ selected_ref = selected_repo_ref(path)
+ if selected_ref and selected_ref.get("type") == REF_TYPE_BRANCH and selected_ref.get("name"):
+ branch = selected_ref["name"]
+ else:
+ branch = default_branch_name(path)
+
+ if request.method == "GET":
+ try:
+ content = read_file_bytes(path, file_path, revision=f"refs/heads/{branch}")
+ except GitCommandError:
+ abort(404, "File not found.")
+ if b"\0" in content[:4096]:
+ abort(400, "Binary files cannot be edited in the browser.")
+ return render(
+ "edit_file.tpl",
+ repo=repo,
+ file_path=file_path,
+ branch=branch,
+ content_value=content.decode("utf-8", "replace"),
+ message_value=f"Update {file_path}",
+ quote_path=quote_path,
+ **repo_page_context(repo, path, selected_ref=selected_ref),
+ )
+
+ content = request.forms.get("content", "")
+ message = (request.forms.get("message") or "").strip()[:200] or f"Update {file_path}"
+ try:
+ commit_file_to_repo(repo, path, file_path, content, message, user, branch=branch)
+ except GitCommandError as exc:
+ return render(
+ "edit_file.tpl",
+ repo=repo,
+ file_path=file_path,
+ branch=branch,
+ content_value=content,
+ message_value=message,
+ error=str(exc),
+ quote_path=quote_path,
+ **repo_page_context(repo, path, selected_ref=selected_ref),
+ )
+ redirect(url_with_ref(f"/{owner}/{repo_name}/src/{quote_path(file_path)}", selected_ref))
+
+
@app.route("/<owner>/<repo_name>/archive/<node>.zip")
def repo_archive(owner, repo_name, node):
repo = get_repo(owner, repo_name)
diff --git a/static/git.svg b/static/git.svg
index 0979cdb..d7bf780 100644
--- a/static/git.svg
+++ b/static/git.svg
@@ -1,3 +1,6 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-git" viewBox="0 0 16 16">
- <path d="M15.698 7.287 8.712.302a1.03 1.03 0 0 0-1.457 0l-1.45 1.45 1.84 1.84a1.223 1.223 0 0 1 1.55 1.56l1.773 1.774a1.224 1.224 0 0 1 1.267 2.025 1.226 1.226 0 0 1-2.002-1.334L8.58 5.963v4.353a1.226 1.226 0 1 1-1.008-.036V5.887a1.226 1.226 0 0 1-.666-1.608L5.093 2.465l-4.79 4.79a1.03 1.03 0 0 0 0 1.457l6.986 6.986a1.03 1.03 0 0 0 1.457 0l6.953-6.953a1.03 1.03 0 0 0 0-1.457"/>
-</svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
+ <circle cx="32" cy="32" r="29" fill="#000000" stroke="#ffffff" stroke-width="6"/>
+ <g transform="translate(14.4 14.4) scale(2.2)" fill="#ffffff">
+ <path d="M15.698 7.287 8.712.302a1.03 1.03 0 0 0-1.457 0l-1.45 1.45 1.84 1.84a1.223 1.223 0 0 1 1.55 1.56l1.773 1.774a1.224 1.224 0 0 1 1.267 2.025 1.226 1.226 0 0 1-2.002-1.334L8.58 5.963v4.353a1.226 1.226 0 1 1-1.008-.036V5.887a1.226 1.226 0 0 1-.666-1.608L5.093 2.465l-4.79 4.79a1.03 1.03 0 0 0 0 1.457l6.986 6.986a1.03 1.03 0 0 0 1.457 0l6.953-6.953a1.03 1.03 0 0 0 0-1.457"/>
+ </g>
+</svg>
diff --git a/static/profile.js b/static/profile.js
deleted file mode 100644
index bb52a2a..0000000
--- a/static/profile.js
+++ /dev/null
@@ -1,14 +0,0 @@
-(() => {
- const dialog = document.getElementById('password-dialog');
- const open = document.getElementById('change-password-open');
- if (!dialog || !open) return;
- open.addEventListener('click', () => dialog.showModal());
- document.getElementById('change-password-cancel').addEventListener('click', () => dialog.close());
- dialog.addEventListener('close', () => {
- dialog.querySelector('form').reset();
- const error = dialog.querySelector('[role="alert"]');
- if (error) error.remove();
- open.focus();
- });
- if (dialog.dataset.reopen === 'true') dialog.showModal();
-})();
diff --git a/static/styles.css b/static/styles.css
index 7c679c7..ca16915 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -7,213 +7,363 @@ html {
}
:root {
- color-scheme: light;
- --page-bg: #fff;
- --text: #111;
- --link: #0645ad;
- --surface: #fff;
- --soft-surface: #fafafa;
- --button-surface: #eee;
- --border: #ddd;
- --soft-border: #eee;
- --strong-border: #999;
- --control-border: #aaa;
- --menu-border: #bbb;
- --muted: #666;
- --detail: #333;
- --danger: #900;
- --notice: #060;
- --ref-hover: #eef4fb;
- --shadow: rgba(0, 0, 0, .12);
- --app-font: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
-}
-
-@media (prefers-color-scheme: dark) {
- :root {
- color-scheme: dark;
- --page-bg: #101214;
- --text: #e8e8e3;
- --link: #7fb4ff;
- --surface: #15191d;
- --soft-surface: #1b2025;
- --button-surface: #242a30;
- --border: #343a40;
- --soft-border: #2a3036;
- --strong-border: #6b727a;
- --control-border: #6b727a;
- --menu-border: #464d55;
- --muted: #a3a9b0;
- --detail: #d6d8d5;
- --danger: #ff8b8b;
- --notice: #7fd18b;
- --ref-hover: #233246;
- --shadow: rgba(0, 0, 0, .45);
- }
+ color-scheme: dark;
+ --page-bg: #000000;
+ --ink: #ffffff;
+ --text: #b3b3b3;
+ --muted: #999999;
+ --chip: #333333;
+ --press: #e2e2e2;
+ --surface: #161616;
+ --surface-border: #262626;
+ --code-bg: #1f1f1f;
+ --app-font: system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
+ --code-font: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
body {
- max-width: 960px;
- margin: 2rem auto;
- padding: 0 1rem 3rem;
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+ min-height: 100svh;
+ margin: 0;
color: var(--text);
background: var(--page-bg);
- font: 16px/1.6 var(--app-font);
+ font: 1rem/1.5 var(--app-font);
+}
+
+main.page {
+ flex: 1 1 auto;
+ width: 100%;
+ max-width: 60rem;
+ margin-inline: auto;
+ padding: clamp(3rem, 9vh, 5.5rem) 24px clamp(3rem, 8vh, 5rem);
+}
+
+h1, h2, h3, h4 {
+ margin: 0 0 .75rem;
+ color: var(--ink);
+ font-weight: 700;
+}
+h1 { font-size: clamp(2rem, 6vw, 2.5rem); line-height: 1.2; }
+h2 { font-size: 1.25rem; line-height: 1.4; }
+h3 { font-size: 1.05rem; line-height: 1.4; }
+
+p, ul, ol, dl { margin: 0 0 .75rem; }
+small { font-size: .875rem; }
+
+a { color: inherit; text-decoration: none; }
+a:hover { color: var(--ink); text-decoration: underline; }
+
+:is(a, button, input, select, textarea):focus-visible {
+ outline: 2px solid var(--ink);
+ outline-offset: 2px;
+}
+
+form { display: grid; gap: .9rem; }
+label { display: grid; gap: .35rem; align-content: start; }
+
+input, textarea, select {
+ width: 100%;
+ padding: 12px 14px;
+ color: var(--ink);
+ background: var(--surface);
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
+ font: inherit;
+}
+input::placeholder { color: var(--muted); }
+textarea { resize: vertical; }
+
+button, .button {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10px;
+ min-height: 48px;
+ padding: 12px 18px;
+ border: 0;
+ border-radius: 999px;
+ background: var(--chip);
+ color: var(--ink);
+ font: inherit;
+ font-weight: 500;
+ text-decoration: none;
+ cursor: pointer;
+}
+button:hover, .button:hover {
+ background: var(--ink);
+ color: var(--page-bg);
+ text-decoration: none;
+}
+button:active, .button:active {
+ background: var(--press);
+ color: var(--page-bg);
+}
+.button.small { min-height: 44px; padding: 8px 14px; }
+.button.danger { background: var(--ink); color: var(--page-bg); }
+.button.danger:hover { background: var(--press); }
+.button.danger:active { background: var(--chip); color: var(--ink); }
+
+form button[type="submit"] { justify-self: start; }
+
+@media (prefers-reduced-motion: no-preference) {
+ button, .button, .nav-icons, .repo-search-link, .ref-picker-option, .ref-picker-toggle, .mention-option {
+ transition: background-color 150ms ease, color 150ms ease;
+ }
+}
+
+code { font-family: var(--code-font); font-size: .9em; background: var(--code-bg); border-radius: 3px; padding: .12em .35em; }
+pre {
+ margin: 0 0 .75rem;
+ overflow-x: auto;
+ padding: .75rem 1rem;
+ color: var(--text);
+ background: var(--surface);
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
+ font: .875rem/1.55 var(--code-font);
+}
+pre code { padding: 0; background: transparent; border-radius: 0; font-size: inherit; }
+.clone-box code {
+ display: block;
+ overflow-x: auto;
+ padding: .75rem 1rem;
+ background: var(--surface);
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
+ font: .875rem/1.55 var(--code-font);
+}
+.diff { max-height: 70vh; overflow: auto; }
+.edit-textarea {
+ font-family: var(--code-font);
+ font-size: .875rem;
+ line-height: 1.55;
+ white-space: pre;
+ overflow-wrap: normal;
+}
+.license-body {
+ max-height: 70vh;
+ overflow: auto;
}
-a { color: var(--link); text-decoration: underline; }
-h1, h2, p, pre, ul, table, form { margin-top: 0; }
-pre, code, input, textarea, select, button { font: inherit; }
-pre, .clone-box code { overflow-x: auto; padding: .6rem; border: 1px solid var(--border); background: var(--soft-surface); font: 14px/1.55 var(--app-font); }
-pre code.hljs { padding: 0; background: transparent; }
.copyable-code {
position: relative;
display: flex;
align-items: stretch;
- border: 1px solid var(--border);
- background: var(--soft-surface);
+ background: var(--surface);
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
}
.copyable-code pre {
margin: 0;
border: 0;
background: transparent;
+ border-radius: 0;
+}
+.code-actions {
+ position: absolute;
+ top: .4rem;
+ right: .5rem;
+ display: inline-flex;
+ align-items: center;
+ gap: .4rem;
+ z-index: 2;
}
.copyable-code pre.code {
flex: 1 1 auto;
min-width: 0;
- padding: 2.1rem .6rem .6rem;
+ padding: .75rem 1rem;
}
.copyable-code pre.line-numbers {
flex: 0 0 auto;
overflow: hidden;
- padding: 2.1rem .55rem .6rem .6rem;
+ padding: .75rem .75rem .75rem 1rem;
color: var(--muted);
text-align: right;
user-select: none;
- border-right: 1px solid var(--border);
+ border-right: 1px solid var(--surface-border);
}
.copy-button {
- position: absolute;
- top: .45rem;
- right: .45rem;
+ position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
- width: 1.9rem;
- height: 1.9rem;
+ width: 2rem;
+ height: 2rem;
+ min-height: 0;
padding: 0;
- border-radius: .35rem;
- background: var(--surface);
- box-shadow: 0 1px 2px var(--shadow);
-}
-.copy-button svg {
- width: 1rem;
- height: 1rem;
- fill: currentColor;
-}
-.copy-button.is-copied {
- color: var(--notice);
- border-color: var(--notice);
-}
-.copy-button.copy-error {
- color: var(--danger);
- border-color: var(--danger);
-}
-input, textarea, select { width: 100%; padding: .4rem; color: var(--text); border: 1px solid var(--control-border); background: var(--surface); }
-table { width: 100%; border-collapse: collapse; }
-th, td { padding: .35rem .5rem; border: 1px solid var(--border); text-align: left; }
-
-button, .button {
- display: inline-block;
- padding: .3rem .55rem;
- color: var(--text);
- background: var(--button-surface);
- border: 1px solid var(--strong-border);
+ border-radius: 999px;
+ background: var(--chip);
+ color: var(--ink);
text-decoration: none;
- cursor: pointer;
-}
-.pagination {
- display: flex;
- flex-wrap: wrap;
- gap: .6rem;
- align-items: center;
- margin-top: 1rem;
}
-.pagination-current, .pagination-disabled { color: var(--muted); }
-.pagination-disabled { padding: .3rem 0; }
+.copy-button:hover { background: var(--ink); color: var(--page-bg); text-decoration: none; }
+.copy-button svg { width: 1rem; height: 1rem; fill: currentColor; }
+.copy-button.is-copied { background: var(--ink); color: var(--page-bg); }
+.copy-button.copy-error { outline: 2px solid var(--ink); outline-offset: 1px; }
-.sr-only {
- position: absolute;
- width: 1px;
- height: 1px;
- padding: 0;
- margin: -1px;
- overflow: hidden;
- clip: rect(0, 0, 0, 0);
- white-space: nowrap;
- border: 0;
-}
-
-.site-header, .repo-header, .profile-header, .panel, .auth-card {
- margin-bottom: 1.5rem;
- padding-bottom: 1rem;
- border-bottom: 1px solid var(--border);
-}
+table { width: 100%; border-collapse: collapse; }
+th, td { padding: .4rem .6rem; border: 1px solid var(--surface-border); text-align: left; }
+th { color: var(--ink); font-weight: 700; }
-.site-header, .nav, .repo-tabs, .filters, .tabs, .panel-heading, .hero-actions, .breadcrumb, .repo-actions, .ref-actions {
+.site-header {
display: flex;
- gap: .75rem;
- align-items: baseline;
+ justify-content: space-between;
+ align-items: center;
+ gap: 1rem;
flex-wrap: wrap;
+ width: 100%;
+ max-width: 60rem;
+ margin-inline: auto;
+ padding: 24px;
}
-
-.site-header, .panel-heading, .repo-header { justify-content: space-between; }
-.repo-title-row { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
-.repo-title-row h1 { margin-bottom: 0; }
.brand {
display: inline-flex;
align-items: center;
gap: 1rem;
- color: var(--text);
- font-weight: 700;
+ color: var(--ink);
line-height: 1;
text-decoration: none;
}
+.brand:hover { color: var(--ink); text-decoration: none; }
.brand svg {
flex: 0 0 auto;
transform: scale(2);
transform-origin: center;
}
-.site-header, .nav { align-items: center; }
+.nav, .repo-tabs, .filters, .tabs, .panel-heading, .hero-actions, .breadcrumb {
+ display: flex;
+ gap: .75rem;
+ align-items: baseline;
+ flex-wrap: wrap;
+}
+.nav { align-items: center; }
+.panel-heading, .repo-header { justify-content: space-between; }
+.panel-heading { margin-bottom: 1.25rem; }
+.panel-heading h2 { margin: 0; }
.nav-icons {
display: inline-flex;
align-items: center;
justify-content: center;
- width: 24px;
- height: 24px;
+ width: 40px;
+ height: 40px;
+ color: var(--text);
+}
+.nav-icons:hover { color: var(--ink); text-decoration: none; }
+.nav-icons svg { display: block; width: 20px; height: 20px; flex-shrink: 0; }
+.nav form, .repo-tabs form, .inline-form { display: inline; }
+
+.colophon {
+ display: flex;
+ justify-content: space-between;
+ gap: 1rem;
+ flex-wrap: wrap;
+ width: 100%;
+ max-width: 60rem;
+ margin-inline: auto;
+ padding: 1.5rem 24px 2.5rem;
+ color: var(--muted);
+ font-size: .875rem;
+}
+.colophon p { margin: 0; }
+.colophon a { color: var(--muted); }
+.colophon a:hover { color: var(--ink); text-decoration: underline; }
+
+.repo-header, .profile-header { margin-bottom: 2.5rem; }
+.repo-header { display: flex; align-items: flex-end; gap: 2rem; flex-wrap: wrap; }
+.panel { margin-bottom: 2.5rem; }
+.panel > :last-child, .repo-header > :last-child, .auth-card > :last-child { margin-bottom: 0; }
+.auth-card { max-width: 32rem; margin-bottom: 2.5rem; }
+.auth-card.wide { max-width: 36rem; }
+.repo-title-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
+.repo-title-row h1 { margin-bottom: 0; }
+
+.repo-tabs .repo-tab { padding: .25rem 0; }
+.repo-tab.active, .filters .active, .tabs .active {
+ color: var(--ink);
font-weight: 700;
- line-height: 1;
text-decoration: none;
- color: var(--muted);
}
-.nav-icons svg { display: block; width: 24px; height: 24px; flex-shrink: 0; }
-.nav form, .repo-tabs form, .inline-form { display: inline; }
-.link-button { padding: 0; color: var(--link); background: none; border: 0; text-decoration: underline; }
-.repo-tabs .repo-tab { padding-bottom: .2rem; border-bottom: 2px solid transparent; }
-.repo-tabs .repo-tab.active { color: var(--text); font-weight: 700; text-decoration: none; }
-.repo-search {
- position: relative;
- width: 18rem;
- max-width: 100%;
- align-self: flex-start;
+
+.link-button, .button-link {
+ display: inline;
+ min-height: 0;
+ padding: 0;
+ border: 0;
+ border-radius: 0;
+ background: none;
+ color: var(--text);
+ font: inherit;
+ text-decoration: none;
+ cursor: pointer;
}
-.repo-search-input {
- width: 350px;
- margin-bottom: 10px;
+.link-button:hover, .button-link:hover {
+ background: none;
+ color: var(--ink);
+ text-decoration: underline;
}
-.repo-search-form {
- display: block;
+
+.eyebrow, .muted, .empty, .issue-list span { color: var(--muted); }
+.eyebrow { font-size: .875rem; }
+
+.repo-list, .clean-list, .commit-list, .file-list, .issue-list, .comment-list, .activity-feed {
+ display: grid;
+ gap: .75rem;
+ padding-left: 0;
margin: 0;
+ list-style: none;
+}
+.commit-list li, .file-list li { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; }
+.commit-list li > code, .file-list li > code { justify-self: start; }
+
+.meta-list { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem 1rem; }
+.meta-list dt { color: var(--muted); }
+.meta-list dd { margin: 0; overflow-x: auto; }
+
+.activity-feed { gap: 1rem; }
+.activity-feed li { padding-bottom: 1rem; border-bottom: 1px solid var(--surface-border); }
+.activity-feed li:last-child { border-bottom: 0; }
+.activity-title, .activity-detail { margin-bottom: .25rem; }
+.activity-detail { color: var(--text); }
+
+.comment { padding-bottom: 1rem; border-bottom: 1px solid var(--surface-border); min-width: 0; }
+.comment:last-child { border-bottom: 0; padding-bottom: 0; }
+.comment-meta {
+ display: flex;
+ gap: .5rem;
+ align-items: baseline;
+ margin-bottom: .35rem;
+}
+.comment-body {
+ line-height: 1.6;
+ overflow-wrap: anywhere;
}
+.comment-body > :last-child { margin-bottom: 0; }
+.comment p, .activity-title, .activity-detail {
+ font-size: 1rem;
+ line-height: 1.6;
+ overflow-wrap: anywhere;
+}
+.comment small, .activity-feed .muted { font-size: .875rem; }
+
+.markdown-body { overflow-x: auto; }
+.markdown-body img { max-width: 100%; }
+.markdown-body h1 { font-size: 1.5rem; margin: 1.5rem 0 .75rem; }
+.markdown-body h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }
+.markdown-body h3 { font-size: 1.05rem; margin: 1.25rem 0 .6rem; }
+.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child { margin-top: 0; }
+.markdown-body blockquote {
+ margin: 0 0 .75rem;
+ padding: .25rem 0 .25rem 1rem;
+ border-left: 2px solid var(--chip);
+ color: var(--muted);
+}
+.markdown-body a { text-decoration: underline; }
+
+.repo-search { position: relative; width: 18rem; max-width: 100%; align-self: flex-start; }
+.repo-search-input { width: 350px; margin-bottom: 10px; }
+.repo-search-form { display: block; margin: 0; }
.panel-heading > .repo-search { margin-left: auto; }
.hero-actions .repo-search-menu { left: 0; right: auto; }
.repo-search-menu {
@@ -229,25 +379,25 @@ button, .button {
max-height: 20rem;
overflow-y: auto;
padding: .45rem;
- border: 1px solid var(--menu-border);
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
background: var(--surface);
- box-shadow: 0 .4rem 1.2rem var(--shadow);
-}
-.repo-search-result {
- display: block;
}
+.repo-search-result { display: block; }
.repo-search-link {
display: flex;
justify-content: space-between;
gap: .75rem;
align-items: baseline;
width: 100%;
- padding: .4rem .5rem;
- color: var(--text);
+ padding: .5rem .6rem;
+ border-radius: 6px;
+ color: var(--ink);
text-decoration: none;
}
.repo-search-link:hover, .repo-search-link:focus {
- background: var(--ref-hover);
+ background: var(--ink);
+ color: var(--page-bg);
text-decoration: none;
}
.repo-search-link strong {
@@ -256,13 +406,27 @@ button, .button {
text-overflow: ellipsis;
white-space: nowrap;
}
-.repo-search-link small {
- flex: 0 0 auto;
- white-space: nowrap;
-}
+.repo-search-link small { flex: 0 0 auto; white-space: nowrap; }
.repo-search-link small, .repo-search-empty { color: var(--muted); }
+.repo-search-link:hover small, .repo-search-link:focus small { color: inherit; }
.repo-search-empty { margin: 0; padding: .3rem .4rem; }
+
.ref-picker { position: relative; display: inline-block; }
+.ref-picker-toggle {
+ display: inline-flex;
+ gap: .25rem;
+ align-items: center;
+ min-height: 0;
+ padding: .3rem .9rem;
+ border: 0;
+ border-radius: 999px;
+ background: var(--chip);
+ color: var(--ink);
+ font: inherit;
+ font-size: .9375rem;
+ cursor: pointer;
+}
+.ref-picker-toggle:hover { background: var(--ink); color: var(--page-bg); }
.ref-picker-menu {
position: absolute;
left: 0;
@@ -271,26 +435,29 @@ button, .button {
width: 20rem;
max-width: calc(100vw - 2rem);
padding: .5rem;
- border: 1px solid var(--menu-border);
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
background: var(--surface);
- box-shadow: 0 .4rem 1.2rem var(--shadow);
}
.ref-picker-search { margin-bottom: .4rem; }
-.ref-picker-options { display: grid; gap: .1rem; max-height: 18rem; overflow-y: auto; }
+.ref-picker-options { display: grid; gap: .15rem; max-height: 18rem; overflow-y: auto; }
.ref-picker-option {
display: flex;
gap: 1rem;
justify-content: space-between;
- padding: .35rem .45rem;
- color: var(--text);
+ padding: .45rem .6rem;
+ border-radius: 6px;
+ color: var(--ink);
text-decoration: none;
}
-.ref-picker-option:hover, .ref-picker-option:focus, .ref-picker-option.active {
- background: var(--ref-hover);
+.ref-picker-option:hover, .ref-picker-option:focus {
+ background: var(--ink);
+ color: var(--page-bg);
text-decoration: none;
}
.ref-picker-option.active { font-weight: 700; }
.ref-picker-current { color: var(--muted); font-weight: 400; }
+.ref-picker-option:hover .ref-picker-current, .ref-picker-option:focus .ref-picker-current { color: inherit; }
.ref-picker-empty { padding: .35rem .45rem; color: var(--muted); }
.ref-picker-footer {
display: flex;
@@ -298,107 +465,47 @@ button, .button {
flex-wrap: wrap;
margin-top: .5rem;
padding-top: .45rem;
- border-top: 1px solid var(--border);
+ border-top: 1px solid var(--surface-border);
}
-.ref-picker-link.active { color: var(--text); font-weight: 700; text-decoration: none; }
-.filters .active, .tabs .active { color: var(--text); font-weight: 700; text-decoration: none; }
+.ref-picker-link.active { color: var(--ink); font-weight: 700; text-decoration: none; }
+
.list-search {
display: inline-flex;
gap: .4rem;
align-items: center;
flex-wrap: wrap;
}
-.list-search input[type="search"] {
- width: 18rem;
- max-width: 100%;
-}
-.hero, .repo-tabs { margin-bottom: 1.5rem; }
-.eyebrow, .muted, .empty, .nav-user, .repo-card small, .issue-list span, .commit-list span, .file-list span, .clean-list span, .file-kind { color: var(--muted); }
-.repo-list, .stack, form, .clean-list, .commit-list, .file-list, .issue-list { display: grid; gap: .75rem; }
-.repo-card { display: block; padding: .75rem 0; border-bottom: 1px solid var(--soft-border); color: var(--text); }
-.repo-card strong, .repo-card span, .repo-card small, .clone-box code { display: block; }
-.markdown-body { overflow-x: auto; }
-.markdown-body img { max-width: 100%; }
-.markdown-body code {
- padding: .12rem .28rem;
- border-radius: .25rem;
- background: var(--soft-surface);
- font: .9em/1.45 var(--app-font);
-}
-.markdown-body pre code {
- display: block;
- padding: 0;
- background: transparent;
- font: inherit;
-}
-.grid.two { display: grid; grid-template-columns: 1fr 18rem; gap: 2rem; }
-.meta-list { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem 1rem; }
-.meta-list dt { color: var(--muted); }
-.meta-list dd { margin: 0; overflow-x: auto; }
-.activity-feed { display: grid; gap: 1rem; padding-left: 0; list-style: none; }
-.activity-feed li { padding-bottom: 1rem; border-bottom: 1px solid var(--soft-border); }
-.activity-title, .activity-detail { margin-bottom: .25rem; }
-.activity-detail { color: var(--detail); }
-.comment-list { display: grid; gap: 1rem; }
-.comment { padding-bottom: 1rem; border-bottom: 1px solid var(--soft-border); }
-.comment, .activity-feed li { min-width: 0; }
-.comment-meta {
+.list-search input[type="search"] { width: 18rem; max-width: 100%; }
+
+.hero-actions { margin-top: 1.25rem; }
+
+.pagination {
display: flex;
- gap: .5rem;
- align-items: baseline;
- margin-bottom: .35rem;
-}
-.comment-body {
- line-height: 1.6;
- overflow-wrap: anywhere;
-}
-.comment-body > :last-child { margin-bottom: 0; }
-.comment p, .activity-title, .activity-detail {
- font-size: 1rem;
- line-height: 1.6;
- overflow-wrap: anywhere;
-}
-.comment small, .activity-feed .muted {
- font-size: .875rem;
+ flex-wrap: wrap;
+ gap: .6rem;
+ align-items: center;
+ margin-top: 1rem;
}
-.diff { max-height: 70vh; }
-.file-table { width: 100%; border-collapse: collapse; }
-.file-table td { padding: .4rem 0; border-bottom: 1px solid var(--soft-border); }
-.file-kind { width: 4rem; }
-.commit-list, .file-list, .issue-list, .clean-list { padding-left: 0; list-style: none; }
-.commit-list li, .file-list li { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; }
-.tag-list li { display: grid; grid-template-columns: 1fr 18rem; gap: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--soft-border); }
-.tag-actions { display: grid; gap: .75rem; align-content: start; }
-.alert { margin-bottom: 1rem; color: var(--danger); }
-.notice { margin-bottom: 1rem; color: var(--notice); }
-.danger-zone { color: var(--danger); }
-.button.danger { color: var(--danger); border-color: var(--danger); }
-.button-link { background: none; border: none; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; font: inherit; }
-.ref-picker-toggle { display: inline-flex; gap: .25rem; align-items: center; background: none; border: none; padding: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: smaller; }
+.pagination-current, .pagination-disabled { color: var(--muted); }
+.pagination-disabled { padding: .3rem 0; }
-@media (max-width: 760px) {
- body { margin-top: 1rem; }
- .repo-search { width: 100%; }
- .repo-search-input { width: 100%; }
- .repo-search-menu { left: 0; right: auto; width: 100%; }
- .grid.two, .commit-list li, .tag-list li { grid-template-columns: 1fr; }
-}
+.alert { margin-bottom: 1rem; color: var(--ink); font-weight: 700; }
+.notice { margin-bottom: 1rem; color: var(--text); }
+.danger-zone { margin-top: 1rem; padding-top: 2rem; border-top: 1px solid var(--surface-border); }
+.danger-zone h2 { margin-top: 0; }
.password-dialog {
width: min(28rem, calc(100% - 2rem));
max-height: calc(100dvh - 2rem);
overflow: auto;
padding: 1.5rem;
- border: 1px solid var(--strong-border);
- border-radius: .5rem;
+ border: 1px solid var(--surface-border);
+ border-radius: 8px;
color: var(--text);
background: var(--surface);
- box-shadow: 0 12px 48px var(--shadow);
}
-.password-dialog::backdrop { background: rgb(0 0 0 / .45); }
+.password-dialog::backdrop { background: rgb(0 0 0 / .6); }
.password-dialog h2 { font-size: 1.25rem; margin-bottom: 1rem; }
-.password-dialog label { display: block; margin-bottom: 1rem; }
-.password-dialog input { margin-top: .25rem; }
.password-dialog .muted { font-size: .875rem; }
.password-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; }
.password-dialog form { margin-bottom: 0; }
@@ -409,16 +516,48 @@ button, .button {
margin: 0;
}
.mention-option {
- flex-shrink: 0;
+ display: flex;
+ justify-content: space-between;
+ gap: .75rem;
+ align-items: baseline;
+ width: 100%;
+ min-height: 0;
+ padding: .5rem .6rem;
border: 0;
+ border-radius: 6px;
background: transparent;
+ color: var(--ink);
+ font-weight: 400;
text-align: left;
cursor: pointer;
}
-.mention-option.active { background: var(--ref-hover); }
+.mention-option:hover, .mention-option.active {
+ background: var(--ink);
+ color: var(--page-bg);
+}
.mention-option small {
color: var(--muted);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
+.mention-option:hover small, .mention-option.active small { color: inherit; }
+
+@media (max-width: 760px) {
+ .repo-search, .repo-search-input { width: 100%; }
+ .repo-search-menu { left: 0; right: auto; width: 100%; }
+ .commit-list li, .file-list li { grid-template-columns: 1fr; }
+ .repo-header { align-items: flex-start; }
+}
+
+.sr-only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ white-space: nowrap;
+ border: 0;
+}
diff --git a/templates/activity_feed.tpl b/templates/activity_feed.tpl
index c2983c9..8eac3e9 100644
--- a/templates/activity_feed.tpl
+++ b/templates/activity_feed.tpl
@@ -16,7 +16,7 @@
% if show_repo_context:
in <a href="{{repo_url}}">{{action["repo_owner_username"]}}/{{action["repo_name"]}}</a> ·
% end
- {{action["occurred_at"]}}
+ {{format_datetime(action["occurred_at"])}}
</p>
% if action["detail"]:
<p class="activity-detail">{{!render_markdown_links(action["detail"])}}</p>
diff --git a/templates/base.tpl b/templates/base.tpl
index fe5774f..7a7f619 100644
--- a/templates/base.tpl
+++ b/templates/base.tpl
@@ -3,21 +3,20 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>{{title or "GitMan"}}</title>
- <link rel="icon" type="image/svg+xml" sizes="32x32" href="/static/git.svg">
-<link rel="icon" type="image/svg+xml" sizes="16x16" href="/static/git.svg">
-<link rel="apple-touch-icon" sizes="180x180" href="/static/git.svg">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" media="(prefers-color-scheme: dark)">
- <link rel="stylesheet" href="/static/styles.css?v=8">
+ <meta name="color-scheme" content="dark">
+ <meta name="theme-color" content="#000000">
+ <meta name="description" content="GitMan: free Git repository hosting for open source software.">
+ <title>{{(title + " · GitMan") if title else "GitMan"}}</title>
+ <link rel="icon" type="image/svg+xml" href="/static/git.svg">
+ <link rel="stylesheet" href="/static/styles.css?v=9">
</head>
<body>
<header class="site-header">
- <a class="brand" href="/">
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-git" viewBox="0 0 16 16">
+ <a class="brand" href="/" aria-label="GitMan home">
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-git" viewBox="0 0 16 16" aria-hidden="true">
<path d="M15.698 7.287 8.712.302a1.03 1.03 0 0 0-1.457 0l-1.45 1.45 1.84 1.84a1.223 1.223 0 0 1 1.55 1.56l1.773 1.774a1.224 1.224 0 0 1 1.267 2.025 1.226 1.226 0 0 1-2.002-1.334L8.58 5.963v4.353a1.226 1.226 0 1 1-1.008-.036V5.887a1.226 1.226 0 0 1-.666-1.608L5.093 2.465l-4.79 4.79a1.03 1.03 0 0 0 0 1.457l6.986 6.986a1.03 1.03 0 0 0 1.457 0l6.953-6.953a1.03 1.03 0 0 0 0-1.457"/>
</svg>
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-arms-up" viewBox="0 0 16 16">
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-arms-up" viewBox="0 0 16 16" aria-hidden="true">
<path d="M8 3a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"/>
<path d="m5.93 6.704-.846 8.451a.768.768 0 0 0 1.523.203l.81-4.865a.59.59 0 0 1 1.165 0l.81 4.865a.768.768 0 0 0 1.523-.203l-.845-8.451A1.5 1.5 0 0 1 10.5 5.5L13 2.284a.796.796 0 0 0-1.239-.998L9.634 3.84a.7.7 0 0 1-.33.235c-.23.074-.665.176-1.304.176-.64 0-1.074-.102-1.305-.176a.7.7 0 0 1-.329-.235L4.239 1.286a.796.796 0 0 0-1.24.998l2.5 3.216c.317.316.475.758.43 1.204Z"/>
</svg>
@@ -42,7 +41,7 @@
</a>
% else:
<a href="/login">Log in</a>
- <a class="button small" href="/signup">Sign up</a>
+ <a class="button" href="/signup">Sign up</a>
% end
</nav>
</header>
@@ -56,8 +55,11 @@
% end
{{!base}}
</main>
+ % import time
+ <footer class="colophon">
+ <p>© {{time.strftime("%Y")}} GitMan</p>
+ </footer>
<script src="/static/mentions.js?v=1" defer></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>
(() => {
const addLineNumbers = (code, rawText) => {
diff --git a/templates/branches.tpl b/templates/branches.tpl
index 679945d..c62e8c6 100644
--- a/templates/branches.tpl
+++ b/templates/branches.tpl
@@ -20,7 +20,7 @@
<code>{{branch["name"]}}</code>
<div style="margin-bottom:20px;">
<strong><a href="/{{repo['owner_username']}}/{{repo['name']}}/commits/{{branch['short_node']}}">{{branch["short_node"]}}</a></strong>
- <small>commit {{branch["short_node"]}} · {{branch["date"]}}</small>
+ <small>commit {{branch["short_node"]}} · {{format_datetime(branch["date"])}}</small>
<p>{{branch["summary"]}}
<small><a href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/src', branch, True)}}">Browse code</a> ·
<a href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/commits', branch, True)}}">Commits</a> ·
diff --git a/templates/comment.tpl b/templates/comment.tpl
index 1e886a6..d3f0886 100644
--- a/templates/comment.tpl
+++ b/templates/comment.tpl
@@ -1,7 +1,7 @@
<article class="comment">
<header class="comment-meta">
<strong><a href="/{{comment["author_username"]}}">@{{comment["author_username"]}}</a></strong>
- <small class="muted">{{comment["created_at"]}}</small>
+ <small class="muted">{{format_datetime(comment["created_at"])}}</small>
</header>
<div class="comment-body markdown-body">{{!render_markdown(comment["body"])}}</div>
</article>
diff --git a/templates/commit_detail.tpl b/templates/commit_detail.tpl
index 037f7b4..de87fcc 100644
--- a/templates/commit_detail.tpl
+++ b/templates/commit_detail.tpl
@@ -12,7 +12,7 @@
<section class="panel">
<h2>{{commit["description"].splitlines()[0] if commit["description"] else commit["short_node"]}}</h2>
- <p class="muted">Commit {{commit["short_node"]}} · {{commit["author"]}} · {{commit["date"]}}</p>
+ <p class="muted">Commit {{commit["short_node"]}} · {{commit["author"]}} · {{format_datetime(commit["date"])}}</p>
<dl class="meta-list">
<dt>Changeset</dt>
<dd>
diff --git a/templates/commits.tpl b/templates/commits.tpl
index 8d39215..a0364de 100644
--- a/templates/commits.tpl
+++ b/templates/commits.tpl
@@ -19,7 +19,7 @@
<code><a href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/commits/' + commit['node'], selected_ref)}}">{{commit["short_node"]}}</a></code>
<div>
<strong>{{commit["summary"]}}</strong>
- <small>{{commit["author"]}} · {{commit["date"]}}</small>
+ <small>{{commit["author"]}} · {{format_datetime(commit["date"])}}</small>
</div>
</li>
% end
diff --git a/templates/edit_file.tpl b/templates/edit_file.tpl
new file mode 100644
index 0000000..6d7a55c
--- /dev/null
+++ b/templates/edit_file.tpl
@@ -0,0 +1,34 @@
+% rebase("base.tpl", title="Edit " + file_path, user=user, error=error, notice=notice)
+
+<section class="repo-header slim">
+ <div>
+ % include("repo_fork_eyebrow.tpl")
+ % include("repo_title.tpl", repo=repo)
+
+ % include("repo_nav.tpl", repo=repo, commit_count=commit_count, issue_counts=issue_counts, pr_counts=pr_counts, star_count=star_count, is_starred=is_starred, is_owner=is_owner, can_maintain=can_maintain)
+
+ <p class="muted">Editing <code>{{file_path}}</code> on branch <code>{{branch}}</code></p>
+ </div>
+</section>
+
+<section class="panel">
+ <h2>Edit file</h2>
+ % if error:
+ <p class="alert">{{error}}</p>
+ % end
+ <form method="post">
+ {{!csrf_field()}}
+ <label>
+ Commit message
+ <input name="message" value="{{message_value}}" maxlength="200">
+ </label>
+ <label>
+ File content
+ <textarea class="edit-textarea" name="content" rows="22" spellcheck="false">{{content_value}}</textarea>
+ </label>
+ <div class="hero-actions">
+ <button class="button" type="submit">Save changes</button>
+ <a class="button-link" href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/src/' + quote_path(file_path), selected_ref)}}">Cancel</a>
+ </div>
+ </form>
+</section>
diff --git a/templates/file.tpl b/templates/file.tpl
index 1d5c747..f6e4022 100644
--- a/templates/file.tpl
+++ b/templates/file.tpl
@@ -30,19 +30,38 @@
<p class="empty">Binary file, {{size}} bytes. Use the raw view to download it.</p>
% else:
<div class="copyable-code" data-code-viewer>
- <button
- class="copy-button"
- type="button"
- aria-label="Copy file contents"
- title="Copy file contents"
- data-copy-raw-url="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/raw/' + quote_path(file_path), selected_ref)}}"
- >
- <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
- <path d="M10 1.5H3.5A1.5 1.5 0 0 0 2 3v8A1.5 1.5 0 0 0 3.5 12.5H5v-1H3.5A.5.5 0 0 1 3 11V3a.5.5 0 0 1 .5-.5H10z"/>
- <path d="M6.5 4A1.5 1.5 0 0 0 5 5.5v7A1.5 1.5 0 0 0 6.5 14h6A1.5 1.5 0 0 0 14 12.5v-7A1.5 1.5 0 0 0 12.5 4zm0 1h6a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-.5.5h-6a.5.5 0 0 1-.5-.5v-7a.5.5 0 0 1 .5-.5"/>
- </svg>
- <span class="sr-only">Copy file contents</span>
- </button>
+ <div class="code-actions">
+ % edit_url = "/" + repo['owner_username'] + "/" + repo['name'] + "/edit/" + quote_path(file_path)
+ % if selected_ref and selected_ref['type'] == 'branch' and selected_ref.get('name'):
+ % edit_url += "?ref_type=branch&ref=" + selected_ref['name']
+ % end
+ % if can_maintain:
+ <a
+ class="copy-button"
+ href="{{edit_url}}"
+ aria-label="Edit file"
+ title="Edit file"
+ >
+ <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
+ <path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325"/>
+ </svg>
+ <span class="sr-only">Edit file</span>
+ </a>
+ % end
+ <button
+ class="copy-button"
+ type="button"
+ aria-label="Copy file contents"
+ title="Copy file contents"
+ data-copy-raw-url="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/raw/' + quote_path(file_path), selected_ref)}}"
+ >
+ <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
+ <path d="M10 1.5H3.5A1.5 1.5 0 0 0 2 3v8A1.5 1.5 0 0 0 3.5 12.5H5v-1H3.5A.5.5 0 0 1 3 11V3a.5.5 0 0 1 .5-.5H10z"/>
+ <path d="M6.5 4A1.5 1.5 0 0 0 5 5.5v7A1.5 1.5 0 0 0 6.5 14h6A1.5 1.5 0 0 0 14 12.5v-7A1.5 1.5 0 0 0 12.5 4zm0 1h6a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-.5.5h-6a.5.5 0 0 1-.5-.5v-7a.5.5 0 0 1 .5-.5"/>
+ </svg>
+ <span class="sr-only">Copy file contents</span>
+ </button>
+ </div>
<pre class="code"><code class="{{language_class}}">{{content}}</code></pre>
</div>
% end
diff --git a/templates/index.tpl b/templates/index.tpl
index c85e177..510c12c 100644
--- a/templates/index.tpl
+++ b/templates/index.tpl
@@ -1,16 +1,16 @@
-% rebase("base.tpl", title="GitMan activity", user=user, error=error, notice=notice)
+% rebase("base.tpl", title="Recent activity", user=user, error=error, notice=notice)
-<section class="panel" style="border-bottom: none;">
+<section class="panel">
<div class="panel-heading">
<div>
<p class ="eyebrow">GitMan.io: Free Git repository hosting for open source software</p>
% if not user:
- <div class="hero-actions" style="margin-bottom:50px;">
+ <div class="hero-actions">
<a class="button" href="/signup">Create an account</a>
- <a class="button secondary" href="/login">Log in</a>
+ <a class="button" href="/login">Log in</a>
</div>
% else:
- <div class="hero-actions" style="margin-bottom:50px;">
+ <div class="hero-actions">
<div class="repo-search" data-repo-search data-repo-search-url="/-/repos/search">
<input
id="repo-search-input"
diff --git a/templates/issue_detail.tpl b/templates/issue_detail.tpl
index f6173e3..39885d7 100644
--- a/templates/issue_detail.tpl
+++ b/templates/issue_detail.tpl
@@ -14,7 +14,7 @@
<div class="panel-heading">
<div>
<h2>(#{{issue["number"]}}) {{!render_mentions(issue["title"])}}</h2>
- <p class="muted"><strong>{{issue["status"]}}</strong> by {{issue["author_username"]}} on {{issue["created_at"]}}</p>
+ <p class="muted"><strong>{{issue["status"]}}</strong> by {{issue["author_username"]}} on {{format_datetime(issue["created_at"])}}</p>
</div>
% if can_maintain:
<form method="post">
diff --git a/templates/license.tpl b/templates/license.tpl
new file mode 100644
index 0000000..cbea028
--- /dev/null
+++ b/templates/license.tpl
@@ -0,0 +1,26 @@
+% rebase("base.tpl", title=repo["owner_username"] + "/" + repo["name"] + " license", user=user, error=error, notice=notice)
+
+<section class="repo-header slim">
+ <div>
+ % include("repo_fork_eyebrow.tpl")
+ % include("repo_title.tpl", repo=repo)
+
+ % include("repo_nav.tpl", repo=repo, commit_count=commit_count, issue_counts=issue_counts, pr_counts=pr_counts, star_count=star_count, is_starred=is_starred, is_owner=is_owner, can_maintain=can_maintain)
+
+ <p class="muted">License</p>
+ </div>
+</section>
+
+<section class="panel">
+ <h2>License</h2>
+ % if license_name:
+ <p class="muted"><code>{{license_name}}</code></p>
+ % if license_html is not None:
+ <div class="markdown-body license-body">{{!license_html}}</div>
+ % elif license_text:
+ <pre class="license-body">{{license_text}}</pre>
+ % end
+ % else:
+ <p class="empty">No license file in this repository.</p>
+ % end
+</section>
diff --git a/templates/new_repo.tpl b/templates/new_repo.tpl
index 118bce8..6d72a3e 100644
--- a/templates/new_repo.tpl
+++ b/templates/new_repo.tpl
@@ -12,7 +12,15 @@
Description
<textarea name="description" rows="3">{{description if defined("description") else ""}}</textarea>
</label>
- <p class="muted">Repositories are public to clone and browse. You can add contributors after creation.</p>
+ <label>
+ License
+ <select name="license">
+ % for value, label in license_choices:
+ <option value="{{value}}" {{'selected' if value == get("selected_license", "") else ''}}>{{label}}</option>
+ % end
+ </select>
+ </label>
+ <p class="muted">Repositories are public to clone and browse. You can add contributors after creation. Choosing a BSD license commits a LICENSE file to the main branch.</p>
<button class="button" type="submit">Create repository</button>
</form>
</section>
diff --git a/templates/notifications.tpl b/templates/notifications.tpl
index f5ccf9f..6f6bbf6 100644
--- a/templates/notifications.tpl
+++ b/templates/notifications.tpl
@@ -1,6 +1,6 @@
-% rebase("base.tpl", title="Notifications · GitMan", user=user, error=error, notice=notice)
+% rebase("base.tpl", title="Notifications", user=user, error=error, notice=notice)
-<section class="panel" style="border-bottom: none;">
+<section class="panel">
<div class="panel-heading">
<div>
<h1>Notifications</h1>
diff --git a/templates/password_dialog.tpl b/templates/password_dialog.tpl
deleted file mode 100644
index 0b5da4c..0000000
--- a/templates/password_dialog.tpl
+++ /dev/null
@@ -1,25 +0,0 @@
-<dialog id="password-dialog" class="password-dialog" aria-labelledby="password-title" data-reopen="{{'true' if get('password_error') else 'false'}}">
- <h2 id="password-title">Change password</h2>
- <form method="post" action="/settings/password">
- {{!csrf_field()}}
- <input type="text" name="username" value="{{user['username']}}" autocomplete="username" hidden>
- % if get('password_error'):
- <p class="alert" role="alert">{{password_error}}</p>
- % end
- <label>Current password
- <input type="password" name="current_password" autocomplete="current-password" maxlength="1024" required autofocus>
- </label>
- <label>New password
- <input type="password" name="new_password" autocomplete="new-password" minlength="8" maxlength="1024" required aria-describedby="password-hint">
- </label>
- <label>Confirm new password
- <input type="password" name="confirm_password" autocomplete="new-password" minlength="8" maxlength="1024" required>
- </label>
- <p class="muted" id="password-hint">At least 8 characters. Other browser sessions will be signed out.</p>
- <div class="password-actions">
- <button type="button" id="change-password-cancel">Cancel</button>
- <button type="submit">Change password</button>
- </div>
- </form>
-</dialog>
-<script src="/static/profile.js?v=1" defer></script>
diff --git a/templates/password_page.tpl b/templates/password_page.tpl
new file mode 100644
index 0000000..88d7492
--- /dev/null
+++ b/templates/password_page.tpl
@@ -0,0 +1,23 @@
+% rebase("base.tpl", title="Change password", user=user, error=error, notice=notice)
+
+<section class="auth-card">
+ <h1>Change password</h1>
+ <form method="post" action="/settings/password">
+ {{!csrf_field()}}
+ <label>
+ Current password
+ <input type="password" name="current_password" autocomplete="current-password" maxlength="1024" required>
+ </label>
+ <label>
+ New password
+ <input type="password" name="new_password" autocomplete="new-password" minlength="8" maxlength="1024" required aria-describedby="password-hint">
+ </label>
+ <label>
+ Confirm new password
+ <input type="password" name="confirm_password" autocomplete="new-password" minlength="8" maxlength="1024" required>
+ </label>
+ <p class="muted" id="password-hint">At least 8 characters. Other browser sessions will be signed out.</p>
+ <button class="button" type="submit">Change password</button>
+ </form>
+ <p class="muted"><a href="/settings/preferences">Back to preferences</a></p>
+</section>
diff --git a/templates/preferences.tpl b/templates/preferences.tpl
new file mode 100644
index 0000000..fef8b10
--- /dev/null
+++ b/templates/preferences.tpl
@@ -0,0 +1,19 @@
+% rebase("base.tpl", title="Preferences", user=user, error=error, notice=notice)
+
+<section class="auth-card wide">
+ <h1>Preferences</h1>
+ <form method="post">
+ {{!csrf_field()}}
+ <label>
+ Time zone
+ <select name="timezone">
+ % for zone in timezone_choices:
+ <option value="{{zone}}" {{'selected' if zone == current_timezone else ''}}>{{zone}}</option>
+ % end
+ </select>
+ </label>
+ <p class="muted">Dates and times across GitMan are shown in your time zone. The default is UTC.</p>
+ <button class="button" type="submit">Save preferences</button>
+ </form>
+ <p class="muted"><a href="/settings/password">Change password</a></p>
+</section>
diff --git a/templates/profile.tpl b/templates/profile.tpl
index 25f1ef0..2198d85 100644
--- a/templates/profile.tpl
+++ b/templates/profile.tpl
@@ -10,9 +10,9 @@
% end
</h1>
<p class="muted"><small>
- Joined {{profile_user["created_at"]}}
+ Joined {{format_datetime(profile_user["created_at"])}}
% if is_self:
- <a class="button-link" href="/settings/profile">Edit profile</a> · <button class="link-button" type="button" id="change-password-open">Change password</button> · <a class="button-link" href="/logout">Log out</a>
+ <a class="button-link" href="/settings/profile">Edit profile</a> · <a class="button-link" href="/settings/preferences">Preferences</a> · <a class="button-link" href="/logout">Log out</a>
% end
</small></p>
% if profile_user["bio"]:
@@ -40,7 +40,7 @@
<br>
{{!render_markdown_links(repo["description"]) or "No description yet."}}
<br>
- <small>Updated {{repo["updated_at"]}} · {{repo["star_count"]}} stars</small>
+ <small>Updated {{format_datetime(repo["updated_at"])}} · {{repo["star_count"]}} stars</small>
</div>
% end
</div>
@@ -54,7 +54,3 @@
% include("pagination.tpl", pagination=pagination)
% end
</section>
-
-% if is_self:
- % include("password_dialog.tpl")
-% end
diff --git a/templates/pull_request_detail.tpl b/templates/pull_request_detail.tpl
index 0ecb377..d1ebc2f 100644
--- a/templates/pull_request_detail.tpl
+++ b/templates/pull_request_detail.tpl
@@ -14,7 +14,7 @@
<div class="panel-heading">
<div>
<h2>(#{{pr["number"]}}) {{!render_mentions(pr["title"])}}</h2>
- <p class="muted"><strong>{{pr["status"]}}</strong> <small>(created by <a href="/{{pr["author_username"]}}">{{pr["author_username"]}}</a> on {{pr["created_at"]}})</small></p>
+ <p class="muted"><strong>{{pr["status"]}}</strong> <small>(created by <a href="/{{pr["author_username"]}}">{{pr["author_username"]}}</a> on {{format_datetime(pr["created_at"])}})</small></p>
<p class="muted"><a href="/{{pr["source_owner_username"]}}/{{pr["source_repo_name"]}}">{{pr["source_owner_username"]}}/{{pr["source_repo_name"]}}</a> into <a href="/{{pr["target_owner_username"]}}/{{pr["target_repo_name"]}}">{{pr["target_owner_username"]}}/{{pr["target_repo_name"]}}</a></p>
<p class="muted">{{format_ref_label(pr["source_ref_type"], pr["source_ref_name"])}} into {{format_ref_label(pr["target_ref_type"], pr["target_ref_name"])}}</p>
</div>
@@ -39,7 +39,7 @@
<p class="empty">No description.</p>
% end
% if pr["status"] == "merged":
- <p class="notice">Merged by {{pr["merged_by_username"] or "unknown"}} on {{pr["merged_at"]}} as <code>{{pr["merge_node"]}}</code>.</p>
+ <p class="notice">Merged by {{pr["merged_by_username"] or "unknown"}} on {{format_datetime(pr["merged_at"])}} as <code>{{pr["merge_node"]}}</code>.</p>
% end
</section>
diff --git a/templates/repo_nav.tpl b/templates/repo_nav.tpl
index 640cf05..641884f 100644
--- a/templates/repo_nav.tpl
+++ b/templates/repo_nav.tpl
@@ -6,6 +6,7 @@
<a class="repo-tab {{'active' if active_tab == 'commits' else ''}}" href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/commits', selected_ref)}}">Commits{{" (" + str(commit_count) + ")" if commit_count else ""}}</a>
<a class="repo-tab {{'active' if active_tab == 'issues' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/issues">Issues{{" (" + str(issue_counts["open"]) + ")" if issue_counts["open"] else ""}}</a>
<a class="repo-tab {{'active' if active_tab == 'pulls' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/pulls">Pull requests{{" (" + str(pr_counts["open"]) + ")" if pr_counts["open"] else ""}}</a>
+ <a class="repo-tab {{'active' if active_tab == 'license' else ''}}" href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/license', selected_ref)}}">License</a>
% if user:
<form class="inline-form" method="post" action="/{{repo['owner_username']}}/{{repo['name']}}/star">
{{!csrf_field()}}
diff --git a/templates/repo_settings.tpl b/templates/repo_settings.tpl
index c9fbff2..28933d4 100644
--- a/templates/repo_settings.tpl
+++ b/templates/repo_settings.tpl
@@ -109,7 +109,7 @@
<ul class="clean-list">
% for contributor in contributors:
<li class="panel-heading">
- <span><a href="/{{contributor['username']}}">{{contributor["username"]}}</a> <span class="muted">added {{contributor["contributor_since"]}}</span></span>
+ <span><a href="/{{contributor['username']}}">{{contributor["username"]}}</a> <span class="muted">added {{format_datetime(contributor["contributor_since"])}}</span></span>
<form class="inline-form" method="post">
{{!csrf_field()}}
<input type="hidden" name="action" value="remove_contributor">
diff --git a/templates/tags.tpl b/templates/tags.tpl
index f1baf9f..35a91ec 100644
--- a/templates/tags.tpl
+++ b/templates/tags.tpl
@@ -20,7 +20,7 @@
<code>{{tag["name"]}}</code>
<div style="margin-bottom:20px;">
<strong><a href="/{{repo['owner_username']}}/{{repo['name']}}/commits/{{tag['short_node']}}">{{tag["short_node"]}}</a></strong>
- <small>commit {{tag["short_node"]}} · {{tag["date"]}}</small>
+ <small>commit {{tag["short_node"]}} · {{format_datetime(tag["date"])}}</small>
<p>{{tag["summary"]}}
<small><a href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/src', tag, True)}}">Browse code</a> ·
<a href="{{url_with_ref('/' + repo['owner_username'] + '/' + repo['name'] + '/commits', tag, True)}}">Commits</a> ·
diff --git a/tests/test_app.py b/tests/test_app.py
index c4806ef..e93626a 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -513,16 +513,17 @@ def test_security_headers_and_secure_cookie_flags(isolated_app):
assert "Secure" in session_cookie
-def test_styles_support_system_dark_mode(isolated_app):
+def test_styles_apply_permanent_dark_theme(isolated_app):
css = (REPO_ROOT_FOR_IMPORTS / "static" / "styles.css").read_text(encoding="utf-8")
client = WsgiClient(isolated_app.app)
response = client.get("/")
- assert "@media (prefers-color-scheme: dark)" in css
assert "color-scheme: dark" in css
- assert "var(--page-bg)" in css
- assert "github-dark.min.css" in response.text
- assert 'media="(prefers-color-scheme: dark)"' in response.text
+ assert "--page-bg: #000000" in css
+ assert "prefers-color-scheme" not in css
+ assert "prefers-reduced-motion: no-preference" in css
+ assert "cdnjs.cloudflare.com" not in response.text
+ assert 'name="theme-color" content="#000000"' in response.text
def test_styles_keep_comment_and_activity_text_readable_on_mobile(isolated_app):
@@ -2703,14 +2704,18 @@ def test_change_password_revokes_other_sessions_and_git_credentials(isolated_app
legacy.cookies['session'] = cookie_encode(('session', str(owner['id'])), gitman.SECRET_KEY).decode()
assert legacy.get('/settings/profile').status_code == 200
profile = client.get('/alice').text
- assert 'id="change-password-open"' in profile
+ assert '/settings/preferences' in profile
+ assert 'password-dialog' not in profile
assert profile.index('aria-label="Notifications"') < profile.index('aria-label="New repository"') < profile.index('aria-label="Profile"')
- assert 'id="change-password-open"' not in WsgiClient(isolated_app.app).get('/alice').text
- assert 'id="change-password-open"' not in client.get('/settings/profile').text
+ password_page = client.get('/settings/password')
+ assert password_page.status_code == 200
+ assert 'name="current_password"' in password_page.text
+ assert '/settings/password' not in WsgiClient(isolated_app.app).get('/alice').text
+ assert client.get('/settings/preferences').status_code == 200
result = client.post('/settings/password', {'current_password': 'correct horse battery staple',
'new_password': 'a different secure password', 'confirm_password': 'a different secure password'})
assert result.status_code == 200 and 'Password changed.' in result.text
- assert 'id="change-password-open"' in result.text
+ assert '<h1>Change password</h1>' in result.text
assert '<h1>Edit profile</h1>' not in result.text
assert client.get('/settings/profile').status_code == 200
for browser in (other, legacy):
@@ -2737,8 +2742,7 @@ def test_change_password_rejects_invalid_input_without_changing_credentials(isol
client.get('/settings/profile')
result = client.post('/settings/password', {'current_password':current, 'new_password':new, 'confirm_password':confirmation})
assert result.status_code == 400
- assert 'data-reopen="true"' in result.text
- assert 'id="change-password-open"' in result.text
+ assert '<h1>Change password</h1>' in result.text
assert '<h1>Edit profile</h1>' not in result.text
assert 'value="'+new+'"' not in result.text
assert isolated_app.get_user_by_id(owner['id'])['password_hash'] == owner['password_hash']
@@ -2757,6 +2761,99 @@ def test_change_password_requires_login_csrf_and_throttles_guessing(isolated_app
assert client.post('/settings/password', {'current_password':'correct horse battery staple', 'new_password':'new-password', 'confirm_password':'new-password'}).status_code == 429
+def test_new_repository_with_bsd_license_commits_license_file(isolated_app):
+ owner = create_user('alice')
+ client = WsgiClient(isolated_app.app)
+ login_client(client, 'alice')
+ new_page = client.get('/new')
+ assert new_page.status_code == 200
+ assert 'None/Custom' in new_page.text
+ for label in ('BSD 0-Clause', 'BSD 1-Clause', 'BSD 2-Clause', 'BSD 3-Clause', 'BSD 4-Clause'):
+ assert label in new_page.text
+
+ result = client.post('/new', {'name': 'licensed', 'description': '', 'license': 'bsd-3'})
+ assert result.status_code == 303
+ path = isolated_app.repo_path('alice', 'licensed')
+ license_text = isolated_app.git_cat(path, 'LICENSE')
+ assert 'BSD 3-Clause License' in license_text
+ assert 'alice' in license_text
+ assert 'Add LICENSE' in client.get('/alice/licensed/commits').text
+ license_page = client.get('/alice/licensed/license')
+ assert license_page.status_code == 200
+ assert 'BSD 3-Clause License' in license_page.text
+ assert 'LICENSE' in client.get('/alice/licensed/src').text
+
+
+def test_new_repository_without_license_skips_license_file(isolated_app):
+ create_user('alice')
+ client = WsgiClient(isolated_app.app)
+ login_client(client, 'alice')
+ assert client.post('/new', {'name': 'bare', 'description': '', 'license': ''}).status_code == 303
+ license_page = client.get('/alice/bare/license')
+ assert license_page.status_code == 200
+ assert 'No license file in this repository.' in license_page.text
+ assert '/alice/bare/license' in client.get('/alice/bare').text
+
+
+def test_repository_files_can_be_edited_from_the_browser(isolated_app):
+ create_user('bob')
+ owner = create_user('alice')
+ isolated_app.create_repository(owner, 'editable', '')
+ path = isolated_app.repo_path('alice', 'editable')
+ commit_file(path, 'notes.txt', 'first version\n', message='initial')
+
+ anonymous = WsgiClient(isolated_app.app)
+ assert anonymous.get('/alice/editable/edit/notes.txt').status_code == 303
+
+ client = WsgiClient(isolated_app.app)
+ login_client(client, 'alice')
+ edit_page = client.get('/alice/editable/edit/notes.txt')
+ assert edit_page.status_code == 200
+ assert 'first version' in edit_page.text
+ assert 'aria-label="Edit file"' in client.get('/alice/editable/src/notes.txt').text
+
+ result = client.post('/alice/editable/edit/notes.txt', {'message': 'Update notes', 'content': 'second version\n'})
+ assert result.status_code == 303
+ assert isolated_app.git_cat(path, 'notes.txt') == 'second version\n'
+ assert 'second version' in client.get('/alice/editable/src/notes.txt').text
+ assert 'Update notes' in client.get('/alice/editable/commits').text
+
+ stranger = WsgiClient(isolated_app.app)
+ login_client(stranger, 'bob')
+ assert stranger.get('/alice/editable/edit/notes.txt').status_code == 403
+ stranger_file = stranger.get('/alice/editable/src/notes.txt')
+ assert stranger_file.status_code == 200
+ assert 'aria-label="Edit file"' not in stranger_file.text
+
+
+def test_preferences_timezone_adapts_displayed_times(isolated_app):
+ owner = create_user('alice')
+ isolated_app.create_repository(owner, 'tzdemo', '')
+ path = isolated_app.repo_path('alice', 'tzdemo')
+ commit_file(path, 'README.md', '# tz\n', message='initial')
+ client = WsgiClient(isolated_app.app)
+ login_client(client, 'alice')
+
+ page = client.get('/settings/preferences')
+ assert page.status_code == 200
+ assert '<option value="Europe/Berlin"' in page.text
+ assert '<option value="UTC" selected' in page.text
+
+ saved = client.post('/settings/preferences', {'timezone': 'Europe/Berlin'})
+ assert saved.status_code == 200
+ assert 'Preferences saved.' in saved.text
+ assert '<option value="Europe/Berlin" selected' in saved.text
+ assert isolated_app.get_user_by_id(owner['id'])['timezone'] == 'Europe/Berlin'
+ assert client.post('/settings/preferences', {'timezone': 'Mars/Olympus'}).status_code == 400
+
+ pattern = re.compile(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}")
+ anonymous_view = WsgiClient(isolated_app.app).get('/alice/tzdemo/commits').text
+ berlin_view = client.get('/alice/tzdemo/commits').text
+ anonymous_time = pattern.search(anonymous_view).group(0)
+ berlin_time = pattern.search(berlin_view).group(0)
+ assert anonymous_time != berlin_time
+
+
def test_session_persists_fourteen_days_but_expires_on_server(isolated_app, monkeypatch):
create_user('alice')
client = WsgiClient(isolated_app.app)
Just saw this, but I added some other things after I merged your other PR @vextoly... I think for now I'm going to put a feature freeze on Gitman for a few weeks to make sure everything is working and to make tiny UI/UX nit picks. We willcome back to this because it definitely has some cool features, my favorite being in browser editing.
I can merge the new features in manually if you'd like
@vextoly Don't worry about it for now, I can go over everything and merge when the time comes.
Alright
I'm thinking we can add timezone and any other prefs on the settings page (like light/dark/auto theme).
I've now put the timezone selection in the main settings page. Password changes also happen on this page. Browser editing and licensing we can merge from here I'm thinking.
I also changed/improved where the global activity feed is located. It now has pagination with load-more-on-scroll. I moved it to the logged in user's profile page. This way we aren't not spending CPU on database lookups for bots and stuff on the homepage. As this is a free service I would like to keep my costs down as much as I can of course.
Nice, thats Understandable