[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Housewarming present for github site



Attached is a small filter that I have been using for a while now when
browsing github repository home-pages. It was written only for the home
page of github repositories with the goal of giving a cleaner display
without losing a lot of major links.

As usual, you can toggle filtering using `f', and toggle a specific
filter using `C-u f'

Enjoy.

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
; ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
; ┃ github repository main page filter                         ┃
; ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
(defun w3m-filter-github-repo-main-page (url)
  "filter distractions for the main page of a github repository."
  (w3m-filter-delete-regions url
    "<div class=\"d-flex" "</header>" nil t nil nil nil 1)
  (w3m-filter-delete-regions url
    "<div class=\"signup-prompt-bg" "<div class=\"f4\">" nil t nil nil nil 1)
  (insert "<hr>")
  ; NOTE: There is inconsistency in some pages. Some have DIV element
  ;       'repository-topics-container', while others have 'overall-summary'.
  (w3m-filter-delete-regions url
    "<div class=\"repository-topics-container" "<div class=\"commit-tease" nil t nil nil nil 1)
  (w3m-filter-delete-regions url
    "<div class=\"overall-summary" "<div class=\"commit-tease" nil t nil nil nil 1)
  (w3m-filter-delete-regions url
    "<div class=\"footer container-lg" "</body>" nil t nil nil nil 1)
  (goto-char (point-min))
  (search-forward "<div class=\"commit-tease" nil t)
  (goto-char (match-beginning 0))
  (insert "<hr>")
  (search-forward "<div class=\"file-wrap\">" nil t)
  (goto-char (match-beginning 0))
  (insert "<hr>")
  (search-forward "</table>" nil t)
  (insert "<hr>")
  )

  (add-to-list 'w3m-filter-configuration
    '(t "filter for github.com repository main page"
        "\\`http[s]?://github\\.com/[^/]+/[^/]+[/]?$"
      w3m-filter-github-repo-main-page))