You are not logged in.

#451 2011-07-16 16:23:12

examon
Member
Registered: 2011-05-07
Posts: 208

Re: luakit browser framework (almost with jQuery!)

mason.larobina wrote:
examon wrote:

Hi guys! I started to use luakit some days ago and I really like it. One thing I've problem with is, that I can't setup 'downloading without asking'.

I set default download location with:

downloads.default_dir = os.getenv("HOME") .. "/down"

and this works ok. Now I wanted to set 'download without asking' so I added next block of code under 'default download location' code.

downloads.default_dir = os.getenv("HOME") .. "/down"
downloads.add_signal("download-location", function (uri, file)
    if not file or file == "" then
        file = (string.match(uri, "/([^/]+)$") 
            or string.match(uri, "^%w+://(.+)") 
            or string.gsub(uri, "/", "_")
            or "untitled")
    end 
    return downloads.default_dir .. "/" .. file
end)

I was following 'FAQ' at luakit.org but 'downloading without asking' doesn't work.

Thanks for help

That should work, and you added it below the `require "downloads"` line in your rc.lua? And are you sure the correct rc.lua is being loaded? (run `luakit -v 2>&1 | grep "luaH_loadrc"`)

Thanks for reply mason.larobina!
I think correct rc.lua is being loaded. Becouse 'defaults download location' code is loaded and is working. But 'download without asking' for some reason isn't loaded or something.

I tested:

luakit -v 2>&1 | grep "luaH_loadrc"

luakit opens but it's still the same... 'download without asking' is not working.

Offline

#452 2011-07-16 18:43:55

mason.larobina
Member
From: Australia
Registered: 2009-07-02
Posts: 200
Website

Re: luakit browser framework (almost with jQuery!)

examon wrote:
mason.larobina wrote:
examon wrote:

Hi guys! I started to use luakit some days ago and I really like it. One thing I've problem with is, that I can't setup 'downloading without asking'.

I set default download location with:

downloads.default_dir = os.getenv("HOME") .. "/down"

and this works ok. Now I wanted to set 'download without asking' so I added next block of code under 'default download location' code.

downloads.default_dir = os.getenv("HOME") .. "/down"
downloads.add_signal("download-location", function (uri, file)
    if not file or file == "" then
        file = (string.match(uri, "/([^/]+)$") 
            or string.match(uri, "^%w+://(.+)") 
            or string.gsub(uri, "/", "_")
            or "untitled")
    end 
    return downloads.default_dir .. "/" .. file
end)

I was following 'FAQ' at luakit.org but 'downloading without asking' doesn't work.

Thanks for help

That should work, and you added it below the `require "downloads"` line in your rc.lua? And are you sure the correct rc.lua is being loaded? (run `luakit -v 2>&1 | grep "luaH_loadrc"`)

Thanks for reply mason.larobina!
I think correct rc.lua is being loaded. Becouse 'defaults download location' code is loaded and is working. But 'download without asking' for some reason isn't loaded or something.

I tested:

luakit -v 2>&1 | grep "luaH_loadrc"

luakit opens but it's still the same... 'download without asking' is not working.

When all else fails chuck a `print("I'm in here")` in the "download-location" signal function.

Edit: and which version of luakit are you using?

Last edited by mason.larobina (2011-07-16 18:46:27)

Offline

#453 2011-07-16 19:07:35

examon
Member
Registered: 2011-05-07
Posts: 208

Re: luakit browser framework (almost with jQuery!)

OK, so I tested:

print("I'm in here")

...without reaction

Im using:

luakit f3a2dbe

Offline

#454 2011-07-16 19:36:51

mason.larobina
Member
From: Australia
Registered: 2009-07-02
Posts: 200
Website

Re: luakit browser framework (almost with jQuery!)

examon wrote:

OK, so I tested:

print("I'm in here")

...without reaction

Im using:

luakit f3a2dbe

I remember the problem now. Fixed here.

You'll have to update to luakit-git in AUR or apply the above patch to /usr/share/luakit/lib/lousy/signal.lua

But you still should have seen a "I'm in here" being printed.

Last edited by mason.larobina (2011-07-16 19:38:12)

Offline

#455 2011-07-16 20:49:58

examon
Member
Registered: 2011-05-07
Posts: 208

Re: luakit browser framework (almost with jQuery!)

mason.larobina wrote:
examon wrote:

OK, so I tested:

print("I'm in here")

...without reaction

Im using:

luakit f3a2dbe

I remember the problem now. Fixed here.

You'll have to update to luakit-git in AUR or apply the above patch to /usr/share/luakit/lib/lousy/signal.lua

But you still should have seen a "I'm in here" being printed.

Thanks!

I installed luakit-git as you recommanded. Now it works flawlessly!

Offline

#456 2011-07-20 09:21:02

mason.larobina
Member
From: Australia
Registered: 2009-07-02
Posts: 200
Website

Re: luakit browser framework (almost with jQuery!)

karottenreibe wrote:
Berticus wrote:

