Closed aartaka closed 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"))
?
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))))
uiop:native-namestring
errors out on wildcards. Use uiop:parse-native-namestring
instead.
Thank you for this feature! Please fix the docstring and I'll merge :)
Done. Docstring of webkit-web-view-evaluate-javascript
is fixed too (is upcase JAVASCRIPT
okay if it's argument name?)
Thanks!
This adds
webkit-web-view-evaluate-javascript-from-gresource
-- a convenience function akin towebkit-web-view-evaluate-javascript
, yet with loading fromgresource
.Applications
readability-mode
for Nyxt similar to Reader View of Epiphany. They usegresource
to load third party library (namely Mozilla's Readability.js). That's for a reason -- plain JavaScript evaluation errors out because of complex object interrelation in the library. So, to implementreadability-mode
, I need to have JavaScript evaluation fromgresource
ffi-buffer-load-javascript-from-file
-- a general-purpose library-loading function that can be useful (e.g. https://github.com/atlas-engineer/nyxt/issues/213), especially for third-party extensions. Draft implementation is:And most of the code is XML generation for
gresource
xDCaveats
webkit-web-view-run-javascript-finish
is used to get results of evaluation fromgresource
. Epiphany people do that, so it shouldn't be dangerous. However, usingwebkit-web-view-run-javascript-from-gresource-finish
can be cleaner and more consistent. Is it worth duplicatingjavascript-evaluation-complete
callback with just one line altered?How Has This Been Tested
cl-webkit
compiles with no warnings on this patch.javascript-evaluation-complete
, so it shouldn't break terribly.EDIT: Battle-tested.