M bookmarks-edit.rkt => bookmarks-edit.rkt +14 -1
@@ 45,6 45,17 @@
[parent panel]
[label "Subscriptions are shown in the new tab when they update (if set in the preferences)."]))
+
+(define side-links-checkbox
+ (new check-box%
+ [label "Side Links"]
+ [parent panel]))
+
+(define side-links-message
+ (new message%
+ [parent panel]
+ [label "Links in this page will open in a new tab."]))
+
(define tags-field
(new text-field%
[label "Tags"]
@@ 89,9 100,10 @@
[title (send title-field get-value)]
[favourite (send favourite-checkbox get-value)]
[subscribe (send subscribe-checkbox get-value)]
+ [side-links (send side-links-checkbox get-value)]
[tags (string-split (send tags-field get-value) "," #:trim? #t)]
[notes (send notes-text get-text)])
- (add-bookmark (make-bookmark url title subscribe favourite 0 tags notes))
+ (add-bookmark (make-bookmark url title subscribe favourite side-links 0 tags notes))
(send bookmarks-edit-window show #f)))
(define save-button
@@ 106,6 118,7 @@
(send title-field set-value (bookmark-title b))
(send favourite-checkbox set-value (bookmark-favourite b))
(send subscribe-checkbox set-value (bookmark-subscribe b))
+ (send side-links-checkbox set-value (bookmark-side-links b))
(send tags-field set-value (string-join (bookmark-tags b) ", "))
(send notes-text insert (bookmark-notes b))
(send bookmarks-edit-window show #t))
M persist.rkt => persist.rkt +88 -38
@@ 53,44 53,94 @@
(define bookmarks (make-parameter (make-hash)))
-(serializable-struct bookmark
- (url
- title
- subscribe
- favourite
- last-checksum
- tags
- notes)
- #:mutable
- #:transparent)
-
-(define (make-bookmark url [title ""] [subscribe #f] [favourite #f] [last-checksum 0] [tags '()] [notes ""])
- (bookmark url title subscribe favourite last-checksum tags notes))
-
-(define (add-bookmark b)
- (let ([bs (bookmarks)])
- (hash-set! bs (bookmark-url b) b)
- (save-bookmarks)))
-
-(define (save-bookmarks)
- (let ([s (serialize (bookmarks))])
- (with-output-to-file bookmarks-file
- (lambda () (write s))
- #:exists 'replace)))
-
-(define (load-bookmarks)
- (let ([bs (if (file-exists? bookmarks-file)
- (with-input-from-file bookmarks-file
- (lambda () (deserialize (read))))
- (make-hash))])
- (bookmarks bs)))
+;(serializable-struct bookmark
+; (url
+; title
+; subscribe
+; favourite
+; last-checksum
+; tags
+; notes)
+; #:mutable
+; #:transparent)
+
+(serializable-struct/versions bookmark 1
+ (url
+ title
+ subscribe
+ favourite
+ side-links
+ last-checksum
+ tags
+ notes)
+ ([0
+ ; Constructor for v0 bookmarks
+ (lambda (url
+ title
+ subscribe
+ favourite
+ last-checksum
+ tags
+ notes)
+ (bookmark url
+ title
+ subscribe
+ favourite
+ #f
+ last-checksum
+ tags
+ notes))
+ ; Cycle-constructor for v0 bookmarks
+ (lambda ()
+ (let ([b0 (bookmark #f #f #f #f #f #f #f #f)])
+ (values
+ b0
+ (lambda (b)
+ (set-bookmark-url! b0 (bookmark-url b))
+ (set-bookmark-title! b0 (bookmark-title b))
+ (set-bookmark-subscribe! b0 (bookmark-subscribe b))
+ (set-bookmark-favourite! b0 (bookmark-favourite b))
+ (set-bookmark-last-checksum! b0 (bookmark-last-checksum b))
+ (set-bookmark-tags! b0 (bookmark-tags b))
+ (set-bookmark-notes! b0 (bookmark-notes b))))))])
+ #:mutable
+ #:transparent)
+
+ (define (make-bookmark url [title ""] [subscribe #f] [favourite #f] [side-links #f] [last-checksum 0] [tags '()] [notes ""])
+ (bookmark url title subscribe favourite side-links last-checksum tags notes))
+
+ (define (add-bookmark b)
+ (let ([bs (bookmarks)])
+ (hash-set! bs (bookmark-url b) b)
+ (save-bookmarks)))
+
+ (define (save-bookmarks)
+ (let ([s (serialize (bookmarks))])
+ (with-output-to-file bookmarks-file
+ (lambda () (write s))
+ #:exists 'replace)))
+
+ (define (load-bookmarks)
+ (let ([bs (if (file-exists? bookmarks-file)
+ (with-input-from-file bookmarks-file
+ (lambda () (deserialize (read))))
+ (make-hash))])
+ (bookmarks bs)
+ (bookmarks)))
+
+ (define (side-load? url)
+ (let* ([bs (load-bookmarks)]
+ [b (hash-ref bs url (bookmark #f #f #f #f #f #f #f #f))])
+ (bookmark-side-links b)))
+
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; MAIN (just help testing stuff)
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(module+ main
- (displayln data-folder)
- (displayln preferences-file)
- (load-bookmarks))
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;;; MAIN (just help testing stuff)
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ (module+ main
+ (displayln data-folder)
+ (displayln preferences-file)
+ (load-bookmarks))
+ <
\ No newline at end of file