Lastly, I'm still having trouble with the follows script (contains leading zeroes, numbers don't update as I type part of the url). In my ~/.config/luakit/follow.lua, I set sort_labels to false.

See my follow-styles branch (http://github.com/karottenreibe/luakit/ … low-styles). That should solve the leading-zeroes issue.

I don't know what you mean by "numbers don't update as I type part of the url".
There is no matching against URLs, only against the text of the matched elements. Also the hint labels are not supposed to update when you type something for two reasons:
a) That's confusing (people who type more quickly might accidentally hit the wrong number)
b) It's not possible to implement this without substantial changes to the codebase

bootleg wrote:

Since the lastest changes in follow.lua, the alternative characters hack didn't work anymore, so I tried something.

Also see my follow-styles branch. It now features a follow style called `charset' that lets you have that functionality. To use it, insert this somewhere after requiring `follow.lua':

follow.style = follow.styles.charset("uietsrn")

Turnover was a little slow but this work has been merged in to the develop branch along with other following script improvements.

You can now control exactly how the labels are generated by what we call "following styles".

Here are some examples:

local s = follow.styles
-- Custom charset.
follow.style = s.charset("asdf")

-- Sort & reverse labels to evenly distribute their leading 
-- characters (this is what I use).
follow.style = s.sort(s.reverse(s.charset("asdfqwerzxcv")))

-- Impractical but funny
follow.style = s.charset("01")

Here is an image of the last one.

Edit: And the default is still number labels & partial link text matching.

Last edited by mason.larobina (2011-07-20 09:23:46)

Offline

#457 2011-07-21 01:26:37

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: luakit browser framework (almost with jQuery!)

I'm wondering, what exactly has to be done to make luakit use userscripts? According to the wiki and the file userscripts.lua these files only have to be put in $XDG_DATA_HOME/luakit/scripts and you're good to go. Butit doesn't seem to work here.
Maybe I'm just picking scripts that don't work with luakit, so does anybody have an example script?

Offline

#458 2011-07-21 04:49:34

joshdmiller
Member
From: California
Registered: 2010-04-25
Posts: 51
Website

Re: luakit browser framework (almost with jQuery!)

Army wrote:

I'm wondering, what exactly has to be done to make luakit use userscripts? According to the wiki and the file userscripts.lua these files only have to be put in $XDG_DATA_HOME/luakit/scripts and you're good to go. Butit doesn't seem to work here.
Maybe I'm just picking scripts that don't work with luakit, so does anybody have an example script?

There are a couple of examples on the luakit.org wiki and I have many userscripts working. Be sure you have the correct "@include" lines in the header.

Can you post your non-working userscript that we can test?

Offline

#459 2011-07-21 05:01:12

joshdmiller
Member
From: California
Registered: 2010-04-25
Posts: 51
Website

Re: luakit browser framework (almost with jQuery!)

Is there a way to have the `referer` header populated on new tabs/windows? I browsed the libsoup and webkit documentation and while I found a libsoup function for this (soup-message-headers-append()), I did not find any way to glue this back to webkit.

Offline

#460 2011-07-21 07:59:06

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: luakit browser framework (almost with jQuery!)

joshdmiller wrote:

There are a couple of examples on the luakit.org wiki and I have many userscripts working. Be sure you have the correct "@include" lines in the header.

Can you post your non-working userscript that we can test?

I'm just too stupid, I put the scripts into ~/.config/luakit/scripts ... Should have gone to bed instead of playing with this ... Of course the scripts work fine after putting them into ~/.local/share/luakit/scripts. Sorry for the noise!

Offline

#461 2011-07-22 15:11:35

mason.larobina
Member
From: Australia
Registered: 2009-07-02
Posts: 200
Website

Re: luakit browser framework (almost with jQuery!)

New luakit release 2011.07.22

Check out the changelog here:

  http://luakit.org/news/8

Or browse the luakit-2011.07.22 source here:

  https://github.com/mason-larobina/luaki … 2011.07.22

I've already reported the [community] packages as out-of-date so it shouldn't be too long before they are updated.

Enjoy guys.

Offline

#462 2011-07-22 15:50:54

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: luakit browser framework (almost with jQuery!)

Nice smile Many good new things in this release! Great work Mason and all other coders!!

Offline

#463 2011-07-28 01:19:17

Tzbob
Member
From: Belgium
Registered: 2011-04-12
Posts: 61

Re: luakit browser framework (almost with jQuery!)

As I have zero experience in lua nor  the time to learn I figured I'd just ask here.

Would it be possible to integrate http://gpl.internetconnection.net/vi/ in a way that it can be called upon textarea's with a hotkey, and to make escape/ctrl+[ accessable to it while doing so?

Really loving this browser!

Offline

#464 2011-08-03 02:56:53

mkaito
Member
From: Spain
Registered: 2010-06-12
Posts: 126
Website

Re: luakit browser framework (almost with jQuery!)

Really, the only thing we're missing in luakit is proper bookmark handling, with tags, and maybe keywords (like the ones in firefox), but mostly, tab completion on :open and :tabopen.


Fear me! I have root! Sometimes...

