gosora/pages.go
Azareal 689b1a804b Static files are now served from memory. This feature's a little experimental, so it will need a lot of testing i.i
Added an executable file. Only works on Windows, if it doesn't work, then try building it for yourself with build.bat or go build
Tweaked run.bat to make it more firewall friendly. It now generates an executable.
Moved the files around to make it more organised.
Added build.bat which you can use to build the program for you and install the libraries the software depends on.
2016-12-05 07:21:17 +00:00

51 lines
871 B
Go

package main
import "strings"
import "os"
import "log"
import "io/ioutil"
import "path/filepath"
type Page struct
{
Title string
Name string
CurrentUser User
ItemList map[int]interface{}
Something interface{}
}
type PageSimple struct
{
Title string
Name string
Something interface{}
}
func add_custom_page(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
// Is this a directory..?
fileInfo, err := os.Stat(path)
is_dir := fileInfo.IsDir()
if err != nil {
return err
}
if is_dir {
return err
}
custom_page, err := ioutil.ReadFile(path)
if err != nil {
return err
}
log.Print("Loaded the '" + path + "' page.")
name := strings.TrimSuffix(path, filepath.Ext(path))
custom_pages[name] = string(custom_page)
return nil
}
func parse_message(msg string) string {
return strings.Replace(msg,"\n","<br>",-1)
}