aboutsummaryrefslogtreecommitdiff
path: root/util/util.go
diff options
context:
space:
mode:
authorFChannel <>2022-05-06 22:45:27 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit39012c6b17073f6933a5ead8beed64df555f7348 (patch)
tree7784d092fe196a9051c81cf6833997607ad2d268 /util/util.go
parentaf542e339e5a611d2a1b5876450bee841b577640 (diff)
converting functions to activitypub object functions
Diffstat (limited to 'util/util.go')
-rw-r--r--util/util.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/util/util.go b/util/util.go
index 0ffbf01..0126556 100644
--- a/util/util.go
+++ b/util/util.go
@@ -2,11 +2,14 @@ package util
import (
"crypto/sha256"
+ "database/sql"
"encoding/hex"
"fmt"
+ "io/ioutil"
"mime/multipart"
"net/http"
"os"
+ "path"
"regexp"
"strings"
@@ -261,3 +264,41 @@ func CreatedNeededDirectories() {
os.MkdirAll("./pem/board", 0700)
}
}
+
+func LoadThemes() {
+ // get list of themes
+ themes, err := ioutil.ReadDir("./static/css/themes")
+ if err != nil {
+ panic(err)
+ }
+
+ for _, f := range themes {
+ if e := path.Ext(f.Name()); e == ".css" {
+ config.Themes = append(config.Themes, strings.TrimSuffix(f.Name(), e))
+ }
+ }
+}
+
+func GetBoardAuth(board string) ([]string, error) {
+ var auth []string
+
+ query := `select type from actorauth where board=$1`
+
+ var rows *sql.Rows
+ var err error
+ if rows, err = config.DB.Query(query, board); err != nil {
+ return auth, err
+ }
+
+ defer rows.Close()
+ for rows.Next() {
+ var _type string
+ if err := rows.Scan(&_type); err != nil {
+ return auth, err
+ }
+
+ auth = append(auth, _type)
+ }
+
+ return auth, nil
+}