diff --git a/my-blog/static/css/style.css b/my-blog/static/css/style.css
index dff34c9..d9b1eb1 100644
--- a/my-blog/static/css/style.css
+++ b/my-blog/static/css/style.css
@@ -199,8 +199,8 @@ a.view-markdown:any-link {
@media (max-width: 1000px) {
.main-content {
- padding: 20px !important;
- max-width: 100% !important;
+ padding: 20px;
+ max-width: 100%;
}
}
@@ -737,7 +737,6 @@ a.view-markdown:any-link {
margin: 0 auto;
margin-top: 48px;
padding-top: 32px;
- border-top: 1px solid #d1d9e0;
}
.comment-container {
@@ -771,23 +770,24 @@ a.view-markdown:any-link {
/* Responsive */
@media (max-width: 1000px) {
.article-container {
- grid-template-columns: 1fr !important;
- gap: 24px !important;
- max-width: 100% !important;
- padding: 0px !important;
- margin: 0 !important;
+ grid-template-columns: 1fr;
+ gap: 24px;
+ max-width: 100%;
+ padding: 0;
+ margin: 0;
}
}
@media (max-width: 1000px) {
.main-header {
- padding: 12px 0 !important;
+ padding: 12px 0;
}
.header-content {
- max-width: 100% !important;
- padding: 0 20px !important;
- grid-template-columns: 0 1fr auto !important;
+ max-width: 100%;
+ padding: 0 20px;
+ grid-template-columns: auto 1fr auto;
+ gap: 0;
}
/* Hide site title text on mobile */
@@ -795,17 +795,20 @@ a.view-markdown:any-link {
display: none;
}
- /* Center logo on mobile */
+ /* Left align logo on mobile */
.logo {
- grid-column: 1 / 3;
- justify-self: center;
+ grid-column: 1;
+ justify-self: left;
padding: 5px;
+ display: flex;
+ justify-content: flex-start;
+ align-items: center;
}
/* Reduce logo size on mobile */
.logo .likeButton {
- width: 40pt !important;
- height: 40pt !important;
+ width: 40pt;
+ height: 40pt;
}
/* Position AI button on the right */
@@ -814,24 +817,17 @@ a.view-markdown:any-link {
justify-self: end;
}
- /* Show only icon for Ask AI button on mobile */
+ /* Ask AI button mobile style */
.ask-ai-btn {
padding: 8px;
min-width: 40px;
justify-content: center;
+ font-size: 0;
+ gap: 0;
}
.ask-ai-btn .ai-icon {
margin: 0;
- }
-
- /* Hide AI button text on mobile, show only icon */
- .ask-ai-btn {
- font-size: 0;
- gap: 0px !important;
- }
-
- .ask-ai-btn .ai-icon {
font-size: 16px;
}
@@ -845,14 +841,14 @@ a.view-markdown:any-link {
}
.article-body pre {
- margin: 16px 0 !important;
- border-radius: 4px !important;
- max-width: 100% !important;
- overflow-x: auto !important;
+ margin: 16px 0;
+ border-radius: 4px;
+ max-width: 100%;
+ overflow-x: auto;
}
.article-body pre code {
- padding: 20px 12px !important;
+ padding: 20px 12px;
word-wrap: break-word;
white-space: pre-wrap;
}
diff --git a/my-blog/static/js/ask-ai.js b/my-blog/static/js/ask-ai.js
new file mode 100644
index 0000000..94f7ad5
--- /dev/null
+++ b/my-blog/static/js/ask-ai.js
@@ -0,0 +1,360 @@
+/**
+ * Ask AI functionality - Pure JavaScript, no jQuery dependency
+ */
+class AskAI {
+ constructor() {
+ this.isReady = false;
+ this.aiProfile = null;
+ this.init();
+ }
+
+ init() {
+ this.setupEventListeners();
+ this.checkAuthOnLoad();
+ }
+
+ setupEventListeners() {
+ // Listen for AI ready signal
+ window.addEventListener('aiChatReady', () => {
+ this.isReady = true;
+ console.log('AI Chat is ready');
+ });
+
+ // Listen for AI profile updates
+ window.addEventListener('aiProfileLoaded', (event) => {
+ this.aiProfile = event.detail;
+ console.log('AI profile loaded:', this.aiProfile);
+ this.updateButton();
+ });
+
+ // Listen for AI responses
+ window.addEventListener('aiResponseReceived', (event) => {
+ this.handleAIResponse(event.detail);
+ });
+
+ // Keyboard shortcuts
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') {
+ this.hide();
+ }
+ if (e.key === 'Enter' && e.target.id === 'aiQuestion' && !e.shiftKey) {
+ e.preventDefault();
+ this.ask();
+ }
+ });
+
+ // Monitor authentication changes
+ this.observeAuth();
+ }
+
+ toggle() {
+ const panel = document.getElementById('askAiPanel');
+ const isVisible = panel.style.display !== 'none';
+
+ if (isVisible) {
+ this.hide();
+ } else {
+ this.show();
+ }
+ }
+
+ show() {
+ const panel = document.getElementById('askAiPanel');
+ panel.style.display = 'block';
+ this.checkAuth();
+ }
+
+ hide() {
+ const panel = document.getElementById('askAiPanel');
+ panel.style.display = 'none';
+ }
+
+ checkAuth() {
+ const userSections = document.querySelectorAll('.user-section');
+ const isAuthenticated = userSections.length > 0;
+
+ const authCheck = document.getElementById('authCheck');
+ const chatForm = document.getElementById('chatForm');
+ const chatHistory = document.getElementById('chatHistory');
+
+ if (isAuthenticated) {
+ authCheck.style.display = 'none';
+ chatForm.style.display = 'block';
+ chatHistory.style.display = 'block';
+
+ if (chatHistory.children.length === 0) {
+ this.showGreeting();
+ }
+
+ setTimeout(() => {
+ document.getElementById('aiQuestion').focus();
+ }, 50);
+ } else {
+ authCheck.style.display = 'block';
+ chatForm.style.display = 'none';
+ chatHistory.style.display = 'none';
+ }
+ }
+
+ checkAuthOnLoad() {
+ setTimeout(() => {
+ this.checkAuth();
+ }, 500);
+ }
+
+ observeAuth() {
+ const observer = new MutationObserver(() => {
+ const userSections = document.querySelectorAll('.user-section');
+ if (userSections.length > 0) {
+ this.checkAuth();
+ observer.disconnect();
+ }
+ });
+
+ observer.observe(document.body, {
+ childList: true,
+ subtree: true
+ });
+ }
+
+ updateButton() {
+ const button = document.getElementById('askAiButton');
+ if (this.aiProfile && this.aiProfile.displayName) {
+ const textNode = button.childNodes[2];
+ if (textNode) {
+ textNode.textContent = this.aiProfile.displayName;
+ }
+ }
+ }
+
+ showGreeting() {
+ if (!this.aiProfile) return;
+
+ const chatHistory = document.getElementById('chatHistory');
+ const greetingDiv = document.createElement('div');
+ greetingDiv.className = 'chat-message ai-message comment-style initial-greeting';
+
+ const avatarElement = this.aiProfile.avatar
+ ? ``
+ : 'π€';
+
+ greetingDiv.innerHTML = `
+