all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Browsing Github using eww
@ 2024-07-27 12:12 James Thomas
  2024-07-27 19:41 ` tpeplt
  0 siblings, 1 reply; 5+ messages in thread
From: James Thomas @ 2024-07-27 12:12 UTC (permalink / raw)
  To: help-gnu-emacs

I had, by now, accumulated the following hacks:

--8<---------------cut here---------------start------------->8---
;; For eww-url-transformers
(defun eww-redirect-github (url)
    "Redirect github.com automatically."
    (replace-regexp-in-string "^https://\\(github.com/\\(.*?\\)/blob\\)/.*" "raw.githubusercontent.com/\\2" url t nil 1))

;; For file list being hidden.
(defun my/eww-tag-script (dom)
    (when-let ((url (eww-current-url))
	       (_ (string-prefix-p "https://github.com/" url))
	       (_ (string= "application/json" (dom-attr dom 'type)))
	       (_ (string= "react-app.embeddedData" (dom-attr dom 'data-target)))
	       (start (point)))
      (seq-map (lambda (i)
		 (shr-ensure-newline)
		 (shr-tag-a
		  (dom-node
		   'a
		   (list
		    (cons
		     'href
		     (replace-regexp-in-string
		      "https://github.com/[a-zA-Z0-9-_.]+/[a-zA-Z0-9-_.]+/tree/[a-zA-Z0-9-_.]+/\\(.+\\)"
		      (gethash "path" i) url t t 1)))
		   (gethash "name" i))))
	       (gethash
		"items"
		(gethash
		 "tree"
		 (gethash
		  "payload"
		  (json-parse-string (car (dom-children dom)))))))
      ;; (put-text-property start (point) 'face 'shr-code)
      ))

(setq shr-external-rendering-functions '((script . my/eww-tag-script)))
--8<---------------cut here---------------end--------------->8---

...for this, but I've realized that the latter, for e.g. may not be
necessary: refreshing the page 3-4 times gets a version with the files
list shown.

So I was wondering if someone out there has something better (simpler,
cheaper, more reliable) to share. Or know of anyone maybe compiling any
such workarounds - for others like Gitlab as well?

Regards,
James



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-02 21:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-27 12:12 Browsing Github using eww James Thomas
2024-07-27 19:41 ` tpeplt
2024-07-27 22:15   ` James Thomas
2024-08-02 19:32     ` Björn Bidar
     [not found]     ` <87msluoh4y.fsf@>
2024-08-02 21:52       ` James Thomas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.