Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mkdocs.config import config_options
from mkdocs.plugins import BasePlugin

import plugin.processor as processor
from plugin import processor
from plugin.processor import process_html
from plugin.utils import resolve_all_authors

Expand Down
36 changes: 18 additions & 18 deletions plugin/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
except ImportError:
TQDM = None

import plugin.processor as processor
from plugin import processor
from plugin.processor import process_html
from plugin.utils import resolve_all_authors

Expand Down Expand Up @@ -304,23 +304,23 @@ def postprocess_site(
# Enable logging only for the synchronous path; pools run without per-task log_fn to remain pickle-safe.
log_fn = (progress.write if verbose and progress else print if verbose else None) if worker_count == 1 else None

task_kwargs = dict(
site_dir=site_dir,
md_index=md_index,
git_data=git_data,
repo_url=repo_url,
site_url=site_url,
default_image=default_image,
add_desc=add_desc,
add_image=add_image,
add_keywords=add_keywords,
add_share_buttons=add_share_buttons,
add_authors=add_authors,
add_json_ld=add_json_ld,
add_css=add_css,
add_copy_llm=add_copy_llm,
verbose=verbose,
)
task_kwargs = {
"site_dir": site_dir,
"md_index": md_index,
"git_data": git_data,
"repo_url": repo_url,
"site_url": site_url,
"default_image": default_image,
"add_desc": add_desc,
"add_image": add_image,
"add_keywords": add_keywords,
"add_share_buttons": add_share_buttons,
"add_authors": add_authors,
"add_json_ld": add_json_ld,
"add_css": add_css,
"add_copy_llm": add_copy_llm,
"verbose": verbose,
}

if worker_count == 1:
for html_file in html_files:
Expand Down
4 changes: 2 additions & 2 deletions plugin/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import json
import re
import subprocess
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Any
from urllib.parse import quote
Expand All @@ -15,7 +15,7 @@

from plugin.utils import calculate_time_difference, get_youtube_video_ids

today = datetime.now()
today = datetime.now(timezone.utc)
DEFAULT_CREATION_DATE = (today - timedelta(days=365)).strftime("%Y-%m-%d %H:%M:%S +0000")
DEFAULT_MODIFIED_DATE = (today - timedelta(days=40)).strftime("%Y-%m-%d %H:%M:%S +0000")

Expand Down
27 changes: 12 additions & 15 deletions plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,17 @@ def resolve_github_user(

# Query the commit API when git history provides a commit for this email. This resolves authors whose commit email
# is linked to a GitHub account but hidden from user search.
if repo_path := _github_repo_path(repo_url):
if commit_sha:
try:
response = requests.get(
f"https://api.github.com/repos/{repo_path}/commits/{commit_sha}", timeout=TIMEOUT
)
if response.status_code == 200:
data = response.json()
author = data.get("author") or {}
if author.get("login") and author.get("avatar_url"):
cache[email] = {"username": author["login"], "avatar": author["avatar_url"]}
return cache[email]
except Exception:
pass
if (repo_path := _github_repo_path(repo_url)) and commit_sha:
try:
response = requests.get(f"https://api.github.com/repos/{repo_path}/commits/{commit_sha}", timeout=TIMEOUT)
if response.status_code == 200:
data = response.json()
author = data.get("author") or {}
if author.get("login") and author.get("avatar_url"):
cache[email] = {"username": author["login"], "avatar": author["avatar_url"]}
return cache[email]
except Exception:
pass

# Query GitHub REST API
if verbose:
Expand Down Expand Up @@ -238,7 +235,7 @@ def resolve_all_authors(
# Build authors list for each file entry
github_repo_url = repo_url or "https://github.com/ultralytics/ultralytics"

for file_path, entry in git_data.items():
for entry in git_data.values():
emails = entry.get("emails", {})
if not emails and default_author:
emails = {default_author: 1}
Expand Down