From: James Thomas <jimjoe@gmx.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Browsing Github using eww
Date: Sat, 03 Aug 2024 03:22:54 +0530 [thread overview]
Message-ID: <865xsiy4ll.fsf@gmx.net> (raw)
In-Reply-To: <87msluoh4y.fsf@> ("Björn Bidar"'s message of "Fri, 02 Aug 2024 22:32:13 +0300")
Björn Bidar wrote:
> James Thomas <jimjoe@gmx.net> writes:
>
>> tpeplt wrote:
>>
>>> James Thomas <jimjoe@gmx.net> writes:
>>>
>>>> I had, by now, accumulated the following hacks:
>>>>
>>>> ...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?
>>>>
>>>
>>> 1. This is not a direct answer to your question, but you might try looking
>>> through the Emacs Lisp packages that you can install via the
>>> ‘list-packages’ command.
>>
>> I see that all of them use either the gh cli or an API token. Thank you
>> for the suggestion, but my current setup seems simpler for now.
>
> Did you try Epkg? It uses Emacsmirror tracks packages from multiple
> sources for packages including those on Github.
>
> It does only require SQLite support either using the builtin support or
> the one provided by EmacsSQL.
I see that, but I think you misunderstand me: I was talking about
github.com itself not being easily accessible for browsing, even for
repos not related to Emacs.
Anyway I'm using my 'cleaned-up' hacks for the time being, which works
well enough (for now):
--8<---------------cut here---------------start------------->8---
;; Add this to the end of 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))
(defun shr-tag-script (dom)
(condition-case nil
(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)))))))
)
(wrong-type-argument nil)))
--8<---------------cut here---------------end--------------->8---
Adapting the code 'search results' page is one thing left to do...
Regards,
James
prev parent reply other threads:[~2024-08-02 21:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=865xsiy4ll.fsf@gmx.net \
--to=jimjoe@gmx.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.