mirror of
https://github.com/Xevion/glance.git
synced 2025-12-15 02:11:55 -06:00
Merge branch 'main' into dev
This commit is contained in:
@@ -136,7 +136,7 @@ func cliMountpointInfo(requestedPath string) int {
|
||||
|
||||
fmt.Println("Path:", usage.Path)
|
||||
fmt.Println("FS type:", ternary(usage.Fstype == "", "unknown", usage.Fstype))
|
||||
fmt.Printf("Used percent: %.1f%%", usage.UsedPercent)
|
||||
fmt.Printf("Used percent: %.1f%%\n", usage.UsedPercent)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ function setupSearchBoxes() {
|
||||
for (let i = 0; i < searchWidgets.length; i++) {
|
||||
const widget = searchWidgets[i];
|
||||
const defaultSearchUrl = widget.dataset.defaultSearchUrl;
|
||||
const target = widget.dataset.target || "_blank";
|
||||
const newTab = widget.dataset.newTab === "true";
|
||||
const inputElement = widget.getElementsByClassName("search-input")[0];
|
||||
const bangElement = widget.getElementsByClassName("search-bang")[0];
|
||||
@@ -143,7 +144,7 @@ function setupSearchBoxes() {
|
||||
const url = searchUrlTemplate.replace("!QUERY!", encodeURIComponent(query));
|
||||
|
||||
if (newTab && !event.ctrlKey || !newTab && event.ctrlKey) {
|
||||
window.open(url, '_blank').focus();
|
||||
window.open(url, target).focus();
|
||||
} else {
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{{ define "widget-content-classes" }}widget-content-frameless{{ end }}
|
||||
|
||||
{{ define "widget-content" }}
|
||||
<div class="search widget-content-frame padding-inline-widget flex gap-15 items-center" data-default-search-url="{{ .SearchEngine }}" data-new-tab="{{ .NewTab }}">
|
||||
<div class="search widget-content-frame padding-inline-widget flex gap-15 items-center" data-default-search-url="{{ .SearchEngine }}" data-new-tab="{{ .NewTab }}" data-target="{{ .Target }}">
|
||||
<div class="search-bangs">
|
||||
{{ range .Bangs }}
|
||||
<input type="hidden" data-shortcut="{{ .Shortcut }}" data-title="{{ .Title }}" data-url="{{ .URL }}">
|
||||
|
||||
@@ -454,11 +454,16 @@ var customAPITemplateFuncs = func() template.FuncMap {
|
||||
|
||||
return d
|
||||
},
|
||||
"parseTime": customAPIFuncParseTime,
|
||||
"parseTime": func(layout, value string) time.Time {
|
||||
return customAPIFuncParseTimeInLocation(layout, value, time.UTC)
|
||||
},
|
||||
"parseLocalTime": func(layout, value string) time.Time {
|
||||
return customAPIFuncParseTimeInLocation(layout, value, time.Local)
|
||||
},
|
||||
"toRelativeTime": dynamicRelativeTimeAttrs,
|
||||
"parseRelativeTime": func(layout, value string) template.HTMLAttr {
|
||||
// Shorthand to do both of the above with a single function call
|
||||
return dynamicRelativeTimeAttrs(customAPIFuncParseTime(layout, value))
|
||||
return dynamicRelativeTimeAttrs(customAPIFuncParseTimeInLocation(layout, value, time.UTC))
|
||||
},
|
||||
// The reason we flip the parameter order is so that you can chain multiple calls together like this:
|
||||
// {{ .JSON.String "foo" | trimPrefix "bar" | doSomethingElse }}
|
||||
@@ -532,8 +537,8 @@ var customAPITemplateFuncs = func() template.FuncMap {
|
||||
},
|
||||
"sortByTime": func(key, layout, order string, results []decoratedGJSONResult) []decoratedGJSONResult {
|
||||
sort.Slice(results, func(a, b int) bool {
|
||||
timeA := customAPIFuncParseTime(layout, results[a].String(key))
|
||||
timeB := customAPIFuncParseTime(layout, results[b].String(key))
|
||||
timeA := customAPIFuncParseTimeInLocation(layout, results[a].String(key), time.UTC)
|
||||
timeB := customAPIFuncParseTimeInLocation(layout, results[b].String(key), time.UTC)
|
||||
|
||||
if order == "asc" {
|
||||
return timeA.Before(timeB)
|
||||
@@ -570,7 +575,7 @@ var customAPITemplateFuncs = func() template.FuncMap {
|
||||
return funcs
|
||||
}()
|
||||
|
||||
func customAPIFuncParseTime(layout, value string) time.Time {
|
||||
func customAPIFuncParseTimeInLocation(layout, value string, loc *time.Location) time.Time {
|
||||
switch strings.ToLower(layout) {
|
||||
case "unix":
|
||||
asInt, err := strconv.ParseInt(value, 10, 64)
|
||||
@@ -589,7 +594,7 @@ func customAPIFuncParseTime(layout, value string) time.Time {
|
||||
layout = time.DateOnly
|
||||
}
|
||||
|
||||
parsed, err := time.Parse(layout, value)
|
||||
parsed, err := time.ParseInLocation(layout, value, loc)
|
||||
if err != nil {
|
||||
return time.Unix(0, 0)
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ func fetchSubredditPosts(
|
||||
var client requestDoer = defaultHTTPClient
|
||||
|
||||
if requestUrlTemplate != "" {
|
||||
requestUrl = strings.ReplaceAll(requestUrlTemplate, "{REQUEST-URL}", requestUrl)
|
||||
requestUrl = strings.ReplaceAll(requestUrlTemplate, "{REQUEST-URL}", url.QueryEscape(requestUrl))
|
||||
} else if proxyClient != nil {
|
||||
client = proxyClient
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ type searchWidget struct {
|
||||
SearchEngine string `yaml:"search-engine"`
|
||||
Bangs []SearchBang `yaml:"bangs"`
|
||||
NewTab bool `yaml:"new-tab"`
|
||||
Target string `yaml:"target"`
|
||||
Autofocus bool `yaml:"autofocus"`
|
||||
Placeholder string `yaml:"placeholder"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user