Skip to content

Commit 1583af3

Browse files
committed
feat: Add force_show option for debugging and enhance update popup styling
1 parent d577678 commit 1583af3

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

auto_refresh_build_pages/js/auto_refresh_build_pages.js.jinja

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ async function checkForUpdate() {
2727
const storedModified = localStorage.getItem('lastModified');
2828
const popupShown = localStorage.getItem('popupShown');
2929

30+
// Force show popup for debugging if enabled
31+
if ({{ force_show|lower }}) {
32+
showUpdatePopup(latestModified);
33+
return;
34+
}
35+
3036
if (storedModified &&
3137
new Date(storedModified).getTime() !==
3238
new Date(latestModified).getTime() &&
@@ -49,28 +55,49 @@ function showUpdatePopup(latestModified) {
4955
const popup = document.createElement('div');
5056
popup.id = 'update-popup';
5157
popup.style.position = 'fixed';
52-
popup.style.bottom = '10px';
53-
popup.style.left = '10px';
54-
popup.style.backgroundColor = 'rgba(0,0,0,0.9)';
55-
popup.style.fontSize = '16px';
58+
popup.style.top = '20px';
59+
popup.style.left = '50%';
60+
popup.style.transform = 'translateX(-50%)';
61+
popup.style.backgroundColor = 'rgba(0,0,0,0.95)';
62+
popup.style.fontSize = '18px';
5663
popup.style.color = 'white';
57-
popup.style.padding = '10px';
58-
popup.style.borderRadius = '5px';
59-
popup.style.zIndex = '1000';
64+
popup.style.padding = '20px 30px';
65+
popup.style.borderRadius = '10px';
66+
popup.style.zIndex = '10000';
67+
popup.style.boxShadow = '0 4px 20px rgba(0,0,0,0.5)';
68+
popup.style.border = '2px solid #007acc';
69+
popup.style.minWidth = '300px';
70+
popup.style.textAlign = 'center';
6071
popup.textContent = '{{ update_message }}';
6172

6273
const yesButton = document.createElement('button');
6374
yesButton.textContent = '{{ yes_button_text }}';
6475
yesButton.style.marginLeft = '10px';
76+
yesButton.style.marginTop = '15px';
77+
yesButton.style.padding = '8px 16px';
78+
yesButton.style.backgroundColor = '#007acc';
6579
yesButton.style.color = 'white';
80+
yesButton.style.border = 'none';
81+
yesButton.style.borderRadius = '5px';
82+
yesButton.style.cursor = 'pointer';
83+
yesButton.style.fontSize = '14px';
84+
yesButton.style.fontWeight = 'bold';
6685
yesButton.onclick = () => {
6786
window.location.reload();
6887
};
6988

7089
const noButton = document.createElement('button');
7190
noButton.textContent = '{{ no_button_text }}';
7291
noButton.style.marginLeft = '10px';
92+
noButton.style.marginTop = '15px';
93+
noButton.style.padding = '8px 16px';
94+
noButton.style.backgroundColor = '#666';
7395
noButton.style.color = 'white';
96+
noButton.style.border = 'none';
97+
noButton.style.borderRadius = '5px';
98+
noButton.style.cursor = 'pointer';
99+
noButton.style.fontSize = '14px';
100+
noButton.style.fontWeight = 'bold';
74101
noButton.onclick = () => {
75102
document.body.removeChild(popup);
76103
};

auto_refresh_build_pages/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AutoRefreshBuildPagesConfig(Config):
2222
yes_button_text = c.Type(str, default="Yes")
2323
no_button_text = c.Type(str, default="No")
2424
check_interval_seconds = c.Type(int, default=60) # in seconds
25+
force_show = c.Type(bool, default=False) # Force show popup for debugging
2526

2627

2728
class AutoRefreshBuildPages(BasePlugin[AutoRefreshBuildPagesConfig]):
@@ -48,6 +49,7 @@ def on_post_build(self, config):
4849
yes_button_text=self.config.yes_button_text,
4950
no_button_text=self.config.no_button_text,
5051
check_interval_seconds=self.config.check_interval_seconds,
52+
force_show=self.config.force_show,
5153
)
5254

5355
js_output = Path(config["site_dir"]) / "js" / "auto_refresh_build_pages.js"

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ plugins:
8383
yes_button_text: "Yes"
8484
no_button_text: "No"
8585
check_interval_seconds: 60
86+
# force_show: true
8687

8788
markdown_extensions:
8889
- pymdownx.highlight

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
__version__ = "1.0.2"
3+
__version__ = "1.0.3"
44

55

66
def readme():

0 commit comments

Comments
 (0)