Offline

#465 2011-08-03 05:29:34

cf8
Member
From: Russia
Registered: 2008-10-21
Posts: 83

Re: luakit browser framework (almost with jQuery!)

mkaito wrote:

[…] but mostly, tab completion on :open and :tabopen.

Wait a minute, we've already have this feature. Take a look here:
http://ompldr.org/vOXFoOA
Just start to type ("linux" for example), press <Tab> - and you'll have it

Offline

#466 2011-08-03 12:51:13

mkaito
Member
From: Spain
Registered: 2010-06-12
Posts: 126
Website

Re: luakit browser framework (almost with jQuery!)

Yeah, it completes on history and commands, but not on bookmarks.


Fear me! I have root! Sometimes...

Offline

#467 2011-08-04 18:12:59

Vain
Member
Registered: 2008-10-19
Posts: 179
Website

Re: luakit browser framework (almost with jQuery!)

Is there a nice way to use scroll marks like in vi? Did a quick search and found nothing, so I came up with this:

add_binds("normal", {
    -- Marks
    buf("^m.$",                     function (w, b)
                                        local widg = w:get_current()
                                        local which = string.sub(b, 2)
                                        scrollmarks = scrollmarks or {}
                                        scrollmarks[widg] = scrollmarks[widg] or {}
                                        scrollmarks[widg][which] = widg:get_scroll_vert()
                                    end),
    buf("^'.$",                     function (w, b)
                                        local widg = w:get_current()
                                        local which = string.sub(b, 2)
                                        scrollmarks = scrollmarks or {}
                                        scrollmarks[widg] = scrollmarks[widg] or {}
                                        if scrollmarks[widg][which]
                                        then
                                            widg:set_scroll_vert(scrollmarks[widg][which])
                                        end
                                    end),
})

I don’t consider this beautiful code but it works.

Offline

#468 2011-08-06 05:22:52

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: luakit browser framework (almost with jQuery!)

Have been looking around but found no mention except for some reference to libunique. Is there a way to make sure that all new windows become new tabs instead? Eg when I click on a news item in google news.

Offline

#469 2011-08-06 07:04:46

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: luakit browser framework (almost with jQuery!)

+1 for that, just wanted to ask the same thing.

Offline

#470 2011-08-06 07:28:23

joshdmiller
Member
From: California
Registered: 2010-04-25
Posts: 51
Website

Re: luakit browser framework (almost with jQuery!)

stryder wrote:

Have been looking around but found no mention except for some reference to libunique. Is there a way to make sure that all new windows become new tabs instead? Eg when I click on a news item in google news.

Copy webview.lua to ~/.config/luakit and look for the window_decision function (line 192 for me). Comment out the entire if statement and replace it with just "w:new_tab(uri)".

Offline

#471 2011-08-06 08:51:22

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: luakit browser framework (almost with jQuery!)

Thanks Josh. Clear instructions, works flawlessly. smile

Since I have to comment out stuff I take it that this cannot be done in userconf.lua? (Just trying to learn...)

Offline

#472 2011-08-06 10:09:48

mkaito
Member
From: Spain
Registered: 2010-06-12
Posts: 126
Website

Re: luakit browser framework (almost with jQuery!)

I have this in my rc.lua, right after require 'webview':

webview.init_funcs.window_decision = function (view, w)
    view:add_signal("new-window-decision", function (v, uri, reason)
        w:new_tab(uri)
        return true
    end)
end

Fear me! I have root! Sometimes...

Offline

#473 2011-08-08 01:38:41

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: luakit browser framework (almost with jQuery!)

Great! This works too. And I have one less file in my luakit folder. Thanks, mkaito.

Offline

#474 2011-08-10 09:37:34

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: luakit browser framework (almost with jQuery!)

I have a little problem, luakit doesn't start the first time after boot. The second try works. Here's what I get at the first try

% luakit

(luakit:1120): GLib-WARNING **: In call to g_spawn_sync(), exit status of a child process was requested but SIGCHLD action was set to SIG_IGN and ECHILD was received by waitpid(), so exit status can't be returned. This is a bug in the program calling g_spawn_sync(); either don't request the exit status, or don't set the SIGCHLD action.

** (luakit:1120): WARNING **: Unable to open a connection to the session bus: Abnormal program termination spawning command line `dbus-launch --autolaunch=e0c4c760e84c7eb0c5730fd4000001e0 --binary-syntax --close-stderr': 

(luakit:1120): GLib-GIO-CRITICAL **: g_dbus_connection_call_sync: assertion `G_IS_DBUS_CONNECTION (connection)' failed
[1]    1120 segmentation fault  luakit

Any ideas?

Offline

#475 2011-08-10 12:06:02

bratmaxe
Member
From: Germany
Registered: 2010-11-07
Posts: 71

Re: luakit browser framework (almost with jQuery!)

I'm quite sure that you will have to start a dbus session to fix this. If you use xinitrc to launch your window manager put this lines on top (or copy them from /etc/skel/.xinitrc)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

Offline

Board footer

Powered by FluxBB