Merge pull request #11520 from AUTOMATIC1111/extension-metadata

Extension metadata
This commit is contained in:
AUTOMATIC1111 2023-07-08 14:30:17 +03:00 committed by GitHub
commit b25925c95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 4 deletions

View File

@ -424,9 +424,19 @@ sort_ordering = [
(False, lambda x: x.get('name', 'z')), (False, lambda x: x.get('name', 'z')),
(True, lambda x: x.get('name', 'z')), (True, lambda x: x.get('name', 'z')),
(False, lambda x: 'z'), (False, lambda x: 'z'),
(True, lambda x: x.get('commit_time', '')),
(True, lambda x: x.get('created_at', '')),
(True, lambda x: x.get('stars', 0)),
] ]
def get_date(info: dict, key):
try:
return datetime.strptime(info.get(key), "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d")
except (ValueError, TypeError):
return ''
def refresh_available_extensions_from_data(hide_tags, sort_column, filter_text=""): def refresh_available_extensions_from_data(hide_tags, sort_column, filter_text=""):
extlist = available_extensions["extensions"] extlist = available_extensions["extensions"]
installed_extension_urls = {normalize_git_url(extension.remote): extension.name for extension in extensions.extensions} installed_extension_urls = {normalize_git_url(extension.remote): extension.name for extension in extensions.extensions}
@ -451,7 +461,10 @@ def refresh_available_extensions_from_data(hide_tags, sort_column, filter_text="
for ext in sorted(extlist, key=sort_function, reverse=sort_reverse): for ext in sorted(extlist, key=sort_function, reverse=sort_reverse):
name = ext.get("name", "noname") name = ext.get("name", "noname")
stars = int(ext.get("stars", 0))
added = ext.get('added', 'unknown') added = ext.get('added', 'unknown')
update_time = get_date(ext, 'commit_time')
create_time = get_date(ext, 'created_at')
url = ext.get("url", None) url = ext.get("url", None)
description = ext.get("description", "") description = ext.get("description", "")
extension_tags = ext.get("tags", []) extension_tags = ext.get("tags", [])
@ -478,7 +491,8 @@ def refresh_available_extensions_from_data(hide_tags, sort_column, filter_text="
code += f""" code += f"""
<tr> <tr>
<td><a href="{html.escape(url)}" target="_blank">{html.escape(name)}</a><br />{tags_text}</td> <td><a href="{html.escape(url)}" target="_blank">{html.escape(name)}</a><br />{tags_text}</td>
<td>{html.escape(description)}<p class="info"><span class="date_added">Added: {html.escape(added)}</span></p></td> <td>{html.escape(description)}<p class="info">
<span class="date_added">Update: {html.escape(update_time)} Added: {html.escape(added)} Created: {html.escape(create_time)}</span><span class="star_count">stars: <b>{stars}</b></a></p></td>
<td>{install_code}</td> <td>{install_code}</td>
</tr> </tr>
@ -562,7 +576,7 @@ def create_ui():
with gr.Row(): with gr.Row():
hide_tags = gr.CheckboxGroup(value=["ads", "localization", "installed"], label="Hide extensions with tags", choices=["script", "ads", "localization", "installed"]) hide_tags = gr.CheckboxGroup(value=["ads", "localization", "installed"], label="Hide extensions with tags", choices=["script", "ads", "localization", "installed"])
sort_column = gr.Radio(value="newest first", label="Order", choices=["newest first", "oldest first", "a-z", "z-a", "internal order", ], type="index") sort_column = gr.Radio(value="newest first", label="Order", choices=["newest first", "oldest first", "a-z", "z-a", "internal order",'update time', 'create time', "stars"], type="index")
with gr.Row(): with gr.Row():
search_extensions_text = gr.Text(label="Search").style(container=False) search_extensions_text = gr.Text(label="Search").style(container=False)

View File

@ -704,11 +704,24 @@ table.popup-table .link{
margin: 0; margin: 0;
} }
#available_extensions .date_added{ #available_extensions .info{
opacity: 0.85; margin: 0.5em 0;
display: flex;
margin-top: auto;
opacity: 0.80;
font-size: 90%; font-size: 90%;
} }
#available_extensions .date_added{
margin-right: auto;
display: inline-block;
}
#available_extensions .star_count{
margin-left: auto;
display: inline-block;
}
/* replace original footer with ours */ /* replace original footer with ours */
footer { footer {