Compare commits

...
17 Commits
Author SHA1 Message Date
Svilen Markov 24f93d8258 Merge pull request #275 from glanceapp/release/v0.6.3
Create release / release (push) Has been cancelled
Release/v0.6.3
2024-12-11 18:56:48 +00:00
Svilen Markov 01016e08d2 Merge branch 'main' into release/v0.6.3 2024-12-11 18:53:40 +00:00
Svilen Markov 949fde1517 Fix edge case in weather widget graph 2024-12-11 18:50:34 +00:00
Svilen Markov 804cf9916b Change simple icons provider and always use latest version 2024-12-11 18:47:30 +00:00
Svilen Markov ef24680baf Fix overlap issues in weather and dns-stats widgets 2024-12-11 18:38:09 +00:00
Svilen Markov 448c795982 Properly close code block in docs 2024-12-07 16:47:58 +00:00
Svilen Markov ee1d7599d5 Add note to preconfigured pages doc 2024-12-07 09:28:36 +00:00
Svilen Markov d90d39933a Merge pull request #228 from Dakhtara/patch-1
Fix typo on configuration for search autofocus property description
2024-10-01 15:28:42 +01:00
Anthony 7e38ab624a Update configuration.md 2024-10-01 08:59:11 +02:00
Svilen Markov 9a36187333 Add /api/healthz endpoint
Create release / release (push) Has been cancelled
2024-09-30 00:42:19 +01:00
Svilen Markov b0c4d70628 Fix bug with collapsible grids inside of group widget
Also move utils to new file
2024-09-30 00:42:19 +01:00
Svilen Markov d5fa6424c1 Fix bookmark icons shrinking when text wraps 2024-09-30 00:42:19 +01:00
Svilen Markov 07fe5b3cb1 Merge pull request #224 from SimJunYou/piholePrivacy
DNS Stats widget - fix Pihole privacy edge case
2024-09-30 00:31:00 +01:00
Svilen Markov 672547cd07 Switch to using custom type for pihole's top blocked domains 2024-09-30 00:24:44 +01:00
SimJunYou 28167403a4 Cover edge case when Pihole's privacy settings are enabled 2024-09-19 17:43:43 +08:00
Svilen Markov eaf08d42dd Merge pull request #220 from paricbat/main
Add important details about the server.base-url property
2024-09-16 08:35:33 +01:00
Veronika Bušová bae95a5e07 Add important details about the server.base-url property 2024-09-15 00:29:46 +02:00
9 changed files with 90 additions and 42 deletions
+6 -1
View File
@@ -138,6 +138,10 @@ A number between 1 and 65,535, so long as that port isn't already used by anythi
#### `base-url` #### `base-url`
The base URL that Glance is hosted under. No need to specify this unless you're using a reverse proxy and are hosting Glance under a directory. If that's the case then you can set this value to `/glance` or whatever the directory is called. Note that the forward slash (`/`) in the beginning is required unless you specify the full domain and path. The base URL that Glance is hosted under. No need to specify this unless you're using a reverse proxy and are hosting Glance under a directory. If that's the case then you can set this value to `/glance` or whatever the directory is called. Note that the forward slash (`/`) in the beginning is required unless you specify the full domain and path.
> [!IMPORTANT]
> You need to strip the `base-url` prefix before forwarding the request to the Glance server.
> In Caddy you can do this using [`handle_path`](https://caddyserver.com/docs/caddyfile/directives/handle_path) or [`uri strip_prefix`](https://caddyserver.com/docs/caddyfile/directives/uri).
#### `assets-path` #### `assets-path`
The path to a directory that will be served by the server under the `/assets/` path. This is handy for widgets like the Monitor where you have to specify an icon URL and you want to self host all the icons rather than pointing to an external source. The path to a directory that will be served by the server under the `/assets/` path. This is handy for widgets like the Monitor where you have to specify an icon URL and you want to self host all the icons rather than pointing to an external source.
@@ -277,6 +281,7 @@ theme:
> .widget-type-rss a { > .widget-type-rss a {
> font-size: 1.5rem; > font-size: 1.5rem;
> } > }
> ```
> >
> In addition, you can also use the `css-class` property which is available on every widget to set custom class names for individual widgets. > In addition, you can also use the `css-class` property which is available on every widget to set custom class names for individual widgets.
@@ -848,7 +853,7 @@ Either a value from the table below or a URL to a custom search engine. Use `{QU
##### `new-tab` ##### `new-tab`
When set to `true`, swaps the shortcuts for showing results in the same or new tab, defaulting to showing results in a new tab. When set to `true`, swaps the shortcuts for showing results in the same or new tab, defaulting to showing results in a new tab.
##### `new-tab` ##### `autofocus`
When set to `true`, automatically focuses the search input on page load. When set to `true`, automatically focuses the search input on page load.
##### `bangs` ##### `bangs`
+4
View File
@@ -4,6 +4,10 @@ Don't want to spend time configuring pages from scratch? No problem! Simply copy
Pull requests with your page configurations are welcome! Pull requests with your page configurations are welcome!
> [!NOTE]
>
> Pages must be placed under a top level `pages:` key, you can read more about that [here](configuration.md#pages).
## Startpage ## Startpage
![](images/startpage-preview.png) ![](images/startpage-preview.png)
+8 -29
View File
@@ -1,27 +1,5 @@
import { setupPopovers } from './popover.js'; import { setupPopovers } from './popover.js';
import { throttledDebounce, isElementVisible } from './utils.js';
function throttledDebounce(callback, maxDebounceTimes, debounceDelay) {
let debounceTimeout;
let timesDebounced = 0;
return function () {
if (timesDebounced == maxDebounceTimes) {
clearTimeout(debounceTimeout);
timesDebounced = 0;
callback();
return;
}
clearTimeout(debounceTimeout);
timesDebounced++;
debounceTimeout = setTimeout(() => {
timesDebounced = 0;
callback();
}, debounceDelay);
};
};
async function fetchPageContent(pageData) { async function fetchPageContent(pageData) {
// TODO: handle non 200 status codes/time outs // TODO: handle non 200 status codes/time outs
@@ -427,7 +405,7 @@ function setupCollapsibleGrids() {
const button = attachExpandToggleButton(gridElement); const button = attachExpandToggleButton(gridElement);
let cardsPerRow = 2; let cardsPerRow;
const resolveCollapsibleItems = () => { const resolveCollapsibleItems = () => {
const hideItemsAfterIndex = cardsPerRow * collapseAfterRows; const hideItemsAfterIndex = cardsPerRow * collapseAfterRows;
@@ -457,12 +435,11 @@ function setupCollapsibleGrids() {
} }
}; };
afterContentReady(() => { const observer = new ResizeObserver(() => {
cardsPerRow = getCardsPerRow(); if (!isElementVisible(gridElement)) {
resolveCollapsibleItems(); return;
}); }
window.addEventListener("resize", () => {
const newCardsPerRow = getCardsPerRow(); const newCardsPerRow = getCardsPerRow();
if (cardsPerRow == newCardsPerRow) { if (cardsPerRow == newCardsPerRow) {
@@ -472,6 +449,8 @@ function setupCollapsibleGrids() {
cardsPerRow = newCardsPerRow; cardsPerRow = newCardsPerRow;
resolveCollapsibleItems(); resolveCollapsibleItems();
}); });
afterContentReady(() => observer.observe(gridElement));
} }
} }
+25
View File
@@ -0,0 +1,25 @@
export function throttledDebounce(callback, maxDebounceTimes, debounceDelay) {
let debounceTimeout;
let timesDebounced = 0;
return function () {
if (timesDebounced == maxDebounceTimes) {
clearTimeout(debounceTimeout);
timesDebounced = 0;
callback();
return;
}
clearTimeout(debounceTimeout);
timesDebounced++;
debounceTimeout = setTimeout(() => {
timesDebounced = 0;
callback();
}, debounceDelay);
};
};
export function isElementVisible(element) {
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
}
+7 -3
View File
@@ -514,6 +514,7 @@ kbd:active {
list-style: none; list-style: none;
position: relative; position: relative;
display: flex; display: flex;
z-index: 1;
} }
.details[open] .summary { .details[open] .summary {
@@ -535,6 +536,10 @@ kbd:active {
opacity: 1; opacity: 1;
} }
.details:not([open]) .list-with-transition {
display: none;
}
.summary::after { .summary::after {
content: "◀"; content: "◀";
font-size: 1.2em; font-size: 1.2em;
@@ -707,6 +712,7 @@ details[open] .summary::after {
justify-content: space-between; justify-content: space-between;
position: relative; position: relative;
margin-bottom: 1.8rem; margin-bottom: 1.8rem;
z-index: 1;
} }
.widget-error-header::before { .widget-error-header::before {
@@ -1050,6 +1056,7 @@ details[open] .summary::after {
border-radius: var(--border-radius); border-radius: var(--border-radius);
padding: 0.5rem; padding: 0.5rem;
opacity: 0.7; opacity: 0.7;
flex-shrink: 0;
} }
.bookmarks-icon { .bookmarks-icon {
@@ -1094,7 +1101,6 @@ details[open] .summary::after {
.dns-stats-graph-gridlines-container { .dns-stats-graph-gridlines-container {
position: absolute; position: absolute;
z-index: -1;
inset: 0; inset: 0;
} }
@@ -1121,7 +1127,6 @@ details[open] .summary::after {
content: ''; content: '';
position: absolute; position: absolute;
inset: 1px 0; inset: 1px 0;
z-index: -1;
opacity: 0; opacity: 0;
background: var(--color-text-base); background: var(--color-text-base);
transition: opacity .2s; transition: opacity .2s;
@@ -1263,7 +1268,6 @@ details[open] .summary::after {
overflow: hidden; overflow: hidden;
mask-image: linear-gradient(0deg, transparent 40%, #000); mask-image: linear-gradient(0deg, transparent 40%, #000);
-webkit-mask-image: linear-gradient(0deg, transparent 40%, #000); -webkit-mask-image: linear-gradient(0deg, transparent 40%, #000);
z-index: -1;
} }
.weather-column-rain::before { .weather-column-rain::before {
+8 -1
View File
@@ -189,12 +189,19 @@ func FetchWeatherForPlace(place *PlaceJson, units string) (*Weather, error) {
minT := slices.Min(temperatures) minT := slices.Min(temperatures)
maxT := slices.Max(temperatures) maxT := slices.Max(temperatures)
temperaturesRange := float64(maxT - minT)
for i := 0; i < 12; i++ { for i := 0; i < 12; i++ {
bars = append(bars, weatherColumn{ bars = append(bars, weatherColumn{
Temperature: temperatures[i], Temperature: temperatures[i],
Scale: float64(temperatures[i]-minT) / float64(maxT-minT),
HasPrecipitation: precipitations[i], HasPrecipitation: precipitations[i],
}) })
if temperaturesRange > 0 {
bars[i].Scale = float64(temperatures[i]-minT) / temperaturesRange
} else {
bars[i].Scale = 1
}
} }
} }
+28 -7
View File
@@ -1,6 +1,7 @@
package feed package feed
import ( import (
"encoding/json"
"errors" "errors"
"log/slog" "log/slog"
"net/http" "net/http"
@@ -9,13 +10,33 @@ import (
) )
type piholeStatsResponse struct { type piholeStatsResponse struct {
TotalQueries int `json:"dns_queries_today"` TotalQueries int `json:"dns_queries_today"`
QueriesSeries map[int64]int `json:"domains_over_time"` QueriesSeries map[int64]int `json:"domains_over_time"`
BlockedQueries int `json:"ads_blocked_today"` BlockedQueries int `json:"ads_blocked_today"`
BlockedSeries map[int64]int `json:"ads_over_time"` BlockedSeries map[int64]int `json:"ads_over_time"`
BlockedPercentage float64 `json:"ads_percentage_today"` BlockedPercentage float64 `json:"ads_percentage_today"`
TopBlockedDomains map[string]int `json:"top_ads"` TopBlockedDomains piholeTopBlockedDomains `json:"top_ads"`
DomainsBlocked int `json:"domains_being_blocked"` DomainsBlocked int `json:"domains_being_blocked"`
}
// If user has some level of privacy enabled on Pihole, `json:"top_ads"` is an empty array
// Use custom unmarshal behavior to avoid not getting the rest of the valid data when unmarshalling
type piholeTopBlockedDomains map[string]int
func (p *piholeTopBlockedDomains) UnmarshalJSON(data []byte) error {
// NOTE: do not change to piholeTopBlockedDomains type here or it will cause a stack overflow
// because of the UnmarshalJSON method getting called recursively
temp := make(map[string]int)
err := json.Unmarshal(data, &temp)
if err != nil {
*p = make(piholeTopBlockedDomains)
} else {
*p = temp
}
return nil
} }
func FetchPiholeStats(instanceURL, token string) (*DNSStats, error) { func FetchPiholeStats(instanceURL, token string) (*DNSStats, error) {
+3
View File
@@ -275,6 +275,9 @@ func (a *Application) Serve() error {
mux.HandleFunc("GET /api/pages/{page}/content/{$}", a.HandlePageContentRequest) mux.HandleFunc("GET /api/pages/{page}/content/{$}", a.HandlePageContentRequest)
mux.HandleFunc("/api/widgets/{widget}/{path...}", a.HandleWidgetRequest) mux.HandleFunc("/api/widgets/{widget}/{path...}", a.HandleWidgetRequest)
mux.HandleFunc("GET /api/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
})
mux.Handle( mux.Handle(
fmt.Sprintf("GET /static/%s/{path...}", a.Config.Server.AssetsHash), fmt.Sprintf("GET /static/%s/{path...}", a.Config.Server.AssetsHash),
+1 -1
View File
@@ -162,7 +162,7 @@ func toSimpleIconIfPrefixed(icon string) (string, bool) {
} }
icon = strings.TrimPrefix(icon, "si:") icon = strings.TrimPrefix(icon, "si:")
icon = "https://cdnjs.cloudflare.com/ajax/libs/simple-icons/11.14.0/" + icon + ".svg" icon = "https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/" + icon + ".svg"
return icon, true return icon, true
} }