BTS

Issue627

Title grml-etc-core: Rewrite of function zurl().
Priority feature Status resolved
Superseder Nosy List ft, mika, z3ttacht
Assigned To ft Topics configs, grml-etc-core, zsh

Created on 2009-02-18.15:26:32 by z3ttacht, last changed 2009-02-23.13:01:30 by ft.

Files
File name Uploaded Type Edit Remove
0001-zshrc-Rewrite-of-function-zurl.patch z3ttacht, 2009-02-18.19:18:11 text/x-diff
0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch z3ttacht, 2009-02-20.11:30:32 text/x-diff
Messages
msg1955 (view) Author: ft Date: 2009-02-23.13:01:29
We believe that your issue has been closed by the upload of
Version 0.3.64 of grml-etc-core from Frank Terbeck <ft@grml.org>.
The explanation is attached below

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Mon, 23 Feb 2009 00:54:05 +0100
Source: grml-etc-core
Binary: grml-etc-core
Architecture: source all
Version: 0.3.64
Distribution: unstable
Urgency: low
Maintainer: Michael Prokop <mika@grml.org>
Changed-By: Frank Terbeck <ft@grml.org>
Description: 
 grml-etc-core - core ecetera files for the grml system
Changes: 
 grml-etc-core (0.3.64) unstable; urgency=low
 .
   * zshrc: rewrite of zurl() by Alexander Steinböck [Closes: issue627]
   * zshrc: put "zsh: repo-name" into screen title if the user is in a
     VCS-controlled directory [Closes: issue635]
Checksums-Sha1: 
 e89d92a4cfb0f75aeb8350f3b18a6b5629e09bcd 873 grml-etc-core_0.3.64.dsc
 4f5c41195d9932e7554d01b40fc9dbc99b87a9af 108861 grml-etc-core_0.3.64.tar.gz
 ed05506f05ff8840ae9a31e67348c9d6515aa50b 111424 grml-etc-core_0.3.64_all.deb
Checksums-Sha256: 
 b34e6d733241ab8191872988a3ef03c5f8fd603d8836bb987aad4aae967b7e3b 873 grml-etc-core_0.3.64.dsc
 c3681d9ac1ef656cd236f5737925d81c1340702d92eb42ec35d124f33941e51a 108861 grml-etc-core_0.3.64.tar.gz
 11924b3017f0346a53777165cef98edc7ea37f489a48c01846a28d95581b4185 111424 grml-etc-core_0.3.64_all.deb
Files: 
 f899993d4f1f4e682af8dfcae11baf7d 873 grml optional grml-etc-core_0.3.64.dsc
 8bf00295f87653f4ccec9a0e2f3b28dc 108861 grml optional grml-etc-core_0.3.64.tar.gz
 0ccfba70bcec0f3d3710a49ecc281026 111424 grml optional grml-etc-core_0.3.64_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFJopyu2N9T+zficugRAuuJAJ9FR5TG0GwFcHZqyA9BRmDuOmdFwQCfYwGj
