57 Commits

Author SHA1 Message Date
081f277b92 custom_components/bahmcloud_store/core.py aktualisiert 2026-01-15 15:15:47 +00:00
28b86e19e1 custom_components/bahmcloud_store/core.py aktualisiert 2026-01-15 15:09:33 +00:00
e863677428 custom_components/bahmcloud_store/core.py aktualisiert 2026-01-15 15:04:13 +00:00
3f6da60c0d revert 2770e56219
revert custom_components/bahmcloud_store/update.py aktualisiert
2026-01-15 14:39:04 +00:00
8ac0ef103c revert 25b9c79114
revert custom_components/bahmcloud_store/views.py aktualisiert
2026-01-15 14:38:54 +00:00
6a0132a25c revert 2c50765d66
revert custom_components/bahmcloud_store/store.py aktualisiert
2026-01-15 14:38:38 +00:00
60c46aa121 revert 1837ed4a13
revert custom_components/bahmcloud_store/metadata.py aktualisiert
2026-01-15 14:38:23 +00:00
1caad401f6 revert c4f0f94a6f
revert custom_components/bahmcloud_store/providers.py aktualisiert
2026-01-15 14:38:11 +00:00
5684c3d5f1 revert 1dbffcc27c
revert custom_components/bahmcloud_store/core.py aktualisiert
2026-01-15 14:38:00 +00:00
f3863ee227 revert a2d123abbf
revert custom_components/bahmcloud_store/__init__.py aktualisiert
2026-01-15 14:37:48 +00:00
e867e82a2d revert 0e6088070e
revert custom_components/bahmcloud_store/manifest.json aktualisiert
2026-01-15 14:37:01 +00:00
2770e56219 custom_components/bahmcloud_store/update.py aktualisiert 2026-01-15 14:32:31 +00:00
25b9c79114 custom_components/bahmcloud_store/views.py aktualisiert 2026-01-15 14:32:17 +00:00
2c50765d66 custom_components/bahmcloud_store/store.py aktualisiert 2026-01-15 14:31:58 +00:00
1837ed4a13 custom_components/bahmcloud_store/metadata.py aktualisiert 2026-01-15 14:31:38 +00:00
c4f0f94a6f custom_components/bahmcloud_store/providers.py aktualisiert 2026-01-15 14:31:16 +00:00
1dbffcc27c custom_components/bahmcloud_store/core.py aktualisiert 2026-01-15 14:30:54 +00:00
a2d123abbf custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 14:30:33 +00:00
0e6088070e custom_components/bahmcloud_store/manifest.json aktualisiert 2026-01-15 14:30:15 +00:00
dc32010bf9 revert 692f0b47da
revert custom_components/bahmcloud_store/providers.py aktualisiert
2026-01-15 14:23:34 +00:00
3ed6a1a18c revert 106872063a
revert custom_components/bahmcloud_store/panel/panel.js aktualisiert
2026-01-15 14:22:11 +00:00
8ff5ab2e31 Dateien nach "custom_components/bahmcloud_store/panel" hochladen 2026-01-15 14:20:58 +00:00
2a0dc9d66c custom_components/bahmcloud_store/styles.css gelöscht 2026-01-15 14:20:03 +00:00
fbfc2e3a6e custom_components/bahmcloud_store/index.html gelöscht 2026-01-15 14:19:54 +00:00
19a5c0fecb custom_components/bahmcloud_store/app.js gelöscht 2026-01-15 14:19:48 +00:00
c0ec7b1797 custom_components/bahmcloud_store/panel.js gelöscht 2026-01-15 14:19:44 +00:00
25f966853a Dateien nach "custom_components/bahmcloud_store" hochladen 2026-01-15 14:09:05 +00:00
3edeab514b custom_components/bahmcloud_store/panel/styles.css gelöscht 2026-01-15 14:08:48 +00:00
d713bf779f custom_components/bahmcloud_store/panel/panel.js gelöscht 2026-01-15 14:08:44 +00:00
2b78feeadf custom_components/bahmcloud_store/panel/index.html gelöscht 2026-01-15 14:08:40 +00:00
a940c68e9e custom_components/bahmcloud_store/panel/app.js gelöscht 2026-01-15 14:08:35 +00:00
6c3cdcde61 Dateien nach "custom_components/bahmcloud_store" hochladen 2026-01-15 14:08:27 +00:00
1fc274bf7c Dateien nach "custom_components/bahmcloud_store" hochladen 2026-01-15 14:08:13 +00:00
4ff94bc185 custom_components/bahmcloud_store/views.py gelöscht 2026-01-15 14:07:49 +00:00
b95b3f5626 custom_components/bahmcloud_store/update.py gelöscht 2026-01-15 14:07:46 +00:00
30d47b775b custom_components/bahmcloud_store/store.py gelöscht 2026-01-15 14:07:42 +00:00
bedf6b6bf8 custom_components/bahmcloud_store/storage.py gelöscht 2026-01-15 14:07:38 +00:00
e2f8b4625a custom_components/bahmcloud_store/providers.py gelöscht 2026-01-15 14:07:34 +00:00
bb340108e2 custom_components/bahmcloud_store/manifest.json gelöscht 2026-01-15 14:07:31 +00:00
a617ca6709 custom_components/bahmcloud_store/metadata.py gelöscht 2026-01-15 14:07:27 +00:00
7789430d4a custom_components/bahmcloud_store/custom_repo_view.py gelöscht 2026-01-15 14:07:23 +00:00
4e8116265d custom_components/bahmcloud_store/core.py gelöscht 2026-01-15 14:07:19 +00:00
06796cf57b custom_components/bahmcloud_store/__init__.py gelöscht 2026-01-15 14:07:15 +00:00
dbcac9df86 custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 13:52:57 +00:00
6ca193580d custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 13:35:18 +00:00
3773b07650 custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 13:27:22 +00:00
24dcc92c00 custom_components/bahmcloud_store/panel/panel.js aktualisiert 2026-01-15 13:23:27 +00:00
596491f885 custom_components/bahmcloud_store/views.py aktualisiert 2026-01-15 13:23:06 +00:00
97c9f01a0a custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 13:22:45 +00:00
c39a948c59 custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 13:09:32 +00:00
4fd0a6ec48 custom_components/bahmcloud_store/panel/panel.js aktualisiert 2026-01-15 13:05:40 +00:00
b84ab944b3 custom_components/bahmcloud_store/__init__.py aktualisiert 2026-01-15 13:05:24 +00:00
ce4bd4f4f1 custom_components/bahmcloud_store/views.py aktualisiert 2026-01-15 13:05:07 +00:00
2dce858a51 custom_components/bahmcloud_store/views.py aktualisiert 2026-01-15 12:55:47 +00:00
2c8da4a049 custom_components/bahmcloud_store/providers.py aktualisiert 2026-01-15 12:55:23 +00:00
692f0b47da custom_components/bahmcloud_store/providers.py aktualisiert 2026-01-15 12:54:13 +00:00
106872063a custom_components/bahmcloud_store/panel/panel.js aktualisiert 2026-01-15 12:45:18 +00:00

