mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 15:44:26 -04:00
re-save index on Ctrl+c to hide in progress message on html output
This commit is contained in:
parent
6f5abd49b4
commit
1b5201fd58
3 changed files with 13 additions and 7 deletions
|
@ -112,6 +112,11 @@ def update_archive(archive_path, links, source=None, resume=None, append=True):
|
||||||
archive_link(link_dir, link)
|
archive_link(link_dir, link)
|
||||||
|
|
||||||
except (KeyboardInterrupt, SystemExit, Exception) as e:
|
except (KeyboardInterrupt, SystemExit, Exception) as e:
|
||||||
|
if isinstance(e, KeyboardInterrupt):
|
||||||
|
# Step 4: Re-write links index with updated titles, icons, and resources
|
||||||
|
all_links, _ = load_links(archive_path=out_dir)
|
||||||
|
write_links_index(out_dir=out_dir, links=all_links, finished=True)
|
||||||
|
print()
|
||||||
print('\n{lightyellow}[X] [{now}] Downloading paused on link {timestamp} ({idx}/{total}){reset}'.format(
|
print('\n{lightyellow}[X] [{now}] Downloading paused on link {timestamp} ({idx}/{total}){reset}'.format(
|
||||||
**ANSI,
|
**ANSI,
|
||||||
now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
@ -217,4 +222,4 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Step 4: Re-write links index with updated titles, icons, and resources
|
# Step 4: Re-write links index with updated titles, icons, and resources
|
||||||
all_links, _ = load_links(archive_path=out_dir)
|
all_links, _ = load_links(archive_path=out_dir)
|
||||||
write_links_index(out_dir=out_dir, links=all_links)
|
write_links_index(out_dir=out_dir, links=all_links, finished=True)
|
||||||
|
|
|
@ -27,7 +27,7 @@ from util import (
|
||||||
|
|
||||||
### Homepage index for all the links
|
### Homepage index for all the links
|
||||||
|
|
||||||
def write_links_index(out_dir, links):
|
def write_links_index(out_dir, links, finished=False):
|
||||||
"""create index.html file for a given list of links"""
|
"""create index.html file for a given list of links"""
|
||||||
|
|
||||||
check_links_structure(links)
|
check_links_structure(links)
|
||||||
|
@ -35,14 +35,14 @@ def write_links_index(out_dir, links):
|
||||||
if not os.path.exists(out_dir):
|
if not os.path.exists(out_dir):
|
||||||
os.makedirs(out_dir)
|
os.makedirs(out_dir)
|
||||||
|
|
||||||
print('{green}[*] [{}] Updating main index files...{reset}'.format(
|
print('{green}[*] [{}] Saving main index files...{reset}'.format(
|
||||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
**ANSI,
|
**ANSI,
|
||||||
))
|
))
|
||||||
write_json_links_index(out_dir, links)
|
write_json_links_index(out_dir, links)
|
||||||
print(' > {}/index.json'.format(pretty_path(out_dir)))
|
print(' > {}/index.json'.format(pretty_path(out_dir)))
|
||||||
|
|
||||||
write_html_links_index(out_dir, links)
|
write_html_links_index(out_dir, links, finished=finished)
|
||||||
print(' > {}/index.html'.format(pretty_path(out_dir)))
|
print(' > {}/index.html'.format(pretty_path(out_dir)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ def parse_json_links_index(out_dir):
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def write_html_links_index(out_dir, links):
|
def write_html_links_index(out_dir, links, finished=False):
|
||||||
"""write the html link index to a given path"""
|
"""write the html link index to a given path"""
|
||||||
|
|
||||||
check_links_structure(links)
|
check_links_structure(links)
|
||||||
|
@ -109,6 +109,7 @@ def write_html_links_index(out_dir, links):
|
||||||
'git_sha': GIT_SHA,
|
'git_sha': GIT_SHA,
|
||||||
'short_git_sha': GIT_SHA[:8],
|
'short_git_sha': GIT_SHA[:8],
|
||||||
'rows': link_rows,
|
'rows': link_rows,
|
||||||
|
'status': 'finished' if finished else 'running',
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(path, 'w', encoding='utf-8') as f:
|
with open(path, 'w', encoding='utf-8') as f:
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-status="$status">
|
||||||
<header>
|
<header>
|
||||||
<div class="header-right">
|
<div class="header-right">
|
||||||
<a href="https://github.com/pirate/ArchiveBox/wiki">Documentation</a> |
|
<a href="https://github.com/pirate/ArchiveBox/wiki">Documentation</a> |
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-center">
|
<div class="header-center">
|
||||||
Archived Sites<br/>
|
Archived Sites <span class="in-progress">(Currently Updating)</span><br/>
|
||||||
<small>Last updated $time_updated</small>
|
<small>Last updated $time_updated</small>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue