diff --git a/CHANGELOG.md b/CHANGELOG.md index cdf7163f8..881ba67cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/javascript/changelog.js b/javascript/changelog.js index 80c9956b8..97dc9daf5 100644 --- a/javascript/changelog.js +++ b/javascript/changelog.js @@ -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; +} diff --git a/javascript/sdnext.css b/javascript/sdnext.css index d412d966f..192d0d487 100644 --- a/javascript/sdnext.css +++ b/javascript/sdnext.css @@ -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; } diff --git a/modules/ui.py b/modules/ui.py index 039ef6487..4a9d35728 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -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') diff --git a/modules/ui_docs.py b/modules/ui_docs.py new file mode 100644 index 000000000..7f85aa851 --- /dev/null +++ b/modules/ui_docs.py @@ -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('  Open GitHub Changelog') + 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('  Open GitHub Wiki') + 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]) diff --git a/wiki b/wiki index 6efc9b690..371344bcb 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 6efc9b6907048762456dbd530ed67e6a48ee4f1b +Subproject commit 371344bcbf8da64f7ae373d1d6d1312ef44898c3