View File

@@ -198,10 +198,14 @@ class BCSCore:
raise BCSError(f"Invalid store.yaml: {e}") from e
async def add_custom_repo(self, url: str, name: str | None) -> CustomRepo:
repo = await self.storage.add_custom_repo(url=url, name=name)
url = str(url or "").strip()
if not url:
raise BCSError("Missing url")
c = await self.storage.add_custom_repo(url, name)
await self.refresh()
self.signal_updated()
return repo
return c
async def remove_custom_repo(self, repo_id: str) -> None:
await self.storage.remove_custom_repo(repo_id)
@@ -214,7 +218,6 @@ class BCSCore:
def list_repos_public(self) -> list[dict[str, Any]]:
out: list[dict[str, Any]] = []
for r in self.repos.values():
resolved_description = r.meta_description or r.provider_description
out.append(
{
"id": r.id,
@@ -223,46 +226,30 @@ class BCSCore:
"source": r.source,
"owner": r.owner,
"provider": r.provider,
"meta_source": r.meta_source,
"meta_name": r.meta_name,
"meta_description": r.meta_description,
"meta_category": r.meta_category,
"meta_author": r.meta_author,
"meta_maintainer": r.meta_maintainer,
"provider_repo_name": r.provider_repo_name,
"provider_description": r.provider_description,
"description": resolved_description,
"category": r.meta_category,
"repo_name": r.provider_repo_name,
"description": r.provider_description or r.meta_description,
"default_branch": r.default_branch,
"latest_version": r.latest_version,
"latest_version_source": r.latest_version_source,
"category": r.meta_category,
"meta_author": r.meta_author,
"meta_maintainer": r.meta_maintainer,
"meta_source": r.meta_source,
}
)
return out
# ----------------------------
# README fetching
# ----------------------------
def _normalize_repo_name(self, name: str | None) -> str | None:
if not name:
return None
n = name.strip()
if n.endswith(".git"):
n = n[:-4]
return n or None
def _split_owner_repo(self, repo_url: str) -> tuple[str | None, str | None]:
u = urlparse(repo_url.rstrip("/"))
parts = [p for p in u.path.strip("/").split("/") if p]
if len(parts) < 2:
return None, None
owner = parts[0].strip() or None
repo = self._normalize_repo_name(parts[1])
return owner, repo
name = parts[1].strip()
if name.endswith(".git"):
name = name[:-4]
name = name.strip() or None
return owner, name
def _is_github(self, repo_url: str) -> bool:
return "github.com" in urlparse(repo_url).netloc.lower()
@@ -282,42 +269,93 @@ class BCSCore:
return None
async def fetch_readme_markdown(self, repo_id: str) -> str | None:
"""Fetch README markdown from GitHub, Gitea or GitLab.
Defensive behavior:
- tries multiple common filenames
- tries multiple branches (default, main, master)
- uses public raw endpoints (no tokens required for public repositories)
"""
repo = self.get_repo(repo_id)
if not repo:
return None
owner, name = self._split_owner_repo(repo.url)
if not owner or not name:
repo_url = (repo.url or "").strip()
if not repo_url:
return None
branch = repo.default_branch or "main"
filenames = ["README.md", "readme.md", "README.MD"]
# Branch fallbacks
branch_candidates: list[str] = []
if repo.default_branch and str(repo.default_branch).strip():
branch_candidates.append(str(repo.default_branch).strip())
for b in ("main", "master"):
if b not in branch_candidates:
branch_candidates.append(b)
# Filename fallbacks
filenames = ["README.md", "readme.md", "README.MD", "README.rst", "README"]
provider = (repo.provider or "").strip().lower()
if not provider:
provider = detect_provider(repo_url) or ""
u = urlparse(repo_url.rstrip("/"))
host = (u.netloc or "").lower()
candidates: list[str] = []
if self._is_github(repo.url):
# raw github content
base = f"https://raw.githubusercontent.com/{owner}/{name}/{branch}"
candidates.extend([f"{base}/{fn}" for fn in filenames])
if self._is_github(repo_url):
owner, name = self._split_owner_repo(repo_url)
if not owner or not name:
return None
for branch in branch_candidates:
base = f"https://raw.githubusercontent.com/{owner}/{name}/{branch}"
candidates.extend([f"{base}/{fn}" for fn in filenames])
elif provider == "gitlab" or "gitlab" in host:
# GitLab can have nested groups: /group/subgroup/repo
parts = [p for p in u.path.strip("/").split("/") if p]
if len(parts) < 2:
return None
repo_name = parts[-1].strip()
if repo_name.endswith(".git"):
repo_name = repo_name[:-4]
group_path = "/".join(parts[:-1]).strip("/")
if not group_path or not repo_name:
return None
root = f"{u.scheme}://{u.netloc}/{group_path}/{repo_name}"
for branch in branch_candidates:
bases = [
f"{root}/-/raw/{branch}",
# Some instances may expose /raw/<branch> as well
f"{root}/raw/{branch}",
]
for b in bases:
candidates.extend([f"{b}/{fn}" for fn in filenames])
elif self._is_gitea(repo_url):
owner, name = self._split_owner_repo(repo_url)
if not owner or not name:
return None
elif self._is_gitea(repo.url):
u = urlparse(repo.url.rstrip("/"))
root = f"{u.scheme}://{u.netloc}/{owner}/{name}"
# gitea raw endpoints (both common forms)
bases = [
f"{root}/raw/branch/{branch}",
f"{root}/raw/{branch}",
]
for b in bases:
candidates.extend([f"{b}/{fn}" for fn in filenames])
for branch in branch_candidates:
bases = [
f"{root}/raw/branch/{branch}",
f"{root}/raw/{branch}",
]
for b in bases:
candidates.extend([f"{b}/{fn}" for fn in filenames])
else:
return None
for url in candidates:
txt = await self._fetch_text(url)
if txt:
if txt and txt.strip():
return txt
return None