Skip to content

Commit

Permalink
Fix reviews not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceWarne committed Aug 17, 2024
1 parent 06727cb commit 33d29ea
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
32 changes: 26 additions & 6 deletions finito-buffer.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@
"Face for book descriptions."
:group 'finito)

(defface finito-book-reviews
'((t :foreground "grey"
:inherit default))
"Face for book reviews."
:group 'finito)

(defface finito-book-review-header
'((t :foreground "grey"
:weight bold
:underline t
:inherit default))
"Face for book review headers."
:group 'finito)

(defface finito-rating
'((t :foreground "gold"
:weight bold))
Expand Down Expand Up @@ -183,7 +197,7 @@ Its nodes should be alists of the form returned by

(defclass finito-book-writer ()
((insert-order :initarg :books-offset
:initform '(title image author rating started-reading last-read description)
:initform '(title image author rating started-reading last-read description review)
:type list
:custom '(repeat symbol)
:documentation "The order of which to insert books attributes"))
Expand All @@ -209,7 +223,7 @@ BOOK-ALIST is an alist of the format returned by `finito--create-book-alist'"
((eq it 'last-read) (when .last-read
(finito-insert-last-read writer .last-read)))
((eq it 'description) (finito-insert-description writer .description))
((eq it 'review) (finito-insert-description writer .review))))))
((eq it 'review) (finito-insert-review writer .review))))))

(cl-defmethod finito-insert-title ((_ finito-book-writer) title)
"Insert TITLE into the current buffer."
Expand Down Expand Up @@ -278,10 +292,16 @@ BOOK-ALIST is an alist of the format returned by `finito--create-book-alist'"
nil
'equal))
(bound-and-true-p finito--show-reviews))
(insert review "\n")
(overlay-put (make-overlay (- (point) 2) (- (point) (length review) 2))
'face
'finito-book-reviews)))
(when review
(let ((review-header "Review:"))
(insert review-header)
(overlay-put (make-overlay (point) (- (point) (length review-header)))
'face
'finito-book-review-header)
(insert " " review "\n")
(overlay-put (make-overlay (- (point) 1) (- (point) (length review) 1))
'face
'finito-book-reviews)))))

(cl-defmethod finito-use-pagination ((_ finito-book-writer))
"Return non-nil if pagination should be used alongside this writer."
Expand Down
16 changes: 8 additions & 8 deletions finito-graphql.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
(maxResults . ($ maxResults))
(langRestrict . ($ langRestrict)))
title authors description isbn thumbnailUri
rating startedReading lastRead))))
rating review startedReading lastRead))))

;; We don't add quotes around %s since null is a value that could potentially
;; be used, and we shouldn't quote that
Expand All @@ -63,7 +63,7 @@
(book
:arguments ((isbn . ($ isbn)))
title authors description isbn thumbnailUri
rating startedReading lastRead))))
rating review startedReading lastRead))))

(defconst finito--isbn-query-variables "{\"isbn\": \"%s\"}")

Expand All @@ -76,7 +76,7 @@
:arguments ((name . ($ name))
(booksPagination . ($ booksPagination)))
(books title authors description isbn thumbnailUri
rating startedReading lastRead)
rating review startedReading lastRead)
(pageInfo totalBooks)))))

(defconst finito--collection-query-variables
Expand Down Expand Up @@ -174,7 +174,7 @@
:arguments ((rating . ($ rating))
(book . ($ book)))
title authors description isbn thumbnailUri
rating startedReading lastRead))))
rating review startedReading lastRead))))

(defconst finito--rate-book-mutation-variables
"{
Expand All @@ -197,7 +197,7 @@
:arguments ((review . ($ review))
(book . ($ book)))
title authors description isbn thumbnailUri
review startedReading lastRead))))
rating review startedReading lastRead))))

(defconst finito--review-book-mutation-variables
"{
Expand All @@ -220,7 +220,7 @@
:arguments ((date . ($ date))
(book . ($ book)))
title authors description isbn thumbnailUri
rating startedReading lastRead))))
rating review startedReading lastRead))))

(defconst finito--start-reading-mutation-variables
"{
Expand All @@ -243,7 +243,7 @@
:arguments ((date . ($ date))
(book . ($ book)))
title authors description isbn thumbnailUri
rating startedReading lastRead))))
rating review startedReading lastRead))))

(defconst finito--finish-reading-mutation-variables
"{
Expand Down Expand Up @@ -292,7 +292,7 @@
(series
:arguments ((book . ($ book)))
title authors description isbn thumbnailUri
rating startedReading lastRead))))
rating review startedReading lastRead))))

(defconst finito--series-query-variables
"{
Expand Down
2 changes: 2 additions & 0 deletions finito.el
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ isbn
img-uri
image-file-name
rating
review
started-reading
last-read"
(let-alist book-response
Expand All @@ -302,6 +303,7 @@ last-read"
(cons 'img-uri .thumbnailUri)
(cons 'image-file-name image-file-name)
(cons 'rating .rating)
(cons 'review .review)
(cons 'started-reading .startedReading)
(cons 'last-read .lastRead)))))

Expand Down

0 comments on commit 33d29ea

Please sign in to comment.