wiki search

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2024-11-07 19:44:53 -05:00
parent 9fef22735f
commit 3f2d3d208d
5 changed files with 86 additions and 14 deletions
+3 -1
View File
@@ -6,9 +6,11 @@ Smaller release just few days after the last one, but with some important fixes
This release can be considered an LTS release before we kick off the next round of major updates.
- Docs:
- add built-in [changelog](https://github.com/vladmandic/automatic/blob/master/CHANGELOG.md) search
- UI built-in [changelog](https://github.com/vladmandic/automatic/blob/master/CHANGELOG.md) search
since changelog is the best up-to-date source of info
go to system -> changelog and search/highligh/navigate directly in UI!
- UI built-in [wiki](https://github.com/vladmandic/automatic/wiki)
go to system -> wiki and search wiki pages directly in UI!
- major [Wiki](https://github.com/vladmandic/automatic/wiki) updates
- Integrations:
- [PuLID](https://github.com/ToTheBeginning/PuLID): Pure and Lightning ID Customization via Contrastive Alignment
+7
View File
@@ -75,3 +75,10 @@ async function initChangelog() {
};
search.addEventListener('keyup', searchChangelog);
}
function wikiSearch(txt) {
log('wikiSearch', txt);
const url = `https://github.com/search?q=repo%3Avladmandic%2Fautomatic+${encodeURIComponent(txt)}&type=wikis`;
// window.open(url, '_blank').focus();
return txt;
}
+5
View File
@@ -326,6 +326,11 @@ div:has(>#tab-gallery-folders) { flex-grow: 0 !important; background-color: var(
.changelog_arrow:hover { background-color: var(--button-primary-border-color-hover); }
.changelog_highlight { background-color: var(--color-warning); }
/* wiki */
#wiki_result > div > div { padding: 0.5em; margin-right: 2em; }
#wiki_result li { display: block; }
#wiki_result h3 { background-color: var(--background-fill-primary); margin: 0; padding: 0.3em; margin-bottom: 0.2em; }
/* loader */
.splash { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1000; display: block; text-align: center; }
.motd { margin-top: 2em; color: var(--body-text-color-subdued); font-family: monospace; font-variant: all-petite-caps; }
+5 -13
View File
@@ -355,20 +355,12 @@ def create_ui(startup_timer = None):
ui_onnx.create_ui()
with gr.TabItem("Change log", id="change_log", elem_id="system_tab_changelog"):
def get_changelog():
with open('CHANGELOG.md', 'r', encoding='utf-8') as f:
content = f.read()
content = content.replace('# Change Log for SD.Next', ' ')
return content
from modules import ui_docs
ui_docs.create_ui_logs()
with gr.Column():
get_changelog_btn = gr.Button(value='Get changelog', elem_id="get_changelog")
with gr.Column():
_changelog_search = gr.Textbox(label="Search", elem_id="changelog_search")
_changelog_result = gr.HTML(elem_id="changelog_result")
changelog_markdown = gr.Markdown('', elem_id="changelog_markdown")
get_changelog_btn.click(fn=get_changelog, outputs=[changelog_markdown], show_progress=True)
with gr.TabItem("Wiki", id="wiki", elem_id="system_tab_wiki"):
from modules import ui_docs
ui_docs.create_ui_wiki()
def unload_sd_weights():
modules.sd_models.unload_model_weights(op='model')
+66
View File
@@ -0,0 +1,66 @@
import gradio as gr
from modules import ui_symbols, ui_components
def create_ui_logs():
def get_changelog():
with open('CHANGELOG.md', 'r', encoding='utf-8') as f:
content = f.read()
content = content.replace('# Change Log for SD.Next', ' ')
return content
with gr.Column():
get_changelog_btn = gr.Button(value='Get changelog', elem_id="get_changelog")
gr.HTML('<a href="https://github.com/vladmandic/automatic/blob/dev/CHANGELOG.md" style="color: #AAA" target="_blank">&nbsp Open GitHub Changelog</a>')
with gr.Column():
_changelog_search = gr.Textbox(label="Search Changelog", elem_id="changelog_search")
_changelog_result = gr.HTML(elem_id="changelog_result")
changelog_markdown = gr.Markdown('', elem_id="changelog_markdown")
get_changelog_btn.click(fn=get_changelog, outputs=[changelog_markdown], show_progress=True)
def create_ui_wiki():
def search_github(search_term):
import requests
from urllib.parse import quote
from installer import install
install('beautifulsoup4')
from bs4 import BeautifulSoup
url = f'https://github.com/search?q=repo%3Avladmandic%2Fautomatic+{quote(search_term)}&type=wikis'
res = requests.get(url, timeout=10)
if res.status_code == 200:
html = res.content
soup = BeautifulSoup(html, 'html.parser')
# remove header links
tags = soup.find_all(attrs={"data-hovercard-url": "/vladmandic/automatic/hovercard"})
for tag in tags:
tag.extract()
# replace relative links with full links
tags = soup.find_all('a')
for tag in tags:
if tag.has_attr('href') and tag['href'].startswith('/'):
tag['href'] = 'https://github.com' + tag['href']
# find result only
result = soup.find(attrs={"data-testid": "results-list"})
if result is None:
return 'No results found'
html = str(result)
return html
else:
return f'Error: {res.status_code}'
with gr.Row():
gr.HTML('<a href="https://github.com/vladmandic/automatic/wiki" style="color: #AAA" target="_blank">&nbsp Open GitHub Wiki</a>')
with gr.Row():
wiki_search = gr.Textbox(label="Search Wiki Pages", elem_id="wiki_search")
wiki_search_btn = ui_components.ToolButton(value=ui_symbols.search, label="Search", elem_id="wiki_search_btn")
with gr.Row():
wiki_result = gr.HTML(elem_id="wiki_result", value='test')
wiki_search.submit(_js="wikiSearch", fn=search_github, inputs=[wiki_search], outputs=[wiki_result])
wiki_search_btn.click(_js="wikiSearch", fn=search_github, inputs=[wiki_search], outputs=[wiki_result])