From 8a1a090deabb1ff37703384c02769f70abb3ba7d Mon Sep 17 00:00:00 2001 From: jnphilipp Date: Mon, 31 Aug 2015 22:45:17 +0200 Subject: [PATCH 1/4] Added userscript to open feed links. --- misc/userscripts/openfeeds | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 misc/userscripts/openfeeds diff --git a/misc/userscripts/openfeeds b/misc/userscripts/openfeeds new file mode 100755 index 000000000..1f3e432a6 --- /dev/null +++ b/misc/userscripts/openfeeds @@ -0,0 +1,30 @@ +#!/bin/bash + +# Copyright 2015 jnphilipp +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +# Opens all links to feeds defined in the head of a site +# +# Ideal for use with tabs-are-windows. Set a hotkey to launch this script, then: +# :bind gF spawn --userscript openfeeds +# +# Use the hotkey to open the feeds in new tab/window, press 'gF' to open +# + +grep cat ${QUTE_HTML} | grep "]*rel=\"alternate\"[^>]*>" | grep -E "(application/((rss|rdf|atom)\+)?xml|text/xml)" | grep -oE "href=\"([^\"]+)\"" | cut -d\" -f2 | while read -r line ; do + echo "open -t ${line}" >> "$QUTE_FIFO" +done From 1cbc555933993883f7bc14c475be4907f1e7d407 Mon Sep 17 00:00:00 2001 From: jnphilipp Date: Tue, 1 Sep 2015 22:08:37 +0200 Subject: [PATCH 2/4] Rewrote userscript to use BeautifulSoup. --- misc/userscripts/openfeeds | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/misc/userscripts/openfeeds b/misc/userscripts/openfeeds index 1f3e432a6..479d0ad1e 100755 --- a/misc/userscripts/openfeeds +++ b/misc/userscripts/openfeeds @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # Copyright 2015 jnphilipp # @@ -20,11 +21,19 @@ # Opens all links to feeds defined in the head of a site # # Ideal for use with tabs-are-windows. Set a hotkey to launch this script, then: -# :bind gF spawn --userscript openfeeds +# :bind gF spawn --userscript openfeeds # # Use the hotkey to open the feeds in new tab/window, press 'gF' to open # -grep cat ${QUTE_HTML} | grep "]*rel=\"alternate\"[^>]*>" | grep -E "(application/((rss|rdf|atom)\+)?xml|text/xml)" | grep -oE "href=\"([^\"]+)\"" | cut -d\" -f2 | while read -r line ; do - echo "open -t ${line}" >> "$QUTE_FIFO" -done +import os +import re + +from bs4 import BeautifulSoup + +if os.environ['QUTE_HTML']: + soup = BeautifulSoup(open(os.environ['QUTE_HTML'], 'r')) + with open(os.environ['QUTE_FIFO'], 'w') as f: + for link in soup.find_all('link', rel='alternate', type=re.compile(r'application/((rss|rdf|atom)\+)?xml|text/xml')): + f.write('open -t %s\n' % link.get('href')) + f.close() From 6ffcb387eb0f307dc8e0f26f46f41c3b41e6a964 Mon Sep 17 00:00:00 2001 From: jnphilipp Date: Wed, 2 Sep 2015 14:02:24 +0200 Subject: [PATCH 3/4] Incorporated The-Compilers suggested chanes. --- misc/userscripts/openfeeds | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/misc/userscripts/openfeeds b/misc/userscripts/openfeeds index 479d0ad1e..9e619ec83 100755 --- a/misc/userscripts/openfeeds +++ b/misc/userscripts/openfeeds @@ -31,9 +31,8 @@ import re from bs4 import BeautifulSoup -if os.environ['QUTE_HTML']: - soup = BeautifulSoup(open(os.environ['QUTE_HTML'], 'r')) - with open(os.environ['QUTE_FIFO'], 'w') as f: - for link in soup.find_all('link', rel='alternate', type=re.compile(r'application/((rss|rdf|atom)\+)?xml|text/xml')): - f.write('open -t %s\n' % link.get('href')) - f.close() +with open(os.environ['QUTE_HTML'], 'r') as f: + soup = BeautifulSoup(f) +with open(os.environ['QUTE_FIFO'], 'w') as f: + for link in soup.find_all('link', rel='alternate', type=re.compile(r'application/((rss|rdf|atom)\+)?xml|text/xml')): + f.write('open -t %s\n' % link.get('href')) From 0fcab6a632bfc3e9b9cfc06ded04901754b84e6a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 2 Sep 2015 14:06:11 +0200 Subject: [PATCH 4/4] Regenerate authors. --- README.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.asciidoc b/README.asciidoc index c8abad993..b0a77488c 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -157,6 +157,7 @@ Contributors, sorted by the number of commits in descending order: * Error 800 * Brian Jackson * sbinix +* jnphilipp * Tobias Patzl * Johannes Altmanninger * Samir Benmendil