Hello community, here is the log from the commit of package urlscan for openSUSE:Factory checked in at 2019-02-08 12:13:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/urlscan (Old) and /work/SRC/openSUSE:Factory/.urlscan.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "urlscan" Fri Feb 8 12:13:41 2019 rev:5 rq:672416 version:0.9.2 Changes: -------- --- /work/SRC/openSUSE:Factory/urlscan/urlscan.changes 2018-12-12 17:31:29.106649248 +0100 +++ /work/SRC/openSUSE:Factory/.urlscan.new.28833/urlscan.changes 2019-02-08 12:13:45.873461149 +0100 @@ -1,0 +2,7 @@ +Thu Feb 7 07:46:49 UTC 2019 - Dr. Werner Fink <wer...@suse.de> + +- Update to version 0.9.2 + * Add shortcut to copy URL to clipboard (primary). + * Add option to pipe URL into external command. + +------------------------------------------------------------------- Old: ---- urlscan-0.9.1.tar.gz New: ---- urlscan-0.9.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ urlscan.spec ++++++ --- /var/tmp/diff_new_pack.olMsUY/_old 2019-02-08 12:13:46.585460883 +0100 +++ /var/tmp/diff_new_pack.olMsUY/_new 2019-02-08 12:13:46.585460883 +0100 @@ -1,7 +1,7 @@ # # spec file for package urlscan # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: urlscan -Version: 0.9.1 +Version: 0.9.2 Release: 0 Summary: An other URL extractor/viewer License: GPL-2.0-or-later ++++++ urlscan-0.9.1.tar.gz -> urlscan-0.9.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.1/README.rst new/urlscan-0.9.2/README.rst --- old/urlscan-0.9.1/README.rst 2018-12-01 00:12:00.000000000 +0100 +++ new/urlscan-0.9.2/README.rst 2019-01-22 00:05:53.000000000 +0100 @@ -49,11 +49,16 @@ - Configure colors via ~/.config/urlscan/config.json. Generate default config file for editing with `P`. Cycle through available palettes with `p`. +- Copy URL to clipboard (primary) with `C`. Requires xsel or xclip. + +- Run a command with the selected URL as the argument or pipe the selected + URL to a command. + Installation and setup ---------------------- -To install urlscan, install from your distribution repositories, from Pypi, -install the `Archlinux Package`_ , or install from source using setup.py. +To install urlscan, install from your distribution repositories (Archlinux), +from Pypi, or install from source using setup.py. .. NOTE:: @@ -82,7 +87,7 @@ :: - urlscan [-n, --no-browser] [-c, --compact] [-d, --dedupe] [-r, --run <expression>] <file> + urlscan [-n, --no-browser] [-c, --compact] [-d, --dedupe] [-r, --run <expression>] [-p, --pipe] <file> Urlscan can extract URLs and email addresses from emails or any text file. Calling with no flags will start the curses browser. Calling with '-n' will just @@ -91,6 +96,12 @@ duplicate URLs. Files can also be piped to urlscan using normal shell pipe mechanisms: `cat <something> | urlscan` or `urlscan < <something>` +Instead of opening a web browser, the selected URL can be passed as the +argument to a command using `--run <command>`. Alternatively, the URL can be +piped to the command using `--run <command> --pipe`. Using --run with --pipe is +preferred if the command supports it, as it is marginally more secure and +tolerant of special characters in the URL. + Theming ------- @@ -115,5 +126,4 @@ sub-parts, rather than just picking one, which may lead to URLs and context appearing twice. (Bypass this by selecting the '--dedupe' option) -.. _Archlinux Package: https://aur.archlinux.org/packages/urlscan-git/ .. _Urwid display attributes: http://urwid.org/manual/displayattributes.html#display-attributes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.1/bin/urlscan new/urlscan-0.9.2/bin/urlscan --- old/urlscan-0.9.1/bin/urlscan 2018-12-01 00:12:00.000000000 +0100 +++ new/urlscan-0.9.2/bin/urlscan 2019-01-22 00:05:53.000000000 +0100 @@ -5,7 +5,7 @@ """ # # Copyright (C) 2006-2007 Daniel Burrows -# Copyright (C) 2018 Scott Hansen +# Copyright (C) 2019 Scott Hansen # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -55,6 +55,9 @@ "instead of opening URL in browser. Use {} to " "represent the URL value in the expression. " "For example: --run 'echo {} | xclip -i'") + arg_parse.add_argument('--pipe', '-p', dest='pipe', + action='store_true', default=False, + help='Pipe URL into the command specified by --run') arg_parse.add_argument('message', nargs='?', default=sys.stdin, help="Filename of the message to parse") return arg_parse.parse_args() @@ -174,7 +177,8 @@ tui = urlchoose.URLChooser(urlscan.msgurls(msg), compact=args.compact, dedupe=args.dedupe, - run=args.run) + run=args.run, + pipe=args.pipe) tui.main() else: out = urlchoose.URLChooser(urlscan.msgurls(msg), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.1/setup.py new/urlscan-0.9.2/setup.py --- old/urlscan-0.9.1/setup.py 2018-12-01 00:12:00.000000000 +0100 +++ new/urlscan-0.9.2/setup.py 2019-01-22 00:05:53.000000000 +0100 @@ -3,12 +3,12 @@ from setuptools import setup setup(name="urlscan", - version="0.9.1", + version="0.9.2", description="View/select the URLs in an email message or file", author="Scott Hansen", author_email="firecat4...@gmail.com", url="https://github.com/firecat53/urlscan", - download_url="https://github.com/firecat53/urlscan/archive/0.9.1.zip", + download_url="https://github.com/firecat53/urlscan/archive/0.9.2.zip", packages=['urlscan'], scripts=['bin/urlscan'], package_data={'urlscan': ['assets/*']}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.1/urlscan/urlchoose.py new/urlscan-0.9.2/urlscan/urlchoose.py --- old/urlscan-0.9.1/urlscan/urlchoose.py 2018-12-01 00:12:00.000000000 +0100 +++ new/urlscan-0.9.2/urlscan/urlchoose.py 2019-01-22 00:05:53.000000000 +0100 @@ -1,5 +1,5 @@ # Copyright (C) 2006-2007 Daniel Burrows -# Copyright (C) 2018 Scott Hansen +# Copyright (C) 2019 Scott Hansen # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -23,7 +23,9 @@ import os from os.path import dirname, exists, expanduser import re -from subprocess import Popen +import shlex +from subprocess import Popen, PIPE +import sys from threading import Thread from time import sleep import webbrowser @@ -90,7 +92,7 @@ class URLChooser: def __init__(self, extractedurls, compact=False, dedupe=False, shorten=True, - run=""): + run="", pipe=False): self.conf = expanduser("~/.config/urlscan/config.json") self.palettes = [] try: @@ -124,6 +126,7 @@ self.shorten = shorten self.compact = compact self.run = run + self.pipe = pipe self.search = False self.search_string = "" self.no_matches = False @@ -146,6 +149,7 @@ header = (":: q - Quit :: " "/ - search :: " "c - context :: " + "C - copy to clipboard :: " "s - URL short :: " "S - all URL short :: " "g/G - top/bottom :: " @@ -220,7 +224,7 @@ return [i for i in keys if i != 'backspace'] def unhandled(self, key): - """Add other keyboard actions (q, j, k, s, S, c, g, G) not handled by + """Add other keyboard actions (q, j, k, s, S, c, C, g, G) not handled by the ListBox widget. """ @@ -292,9 +296,9 @@ elif key in ('S', 'u'): # Toggle all shortened or escaped URLs if key == 'S': - self.shorten = False if self.shorten is True else True + self.shorten = not self.shorten if key == 'u': - self.unesc = False if self.unesc is True else True + self.unesc = not self.unesc self.urls, self.urls_unesc = self.urls_unesc, self.urls urls = iter(self.urls) for item in self.items: @@ -315,7 +319,24 @@ self.items, self.items_com = self.items_com, self.items self.top.body = urwid.ListBox(self.items) self.top.body.focus_position = self._cur_focus(fpo) - self.compact = False if self.compact is True else True + self.compact = not self.compact + elif key == 'C': + # Copy highlighted url to clipboard + fpo = self.top.body.focus_position + url_idx = len([i for i in self.items[:fpo + 1] + if isinstance(i, urwid.Columns)]) - 1 + if self.compact is False and fpo <= 1: + return + url = self.urls[url_idx] + cmds = ("xsel -i", "xclip -i") + for cmd in cmds: + try: + proc = Popen(shlex.split(cmd), stdin=PIPE) + proc.communicate(input=url.encode(sys.getdefaultencoding())) + self._footer_start_thread("Copied url to primary selection", 5) + except OSError: + continue + break elif key == 'p': # Loop through available palettes self.palette_idx += 1 @@ -462,8 +483,12 @@ self.enter = False elif not self.run: webbrowser.open(url) + elif self.run and self.pipe: + process = Popen(shlex.split(self.run), stdout=PIPE, stdin=PIPE) + process.communicate(input=url.encode(sys.getdefaultencoding())) else: Popen(self.run.format(url), shell=True).communicate() + size = self.tui.get_cols_rows() self.draw_screen(size) return browse diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.1/urlscan/urlscan.py new/urlscan-0.9.2/urlscan/urlscan.py --- old/urlscan-0.9.1/urlscan/urlscan.py 2018-12-01 00:12:00.000000000 +0100 +++ new/urlscan-0.9.2/urlscan/urlscan.py 2019-01-22 00:05:53.000000000 +0100 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (C) 2006-2007 Daniel Burrows -# Copyright (C) 2018 Scott Hansen +# Copyright (C) 2019 Scott Hansen # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.1/urlscan.1 new/urlscan-0.9.2/urlscan.1 --- old/urlscan-0.9.1/urlscan.1 2018-12-01 00:12:00.000000000 +0100 +++ new/urlscan-0.9.2/urlscan.1 2019-01-22 00:05:53.000000000 +0100 @@ -1,6 +1,6 @@ .\" Hey, EMACS: -*- nroff -*- -.TH URLSCAN 1 "July 29, 2018" +.TH URLSCAN 1 "January 14, 2019" .SH NAME urlscan \- browse the URLs in an email message from a terminal @@ -32,13 +32,15 @@ \fB2.\fR Extraction and display of the context surrounding each URL. Toggle context view on/off with `c`. -\fB3.\fR URLs are shortened by default to fit on one line. Toggle one or all +\fB3.\fR Copy current URL to clipboard primary selection with `C`. + +\fB4.\fR URLs are shortened by default to fit on one line. Toggle one or all shortened URLs with `s` or `S`. -\fB4.\fR Incremental case-insensitive search using `/`. Footer shows current +\fB5.\fR Incremental case-insensitive search using `/`. Footer shows current search term. `/` again resets search. -\fB5.\fR Cycle through all available palettes (color and black & white available +\fB6.\fR Cycle through all available palettes (color and black & white available by default) using `p`. `P` will generate a ~/.config/urlscan/config.json file for editing or adding additional pallettes. See @@ -46,7 +48,10 @@ for options and allowed values. -\fB5.\fR `u` will unescape the highlighted URL if necessary. +\fB7.\fR `u` will unescape the highlighted URL if necessary. + +\fB8.\fR Run a command with the selected URL as the argument or pipe the selected + URL to a command using the `--run` and `--pipe` arguments. .SH OPTIONS .TP @@ -66,6 +71,13 @@ \<expression\> to substitute in the URL. Example: $ urlscan --run 'echo {} | xclip -i' file.txt +.TP +.B \-p, \-\-pipe +Pipe the selected URL to the command specified by `--run`. This is preferred +when the command supports it, as it is more secure and tolerant of special +characters in the URL. Example: + + $ urlscan --run 'xclip -i' --pipe file.txt .SH MUTT INTEGRATION