~lioploum/offpunk

0fda6f5623b9976a079d50a8e8c2c0c54f507f80 — Ploum 3 months ago 1bf98cf
--cache-validity argument added to opnk and netcach (#37)
5 files changed, 15 insertions(+), 6 deletions(-)

M CHANGELOG
M man/netcache.1
M man/opnk.1
M netcache.py
M opnk.py
M CHANGELOG => CHANGELOG +2 -1
@@ 12,8 12,9 @@
- offpunk: "gus" was broken, it is functionnal again
- opnk/offpunk: more informative prompt in less
- ansicat: added support for HTML description elements <dt> and <dd> (by Bert Livens)
- opnk: added "--mode" command-line argument (bug #37)
- opnk: added "--mode" command-line argument (bug #39)
- offpunk: support for "preformatted" theming (bug #38)
- opnk/netcache: added "--cache-validity" command-line argument (bug #37)

## 2.1 - December 15th 2023
- freshly updated gemtext/rss links are highlighted ("new_link" theme option)

M man/netcache.1 => man/netcache.1 +2 -0
@@ 56,6 56,8 @@ The value is expressed in megabytes.
.It Fl \-timeout Ar TIMEOUT
time to wait before cancelling connection.
The value is expressed in seconds.
.It Fl \-cache-validity CACHE_VALIDITY
Maximum age (in second) of the cached version before redownloading a new version.
.El
.
.Sh EXIT STATUS

M man/opnk.1 => man/opnk.1 +2 -0
@@ 39,6 39,8 @@ path to the file or URL to open.
Show a help message and exit
.It Fl \-mode Ar MODE
MODE to use to render to choose between normal (default), full or source
.It Fl \-cache-validity CACHE_VALIDITY
Maximum age (in second) of the cached version before redownloading a new version.
.El
.
.Sh EXIT STATUS

M netcache.py => netcache.py +5 -4
@@ 878,11 878,12 @@ def main():
                        help="Cancel download of items above that size (value in Mb).")
    parser.add_argument("--timeout", type=int,
                        help="Time to wait before cancelling connection (in second).")
    parser.add_argument("--cache-validity",type=int, default=0,
                        help="maximum age, in second, of the cached version before \
                                redownloading a new version")
    # No argument: write help
    parser.add_argument('url', metavar='URL', nargs='*',
                        help='download URL and returns the content or the path to a cached version')
    # arg = URL: download and returns cached URI
    # --cache-validity : do not download if cache is valid
    # --validity : returns the date of the cached version, Null if no version
    # --force-download : download and replace cache, even if valid
    args = parser.parse_args()


@@ 893,8 894,8 @@ def main():
        if args.offline:
            path = get_cache_path(u)
        else:
            print("Download URL: %s" %u)
            path,url = fetch(u,max_size=args.max_size,timeout=args.timeout)
            path,url = fetch(u,max_size=args.max_size,timeout=args.timeout,\
                                validity=args.cache_validity)
        if args.path:
            print(path)
        else:

M opnk.py => opnk.py +4 -1
@@ 285,10 285,13 @@ def main():
                                With HTML, the normal mode try to extract the article.")
    parser.add_argument("content",metavar="INPUT", nargs="*", 
                         default=sys.stdin, help="Path to the file or URL to open")
    parser.add_argument("--cache-validity",type=int, default=0,
                        help="maximum age, in second, of the cached version before \
                                redownloading a new version")
    args = parser.parse_args()
    cache = opencache()
    for f in args.content:
        cache.opnk(f,mode=args.mode)
        cache.opnk(f,mode=args.mode,validity=args.cache_validity)

if __name__ == "__main__":
    main()