mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 15:14:31 -04:00
handle urls with special characters properly
This commit is contained in:
parent
6a8f6f52af
commit
97249a1861
5 changed files with 22 additions and 22 deletions
|
@ -119,9 +119,9 @@ def archive_link(link: Link, link_dir: Optional[str]=None) -> Link:
|
|||
|
||||
# print(' ', stats)
|
||||
|
||||
# If any changes were made, update the link index json and html
|
||||
write_link_index(link, link_dir=link.link_dir)
|
||||
|
||||
# If any changes were made, update the main links index json and html
|
||||
was_changed = stats['succeeded'] or stats['failed']
|
||||
if was_changed:
|
||||
patch_links_index(link)
|
||||
|
|
|
@ -17,6 +17,8 @@ from .config import (
|
|||
from .util import (
|
||||
merge_links,
|
||||
urlencode,
|
||||
htmlencode,
|
||||
urldecode,
|
||||
derived_link_info,
|
||||
wget_output_path,
|
||||
enforce_types,
|
||||
|
@ -267,12 +269,13 @@ def write_html_link_index(link: Link, link_dir: Optional[str]=None) -> None:
|
|||
|
||||
path = os.path.join(link_dir, 'index.html')
|
||||
|
||||
html_index = Template(link_html).substitute({
|
||||
template_vars: Mapping[str, str] = {
|
||||
**derived_link_info(link),
|
||||
'title': (
|
||||
link.title
|
||||
or (link.base_url if link.is_archived else TITLE_LOADING_MSG)
|
||||
),
|
||||
'url_str': htmlencode(urldecode(link.base_url)),
|
||||
'archive_url': urlencode(
|
||||
wget_output_path(link)
|
||||
or (link.domain if link.is_archived else 'about:blank')
|
||||
|
@ -281,6 +284,8 @@ def write_html_link_index(link: Link, link_dir: Optional[str]=None) -> None:
|
|||
'tags': link.tags or 'untagged',
|
||||
'status': 'archived' if link.is_archived else 'not yet archived',
|
||||
'status_color': 'success' if link.is_archived else 'danger',
|
||||
})
|
||||
}
|
||||
|
||||
html_index = Template(link_html).substitute(**template_vars)
|
||||
|
||||
atomic_write(html_index, path)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<title>Archived Sites</title>
|
||||
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
|
@ -179,13 +180,13 @@
|
|||
<header>
|
||||
<div class="header-top container-fluid">
|
||||
<div class="row nav">
|
||||
<div class="col-lg-6">
|
||||
<div class="col-sm-2">
|
||||
<a href="?" class="header-archivebox" title="Last updated: $time_updated">
|
||||
<img src="static/archive.png" alt="Logo"/>
|
||||
ArchiveBox: Index
|
||||
ArchiveBox
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="col-sm-10" style="text-align: right">
|
||||
<a href="https://github.com/pirate/ArchiveBox/wiki">Documentation</a> |
|
||||
<a href="https://github.com/pirate/ArchiveBox">Source</a> |
|
||||
<a href="https://archivebox.io">Website</a>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>$title</title>
|
||||
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
|
@ -237,21 +238,14 @@
|
|||
<header>
|
||||
<div class="header-top container-fluid">
|
||||
<div class="row nav">
|
||||
<div class="col-lg-6">
|
||||
<div class="col-lg-2" style="line-height: 64px;">
|
||||
|
||||
<a href="../../index.html" class="header-archivebox" title="Go to Main Index...">
|
||||
<img src="../../static/archive.png" alt="Archive Icon">
|
||||
ArchiveBox:
|
||||
ArchiveBox
|
||||
</a>
|
||||
<a href="#">Page Details</a>
|
||||
<br/>
|
||||
<small style="margin-top: 5px; display: block; opacity: 0.7">
|
||||
<a href="../../index.html">Index</a> |
|
||||
<a href="https://github.com/pirate/ArchiveBox">Github</a> |
|
||||
<a href="https://github.com/pirate/ArchiveBox/wiki">Documentation</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="col-lg-10">
|
||||
<img src="$link_dir/$favicon_url" alt="Favicon">
|
||||
|
||||
$title
|
||||
|
@ -259,8 +253,8 @@
|
|||
<a href="#" class="header-toggle">▾</a>
|
||||
<br/>
|
||||
<small>
|
||||
<a href="$url" title="Toggle info panel..." class="header-url" title="$url">
|
||||
$base_url
|
||||
<a href="$url" class="header-url" title="$url">
|
||||
$url_str
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
|
|
|
@ -309,7 +309,7 @@ def wget_output_path(link: Link) -> Optional[str]:
|
|||
search_dir = os.path.join(
|
||||
link.link_dir,
|
||||
domain(link.url),
|
||||
full_path,
|
||||
urldecode(full_path),
|
||||
)
|
||||
|
||||
for _ in range(4):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue