Hidden Files (#86)

Adds the following changes
- rename "Permissions" to "Perm"
- use a "-" if the mimetype is unknown
- add a button to hide and show hidden files
- fix the datetime to format based on how far in the past the date is
This commit is contained in:
Sylvie Crowe
2024-06-27 18:13:42 -07:00
committed by GitHub
parent 4d4e026749
commit ecd2464bbf
3 changed files with 100 additions and 152 deletions
-59
View File
@@ -1,59 +0,0 @@
// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
package wconfig
import (
"encoding/json"
"fmt"
)
type DateTimeStyle uint8
const (
DateTimeStyleFull = iota + 1
DateTimeStyleLong
DateTimeStyleMedium
DateTimeStyleShort
)
var dateTimeStyleToString = map[uint8]string{
1: "full",
2: "long",
3: "medium",
4: "short",
}
var stringToDateTimeStyle = map[string]uint8{
"full": 1,
"long": 2,
"medium": 3,
"short": 4,
}
func (dts DateTimeStyle) String() string {
return dateTimeStyleToString[uint8(dts)]
}
func parseDateTimeStyle(input string) (DateTimeStyle, error) {
value, ok := stringToDateTimeStyle[input]
if !ok {
return DateTimeStyle(0), fmt.Errorf("%q is not a valid date-time style", input)
}
return DateTimeStyle(value), nil
}
func (dts DateTimeStyle) MarshalJSON() ([]byte, error) {
return json.Marshal(dts.String())
}
func (dts *DateTimeStyle) UnmarshalJSON(data []byte) (err error) {
var buffer string
if err := json.Unmarshal(data, &buffer); err != nil {
return err
}
if *dts, err = parseDateTimeStyle(buffer); err != nil {
return err
}
return nil
}
-19
View File
@@ -27,17 +27,6 @@ type TerminalConfigType struct {
FontFamily string `json:"fontfamily,omitempty"`
}
type DateTimeConfigType struct {
Locale string `json:"locale"`
Format DateTimeFormatConfigType `json:"format"`
}
type DateTimeFormatConfigType struct {
DateStyle DateTimeStyle `json:"dateStyle"`
TimeStyle DateTimeStyle `json:"timeStyle"`
//TimeZone string `json:"timeZone"` TODO: need a universal way to obtain this before adding it
}
type MimeTypeConfigType struct {
Icon string `json:"icon"`
Color string `json:"color"`
@@ -49,7 +38,6 @@ type BlockHeaderOpts struct {
type SettingsConfigType struct {
MimeTypes map[string]MimeTypeConfigType `json:"mimetypes"`
DateTime DateTimeConfigType `json:"datetime"`
Term TerminalConfigType `json:"term"`
Widgets []WidgetsConfigType `json:"widgets"`
BlockHeader BlockHeaderOpts `json:"blockheader"`
@@ -57,13 +45,6 @@ type SettingsConfigType struct {
func getSettingsConfigDefaults() SettingsConfigType {
return SettingsConfigType{
DateTime: DateTimeConfigType{
Locale: wavebase.DetermineLocale(),
Format: DateTimeFormatConfigType{
DateStyle: DateTimeStyleMedium,
TimeStyle: DateTimeStyleMedium,
},
},
MimeTypes: map[string]MimeTypeConfigType{
"audio": {Icon: "file-audio"},
"application/pdf": {Icon: "file-pdf"},