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

* Re: Browsing Github using eww
  2024-07-27 12:12 Browsing Github using eww James Thomas
@ 2024-07-27 19:41 ` tpeplt
  2024-07-27 22:15   ` James Thomas
  0 siblings, 1 reply; 5+ messages in thread
From: tpeplt @ 2024-07-27 19:41 UTC (permalink / raw)
  To: James Thomas; +Cc: help-gnu-emacs

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.  Between the built-in packages, those
   provided at the GNU repository, and those provided at the
   ‘melpa-stable’ archive, there are over 3000 packages.  You could
   search for "github" among that set to find a number of packages
   related to Github.

   Unfortunately, the descriptions provided with many packages are too
   brief (or non-existent) to decide whether a given package will do
   what you want, but you could try installing a package, reading its
   documentation, if any, or its code, if there is none.  If you then
   find it unsuitable, use ‘list-packages’ a second time to uninstall
   the package.

   To browse both the GNU and ‘melpa-stable’ archives, you need to set
   the Emacs option ‘package-archives’ to include both:

   http://stable.melpa.org/packages/ and https://elpa.gnu.org/packages/

   M-x customize-option RET

   Then respond to the "Customize variable: " prompt with
   ‘package-archives’ (no quotes).  Enter the two URLs above and click
   on ‘Apply’ or ‘Apply and Save’.

2. If that does not provide a solution, you could provide an English
   description of features that you would like to have when using ‘eww’
   with Github.  Then some reader(s) might suggest possible solutions.

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.



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

* Re: Browsing Github using eww
  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@>
  0 siblings, 2 replies; 5+ messages in thread
From: James Thomas @ 2024-07-27 22:15 UTC (permalink / raw)
  To: help-gnu-emacs

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.

> 2. If that does not provide a solution, you could provide an English
>    description of features that you would like to have when using ‘eww’
>    with Github.  Then some reader(s) might suggest possible solutions.

Well, the only one 'missing' for the time being would be the codebase
search results (that 'github-explorer' of the above for e.g. seems to
provide). Let me see if I can whip something up myself... if noone has
anything already.

Regards,
James



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

* Re: Browsing Github using eww
  2024-07-27 22:15   ` James Thomas
@ 2024-08-02 19:32     ` Björn Bidar
       [not found]     ` <87msluoh4y.fsf@>
  1 sibling, 0 replies; 5+ messages in thread
From: Björn Bidar @ 2024-08-02 19:32 UTC (permalink / raw)
  To: James Thomas; +Cc: help-gnu-emacs

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.



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

* Re: Browsing Github using eww
       [not found]     ` <87msluoh4y.fsf@>
@ 2024-08-02 21:52       ` James Thomas
  0 siblings, 0 replies; 5+ messages in thread
From: James Thomas @ 2024-08-02 21:52 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ 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.