save cookies between sessions

This commit is contained in:
Daniel Barlow 2022-02-06 15:05:00 +00:00
parent 92265c3d4b
commit 68af0b779f
2 changed files with 20 additions and 9 deletions

View File

@ -9,5 +9,4 @@ Touchscreen-friendly wrapper around Webkit
- find out if it's going to eat cpu like luakit does - find out if it's going to eat cpu like luakit does
- some kind of bookmarks/favourites/pinned tabs/memory of visited sites - some kind of bookmarks/favourites/pinned tabs/memory of visited sites
- ESC in url bar cancels typing - ESC in url bar cancels typing
- support cookies (may need to save them across sessions?)
- warning for insecure sites - warning for insecure sites

View File

@ -4,11 +4,20 @@
(local Gtk lgi.Gtk) (local Gtk lgi.Gtk)
(local WebKit2 lgi.WebKit2) (local WebKit2 lgi.WebKit2)
(local cache-dir (.. (os.getenv "HOME") "/.cache")) (local cache-dir (.. (os.getenv "HOME") "/.cache/just"))
(local content-filter-store (local content-filter-store
(WebKit2.UserContentFilterStore {:path cache-dir})) (WebKit2.UserContentFilterStore {:path cache-dir}))
(-> (WebKit2.WebContext:get_default)
(: :get_website_data_manager)
(: :get_cookie_manager)
(: :set_persistent_storage
(.. cache-dir "/cookies.db")
WebKit2.CookiePersistentStorage.SQLITE))
(fn event-bus [] (fn event-bus []
(let [subscriptions {} (let [subscriptions {}
vivify (fn [n v] vivify (fn [n v]
@ -88,7 +97,7 @@ progress, trough {
(bus:publish (if self.is_loading :start-loading :stop-loading)) (bus:publish (if self.is_loading :start-loading :stop-loading))
)) ))
(let [current-url "https://terse.telent.net/admin/stream" (let [current-url "https://terse.telent.net"
bus (event-bus) bus (event-bus)
window (Gtk.Window { window (Gtk.Window {
:title "Just browsing" :title "Just browsing"
@ -107,12 +116,10 @@ progress, trough {
:fraction 1.0 :fraction 1.0
:margin 0 :margin 0
}) })
url (doto (Gtk.Entry { url (Gtk.Entry {
:on_activate :on_activate
(fn [self] (fn [self] (bus:publish :fetch self.text))
(bus:publish :fetch self.text)) })
})
(: :set_text current-url))
stop (doto (Gtk.Button { stop (doto (Gtk.Button {
:on_clicked #(bus:publish :stop-loading) :on_clicked #(bus:publish :stop-loading)
}) })
@ -165,4 +172,9 @@ progress, trough {
(window:show_all)) (window:show_all))
(: (WebKit2.WebContext:get_default) :get_website_data_manager)
(Gtk.main) (Gtk.main)