joachifm / cl-webkit

A binding to WebKitGTK+ for Common Lisp
MIT License
53 stars 16 forks source link

Add webkit-web-view-evaluate-javascript-from-gresource. #49

Closed aartaka closed 3 years ago

aartaka commented 3 years ago

This adds webkit-web-view-evaluate-javascript-from-gresource -- a convenience function akin to webkit-web-view-evaluate-javascript, yet with loading from gresource.

Applications

Caveats

How Has This Been Tested

EDIT: Battle-tested.

Ambrevar commented 3 years ago
(merge-pathnames (pathname (str:concat (pathname-name pathname) ".gresource.xml"))
                                       (uiop:pathname-directory-pathname pathname))

Why not just

(pathname (str:concat (namestring pathname) ".gresource.xml"))

?

Ambrevar commented 3 years ago

This

(str:concat ,(pathname-name pathname)
                                                                 "."
                                                                 ,(pathname-type pathname))

yields the wrong thing when the pathname does not have an extension.

Flet this instead:

(defun file-basename (file)
  "Return the file basename (including the extension)."
  (apply #'str:concat (pathname-name file)
         (sera:and-let* ((ext (file-extension file)))
           `("." ,ext))))
Ambrevar commented 3 years ago

uiop:native-namestring errors out on wildcards. Use uiop:parse-native-namestring instead.

Ambrevar commented 3 years ago

Thank you for this feature! Please fix the docstring and I'll merge :)

aartaka commented 3 years ago

Done. Docstring of webkit-web-view-evaluate-javascript is fixed too (is upcase JAVASCRIPT okay if it's argument name?)

Ambrevar commented 3 years ago

Thanks!