+J/t1EIeIrab8a+zqhNMSkQ=
=Vfaj
-----END PGP SIGNATURE-----
msg1922 (view) Author: z3ttacht Date: 2009-02-20.11:30:32
> > Before invoking zurl(), the given URL gets tested for existence by
> > 'ping -c 1 $url'.
> > May that be too much of user guidance? Let alone paternalism. (o;
> This one doesn't apply anymore. Update?
Should work again.

> > > The function however is now just using zsh in-house means [...]
> > Actually, almost. There's still wget, which could probably be
> > replaced; but that's not really a priority...
> Are you thinking of zshtcpsys(1)?
msg1915 (view) Author: ft Date: 2009-02-19.16:52:26
Alexander Steinböck <bts@bts.grml.org>:
> Before invoking zurl(), the given URL gets tested for existence by
> 'ping -c 1 $url'.
> May that be too much of user guidance? Let alone paternalism. (o;

The other patch is in:
<http://git.grml.org/?p=grml-etc-core.git;a=commit;h=ccc94f4a8dcf92bdf3adacbdbf97c18b55fa0f8d>

This one doesn't apply anymore. Update?

Regards, Frank
msg1912 (view) Author: z3ttacht Date: 2009-02-18.19:18:11
> > The function however is now just using zsh in-house means [...]
> Actually, almost. There's still wget, which could probably be
> replaced; but that's not really a priority...
Are you thinking of zshtcpsys(1)?

> A check if wget is installed would be better, though.
> [...]
> add a check for external programs (wget) via 'check_com -c ...'.
Done.

> >  # create small urls via tinyurl.com using wget, grep and sed
> s:,.*$::
Good catch.
Done.

> I didn't try to understand what's going on here. But I'll trust you,
> that it works.
I'm flattered. (o; But I hope I've tested enough.
msg1911 (view) Author: ft Date: 2009-02-18.15:36:46
Alexander Steinböck <bts@bts.grml.org>:
> From 69e0206b11398ef84ff181d853749873a87c65db Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?Alexander=20Steinb=C3=B6ck?= <z3ttacht@grml.org>
> Date: Wed, 18 Feb 2009 16:01:13 +0100
> Subject: [PATCH 1/2] zshrc: Rewrite of function zurl().
> 
> Because of changes in the HTML source code of TinyURL, zurl() wasn't working
> properly anymore. For instance, it's now 'copy(http://tinyurl.com/7efkze)'
> instead of 'value="(http://tinyurl.com/7efkze)'.

Heh, I noticed this, too, a few days back. But I was *way* to lazy to
fix it.

> The function however is now just using zsh in-house means and tries to provide

Actually, almost. There's still wget, which could probably be
replaced; but that's not really a priority...

A check if wget is installed would be better, though.

> some decent output. Including TinyURL's new preview feature.
> <http://tinyurl.com/preview.php>
> ---
>  etc/zsh/zshrc |   24 ++++++++++++++++--------
>  1 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
> index 51141a1..9e2864c 100644
> --- a/etc/zsh/zshrc
> +++ b/etc/zsh/zshrc
> @@ -3924,15 +3924,23 @@ fi
>  
>  # create small urls via tinyurl.com using wget, grep and sed

s:,.*$::

>  zurl() {
> +#   Prepend 'http://' to given URL where necessary for later output.
> +    [[ ${url} != http(s|)://* ]] && url='http://'${url}
> +    local tiny='http://tinyurl.com/create.php?url='
> +    local grabber='wget -O- -o/dev/null'
> +#   Looking for i.e.`copy('http://tinyurl.com/7efkze')' in TinyURL's html code.
> +    local search='copy\(?http://tinyurl.com/[[:alnum:]]##*'
> +    local result=${(M)${${${(f)"$(${=grabber} ${tiny}${url})"}[(fr)${search}*]}//[()\';]/}%%http:*}
> +#   TinyURL provides the rather new feature preview for more confidence. <http://tinyurl.com/preview.php>
> +    local preview='http://preview.'${result#http://}
> +
> +    printf '%s\n\n' "${PN} - Shrinking long URLs via webservice TinyURL <http://tinyurl.com>."
> +    printf '%s\t%s\n\n' 'Given URL:' ${url}
> +    printf '%s\t%s\n\t\t%s\n' 'TinyURL:' ${result} ${preview}
>  }

I didn't try to understand what's going on here. But I'll trust you,
that it works.

Nice one, if you can fix the comment as I mentioned and add a check
for external programs (wget) via 'check_com -c ...'.

Regards, Frank
msg1910 (view) Author: z3ttacht Date: 2009-02-18.15:30:36
Before invoking zurl(), the given URL gets tested for existence by
'ping -c 1 $url'.
May that be too much of user guidance? Let alone paternalism. (o;
msg1908 (view) Author: z3ttacht Date: 2009-02-18.15:26:32
Because of changes in the HTML source code of TinyURL, zurl() wasn't working
properly anymore. For instance, it's now 'copy(http://tinyurl.com/7efkze)'
instead of 'value="(http://tinyurl.com/7efkze)'.

The function however is now just using zsh in-house means and tries to provide
some decent output. Including TinyURL's new preview feature.
<http://tinyurl.com/preview.php>
History
Date User Action Args
2009-02-23 13:01:30ftsetstatus: chatting -> resolved
nosy: mika, ft, z3ttacht
messages: + msg1955
2009-02-20 11:33:32z3ttachtsetfiles: - 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
2009-02-20 11:30:34z3ttachtsetfiles: + 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
messages: + msg1922
2009-02-19 16:52:27ftsetnosy: mika, ft, z3ttacht
messages: + msg1915
2009-02-18 19:43:08z3ttachtsetfiles: - 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
2009-02-18 19:33:53z3ttachtsetfiles: + 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
2009-02-18 19:31:24z3ttachtsetfiles: + 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
2009-02-18 19:30:48z3ttachtsetfiles: - 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
2009-02-18 19:20:13z3ttachtsetnosy: mika, ft, z3ttacht
assignedto: ft
2009-02-18 19:19:36z3ttachtsetfiles: - 0001-zshrc-Rewrite-of-function-zurl.patch
nosy: mika, ft, z3ttacht
2009-02-18 19:18:12z3ttachtsetfiles: + 0001-zshrc-Rewrite-of-function-zurl.patch
nosy: mika, ft, z3ttacht
messages: + msg1912
2009-02-18 15:36:47ftsetnosy: mika, ft, z3ttacht
messages: + msg1911
2009-02-18 15:30:36z3ttachtsetfiles: + 0002-zshrc-zurl-Testing-existence-of-given-URL-by-pin.patch
nosy: mika, ft, z3ttacht
status: unread -> chatting
messages: + msg1910
2009-02-18 15:26:32z3ttachtcreate