commit 68af0b779f2639904fb1b04382bb09eec36c087d
parent 92265c3d4bbe7f91fe680a8388e7110aa8bf7171
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 6 Feb 2022 15:05:00 +0000
save cookies between sessions
Diffstat:
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/just/README.md b/just/README.md
@@ -9,5 +9,4 @@ Touchscreen-friendly wrapper around Webkit
- find out if it's going to eat cpu like luakit does
- some kind of bookmarks/favourites/pinned tabs/memory of visited sites
- ESC in url bar cancels typing
-- support cookies (may need to save them across sessions?)
- warning for insecure sites
diff --git a/just/just.fnl b/just/just.fnl
@@ -4,11 +4,20 @@
(local Gtk lgi.Gtk)
(local WebKit2 lgi.WebKit2)
-(local cache-dir (.. (os.getenv "HOME") "/.cache"))
+(local cache-dir (.. (os.getenv "HOME") "/.cache/just"))
(local content-filter-store
(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 []
(let [subscriptions {}
vivify (fn [n v]
@@ -88,7 +97,7 @@ progress, trough {
(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)
window (Gtk.Window {
:title "Just browsing"
@@ -107,12 +116,10 @@ progress, trough {
:fraction 1.0
:margin 0
})
- url (doto (Gtk.Entry {
- :on_activate
- (fn [self]
- (bus:publish :fetch self.text))
- })
- (: :set_text current-url))
+ url (Gtk.Entry {
+ :on_activate
+ (fn [self] (bus:publish :fetch self.text))
+ })
stop (doto (Gtk.Button {
:on_clicked #(bus:publish :stop-loading)
})
@@ -165,4 +172,9 @@ progress, trough {
(window:show_all))
+(: (WebKit2.WebContext:get_default) :get_website_data_manager)
+
+
+
+
(Gtk.main)