mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 23:24:30 -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)
|
# print(' ', stats)
|
||||||
|
|
||||||
# If any changes were made, update the link index json and html
|
|
||||||
write_link_index(link, link_dir=link.link_dir)
|
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']
|
was_changed = stats['succeeded'] or stats['failed']
|
||||||
if was_changed:
|
if was_changed:
|
||||||
patch_links_index(link)
|
patch_links_index(link)
|
||||||
|
|
|
@ -17,6 +17,8 @@ from .config import (
|
||||||
from .util import (
|
from .util import (
|
||||||
merge_links,
|
merge_links,
|
||||||
urlencode,
|
urlencode,
|
||||||
|
htmlencode,
|
||||||
|
urldecode,
|
||||||
derived_link_info,
|
derived_link_info,
|
||||||
wget_output_path,
|
wget_output_path,
|
||||||
enforce_types,
|
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')
|
path = os.path.join(link_dir, 'index.html')
|
||||||
|
|
||||||
html_index = Template(link_html).substitute({
|
template_vars: Mapping[str, str] = {
|
||||||
**derived_link_info(link),
|
**derived_link_info(link),
|
||||||
'title': (
|
'title': (
|
||||||
link.title
|
link.title
|
||||||
or (link.base_url if link.is_archived else TITLE_LOADING_MSG)
|
or (link.base_url if link.is_archived else TITLE_LOADING_MSG)
|
||||||
),
|
),
|
||||||
|
'url_str': htmlencode(urldecode(link.base_url)),
|
||||||
'archive_url': urlencode(
|
'archive_url': urlencode(
|
||||||
wget_output_path(link)
|
wget_output_path(link)
|
||||||
or (link.domain if link.is_archived else 'about:blank')
|
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',
|
'tags': link.tags or 'untagged',
|
||||||
'status': 'archived' if link.is_archived else 'not yet archived',
|
'status': 'archived' if link.is_archived else 'not yet archived',
|
||||||
'status_color': 'success' if link.is_archived else 'danger',
|
'status_color': 'success' if link.is_archived else 'danger',
|
||||||
})
|
}
|
||||||
|
|
||||||
|
html_index = Template(link_html).substitute(**template_vars)
|
||||||
|
|
||||||
atomic_write(html_index, path)
|
atomic_write(html_index, path)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<title>Archived Sites</title>
|
<title>Archived Sites</title>
|
||||||
|
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -179,13 +180,13 @@
|
||||||
<header>
|
<header>
|
||||||
<div class="header-top container-fluid">
|
<div class="header-top container-fluid">
|
||||||
<div class="row nav">
|
<div class="row nav">
|
||||||
<div class="col-lg-6">
|
<div class="col-sm-2">
|
||||||
<a href="?" class="header-archivebox" title="Last updated: $time_updated">
|
<a href="?" class="header-archivebox" title="Last updated: $time_updated">
|
||||||
<img src="static/archive.png" alt="Logo"/>
|
<img src="static/archive.png" alt="Logo"/>
|
||||||
ArchiveBox: Index
|
ArchiveBox
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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/wiki">Documentation</a> |
|
||||||
<a href="https://github.com/pirate/ArchiveBox">Source</a> |
|
<a href="https://github.com/pirate/ArchiveBox">Source</a> |
|
||||||
<a href="https://archivebox.io">Website</a>
|
<a href="https://archivebox.io">Website</a>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<html>
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>$title</title>
|
<title>$title</title>
|
||||||
|
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -237,21 +238,14 @@
|
||||||
<header>
|
<header>
|
||||||
<div class="header-top container-fluid">
|
<div class="header-top container-fluid">
|
||||||
<div class="row nav">
|
<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...">
|
<a href="../../index.html" class="header-archivebox" title="Go to Main Index...">
|
||||||
<img src="../../static/archive.png" alt="Archive Icon">
|
<img src="../../static/archive.png" alt="Archive Icon">
|
||||||
ArchiveBox:
|
ArchiveBox
|
||||||
</a>
|
</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>
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-10">
|
||||||
<img src="$link_dir/$favicon_url" alt="Favicon">
|
<img src="$link_dir/$favicon_url" alt="Favicon">
|
||||||
|
|
||||||
$title
|
$title
|
||||||
|
@ -259,8 +253,8 @@
|
||||||
<a href="#" class="header-toggle">▾</a>
|
<a href="#" class="header-toggle">▾</a>
|
||||||
<br/>
|
<br/>
|
||||||
<small>
|
<small>
|
||||||
<a href="$url" title="Toggle info panel..." class="header-url" title="$url">
|
<a href="$url" class="header-url" title="$url">
|
||||||
$base_url
|
$url_str
|
||||||
</a>
|
</a>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -309,7 +309,7 @@ def wget_output_path(link: Link) -> Optional[str]:
|
||||||
search_dir = os.path.join(
|
search_dir = os.path.join(
|
||||||
link.link_dir,
|
link.link_dir,
|
||||||
domain(link.url),
|
domain(link.url),
|
||||||
full_path,
|
urldecode(full_path),
|
||||||
)
|
)
|
||||||
|
|
||||||
for _ in range(4):
|
for _ in range(4):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue