diff --git a/archivebox/cli/archivebox_list.py b/archivebox/cli/archivebox_list.py index 0f5d6a80..04d43dc7 100644 --- a/archivebox/cli/archivebox_list.py +++ b/archivebox/cli/archivebox_list.py @@ -46,6 +46,11 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional action='store_true', help="Print the output in JSON format with all columns included.", ) + group.add_argument( + '--html', + action='store_true', + help="Print the output in HTML format" + ) parser.add_argument( '--index', action='store_true', @@ -117,6 +122,7 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional sort=command.sort, csv=command.csv, json=command.json, + html=command.html, index=command.index, out_dir=pwd or OUTPUT_DIR, ) diff --git a/archivebox/index/html.py b/archivebox/index/html.py index 9ce14988..5be87fb7 100644 --- a/archivebox/index/html.py +++ b/archivebox/index/html.py @@ -31,6 +31,7 @@ from ..config import ( join = lambda *paths: os.path.join(*paths) MAIN_INDEX_TEMPLATE = join(TEMPLATES_DIR, 'main_index.html') +MINIMAL_INDEX_TEMPLATE = join(TEMPLATES_DIR, 'main_index_minimal.html') MAIN_INDEX_ROW_TEMPLATE = join(TEMPLATES_DIR, 'main_index_row.html') LINK_DETAILS_TEMPLATE = join(TEMPLATES_DIR, 'link_details.html') TITLE_LOADING_MSG = 'Not yet archived...' @@ -63,10 +64,10 @@ def write_html_main_index(links: List[Link], out_dir: str=OUTPUT_DIR, finished: @enforce_types -def main_index_template(links: List[Link], finished: bool=True) -> str: +def main_index_template(links: List[Link], finished: bool=True, template: str=MAIN_INDEX_TEMPLATE) -> str: """render the template for the entire main index""" - return render_legacy_template(MAIN_INDEX_TEMPLATE, { + return render_legacy_template(template, { 'version': VERSION, 'git_sha': GIT_SHA, 'num_links': str(len(links)), diff --git a/archivebox/logging_util.py b/archivebox/logging_util.py index 6a9b4301..5a7cab20 100644 --- a/archivebox/logging_util.py +++ b/archivebox/logging_util.py @@ -462,6 +462,7 @@ def printable_filesize(num_bytes: Union[int, float]) -> str: @enforce_types def printable_folders(folders: Dict[str, Optional["Link"]], json: bool=False, + html: bool=False, csv: Optional[str]=None, index: bool=False) -> str: links = folders.values() @@ -478,7 +479,14 @@ def printable_folders(folders: Dict[str, Optional["Link"]], else: output = links return to_json(output, indent=4, sort_keys=True) - + elif html: + from .index.html import main_index_template + if index: + output = main_index_template(links, True) + else: + from .index.html import MINIMAL_INDEX_TEMPLATE + output = main_index_template(links, True, MINIMAL_INDEX_TEMPLATE) + return output elif csv: from .index.csv import links_to_csv return links_to_csv(folders.values(), cols=csv.split(','), header=True) diff --git a/archivebox/main.py b/archivebox/main.py index 624e9cf6..5b699af0 100644 --- a/archivebox/main.py +++ b/archivebox/main.py @@ -730,6 +730,7 @@ def list_all(filter_patterns_str: Optional[str]=None, sort: Optional[str]=None, csv: Optional[str]=None, json: bool=False, + html: bool=False, index: bool=False, out_dir: str=OUTPUT_DIR) -> Iterable[Link]: """List, filter, and export information about archive entries""" @@ -763,7 +764,7 @@ def list_all(filter_patterns_str: Optional[str]=None, out_dir=out_dir, ) - print(printable_folders(folders, json=json, csv=csv, index=index)) + print(printable_folders(folders, json=json, csv=csv, html=html, index=index)) return folders diff --git a/archivebox/themes/legacy/main_index_minimal.html b/archivebox/themes/legacy/main_index_minimal.html new file mode 100644 index 00000000..c1c2fd3d --- /dev/null +++ b/archivebox/themes/legacy/main_index_minimal.html @@ -0,0 +1,20 @@ + + +
+Bookmarked | +Saved Link ($num_links) | +Files | + +
---|