Skip to content

Instantly share code, notes, and snippets.

@luboszima
Created July 13, 2025 17:33
Show Gist options
  • Save luboszima/0a55806ee45011bd7686662b9f2fdcd1 to your computer and use it in GitHub Desktop.
Save luboszima/0a55806ee45011bd7686662b9f2fdcd1 to your computer and use it in GitHub Desktop.
glance wiget for Github Notifications
- type: custom-api
title: GitHub Notifications
url: https://api.github.com/notifications?all=true&per_page=20
headers:
Authorization: Bearer ${GITHUB_TOKEN}
Accept: application/vnd.github+json
template: |
<ul class="list list-gap-14 collapsible-container" data-collapse-after="6">
{{ range .JSON.Array "" }}
{{ if (.String "subject.url") }}
{{
$notification := newRequest (.String "subject.url")
| withHeader "Authorization" "Bearer ${GITHUB_TOKEN}"
| getResponse
}}
<li>
<a href="{{ $notification.JSON.String "html_url" }}" class="size-title-dynamic color-primary-if-not-visited" target="_blank" rel="noreferrer">{{ .String "subject.title" }}</a>
<ul class="list-horizontal-text flex-nowrap">
<li class="min-width-0" {{ .String "updated_at" | parseTime "rfc3339" | toRelativeTime }}></li>
<li class="min-width-0"><a target="_blank" href="https://github.com/{{ .String "repository.full_name" }}">{{ .String "repository.full_name" }}</a></li>
</ul>
</li>
{{ end }}
{{ end }}
</ul>
@luboszima
Copy link
Author

luboszima commented Jul 13, 2025

  1. create classic token with Notifications permission (read only): https://github.com/settings/tokens
  2. in your glance app setup new env variable (possibly in docker-compose.yml): GITHUB_TOKEN value will be your token
  3. Add to your glance dashboard yml definition custom-api from this gist.

This widget is created to be part of small column.

- name: Home
  columns:
    - size: small
      widgets:
        - type: custom-api
          title: GitHub Notifications
          url: https://api.github.com/notifications?all=true&per_page=20
          headers:
            Authorization: Bearer ${GITHUB_TOKEN}
            Accept: application/vnd.github+json
          template: |
            <ul class="list list-gap-14 collapsible-container" data-collapse-after="6">
            {{ range .JSON.Array "" }}
              {{ if (.String "subject.url") }}
                {{
                  $notification := newRequest (.String "subject.url")
                    | withHeader "Authorization" "Bearer ${GITHUB_TOKEN}"
                    | getResponse
                }}
            
              <li>
                <a href="{{ $notification.JSON.String "html_url" }}" class="size-title-dynamic color-primary-if-not-visited" target="_blank" rel="noreferrer">{{ .String "subject.title" }}</a>
                <ul class="list-horizontal-text flex-nowrap">
                  <li class="min-width-0" {{ .String "updated_at" | parseTime "rfc3339" | toRelativeTime }}></li>
                  <li class="min-width-0"><a target="_blank" href="https://github.com/{{ .String "repository.full_name" }}">{{ .String "repository.full_name" }}</a></li>
                </ul>
              </li>
              {{ end }}
            {{ end }}
            </ul>
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment