LINUX.ORG.RU

История изменений

Исправление dataman, (текущая версия) :

Зачем там скрипты, что ими делать?

https://github.com/rkd77/elinks/blob/master/doc/lua-scripting.txt:

… Go to URL on steroids

There are some web sites that I visit often. Bookmarks are okay, but they are separate from the «Go to URL» dialog box, so I keep forgetting to use them. Also, when I visit a search engine home page, all I really want to do is enter a search term.

The following script allows me to type certain strings into the «Go to URL» dialog box, and it will convert them to the URL I actually want to visit. As a bonus, it allows me perform some searches on sites like Google without loading up the front page first.

TIP: The URI rewriting feature of ELinks handles many of the same tasks as the Lua hook shown here, and you can conveniently configure it via the option manager. It is not quite as versatile, though.

function match (prefix, url)
    return string.sub (url, 1, string.len (prefix)) == prefix
end

function strip (str)
    return string.gsub (str, "^%s*(.-)%s*$", "%1")
end

function plusify (str)
    return string.gsub (str, "%s", "+")
end

function goto_url_hook (url, current_url)
    -- Google search (e.g. ,gg unix browsers).
    if match (",gg", url) then
        url = plusify (strip (string.sub (url, 4)))
        return "http://www.google.com/search?q="..url.."&btnG=Google+Search"

    -- Freshmeat search.
    elseif match (",fm", url) then
        url = plusify (strip (string.sub (url, 4)))
        return "http://www.freshmeat.net/search/?q="..url

    -- Dictionary.com search (e.g. ,dict congenial).
    elseif match (",dict", url) then
        url = plusify (strip (string.sub (url, 6)))
        return "http://www.dictionary.com/cgi-bin/dict.pl?db=%2A&term="..url

    -- RPM search (e.g. ,rpm links).
    elseif match (",rpm", url) then
        url = plusify (strip (string.sub (url, 5)))
        return "http://www.rpmfind.net/linux/rpm2html/search.php?query="
                ..url.."&submit=Search+..."

    -- Netcraft.com search (e.g. ,whatis www.google.com).
    elseif match (",whatis", url) then
        url = plusify (strip (string.sub (url, 8)))
        return "http://uptime.netcraft.com/up/graph/?host="..url

    -- LinuxToday home page.
    elseif match (",lt", url) then
        return "http://linuxtoday.com/"

    -- Weather forecast for Melbourne, Australia.
    elseif match (",forecast", url) then
        return "http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV10450.txt"

    -- Unmatched
    else
        return url
    end
end

И в https://github.com/rkd77/elinks/tree/master/contrib есть куча примеров.

Исходная версия dataman, :

Зачем там скрипты, что ими делать?

Go to URL on steroids

There are some web sites that I visit often. Bookmarks are okay, but they are separate from the «Go to URL» dialog box, so I keep forgetting to use them. Also, when I visit a search engine home page, all I really want to do is enter a search term.

The following script allows me to type certain strings into the «Go to URL» dialog box, and it will convert them to the URL I actually want to visit. As a bonus, it allows me perform some searches on sites like Google without loading up the front page first.

TIP: The URI rewriting feature of ELinks handles many of the same tasks as the Lua hook shown here, and you can conveniently configure it via the option manager. It is not quite as versatile, though.

function match (prefix, url)
    return string.sub (url, 1, string.len (prefix)) == prefix
end

function strip (str)
    return string.gsub (str, "^%s*(.-)%s*$", "%1")
end

function plusify (str)
    return string.gsub (str, "%s", "+")
end

function goto_url_hook (url, current_url)
    -- Google search (e.g. ,gg unix browsers).
    if match (",gg", url) then
        url = plusify (strip (string.sub (url, 4)))
        return "http://www.google.com/search?q="..url.."&btnG=Google+Search"

    -- Freshmeat search.
    elseif match (",fm", url) then
        url = plusify (strip (string.sub (url, 4)))
        return "http://www.freshmeat.net/search/?q="..url

    -- Dictionary.com search (e.g. ,dict congenial).
    elseif match (",dict", url) then
        url = plusify (strip (string.sub (url, 6)))
        return "http://www.dictionary.com/cgi-bin/dict.pl?db=%2A&term="..url

    -- RPM search (e.g. ,rpm links).
    elseif match (",rpm", url) then
        url = plusify (strip (string.sub (url, 5)))
        return "http://www.rpmfind.net/linux/rpm2html/search.php?query="
                ..url.."&submit=Search+..."

    -- Netcraft.com search (e.g. ,whatis www.google.com).
    elseif match (",whatis", url) then
        url = plusify (strip (string.sub (url, 8)))
        return "http://uptime.netcraft.com/up/graph/?host="..url

    -- LinuxToday home page.
    elseif match (",lt", url) then
        return "http://linuxtoday.com/"

    -- Weather forecast for Melbourne, Australia.
    elseif match (",forecast", url) then
        return "http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV10450.txt"

    -- Unmatched
    else
        return url
    end
end