aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-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
+}