mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-27 09:11:57 +02:00
Merge remote-tracking branch 'origin/extension_install_02' into extension_install_02
This commit is contained in:
commit
7366200571
@ -88,9 +88,9 @@ async def add_installed_extension(
|
|||||||
|
|
||||||
await (conn or db).execute(
|
await (conn or db).execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO installed_extensions (id, version, name, short_description, icon, icon_url, stars, meta) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
INSERT INTO installed_extensions (id, version, name, short_description, icon, stars, meta) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
ON CONFLICT (id) DO
|
ON CONFLICT (id) DO
|
||||||
UPDATE SET (version, name, active, short_description, icon, icon_url, stars, meta) = (?, ?, ?, ?, ?, ?, ?, ?)
|
UPDATE SET (version, name, active, short_description, icon, stars, meta) = (?, ?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(
|
(
|
||||||
ext.id,
|
ext.id,
|
||||||
@ -98,7 +98,6 @@ async def add_installed_extension(
|
|||||||
ext.name,
|
ext.name,
|
||||||
ext.short_description,
|
ext.short_description,
|
||||||
ext.icon,
|
ext.icon,
|
||||||
ext.icon_url,
|
|
||||||
ext.stars,
|
ext.stars,
|
||||||
json.dumps(meta),
|
json.dumps(meta),
|
||||||
version,
|
version,
|
||||||
@ -106,7 +105,6 @@ async def add_installed_extension(
|
|||||||
False,
|
False,
|
||||||
ext.short_description,
|
ext.short_description,
|
||||||
ext.icon,
|
ext.icon,
|
||||||
ext.icon_url,
|
|
||||||
ext.stars,
|
ext.stars,
|
||||||
json.dumps(meta),
|
json.dumps(meta),
|
||||||
),
|
),
|
||||||
|
@ -294,7 +294,6 @@ async def m010_create_installed_extensions_table(db):
|
|||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
short_description TEXT,
|
short_description TEXT,
|
||||||
icon TEXT,
|
icon TEXT,
|
||||||
icon_url TEXT,
|
|
||||||
stars INT NOT NULL DEFAULT 0,
|
stars INT NOT NULL DEFAULT 0,
|
||||||
active BOOLEAN DEFAULT false,
|
active BOOLEAN DEFAULT false,
|
||||||
meta TEXT NOT NULL DEFAULT '{}'
|
meta TEXT NOT NULL DEFAULT '{}'
|
||||||
|
@ -736,7 +736,7 @@ async def api_install_extension(
|
|||||||
status_code=HTTPStatus.NOT_FOUND, detail="Release not found"
|
status_code=HTTPStatus.NOT_FOUND, detail="Release not found"
|
||||||
)
|
)
|
||||||
ext_info = InstallableExtension(
|
ext_info = InstallableExtension(
|
||||||
id=data.ext_id, name=data.ext_id, installed_release=release
|
id=data.ext_id, name=data.ext_id, installed_release=release, icon=release.icon
|
||||||
)
|
)
|
||||||
|
|
||||||
ext_info.download_archive()
|
ext_info.download_archive()
|
||||||
|
@ -106,10 +106,12 @@ class ExtensionRelease(BaseModel):
|
|||||||
version: str
|
version: str
|
||||||
archive: str
|
archive: str
|
||||||
source_repo: str
|
source_repo: str
|
||||||
|
is_github_release = False
|
||||||
hash: Optional[str]
|
hash: Optional[str]
|
||||||
html_url: Optional[str]
|
html_url: Optional[str]
|
||||||
description: Optional[str]
|
description: Optional[str]
|
||||||
details_html: Optional[str] = None
|
details_html: Optional[str] = None
|
||||||
|
icon: Optional[str]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_github_release(
|
def from_github_release(
|
||||||
@ -121,6 +123,7 @@ class ExtensionRelease(BaseModel):
|
|||||||
version=r.tag_name,
|
version=r.tag_name,
|
||||||
archive=r.zipball_url,
|
archive=r.zipball_url,
|
||||||
source_repo=source_repo,
|
source_repo=source_repo,
|
||||||
|
is_github_release=True,
|
||||||
# description=r.body, # bad for JSON
|
# description=r.body, # bad for JSON
|
||||||
html_url=r.html_url,
|
html_url=r.html_url,
|
||||||
)
|
)
|
||||||
@ -181,7 +184,7 @@ class GitHubRepo(BaseModel):
|
|||||||
class ExtensionConfig(BaseModel):
|
class ExtensionConfig(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
short_description: str
|
short_description: str
|
||||||
tile: str
|
tile: str = ""
|
||||||
|
|
||||||
|
|
||||||
class InstallableExtension(BaseModel):
|
class InstallableExtension(BaseModel):
|
||||||
@ -189,7 +192,6 @@ class InstallableExtension(BaseModel):
|
|||||||
name: str
|
name: str
|
||||||
short_description: Optional[str] = None
|
short_description: Optional[str] = None
|
||||||
icon: Optional[str] = None
|
icon: Optional[str] = None
|
||||||
icon_url: Optional[str] = None
|
|
||||||
dependencies: List[str] = []
|
dependencies: List[str] = []
|
||||||
is_admin_only: bool = False
|
is_admin_only: bool = False
|
||||||
stars: int = 0
|
stars: int = 0
|
||||||
@ -287,9 +289,13 @@ class InstallableExtension(BaseModel):
|
|||||||
|
|
||||||
self.name = config_json.get("name")
|
self.name = config_json.get("name")
|
||||||
self.short_description = config_json.get("short_description")
|
self.short_description = config_json.get("short_description")
|
||||||
self.icon = config_json.get("icon")
|
|
||||||
if self.installed_release and config_json.get("tile"):
|
if (
|
||||||
self.icon_url = icon_to_github_url(
|
self.installed_release
|
||||||
|
and self.installed_release.is_github_release
|
||||||
|
and config_json.get("tile")
|
||||||
|
):
|
||||||
|
self.icon = icon_to_github_url(
|
||||||
self.installed_release.source_repo, config_json.get("tile")
|
self.installed_release.source_repo, config_json.get("tile")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -345,7 +351,7 @@ class InstallableExtension(BaseModel):
|
|||||||
short_description=config.short_description,
|
short_description=config.short_description,
|
||||||
version="0",
|
version="0",
|
||||||
stars=repo.stargazers_count,
|
stars=repo.stargazers_count,
|
||||||
icon_url=icon_to_github_url(
|
icon=icon_to_github_url(
|
||||||
f"{github_release.organisation}/{github_release.repository}",
|
f"{github_release.organisation}/{github_release.repository}",
|
||||||
config.tile,
|
config.tile,
|
||||||
),
|
),
|
||||||
@ -427,6 +433,7 @@ class InstallableExtension(BaseModel):
|
|||||||
description=e.short_description,
|
description=e.short_description,
|
||||||
details_html=e.details,
|
details_html=e.details,
|
||||||
html_url=e.html_url,
|
html_url=e.html_url,
|
||||||
|
icon=e.icon,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user