0.4.0.0.a5
- Minor styling fix for the docsite footer - Cleaned up data, variables, etc. relating to the docsite
This commit is contained in:
		
							parent
							
								
									985888fb5a
								
							
						
					
					
						commit
						d768712b75
					
				
							
								
								
									
										2
									
								
								bot.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								bot.py
									
									
									
									
									
								
							@ -9,7 +9,7 @@ from modules.common.boot_notice import post_boot_notice
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Version consists of:
 | 
					# Version consists of:
 | 
				
			||||||
# Major.Enhancement.Minor.Patch.Test  (Test is alphanumeric; doesn’t trigger auto update)
 | 
					# Major.Enhancement.Minor.Patch.Test  (Test is alphanumeric; doesn’t trigger auto update)
 | 
				
			||||||
VERSION = "0.4.0.0.a4"
 | 
					VERSION = "0.4.0.0.a5"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ---------- Env loading ----------
 | 
					# ---------- Env loading ----------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -634,6 +634,9 @@ _HTML = """<!doctype html>
 | 
				
			|||||||
  .flag-emoji { height:1em; width:auto; vertical-align:-0.18em; border-radius:2px; display:inline-block; }
 | 
					  .flag-emoji { height:1em; width:auto; vertical-align:-0.18em; border-radius:2px; display:inline-block; }
 | 
				
			||||||
  footer { margin-top:16px; color:var(--muted); font-size:12px; text-align:center; }
 | 
					  footer { margin-top:16px; color:var(--muted); font-size:12px; text-align:center; }
 | 
				
			||||||
  footer .line { margin:4px 0; }
 | 
					  footer .line { margin:4px 0; }
 | 
				
			||||||
 | 
					  footer a { color: var(--fg); text-decoration: none; border-bottom: 1px dotted #334155; }
 | 
				
			||||||
 | 
					  footer a:hover { text-decoration: underline; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Copy modal */
 | 
					  /* Copy modal */
 | 
				
			||||||
  #copyModal { position: fixed; inset: 0; display:none; align-items:center; justify-content:center; z-index: 10; }
 | 
					  #copyModal { position: fixed; inset: 0; display:none; align-items:center; justify-content:center; z-index: 10; }
 | 
				
			||||||
@ -723,7 +726,9 @@ _HTML = """<!doctype html>
 | 
				
			|||||||
<footer id="footer">
 | 
					<footer id="footer">
 | 
				
			||||||
  <div class="line" id="copyright"></div>
 | 
					  <div class="line" id="copyright"></div>
 | 
				
			||||||
  <div class="line" id="statusline">Uptime: — · Version: v—</div>
 | 
					  <div class="line" id="statusline">Uptime: — · Version: v—</div>
 | 
				
			||||||
    <div class="line" id="coffee"><a href="https://throne.com/ookamikuntv/item/39590391-c582-4c5d-8795-fe6f1925eaae">Buy me a :coffee:</a></div>
 | 
					  <div class="line" id="coffee" style="display:__SUPPORT_VIS__">
 | 
				
			||||||
 | 
					    <a id="supportLink" href="__SUPPORT_URL__" target="_blank" rel="noopener noreferrer">__SUPPORT_LABEL__</a>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
</footer>
 | 
					</footer>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <!-- Copy/share modal -->
 | 
					  <!-- Copy/share modal -->
 | 
				
			||||||
@ -866,7 +871,7 @@ function openCopyModal(text) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  function moduleSansPrefix(r) {
 | 
					  function moduleSansPrefix(r) {
 | 
				
			||||||
    const m = r.module || '';
 | 
					    const m = r.module || '';
 | 
				
			||||||
    return m.replace(/^modules?\\./, '');
 | 
					    return m.replace(/^modules?\./, '').replace(/^discord\.ext\./, '');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async function shareFor(r) {
 | 
					  async function shareFor(r) {
 | 
				
			||||||
@ -1152,6 +1157,28 @@ class _DocsHandler(BaseHTTPRequestHandler):
 | 
				
			|||||||
                    schema = build_command_schema(self.bot)
 | 
					                    schema = build_command_schema(self.bot)
 | 
				
			||||||
                    inline = json.dumps(_to_primitive(schema), ensure_ascii=False, separators=(",", ":"))
 | 
					                    inline = json.dumps(_to_primitive(schema), ensure_ascii=False, separators=(",", ":"))
 | 
				
			||||||
                    html = html.replace("</head>", f"<script>window.__DATA__={inline};</script></head>")
 | 
					                    html = html.replace("</head>", f"<script>window.__DATA__={inline};</script></head>")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    # Inject support link + visibility
 | 
				
			||||||
 | 
					                    support_url = getattr(_DocsHandler, "support_url", "") or ""
 | 
				
			||||||
 | 
					                    support_label = getattr(_DocsHandler, "support_label", "Buy me a ☕")
 | 
				
			||||||
 | 
					                    vis = "block" if support_url else "none"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    html = (html
 | 
				
			||||||
 | 
					                        .replace("__SUPPORT_URL__", support_url)
 | 
				
			||||||
 | 
					                        .replace("__SUPPORT_LABEL__", support_label)
 | 
				
			||||||
 | 
					                        .replace("__SUPPORT_VIS__", vis)
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    # Fallback to values stored on the cog (we’ll wire them below in _start_server)
 | 
				
			||||||
 | 
					                    support_url = support_url or getattr(_DocsHandler, "support_url", "")
 | 
				
			||||||
 | 
					                    support_label = support_label or getattr(_DocsHandler, "support_label", "Buy me a ☕")
 | 
				
			||||||
 | 
					                    vis = "block" if support_url else "none"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    html = (html
 | 
				
			||||||
 | 
					                        .replace("__SUPPORT_URL__", support_url)
 | 
				
			||||||
 | 
					                        .replace("__SUPPORT_LABEL__", support_label)
 | 
				
			||||||
 | 
					                        .replace("__SUPPORT_VIS__", vis)
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
                except Exception:
 | 
					                except Exception:
 | 
				
			||||||
                    traceback.print_exc()
 | 
					                    traceback.print_exc()
 | 
				
			||||||
                self.wfile.write(html.encode("utf-8"))
 | 
					                self.wfile.write(html.encode("utf-8"))
 | 
				
			||||||
@ -1188,6 +1215,8 @@ class _DocsHandler(BaseHTTPRequestHandler):
 | 
				
			|||||||
def _start_server(bot: commands.Bot, host: str, port: int, title: str):
 | 
					def _start_server(bot: commands.Bot, host: str, port: int, title: str):
 | 
				
			||||||
    _DocsHandler.bot = bot
 | 
					    _DocsHandler.bot = bot
 | 
				
			||||||
    _DocsHandler.title = title
 | 
					    _DocsHandler.title = title
 | 
				
			||||||
 | 
					    _DocsHandler.support_url = getattr(bot, "docs_support_url", None)
 | 
				
			||||||
 | 
					    _DocsHandler.support_label = getattr(bot, "docs_support_label", None)
 | 
				
			||||||
    _DocsHandler.force_ready = os.getenv("SHAI_OFFLINE", "").lower() in {"1", "true", "yes"}
 | 
					    _DocsHandler.force_ready = os.getenv("SHAI_OFFLINE", "").lower() in {"1", "true", "yes"}
 | 
				
			||||||
    httpd = ThreadingHTTPServer((host, port), _DocsHandler)
 | 
					    httpd = ThreadingHTTPServer((host, port), _DocsHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1207,9 +1236,19 @@ class DocsSite(commands.Cog):
 | 
				
			|||||||
    def __init__(self, bot: commands.Bot):
 | 
					    def __init__(self, bot: commands.Bot):
 | 
				
			||||||
        self.bot = bot
 | 
					        self.bot = bot
 | 
				
			||||||
        r = cfg(bot)
 | 
					        r = cfg(bot)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.host = r.get("docs_host", "0.0.0.0")     # SHAI_DOCS_HOST
 | 
					        self.host = r.get("docs_host", "0.0.0.0")     # SHAI_DOCS_HOST
 | 
				
			||||||
        self.port = r.int("docs_port", 8910)          # SHAI_DOCS_PORT
 | 
					        self.port = r.int("docs_port", 8910)          # SHAI_DOCS_PORT
 | 
				
			||||||
        self.title = r.get("docs_title", "ShaiWatcher Commands")  # SHAI_DOCS_TITLE
 | 
					        self.title = r.get("docs_title", "ShaiWatcher Commands")  # SHAI_DOCS_TITLE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Support link config
 | 
				
			||||||
 | 
					        self.support_url = r.get("docs_support_url", "https://throne.com/ookamikuntv/item/39590391-c582-4c5d-8795-fe6f1925eaae")
 | 
				
			||||||
 | 
					        self.support_label = r.get("docs_support_label", "Buy me a ☕")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Expose to handler via bot (read in _start_server)
 | 
				
			||||||
 | 
					        self.bot.docs_support_url = self.support_url
 | 
				
			||||||
 | 
					        self.bot.docs_support_label = self.support_label
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        _start_server(self.bot, self.host, self.port, self.title)
 | 
					        _start_server(self.bot, self.host, self.port, self.title)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def force_ready(self, value: bool = True):
 | 
					    def force_ready(self, value: bool = True):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user