X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-to-html;h=0d0831f3fd8a9746d388087eea5801b30a4e47b5;hb=61819058a9f7804efddfbe596785abf7eea349db;hp=f0146f8ea0c6137d15458609603be10635805fba;hpb=fb9f586a19b5872d1436d0dbe3e898ec463f72d6;p=obsolete%2Fnotmuch-to-html diff --git a/notmuch-to-html b/notmuch-to-html index f0146f8..0d0831f 100755 --- a/notmuch-to-html +++ b/notmuch-to-html @@ -1,6 +1,10 @@ #!/usr/bin/python # +# Generate an HTML page with the result of one or more notmuch +# searches, (with links to gmane views of each email if available). +# # Copyright (c) 2011-2012 David Bremner +# Copyright (c) 2014 Carl Worth This view is generated from the following query:', '

', '

', ' ', - view['query-string'], + 'notmuch search ' + view['query-string'], ' ', '

', ]: @@ -255,16 +259,27 @@ class HtmlPage (Page): parser = argparse.ArgumentParser() parser.add_argument('--text', help='output plain text format', action='store_true') -parser.add_argument('--config', help='load config from given file', - metavar='PATH') +group = parser.add_mutually_exclusive_group() +group.add_argument('--config', help='path to configuration file', + metavar='PATH') +group.add_argument('--query', help='path to configuration file', + metavar='PATH') parser.add_argument('--list-views', help='list views', action='store_true') -parser.add_argument('--get-query', help='get query for view', - metavar='VIEW') args = parser.parse_args() -config = read_config(path=args.config) +if (args.config): + config = read_config(path=args.config) +elif (args.query): + config = json.loads(DEFAULT_CONFIG.format(query=args.query)) +else: + print ('''To use notmuch-to-html, you need to provide a notmuch query. Try: + + notmuch-to-html --query=tag:inbox + +Or 'notmuch-to-html --help' for additional options.''') + exit (0) _PAGES['text'] = Page() _PAGES['html'] = HtmlPage( @@ -309,29 +324,25 @@ _PAGES['html'] = HtmlPage(

{title}

-

-Generated: {date}
{blurb}

Views

-'''.format(date=datetime.datetime.utcnow().date(), - title=config['meta']['title'], +'''.format(title=config['meta']['title'], blurb=config['meta']['blurb'], encoding=_ENCODING, inter_message_padding='0.25em', border_radius='0.5em'), - footer='\n\n', + footer='''
+

Generated: {date} courtesy of notmuch and notmuch-to-html. + + +'''.format(date=datetime.datetime.utcnow().date()) ) if args.list_views: for view in config['views']: print(view['title']) sys.exit(0) -elif args.get_query != None: - for view in config['views']: - if args.get_query == view['title']: - print(' and '.join(view['query'])) - sys.exit(0) else: # only import notmuch if needed import notmuch @@ -343,3 +354,12 @@ else: db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY) page.write(database=db, views=config['views']) + +if (args.query): + print ('''To customize the output use 'notmuch-to-html --config=CONFIG_FILE' after +placing the following content into CONFIG_FILE (note that you can add +additional views with their own queries): + + +''', file=sys.stderr) + print (json.dumps(config, indent=4, separators=(',',':')), file=sys.stderr)