We now use Go 1.11 modules. This should help with build times, deployment and development, although it does mean that the minimum requirement for Gosora has been bumped up from Go 1.10 to Go 1.11
Added support for dyntmpl to the template system. The Account Dashboard now sort of uses dyntmpl, more work needed here. Renamed the pre_render_view_topic hook to pre_render_topic. Added the GetCurrentLangPack() function. Added the alerts_no_new_alerts phrase. Added the account_level_list phrase. Refactored the route rename logic in the patcher to cut down on the amount of boilerplate. Added more route renames to the patcher. You will need to run the patcher / updater in this commit.
This commit is contained in:
parent
35b1613005
commit
bf851bd9fc
|
@ -27,5 +27,5 @@ QueryGen
|
||||||
RouterGen
|
RouterGen
|
||||||
Patcher
|
Patcher
|
||||||
Gosora
|
Gosora
|
||||||
Install
|
Installer
|
||||||
template_*.go
|
template_*.go
|
|
@ -37,7 +37,7 @@ Other modern features like alerts, likes, advanced dashboard with live stats (CP
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
Go 1.10 or newer - You will need to install this. Pick the .msi, if you want everything sorted out for you rather than having to go around updating the environment settings. https://golang.org/doc/install
|
Go 1.11 or newer - You will need to install this. Pick the .msi, if you want everything sorted out for you rather than having to go around updating the environment settings. https://golang.org/doc/install
|
||||||
|
|
||||||
For Ubuntu, you can consult: https://tecadmin.net/install-go-on-ubuntu/
|
For Ubuntu, you can consult: https://tecadmin.net/install-go-on-ubuntu/
|
||||||
You will also want to run `ln -s /usr/local/go/bin/go` (replace /usr/local with where ever you put Go), so that go becomes visible to other users.
|
You will also want to run `ln -s /usr/local/go/bin/go` (replace /usr/local with where ever you put Go), so that go becomes visible to other users.
|
||||||
|
@ -135,7 +135,7 @@ These are the libraries and pieces of software which Gosora relies on to functio
|
||||||
|
|
||||||
A few of these like Rez aren't currently in use, but are things we think we'll need in the very near future and want to have those things ready, so that we can quickly slot them in.
|
A few of these like Rez aren't currently in use, but are things we think we'll need in the very near future and want to have those things ready, so that we can quickly slot them in.
|
||||||
|
|
||||||
* Go 1.10+
|
* Go 1.11+
|
||||||
|
|
||||||
* MariaDB (or any other MySQL compatible database engine). We'll allow other database engines in the future.
|
* MariaDB (or any other MySQL compatible database engine). We'll allow other database engines in the future.
|
||||||
|
|
||||||
|
|
10
build-linux
10
build-linux
|
@ -13,10 +13,10 @@ echo "Running the router generator"
|
||||||
./RouterGen
|
./RouterGen
|
||||||
|
|
||||||
echo "Building the query generator"
|
echo "Building the query generator"
|
||||||
cd ./query_gen
|
cd ./cmd/query_gen
|
||||||
go build -o QueryGen
|
go build -o QueryGen
|
||||||
mv ./QueryGen ..
|
mv ./QueryGen ../..
|
||||||
cd ..
|
cd ../..
|
||||||
echo "Running the query generator"
|
echo "Running the query generator"
|
||||||
./QueryGen
|
./QueryGen
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ go build -o Gosora
|
||||||
|
|
||||||
echo "Building the installer"
|
echo "Building the installer"
|
||||||
cd ./install
|
cd ./install
|
||||||
go build -o Install
|
go build -o Installer
|
||||||
mv ./Install ..
|
mv ./Installer ..
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
@ -13,10 +13,10 @@ echo "Running the router generator"
|
||||||
./RouterGen
|
./RouterGen
|
||||||
|
|
||||||
echo "Building the query generator"
|
echo "Building the query generator"
|
||||||
cd ./query_gen
|
cd ./cmd/query_gen
|
||||||
go build -o QueryGen
|
go build -o QueryGen
|
||||||
mv ./QueryGen ..
|
mv ./QueryGen ../..
|
||||||
cd ..
|
cd ../..
|
||||||
echo "Running the query generator"
|
echo "Running the query generator"
|
||||||
./QueryGen
|
./QueryGen
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ go build -o Gosora -tags no_ws
|
||||||
|
|
||||||
echo "Building the installer"
|
echo "Building the installer"
|
||||||
cd ./install
|
cd ./install
|
||||||
go build -o Install
|
go build -o Installer
|
||||||
mv ./Install ..
|
mv ./Installer ..
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
@ -20,7 +20,7 @@ if %errorlevel% neq 0 (
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Building the installer
|
echo Building the installer
|
||||||
go build ./install
|
go build "./cmd/install"
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
pause
|
pause
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
@ -34,7 +34,7 @@ if %errorlevel% neq 0 (
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Building the query generator
|
echo Building the query generator
|
||||||
go build ./query_gen
|
go build "./cmd/query_gen"
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
pause
|
pause
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
|
|
@ -22,7 +22,7 @@ if %errorlevel% neq 0 (
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Building the installer
|
echo Building the installer
|
||||||
go build ./install
|
go build "./cmd/install"
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
pause
|
pause
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
@ -36,7 +36,7 @@ if %errorlevel% neq 0 (
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Building the query generator
|
echo Building the query generator
|
||||||
go build ./query_gen
|
go build "./cmd/query_gen"
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
pause
|
pause
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
|
|
@ -0,0 +1,320 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Gosora Installer
|
||||||
|
* Copyright Azareal 2017 - 2019
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"runtime/debug"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Azareal/Gosora/install"
|
||||||
|
)
|
||||||
|
|
||||||
|
var scanner *bufio.Scanner
|
||||||
|
|
||||||
|
var siteShortName string
|
||||||
|
var siteName string
|
||||||
|
var siteURL string
|
||||||
|
var serverPort string
|
||||||
|
|
||||||
|
var defaultAdapter = "mysql"
|
||||||
|
var defaultHost = "localhost"
|
||||||
|
var defaultUsername = "root"
|
||||||
|
var defaultDbname = "gosora"
|
||||||
|
var defaultSiteShortName = "SN"
|
||||||
|
var defaultSiteName = "Site Name"
|
||||||
|
var defaultsiteURL = "localhost"
|
||||||
|
var defaultServerPort = "80" // 8080's a good one, if you're testing and don't want it to clash with port 80
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
||||||
|
defer func() {
|
||||||
|
r := recover()
|
||||||
|
if r != nil {
|
||||||
|
fmt.Println(r)
|
||||||
|
debug.PrintStack()
|
||||||
|
pressAnyKey()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
scanner = bufio.NewScanner(os.Stdin)
|
||||||
|
fmt.Println("Welcome to Gosora's Installer")
|
||||||
|
fmt.Println("We're going to take you through a few steps to help you get started :)")
|
||||||
|
adap, ok := handleDatabaseDetails()
|
||||||
|
if !ok {
|
||||||
|
err := scanner.Err()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
err = errors.New("Something went wrong!")
|
||||||
|
}
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !getSiteDetails() {
|
||||||
|
err := scanner.Err()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
err = errors.New("Something went wrong!")
|
||||||
|
}
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err := adap.InitDatabase()
|
||||||
|
if err != nil {
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = adap.TableDefs()
|
||||||
|
if err != nil {
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = adap.CreateAdmin()
|
||||||
|
if err != nil {
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = adap.InitialData()
|
||||||
|
if err != nil {
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configContents := []byte(`{
|
||||||
|
"Site": {
|
||||||
|
"ShortName":"` + siteShortName + `",
|
||||||
|
"Name":"` + siteName + `",
|
||||||
|
"URL":"` + siteURL + `",
|
||||||
|
"Port":"` + serverPort + `",
|
||||||
|
"EnableSsl":false,
|
||||||
|
"EnableEmails":false,
|
||||||
|
"HasProxy":false,
|
||||||
|
"Language": "english"
|
||||||
|
},
|
||||||
|
"Config": {
|
||||||
|
"SslPrivkey": "",
|
||||||
|
"SslFullchain": "",
|
||||||
|
"SMTPServer": "",
|
||||||
|
"SMTPUsername": "",
|
||||||
|
"SMTPPassword": "",
|
||||||
|
"SMTPPort": "25",
|
||||||
|
|
||||||
|
"MaxRequestSizeStr":"5MB",
|
||||||
|
"UserCache":"static",
|
||||||
|
"TopicCache":"static",
|
||||||
|
"UserCacheCapacity":150,
|
||||||
|
"TopicCacheCapacity":250,
|
||||||
|
"DefaultPath":"/topics/",
|
||||||
|
"DefaultGroup":3,
|
||||||
|
"ActivationGroup":5,
|
||||||
|
"StaffCSS":"staff_post",
|
||||||
|
"DefaultForum":2,
|
||||||
|
"MinifyTemplates":true,
|
||||||
|
"BuildSlugs":true,
|
||||||
|
"ServerCount":1,
|
||||||
|
"Noavatar":"https://api.adorable.io/avatars/{width}/{id}@{site_url}.png",
|
||||||
|
"ItemsPerPage":25
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"Adapter": "` + adap.Name() + `",
|
||||||
|
"Host": "` + adap.DBHost() + `",
|
||||||
|
"Username": "` + adap.DBUsername() + `",
|
||||||
|
"Password": "` + adap.DBPassword() + `",
|
||||||
|
"Dbname": "` + adap.DBName() + `",
|
||||||
|
"Port": "` + adap.DBPort() + `",
|
||||||
|
|
||||||
|
"TestAdapter": "` + adap.Name() + `",
|
||||||
|
"TestHost": "",
|
||||||
|
"TestUsername": "",
|
||||||
|
"TestPassword": "",
|
||||||
|
"TestDbname": "",
|
||||||
|
"TestPort": ""
|
||||||
|
},
|
||||||
|
"Dev": {
|
||||||
|
"DebugMode":true,
|
||||||
|
"SuperDebug":false
|
||||||
|
}
|
||||||
|
}`)
|
||||||
|
|
||||||
|
fmt.Println("Opening the configuration file")
|
||||||
|
configFile, err := os.Create("./config/config.json")
|
||||||
|
if err != nil {
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Writing to the configuration file...")
|
||||||
|
_, err = configFile.Write(configContents)
|
||||||
|
if err != nil {
|
||||||
|
abortError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configFile.Sync()
|
||||||
|
configFile.Close()
|
||||||
|
fmt.Println("Finished writing to the configuration file")
|
||||||
|
|
||||||
|
fmt.Println("Yay, you have successfully installed Gosora!")
|
||||||
|
fmt.Println("Your name is Admin and you can login with the password 'password'. Don't forget to change it! Seriously. It's really insecure.")
|
||||||
|
pressAnyKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
func abortError(err error) {
|
||||||
|
fmt.Println(err)
|
||||||
|
fmt.Println("Aborting installation...")
|
||||||
|
pressAnyKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleDatabaseDetails() (adap install.InstallAdapter, ok bool) {
|
||||||
|
var dbAdapter string
|
||||||
|
var dbHost string
|
||||||
|
var dbUsername string
|
||||||
|
var dbPassword string
|
||||||
|
var dbName string
|
||||||
|
// TODO: Let the admin set the database port?
|
||||||
|
//var dbPort string
|
||||||
|
|
||||||
|
for {
|
||||||
|
fmt.Println("Which database adapter do you wish to use? mysql, mssql, or mysql? Default: mysql")
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
dbAdapter := strings.TrimSpace(scanner.Text())
|
||||||
|
if dbAdapter == "" {
|
||||||
|
dbAdapter = defaultAdapter
|
||||||
|
}
|
||||||
|
adap, ok = install.Lookup(dbAdapter)
|
||||||
|
if ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
fmt.Println("That adapter doesn't exist")
|
||||||
|
}
|
||||||
|
fmt.Println("Set database adapter to " + dbAdapter)
|
||||||
|
|
||||||
|
fmt.Println("Database Host? Default: " + defaultHost)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
dbHost = scanner.Text()
|
||||||
|
if dbHost == "" {
|
||||||
|
dbHost = defaultHost
|
||||||
|
}
|
||||||
|
fmt.Println("Set database host to " + dbHost)
|
||||||
|
|
||||||
|
fmt.Println("Database Username? Default: " + defaultUsername)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
dbUsername = scanner.Text()
|
||||||
|
if dbUsername == "" {
|
||||||
|
dbUsername = defaultUsername
|
||||||
|
}
|
||||||
|
fmt.Println("Set database username to " + dbUsername)
|
||||||
|
|
||||||
|
fmt.Println("Database Password? Default: ''")
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
dbPassword = scanner.Text()
|
||||||
|
if len(dbPassword) == 0 {
|
||||||
|
fmt.Println("You didn't set a password for this user. This won't block the installation process, but it might create security issues in the future.")
|
||||||
|
fmt.Println("")
|
||||||
|
} else {
|
||||||
|
fmt.Println("Set password to " + obfuscatePassword(dbPassword))
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Database Name? Pick a name you like or one provided to you. Default: " + defaultDbname)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
dbName = scanner.Text()
|
||||||
|
if dbName == "" {
|
||||||
|
dbName = defaultDbname
|
||||||
|
}
|
||||||
|
fmt.Println("Set database name to " + dbName)
|
||||||
|
|
||||||
|
adap.SetConfig(dbHost, dbUsername, dbPassword, dbName, adap.DefaultPort())
|
||||||
|
return adap, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSiteDetails() bool {
|
||||||
|
fmt.Println("Okay. We also need to know some actual information about your site!")
|
||||||
|
fmt.Println("What's your site's name? Default: " + defaultSiteName)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
siteName = scanner.Text()
|
||||||
|
if siteName == "" {
|
||||||
|
siteName = defaultSiteName
|
||||||
|
}
|
||||||
|
fmt.Println("Set the site name to " + siteName)
|
||||||
|
|
||||||
|
// ? - We could compute this based on the first letter of each word in the site's name, if it's name spans multiple words. I'm not sure how to do this for single word names.
|
||||||
|
fmt.Println("Can we have a short abbreviation for your site? Default: " + defaultSiteShortName)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
siteShortName = scanner.Text()
|
||||||
|
if siteShortName == "" {
|
||||||
|
siteShortName = defaultSiteShortName
|
||||||
|
}
|
||||||
|
fmt.Println("Set the short name to " + siteShortName)
|
||||||
|
|
||||||
|
fmt.Println("What's your site's url? Default: " + defaultsiteURL)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
siteURL = scanner.Text()
|
||||||
|
if siteURL == "" {
|
||||||
|
siteURL = defaultsiteURL
|
||||||
|
}
|
||||||
|
fmt.Println("Set the site url to " + siteURL)
|
||||||
|
|
||||||
|
fmt.Println("What port do you want the server to listen on? If you don't know what this means, you should probably leave it on the default. Default: " + defaultServerPort)
|
||||||
|
if !scanner.Scan() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
serverPort = scanner.Text()
|
||||||
|
if serverPort == "" {
|
||||||
|
serverPort = defaultServerPort
|
||||||
|
}
|
||||||
|
_, err := strconv.Atoi(serverPort)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("That's not a valid number!")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
fmt.Println("Set the server port to " + serverPort)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func obfuscatePassword(password string) (out string) {
|
||||||
|
for i := 0; i < len(password); i++ {
|
||||||
|
out += "*"
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func pressAnyKey() {
|
||||||
|
//fmt.Println("Press any key to exit...")
|
||||||
|
fmt.Println("Please press enter to exit...")
|
||||||
|
for scanner.Scan() {
|
||||||
|
_ = scanner.Text()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/* WIP Under Construction */
|
/* WIP Under Construction */
|
||||||
package main
|
package main // import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -8,7 +8,7 @@ import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"./lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Make sure all the errors in this file propagate upwards properly
|
// TODO: Make sure all the errors in this file propagate upwards properly
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
import "./lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
type PrimaryKeySpitter struct {
|
type PrimaryKeySpitter struct {
|
||||||
keys map[string]string
|
keys map[string]string
|
|
@ -1,6 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "./lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
func createTables(adapter qgen.Adapter) error {
|
func createTables(adapter qgen.Adapter) error {
|
||||||
qgen.Install.CreateTable("users", "utf8mb4", "utf8mb4_general_ci",
|
qgen.Install.CreateTable("users", "utf8mb4", "utf8mb4_general_ci",
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Gosora Alerts System
|
* Gosora Alerts System
|
||||||
* Copyright Azareal 2017 - 2018
|
* Copyright Azareal 2017 - 2019
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package common
|
package common
|
||||||
|
@ -12,7 +12,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AlertStmts struct {
|
type AlertStmts struct {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Attachments AttachmentStore
|
var Attachments AttachmentStore
|
||||||
|
|
|
@ -3,7 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ModLogs LogStore
|
var ModLogs LogStore
|
||||||
|
|
|
@ -16,8 +16,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"./gauth"
|
"github.com/Azareal/Gosora/common/gauth"
|
||||||
//"golang.org/x/crypto/argon2"
|
//"golang.org/x/crypto/argon2"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package common
|
/*
|
||||||
|
*
|
||||||
|
* Gosora Common Resources
|
||||||
|
* Copyright Azareal 2018 - 2019
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package common // import "github.com/Azareal/Gosora/common"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log"
|
"log"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"../query_gen/lib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var SoftwareVersion = Version{Major: 0, Minor: 2, Patch: 0, Tag: "dev"}
|
var SoftwareVersion = Version{Major: 0, Minor: 2, Patch: 0, Tag: "dev"}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package counters
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AgentViewCounter *DefaultAgentViewCounter
|
var AgentViewCounter *DefaultAgentViewCounter
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ForumViewCounter *DefaultForumViewCounter
|
var ForumViewCounter *DefaultForumViewCounter
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package counters
|
package counters
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import ".."
|
import "github.com/Azareal/Gosora/common"
|
||||||
import "../../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var LangViewCounter *DefaultLangViewCounter
|
var LangViewCounter *DefaultLangViewCounter
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var PostCounter *DefaultPostCounter
|
var PostCounter *DefaultPostCounter
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ReferrerTracker *DefaultReferrerTracker
|
var ReferrerTracker *DefaultReferrerTracker
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Rename this?
|
// TODO: Rename this?
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package counters
|
package counters
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import ".."
|
import "github.com/Azareal/Gosora/common"
|
||||||
import "../../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var RouteViewCounter *DefaultRouteViewCounter
|
var RouteViewCounter *DefaultRouteViewCounter
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package counters
|
package counters
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import ".."
|
import "github.com/Azareal/Gosora/common"
|
||||||
import "../../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var OSViewCounter *DefaultOSViewCounter
|
var OSViewCounter *DefaultOSViewCounter
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var TopicCounter *DefaultTopicCounter
|
var TopicCounter *DefaultTopicCounter
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
".."
|
"github.com/Azareal/Gosora/common"
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var TopicViewCounter *DefaultTopicViewCounter
|
var TopicViewCounter *DefaultTopicViewCounter
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var Emails EmailStore
|
var Emails EmailStore
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrPluginNotInstallable = errors.New("This plugin is not installable")
|
var ErrPluginNotInstallable = errors.New("This plugin is not installable")
|
||||||
|
@ -218,7 +218,7 @@ var PreRenderHooks = map[string][]func(http.ResponseWriter, *http.Request, *User
|
||||||
"pre_render_forum_list": nil,
|
"pre_render_forum_list": nil,
|
||||||
"pre_render_forum": nil,
|
"pre_render_forum": nil,
|
||||||
"pre_render_topic_list": nil,
|
"pre_render_topic_list": nil,
|
||||||
"pre_render_view_topic": nil,
|
"pre_render_topic": nil,
|
||||||
"pre_render_profile": nil,
|
"pre_render_profile": nil,
|
||||||
"pre_render_custom_page": nil,
|
"pre_render_custom_page": nil,
|
||||||
"pre_render_tmpl_page": nil,
|
"pre_render_tmpl_page": nil,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"../tmpl_client"
|
"github.com/Azareal/Gosora/tmpl_client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SFileList map[string]SFile
|
type SFileList map[string]SFile
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ? - Can we avoid duplicating the items in this list in a bunch of places?
|
// ? - Can we avoid duplicating the items in this list in a bunch of places?
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var FPStore ForumPermsStore
|
var FPStore ForumPermsStore
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var forumCreateMutex sync.Mutex
|
var forumCreateMutex sync.Mutex
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var blankGroup = Group{ID: 0, Name: ""}
|
var blankGroup = Group{ID: 0, Name: ""}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Groups GroupStore
|
var Groups GroupStore
|
||||||
|
|
|
@ -3,7 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var IPSearch IPSearcher
|
var IPSearch IPSearcher
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Menus *DefaultMenuStore
|
var Menus *DefaultMenuStore
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MenuItemList []MenuItem
|
type MenuItemList []MenuItem
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var MFAstore MFAStore
|
var MFAstore MFAStore
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var RegLogs RegLogStore
|
var RegLogs RegLogStore
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CustomPageStmts struct {
|
type CustomPageStmts struct {
|
||||||
|
|
|
@ -157,6 +157,8 @@ type EmailListPage struct {
|
||||||
|
|
||||||
type AccountDashPage struct {
|
type AccountDashPage struct {
|
||||||
*Header
|
*Header
|
||||||
|
HTMLID string
|
||||||
|
TmplName string
|
||||||
MFASetup bool
|
MFASetup bool
|
||||||
CurrentScore int
|
CurrentScore int
|
||||||
NextScore int
|
NextScore int
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Refactor the perms system
|
// TODO: Refactor the perms system
|
||||||
|
|
|
@ -276,6 +276,11 @@ func getPhrasePlaceholder(prefix string, suffix string) string {
|
||||||
return "{lang." + prefix + "[" + suffix + "]}"
|
return "{lang." + prefix + "[" + suffix + "]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Please don't mutate *LanguagePack
|
||||||
|
func GetCurrentLangPack() *LanguagePack {
|
||||||
|
return currentLangPack.Load().(*LanguagePack)
|
||||||
|
}
|
||||||
|
|
||||||
// ? - Use runtime reflection for updating phrases?
|
// ? - Use runtime reflection for updating phrases?
|
||||||
// TODO: Implement these
|
// TODO: Implement these
|
||||||
func AddPhrase() {
|
func AddPhrase() {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Polls PollStore
|
var Polls PollStore
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"html"
|
"html"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var profileReplyStmts ProfileReplyStmts
|
var profileReplyStmts ProfileReplyStmts
|
||||||
|
|
|
@ -3,7 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Prstore ProfileReplyStore
|
var Prstore ProfileReplyStore
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"html"
|
"html"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReplyUser struct {
|
type ReplyUser struct {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var Rstore ReplyStore
|
var Rstore ReplyStore
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Make the default report forum ID configurable
|
// TODO: Make the default report forum ID configurable
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SettingBox atomic.Value // An atomic value pointing to a SettingBox
|
var SettingBox atomic.Value // An atomic value pointing to a SettingBox
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var Subscriptions SubscriptionStore
|
var Subscriptions SubscriptionStore
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaskStmts struct {
|
type TaskStmts struct {
|
||||||
|
|
|
@ -4,14 +4,15 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"math"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"./alerts"
|
"github.com/Azareal/Gosora/common/alerts"
|
||||||
"./templates"
|
"github.com/Azareal/Gosora/common/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Ctemplates []string
|
var Ctemplates []string
|
||||||
|
@ -27,6 +28,7 @@ type CTmpl struct {
|
||||||
Imports []string
|
Imports []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor the template trees to not need these
|
||||||
// TODO: Stop duplicating these bits of code
|
// TODO: Stop duplicating these bits of code
|
||||||
// nolint
|
// nolint
|
||||||
func interpretedTopicTemplate(pi TopicPage, w io.Writer) error {
|
func interpretedTopicTemplate(pi TopicPage, w io.Writer) error {
|
||||||
|
@ -122,6 +124,15 @@ var Template_ip_search_handle = func(pi IPSearchPage, w io.Writer) error {
|
||||||
return Templates.ExecuteTemplate(w, mapping+".html", pi)
|
return Templates.ExecuteTemplate(w, mapping+".html", pi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint
|
||||||
|
var Template_account_handle = func(pi AccountDashPage, w io.Writer) error {
|
||||||
|
mapping, ok := Themes[DefaultThemeBox.Load().(string)].TemplatesMap["account"]
|
||||||
|
if !ok {
|
||||||
|
mapping = "account"
|
||||||
|
}
|
||||||
|
return Templates.ExecuteTemplate(w, mapping+".html", pi)
|
||||||
|
}
|
||||||
|
|
||||||
func tmplInitUsers() (User, User, User) {
|
func tmplInitUsers() (User, User, User) {
|
||||||
avatar, microAvatar := BuildAvatar(62, "")
|
avatar, microAvatar := BuildAvatar(62, "")
|
||||||
user := User{62, BuildProfileURL("fake-user", 62), "Fake User", "compiler@localhost", 0, false, false, false, false, false, false, GuestPerms, make(map[string]bool), "", false, "", avatar, microAvatar, "", "", "", "", 0, 0, 0, "0.0.0.0.0", 0}
|
user := User{62, BuildProfileURL("fake-user", 62), "Fake User", "compiler@localhost", 0, false, false, false, false, false, false, GuestPerms, make(map[string]bool), "", false, "", avatar, microAvatar, "", "", "", "", 0, 0, 0, "0.0.0.0.0", 0}
|
||||||
|
@ -172,7 +183,7 @@ func CompileTemplates() error {
|
||||||
c.SetConfig(config)
|
c.SetConfig(config)
|
||||||
c.SetBaseImportMap(map[string]string{
|
c.SetBaseImportMap(map[string]string{
|
||||||
"io": "io",
|
"io": "io",
|
||||||
"./common": "./common",
|
"github.com/Azareal/Gosora/common": "github.com/Azareal/Gosora/common",
|
||||||
})
|
})
|
||||||
c.SetBuildTags("!no_templategen")
|
c.SetBuildTags("!no_templategen")
|
||||||
|
|
||||||
|
@ -285,6 +296,18 @@ func CompileTemplates() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mfaSetup := false
|
||||||
|
prevScore := GetLevelScore(header.CurrentUser.Level)
|
||||||
|
currentScore := header.CurrentUser.Score - prevScore
|
||||||
|
nextScore := GetLevelScore(header.CurrentUser.Level+1) - prevScore
|
||||||
|
perc := int(math.Ceil((float64(nextScore) / float64(currentScore)) * 100))
|
||||||
|
|
||||||
|
accountPage := AccountDashPage{header, "dashboard", "account_own_edit", mfaSetup, currentScore, nextScore, user.Level + 1, perc * 2}
|
||||||
|
accountTmpl, err := compile("account", "common.AccountDashPage", accountPage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var writeTemplate = func(name string, content string) {
|
var writeTemplate = func(name string, content string) {
|
||||||
log.Print("Writing template '" + name + "'")
|
log.Print("Writing template '" + name + "'")
|
||||||
|
@ -327,6 +350,7 @@ func CompileTemplates() error {
|
||||||
writeTemplate("login", loginTmpl)
|
writeTemplate("login", loginTmpl)
|
||||||
writeTemplate("register", registerTmpl)
|
writeTemplate("register", registerTmpl)
|
||||||
writeTemplate("ip_search", ipSearchTmpl)
|
writeTemplate("ip_search", ipSearchTmpl)
|
||||||
|
writeTemplate("account", accountTmpl)
|
||||||
writeTemplate("error", errorTmpl)
|
writeTemplate("error", errorTmpl)
|
||||||
writeTemplateList(c, &wg, "./")
|
writeTemplateList(c, &wg, "./")
|
||||||
return nil
|
return nil
|
||||||
|
@ -347,7 +371,7 @@ func CompileJSTemplates() error {
|
||||||
c.SetConfig(config)
|
c.SetConfig(config)
|
||||||
c.SetBaseImportMap(map[string]string{
|
c.SetBaseImportMap(map[string]string{
|
||||||
"io": "io",
|
"io": "io",
|
||||||
"../common/alerts": "../common/alerts",
|
"github.com/Azareal/Gosora/common/alerts": "github.com/Azareal/Gosora/common/alerts",
|
||||||
})
|
})
|
||||||
c.SetBuildTags("!no_templategen")
|
c.SetBuildTags("!no_templategen")
|
||||||
|
|
||||||
|
@ -365,7 +389,7 @@ func CompileJSTemplates() error {
|
||||||
|
|
||||||
c.SetBaseImportMap(map[string]string{
|
c.SetBaseImportMap(map[string]string{
|
||||||
"io": "io",
|
"io": "io",
|
||||||
"../common": "../common",
|
"github.com/Azareal/Gosora/common": "github.com/Azareal/Gosora/common",
|
||||||
})
|
})
|
||||||
// TODO: Fix the import loop so we don't have to use this hack anymore
|
// TODO: Fix the import loop so we don't have to use this hack anymore
|
||||||
c.SetBuildTags("!no_templategen,tmplgentopic")
|
c.SetBuildTags("!no_templategen,tmplgentopic")
|
||||||
|
|
|
@ -87,6 +87,7 @@ func NewCTemplateSet() *CTemplateSet {
|
||||||
"lang": true,
|
"lang": true,
|
||||||
"level": true,
|
"level": true,
|
||||||
"scope": true,
|
"scope": true,
|
||||||
|
"dyntmpl": true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -733,6 +734,42 @@ ArgLoop:
|
||||||
literal = true
|
literal = true
|
||||||
break ArgLoop
|
break ArgLoop
|
||||||
case "dyntmpl":
|
case "dyntmpl":
|
||||||
|
var nameParam, pageParam, headParam string
|
||||||
|
// TODO: Implement string literals properly
|
||||||
|
// TODO: Should we check to see if pos+3 is within the bounds of the slice?
|
||||||
|
nameOperand := node.Args[pos+1].String()
|
||||||
|
pageOperand := node.Args[pos+2].String()
|
||||||
|
headOperand := node.Args[pos+3].String()
|
||||||
|
|
||||||
|
if len(nameOperand) == 0 || len(pageOperand) == 0 || len(headOperand) == 0 {
|
||||||
|
panic("None of the three operands for function dyntmpl can be left blank")
|
||||||
|
}
|
||||||
|
if nameOperand[0] == '"' {
|
||||||
|
nameParam = nameOperand
|
||||||
|
} else {
|
||||||
|
nameParam, _ = c.compileIfVarsub(nameOperand, varholder, templateName, holdreflect)
|
||||||
|
}
|
||||||
|
if pageOperand[0] == '"' {
|
||||||
|
panic("The page operand for function dyntmpl cannot be a string")
|
||||||
|
}
|
||||||
|
if headOperand[0] == '"' {
|
||||||
|
panic("The head operand for function dyntmpl cannot be a string")
|
||||||
|
}
|
||||||
|
|
||||||
|
pageParam, val3 := c.compileIfVarsub(pageOperand, varholder, templateName, holdreflect)
|
||||||
|
if !val3.IsValid() {
|
||||||
|
panic("val3 is invalid")
|
||||||
|
}
|
||||||
|
headParam, val4 := c.compileIfVarsub(headOperand, varholder, templateName, holdreflect)
|
||||||
|
if !val4.IsValid() {
|
||||||
|
panic("val4 is invalid")
|
||||||
|
}
|
||||||
|
val = val4
|
||||||
|
|
||||||
|
// TODO: Refactor this
|
||||||
|
// TODO: Call the template function directly rather than going through RunThemeTemplate to eliminate a round of indirection?
|
||||||
|
out = "{\nerr := common.RunThemeTemplate(" + headParam + ".Theme.Name," + nameParam + "," + pageParam + ",w)\n"
|
||||||
|
out += "if err != nil {\nreturn err\n}\n}\n"
|
||||||
literal = true
|
literal = true
|
||||||
break ArgLoop
|
break ArgLoop
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Something more thread-safe
|
// TODO: Something more thread-safe
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is also in reply.go
|
// This is also in reply.go
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var TopicList TopicListInt
|
var TopicList TopicListInt
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Add the watchdog goroutine
|
// TODO: Add the watchdog goroutine
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"github.com/go-sql-driver/mysql"
|
"github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Docks WidgetDocks
|
var Docks WidgetDocks
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Move some features into methods on this?
|
// TODO: Move some features into methods on this?
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -142,13 +142,13 @@ go build ./router_gen
|
||||||
|
|
||||||
router_gen.exe
|
router_gen.exe
|
||||||
|
|
||||||
go build ./query_gen
|
go build ./cmd/query_gen
|
||||||
|
|
||||||
query_gen.exe
|
query_gen.exe
|
||||||
|
|
||||||
go build -o gosora.exe
|
go build -o gosora.exe
|
||||||
|
|
||||||
go build ./install
|
go build "./cmd/install"
|
||||||
|
|
||||||
install.exe
|
install.exe
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hyperPageCache *HyperPageCache
|
var hyperPageCache *HyperPageCache
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package guilds
|
package guilds
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "../../../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
var Gstore GuildStore
|
var Gstore GuildStore
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package guilds
|
package guilds // import "github.com/Azareal/Gosora/extend/guilds/lib"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -10,7 +10,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../../../common"
|
"github.com/Azareal/Gosora/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A blank list to fill out that parameter in Page for routes which don't use it
|
// A blank list to fill out that parameter in Page for routes which don't use it
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./extend/guilds/lib"
|
"github.com/Azareal/Gosora/extend/guilds/lib"
|
||||||
"./query_gen/lib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Add a better way of splitting up giant plugins like this
|
// TODO: Add a better way of splitting up giant plugins like this
|
|
@ -5,7 +5,7 @@ package main
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "./common"
|
import "github.com/Azareal/Gosora/common"
|
||||||
|
|
||||||
// nolint
|
// nolint
|
||||||
type Stmts struct {
|
type Stmts struct {
|
||||||
|
|
|
@ -6,8 +6,8 @@ package main
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "./common"
|
import "github.com/Azareal/Gosora/common"
|
||||||
//import "./query_gen/lib"
|
//import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
// nolint
|
// nolint
|
||||||
type Stmts struct {
|
type Stmts struct {
|
||||||
|
|
|
@ -5,7 +5,7 @@ package main
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "./common"
|
import "github.com/Azareal/Gosora/common"
|
||||||
|
|
||||||
// nolint
|
// nolint
|
||||||
type Stmts struct {
|
type Stmts struct {
|
||||||
|
|
|
@ -14,10 +14,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./common/counters"
|
"github.com/Azareal/Gosora/common/counters"
|
||||||
"./routes"
|
"github.com/Azareal/Gosora/routes"
|
||||||
"./routes/panel"
|
"github.com/Azareal/Gosora/routes/panel"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrNoRoute = errors.New("That route doesn't exist.")
|
var ErrNoRoute = errors.New("That route doesn't exist.")
|
||||||
|
|
|
@ -2,22 +2,22 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var dbTablePrimaryKeys = map[string]string{
|
var dbTablePrimaryKeys = map[string]string{
|
||||||
"users_groups_scheduler":"uid",
|
|
||||||
"replies":"rid",
|
|
||||||
"attachments":"attachID",
|
"attachments":"attachID",
|
||||||
"revisions":"reviseID",
|
|
||||||
"polls":"pollID",
|
|
||||||
"users_replies":"rid",
|
|
||||||
"activity_stream":"asid",
|
|
||||||
"users":"uid",
|
|
||||||
"pages":"pid",
|
|
||||||
"word_filters":"wfid",
|
|
||||||
"menus":"mid",
|
|
||||||
"registration_logs":"rlid",
|
|
||||||
"forums":"fid",
|
|
||||||
"users_2fa_keys":"uid",
|
|
||||||
"users_avatar_queue":"uid",
|
|
||||||
"topics":"tid",
|
"topics":"tid",
|
||||||
"users_groups":"gid",
|
"replies":"rid",
|
||||||
|
"polls":"pollID",
|
||||||
|
"users_2fa_keys":"uid",
|
||||||
|
"users_groups_scheduler":"uid",
|
||||||
|
"revisions":"reviseID",
|
||||||
|
"users_replies":"rid",
|
||||||
|
"menus":"mid",
|
||||||
|
"users":"uid",
|
||||||
|
"forums":"fid",
|
||||||
|
"activity_stream":"asid",
|
||||||
|
"word_filters":"wfid",
|
||||||
"menu_items":"miid",
|
"menu_items":"miid",
|
||||||
|
"pages":"pid",
|
||||||
|
"registration_logs":"rlid",
|
||||||
|
"users_groups":"gid",
|
||||||
|
"users_avatar_queue":"uid",
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./install/install"
|
"github.com/Azareal/Gosora/install/install"
|
||||||
"./query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"./routes"
|
"github.com/Azareal/Gosora/routes"
|
||||||
//"github.com/husobee/vestigo"
|
//"github.com/husobee/vestigo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
module github.com/Azareal/Gosora
|
||||||
|
|
||||||
|
require (
|
||||||
|
cloud.google.com/go v0.31.0 // indirect
|
||||||
|
github.com/Azareal/gopsutil v0.0.0-20170716174751-0763ca4e911d
|
||||||
|
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f // indirect
|
||||||
|
github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7
|
||||||
|
github.com/go-ole/go-ole v1.2.1 // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.4.0
|
||||||
|
github.com/gorilla/websocket v1.4.0
|
||||||
|
github.com/lib/pq v1.0.0
|
||||||
|
github.com/oschwald/geoip2-golang v1.2.1
|
||||||
|
github.com/oschwald/maxminddb-golang v1.3.0 // indirect
|
||||||
|
github.com/pkg/errors v0.8.0
|
||||||
|
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
|
||||||
|
golang.org/x/crypto v0.0.0-20181025213731-e84da0312774
|
||||||
|
google.golang.org/appengine v1.2.0 // indirect
|
||||||
|
gopkg.in/sourcemap.v1 v1.0.5 // indirect
|
||||||
|
gopkg.in/src-d/go-git.v4 v4.7.1
|
||||||
|
)
|
|
@ -0,0 +1,89 @@
|
||||||
|
cloud.google.com/go v0.31.0 h1:o9K5MWWt2wk+d9jkGn2DAZ7Q9nUdnFLOpK9eIkDwONQ=
|
||||||
|
cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
github.com/Azareal/gopsutil v0.0.0-20170716174751-0763ca4e911d h1:biEIFfkaXGysjNAACgZ9yeCKkR3jOcARFgDewOhrwHw=
|
||||||
|
github.com/Azareal/gopsutil v0.0.0-20170716174751-0763ca4e911d/go.mod h1:BxcRRJJc1AsnFl41ujb+8dv75d1fRCRYAnAXAsFypq4=
|
||||||
|
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f h1:5ZfJxyXo8KyX8DgGXC5B7ILL8y51fci/qYz2B4j8iLY=
|
||||||
|
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||||
|
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
||||||
|
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f h1:WH0w/R4Yoey+04HhFxqZ6VX6I0d7RMyw5aXQ9UTvQPs=
|
||||||
|
github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc=
|
||||||
|
github.com/emirpasic/gods v1.9.0 h1:rUF4PuzEjMChMiNsVjdI+SyLu7rEqpQ5reNFnhC7oFo=
|
||||||
|
github.com/emirpasic/gods v1.9.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||||
|
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
|
||||||
|
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/gliderlabs/ssh v0.1.1 h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw=
|
||||||
|
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||||
|
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
|
||||||
|
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
|
||||||
|
github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk=
|
||||||
|
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||||
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||||
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||||
|
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||||
|
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e h1:RgQk53JHp/Cjunrr1WlsXSZpqXn+uREuHvUVcK82CV8=
|
||||||
|
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
|
||||||
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
||||||
|
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/oschwald/geoip2-golang v1.2.1 h1:3iz+jmeJc6fuCyWeKgtXSXu7+zvkxJbHFXkMT5FVebU=
|
||||||
|
github.com/oschwald/geoip2-golang v1.2.1/go.mod h1:0LTTzix/Ao1uMvOhAV4iLU0Lz7eCrP94qZWBTDKf0iE=
|
||||||
|
github.com/oschwald/maxminddb-golang v1.3.0 h1:oTh8IBSj10S5JNlUDg5WjJ1QdBMdeaZIkPEVfESSWgE=
|
||||||
|
github.com/oschwald/maxminddb-golang v1.3.0/go.mod h1:3jhIUymTJ5VREKyIhWm66LJiQt04F0UCDdodShpjWsY=
|
||||||
|
github.com/pelletier/go-buffruneio v0.2.0 h1:U4t4R6YkofJ5xHm3dJzuRpPZ0mr5MMCoAWooScCR7aA=
|
||||||
|
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
|
||||||
|
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||||
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d h1:1VUlQbCfkoSGv7qP7Y+ro3ap1P1pPZxgdGVqiTVy5C4=
|
||||||
|
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY=
|
||||||
|
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||||
|
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||||
|
github.com/src-d/gcfg v1.3.0 h1:2BEDr8r0I0b8h/fOqwtxCEiq2HJu8n2JGZJQFGXWLjg=
|
||||||
|
github.com/src-d/gcfg v1.3.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
|
||||||
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/xanzy/ssh-agent v0.2.0 h1:Adglfbi5p9Z0BmK2oKU9nTG+zKfniSfnaMYB+ULd+Ro=
|
||||||
|
github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8=
|
||||||
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20181025213731-e84da0312774 h1:a4tQYYYuK9QdeO/+kEvNYyuR21S+7ve5EANok6hABhI=
|
||||||
|
golang.org/x/crypto v0.0.0-20181025213731-e84da0312774/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 h1:lkiLiLBHGoH3XnqSLUIaBsilGMUjI+Uy2Xu2JLUtTas=
|
||||||
|
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
google.golang.org/appengine v1.2.0 h1:S0iUepdCWODXRvtE+gcRDd15L+k+k1AiHlMiMjefH24=
|
||||||
|
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
|
||||||
|
gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78=
|
||||||
|
gopkg.in/src-d/go-billy.v4 v4.2.1 h1:omN5CrMrMcQ+4I8bJ0wEhOBPanIRWzFC953IiXKdYzo=
|
||||||
|
gopkg.in/src-d/go-billy.v4 v4.2.1/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
|
||||||
|
gopkg.in/src-d/go-git-fixtures.v3 v3.1.1 h1:XWW/s5W18RaJpmo1l0IYGqXKuJITWRFuA45iOf1dKJs=
|
||||||
|
gopkg.in/src-d/go-git-fixtures.v3 v3.1.1/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
||||||
|
gopkg.in/src-d/go-git.v4 v4.7.1 h1:phAV/kNULxfYEvyInGdPuq3U2MtPpJdgmtOUF3cghkQ=
|
||||||
|
gopkg.in/src-d/go-git.v4 v4.7.1/go.mod h1:xrJH/YX8uSWewT6evfocf8qsivF18JgCN7/IMitOptY=
|
||||||
|
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||||
|
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
|
@ -1,7 +1,7 @@
|
||||||
cd ./install
|
cd ./install
|
||||||
go generate
|
go generate
|
||||||
go build -o Install
|
go build -o Installer
|
||||||
mv ./Install ..
|
mv ./Installer ..
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
./Install --dbType=mysql --dbHost=localhost --dbUser=$MYSQL_USER --dbPassword=$MYSQL_PASSWORD --dbName=$MYSQL_DATABASE --shortSiteName=$SITE_SHORT_NAME --siteName=$SITE_NAME --siteURL=$SITE_URL --serverPort=$SERVER_PORT--secureServerPort=$SECURE_SERVER_PORT
|
./Installer --dbType=mysql --dbHost=localhost --dbUser=$MYSQL_USER --dbPassword=$MYSQL_PASSWORD --dbName=$MYSQL_DATABASE --shortSiteName=$SITE_SHORT_NAME --siteName=$SITE_NAME --siteURL=$SITE_URL --serverPort=$SERVER_PORT--secureServerPort=$SECURE_SERVER_PORT
|
|
@ -40,9 +40,9 @@ go get -u github.com/fsnotify/fsnotify
|
||||||
echo "Building the installer"
|
echo "Building the installer"
|
||||||
cd ./install
|
cd ./install
|
||||||
go generate
|
go generate
|
||||||
go build -o Install
|
go build -o Installer
|
||||||
mv ./Install ..
|
mv ./Installer ..
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo "Running the installer"
|
echo "Running the installer"
|
||||||
./Install
|
./Installer
|
||||||
|
|
|
@ -109,7 +109,7 @@ if %errorlevel% neq 0 (
|
||||||
|
|
||||||
echo Building the installer
|
echo Building the installer
|
||||||
go generate
|
go generate
|
||||||
go build ./install
|
go build "./cmd/install"
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
pause
|
pause
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
|
|
@ -1,320 +1,48 @@
|
||||||
/*
|
package install
|
||||||
*
|
|
||||||
* Gosora Installer
|
|
||||||
* Copyright Azareal 2017 - 2018
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"runtime/debug"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"./install"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var scanner *bufio.Scanner
|
var adapters = make(map[string]InstallAdapter)
|
||||||
|
|
||||||
var siteShortName string
|
type InstallAdapter interface {
|
||||||
var siteName string
|
Name() string
|
||||||
var siteURL string
|
DefaultPort() string
|
||||||
var serverPort string
|
SetConfig(dbHost string, dbUsername string, dbPassword string, dbName string, dbPort string)
|
||||||
|
InitDatabase() error
|
||||||
|
TableDefs() error
|
||||||
|
InitialData() error
|
||||||
|
CreateAdmin() error
|
||||||
|
|
||||||
var defaultAdapter = "mysql"
|
DBHost() string
|
||||||
var defaultHost = "localhost"
|
DBUsername() string
|
||||||
var defaultUsername = "root"
|
DBPassword() string
|
||||||
var defaultDbname = "gosora"
|
DBName() string
|
||||||
var defaultSiteShortName = "SN"
|
DBPort() string
|
||||||
var defaultSiteName = "Site Name"
|
|
||||||
var defaultsiteURL = "localhost"
|
|
||||||
var defaultServerPort = "80" // 8080's a good one, if you're testing and don't want it to clash with port 80
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
|
||||||
defer func() {
|
|
||||||
r := recover()
|
|
||||||
if r != nil {
|
|
||||||
fmt.Println(r)
|
|
||||||
debug.PrintStack()
|
|
||||||
pressAnyKey()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
scanner = bufio.NewScanner(os.Stdin)
|
|
||||||
fmt.Println("Welcome to Gosora's Installer")
|
|
||||||
fmt.Println("We're going to take you through a few steps to help you get started :)")
|
|
||||||
adap, ok := handleDatabaseDetails()
|
|
||||||
if !ok {
|
|
||||||
err := scanner.Err()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
} else {
|
|
||||||
err = errors.New("Something went wrong!")
|
|
||||||
}
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !getSiteDetails() {
|
|
||||||
err := scanner.Err()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
} else {
|
|
||||||
err = errors.New("Something went wrong!")
|
|
||||||
}
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err := adap.InitDatabase()
|
|
||||||
if err != nil {
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = adap.TableDefs()
|
|
||||||
if err != nil {
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = adap.CreateAdmin()
|
|
||||||
if err != nil {
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = adap.InitialData()
|
|
||||||
if err != nil {
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
configContents := []byte(`{
|
|
||||||
"Site": {
|
|
||||||
"ShortName":"` + siteShortName + `",
|
|
||||||
"Name":"` + siteName + `",
|
|
||||||
"URL":"` + siteURL + `",
|
|
||||||
"Port":"` + serverPort + `",
|
|
||||||
"EnableSsl":false,
|
|
||||||
"EnableEmails":false,
|
|
||||||
"HasProxy":false,
|
|
||||||
"Language": "english"
|
|
||||||
},
|
|
||||||
"Config": {
|
|
||||||
"SslPrivkey": "",
|
|
||||||
"SslFullchain": "",
|
|
||||||
"SMTPServer": "",
|
|
||||||
"SMTPUsername": "",
|
|
||||||
"SMTPPassword": "",
|
|
||||||
"SMTPPort": "25",
|
|
||||||
|
|
||||||
"MaxRequestSizeStr":"5MB",
|
|
||||||
"UserCache":"static",
|
|
||||||
"TopicCache":"static",
|
|
||||||
"UserCacheCapacity":150,
|
|
||||||
"TopicCacheCapacity":250,
|
|
||||||
"DefaultPath":"/topics/",
|
|
||||||
"DefaultGroup":3,
|
|
||||||
"ActivationGroup":5,
|
|
||||||
"StaffCSS":"staff_post",
|
|
||||||
"DefaultForum":2,
|
|
||||||
"MinifyTemplates":true,
|
|
||||||
"BuildSlugs":true,
|
|
||||||
"ServerCount":1,
|
|
||||||
"Noavatar":"https://api.adorable.io/avatars/{width}/{id}@{site_url}.png",
|
|
||||||
"ItemsPerPage":25
|
|
||||||
},
|
|
||||||
"Database": {
|
|
||||||
"Adapter": "` + adap.Name() + `",
|
|
||||||
"Host": "` + adap.DBHost() + `",
|
|
||||||
"Username": "` + adap.DBUsername() + `",
|
|
||||||
"Password": "` + adap.DBPassword() + `",
|
|
||||||
"Dbname": "` + adap.DBName() + `",
|
|
||||||
"Port": "` + adap.DBPort() + `",
|
|
||||||
|
|
||||||
"TestAdapter": "` + adap.Name() + `",
|
|
||||||
"TestHost": "",
|
|
||||||
"TestUsername": "",
|
|
||||||
"TestPassword": "",
|
|
||||||
"TestDbname": "",
|
|
||||||
"TestPort": ""
|
|
||||||
},
|
|
||||||
"Dev": {
|
|
||||||
"DebugMode":true,
|
|
||||||
"SuperDebug":false
|
|
||||||
}
|
|
||||||
}`)
|
|
||||||
|
|
||||||
fmt.Println("Opening the configuration file")
|
|
||||||
configFile, err := os.Create("./config/config.json")
|
|
||||||
if err != nil {
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Writing to the configuration file...")
|
|
||||||
_, err = configFile.Write(configContents)
|
|
||||||
if err != nil {
|
|
||||||
abortError(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
configFile.Sync()
|
|
||||||
configFile.Close()
|
|
||||||
fmt.Println("Finished writing to the configuration file")
|
|
||||||
|
|
||||||
fmt.Println("Yay, you have successfully installed Gosora!")
|
|
||||||
fmt.Println("Your name is Admin and you can login with the password 'password'. Don't forget to change it! Seriously. It's really insecure.")
|
|
||||||
pressAnyKey()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func abortError(err error) {
|
func Lookup(name string) (InstallAdapter, bool) {
|
||||||
fmt.Println(err)
|
adap, ok := adapters[name]
|
||||||
fmt.Println("Aborting installation...")
|
return adap, ok
|
||||||
pressAnyKey()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleDatabaseDetails() (adap install.InstallAdapter, ok bool) {
|
func createAdmin() error {
|
||||||
var dbAdapter string
|
fmt.Println("Creating the admin user")
|
||||||
var dbHost string
|
hashedPassword, salt, err := BcryptGeneratePassword("password")
|
||||||
var dbUsername string
|
|
||||||
var dbPassword string
|
|
||||||
var dbName string
|
|
||||||
// TODO: Let the admin set the database port?
|
|
||||||
//var dbPort string
|
|
||||||
|
|
||||||
for {
|
|
||||||
fmt.Println("Which database adapter do you wish to use? mysql, mssql, or mysql? Default: mysql")
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
dbAdapter := strings.TrimSpace(scanner.Text())
|
|
||||||
if dbAdapter == "" {
|
|
||||||
dbAdapter = defaultAdapter
|
|
||||||
}
|
|
||||||
adap, ok = install.Lookup(dbAdapter)
|
|
||||||
if ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
fmt.Println("That adapter doesn't exist")
|
|
||||||
}
|
|
||||||
fmt.Println("Set database adapter to " + dbAdapter)
|
|
||||||
|
|
||||||
fmt.Println("Database Host? Default: " + defaultHost)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
dbHost = scanner.Text()
|
|
||||||
if dbHost == "" {
|
|
||||||
dbHost = defaultHost
|
|
||||||
}
|
|
||||||
fmt.Println("Set database host to " + dbHost)
|
|
||||||
|
|
||||||
fmt.Println("Database Username? Default: " + defaultUsername)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
dbUsername = scanner.Text()
|
|
||||||
if dbUsername == "" {
|
|
||||||
dbUsername = defaultUsername
|
|
||||||
}
|
|
||||||
fmt.Println("Set database username to " + dbUsername)
|
|
||||||
|
|
||||||
fmt.Println("Database Password? Default: ''")
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
dbPassword = scanner.Text()
|
|
||||||
if len(dbPassword) == 0 {
|
|
||||||
fmt.Println("You didn't set a password for this user. This won't block the installation process, but it might create security issues in the future.")
|
|
||||||
fmt.Println("")
|
|
||||||
} else {
|
|
||||||
fmt.Println("Set password to " + obfuscatePassword(dbPassword))
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Database Name? Pick a name you like or one provided to you. Default: " + defaultDbname)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
dbName = scanner.Text()
|
|
||||||
if dbName == "" {
|
|
||||||
dbName = defaultDbname
|
|
||||||
}
|
|
||||||
fmt.Println("Set database name to " + dbName)
|
|
||||||
|
|
||||||
adap.SetConfig(dbHost, dbUsername, dbPassword, dbName, adap.DefaultPort())
|
|
||||||
return adap, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSiteDetails() bool {
|
|
||||||
fmt.Println("Okay. We also need to know some actual information about your site!")
|
|
||||||
fmt.Println("What's your site's name? Default: " + defaultSiteName)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
siteName = scanner.Text()
|
|
||||||
if siteName == "" {
|
|
||||||
siteName = defaultSiteName
|
|
||||||
}
|
|
||||||
fmt.Println("Set the site name to " + siteName)
|
|
||||||
|
|
||||||
// ? - We could compute this based on the first letter of each word in the site's name, if it's name spans multiple words. I'm not sure how to do this for single word names.
|
|
||||||
fmt.Println("Can we have a short abbreviation for your site? Default: " + defaultSiteShortName)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
siteShortName = scanner.Text()
|
|
||||||
if siteShortName == "" {
|
|
||||||
siteShortName = defaultSiteShortName
|
|
||||||
}
|
|
||||||
fmt.Println("Set the short name to " + siteShortName)
|
|
||||||
|
|
||||||
fmt.Println("What's your site's url? Default: " + defaultsiteURL)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
siteURL = scanner.Text()
|
|
||||||
if siteURL == "" {
|
|
||||||
siteURL = defaultsiteURL
|
|
||||||
}
|
|
||||||
fmt.Println("Set the site url to " + siteURL)
|
|
||||||
|
|
||||||
fmt.Println("What port do you want the server to listen on? If you don't know what this means, you should probably leave it on the default. Default: " + defaultServerPort)
|
|
||||||
if !scanner.Scan() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
serverPort = scanner.Text()
|
|
||||||
if serverPort == "" {
|
|
||||||
serverPort = defaultServerPort
|
|
||||||
}
|
|
||||||
_, err := strconv.Atoi(serverPort)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("That's not a valid number!")
|
return err
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
fmt.Println("Set the server port to " + serverPort)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func obfuscatePassword(password string) (out string) {
|
// Build the admin user query
|
||||||
for i := 0; i < len(password); i++ {
|
adminUserStmt, err := qgen.Builder.SimpleInsert("users", "name, password, salt, email, group, is_super_admin, active, createdAt, lastActiveAt, lastLiked, oldestItemLikedCreatedAt, message, last_ip", "'Admin',?,?,'admin@localhost',1,1,1,UTC_TIMESTAMP(),UTC_TIMESTAMP(),UTC_TIMESTAMP(),UTC_TIMESTAMP(),'','127.0.0.1'")
|
||||||
out += "*"
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
func pressAnyKey() {
|
// Run the admin user query
|
||||||
//fmt.Println("Press any key to exit...")
|
_, err = adminUserStmt.Exec(hashedPassword, salt)
|
||||||
fmt.Println("Please press enter to exit...")
|
return err
|
||||||
for scanner.Scan() {
|
|
||||||
_ = scanner.Text()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package install
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"../../query_gen/lib"
|
|
||||||
)
|
|
||||||
|
|
||||||
var adapters = make(map[string]InstallAdapter)
|
|
||||||
|
|
||||||
type InstallAdapter interface {
|
|
||||||
Name() string
|
|
||||||
DefaultPort() string
|
|
||||||
SetConfig(dbHost string, dbUsername string, dbPassword string, dbName string, dbPort string)
|
|
||||||
InitDatabase() error
|
|
||||||
TableDefs() error
|
|
||||||
InitialData() error
|
|
||||||
CreateAdmin() error
|
|
||||||
|
|
||||||
DBHost() string
|
|
||||||
DBUsername() string
|
|
||||||
DBPassword() string
|
|
||||||
DBName() string
|
|
||||||
DBPort() string
|
|
||||||
}
|
|
||||||
|
|
||||||
func Lookup(name string) (InstallAdapter, bool) {
|
|
||||||
adap, ok := adapters[name]
|
|
||||||
return adap, ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func createAdmin() error {
|
|
||||||
fmt.Println("Creating the admin user")
|
|
||||||
hashedPassword, salt, err := BcryptGeneratePassword("password")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the admin user query
|
|
||||||
adminUserStmt, err := qgen.Builder.SimpleInsert("users", "name, password, salt, email, group, is_super_admin, active, createdAt, lastActiveAt, lastLiked, oldestItemLikedCreatedAt, message, last_ip", "'Admin',?,?,'admin@localhost',1,1,1,UTC_TIMESTAMP(),UTC_TIMESTAMP(),UTC_TIMESTAMP(),UTC_TIMESTAMP(),'','127.0.0.1'")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run the admin user query
|
|
||||||
_, err = adminUserStmt.Exec(hashedPassword, salt)
|
|
||||||
return err
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/denisenkom/go-mssqldb"
|
_ "github.com/denisenkom/go-mssqldb"
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
"register_username_too_long_prefix":"The username is too long, max: ",
|
"register_username_too_long_prefix":"The username is too long, max: ",
|
||||||
"register_email_fail":"We were unable to send the email for you to confirm that this email address belongs to you. You may not have access to some functionality until you do so. Please ask an administrator for assistance.",
|
"register_email_fail":"We were unable to send the email for you to confirm that this email address belongs to you. You may not have access to some functionality until you do so. Please ask an administrator for assistance.",
|
||||||
|
|
||||||
|
"alerts_no_new_alerts":"No new alerts",
|
||||||
"alerts_no_actor":"Unable to find the actor",
|
"alerts_no_actor":"Unable to find the actor",
|
||||||
"alerts_no_target_user":"Unable to find the target user",
|
"alerts_no_target_user":"Unable to find the target user",
|
||||||
"alerts_no_linked_topic":"Unable to find the linked topic",
|
"alerts_no_linked_topic":"Unable to find the linked topic",
|
||||||
|
@ -132,6 +133,7 @@
|
||||||
"account_mfa":"Manage 2FA",
|
"account_mfa":"Manage 2FA",
|
||||||
"account_mfa_setup":"Setup 2FA",
|
"account_mfa_setup":"Setup 2FA",
|
||||||
"account_email":"Email Manager",
|
"account_email":"Email Manager",
|
||||||
|
"account_level_list":"Level Progress",
|
||||||
|
|
||||||
"panel_dashboard":"Control Panel Dashboard",
|
"panel_dashboard":"Control Panel Dashboard",
|
||||||
"panel_forums":"Forum Manager",
|
"panel_forums":"Forum Manager",
|
||||||
|
|
12
main.go
12
main.go
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Gosora Main File
|
* Gosora Main File
|
||||||
* Copyright Azareal 2016 - 2018
|
* Copyright Azareal 2016 - 2019
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package main
|
package main // import "github.com/Azareal/Gosora"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -21,10 +21,10 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./common/counters"
|
"github.com/Azareal/Gosora/common/counters"
|
||||||
"./query_gen/lib"
|
"github.com/Azareal/Gosora/routes"
|
||||||
"./routes"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func recordMustExist(t *testing.T, err error, errmsg string, args ...interface{}) {
|
func recordMustExist(t *testing.T, err error, errmsg string, args ...interface{}) {
|
||||||
|
|
4
mssql.go
4
mssql.go
|
@ -12,8 +12,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/denisenkom/go-mssqldb"
|
_ "github.com/denisenkom/go-mssqldb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
4
mysql.go
4
mysql.go
|
@ -11,8 +11,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"../common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"../query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -16,6 +16,7 @@ func init() {
|
||||||
addPatch(5, patch5)
|
addPatch(5, patch5)
|
||||||
addPatch(6, patch6)
|
addPatch(6, patch6)
|
||||||
addPatch(7, patch7)
|
addPatch(7, patch7)
|
||||||
|
addPatch(8, patch8)
|
||||||
}
|
}
|
||||||
|
|
||||||
func patch0(scanner *bufio.Scanner) (err error) {
|
func patch0(scanner *bufio.Scanner) (err error) {
|
||||||
|
@ -131,91 +132,29 @@ func patch0(scanner *bufio.Scanner) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func patch1(scanner *bufio.Scanner) error {
|
func patch1(scanner *bufio.Scanner) error {
|
||||||
// ! Don't reuse this function blindly, it doesn't escape apostrophes
|
var routes = map[string]string{
|
||||||
var replaceTextWhere = func(replaceThis string, withThis string) error {
|
"routeAccountEditCriticalSubmit": "routes.AccountEditCriticalSubmit",
|
||||||
return execStmt(qgen.Builder.SimpleUpdate("viewchunks", "route = '"+withThis+"'", "route = '"+replaceThis+"'"))
|
"routeAccountEditAvatar": "routes.AccountEditAvatar",
|
||||||
|
"routeAccountEditAvatarSubmit": "routes.AccountEditAvatarSubmit",
|
||||||
|
"routeAccountEditUsername": "routes.AccountEditUsername",
|
||||||
|
"routeAccountEditUsernameSubmit": "routes.AccountEditUsernameSubmit",
|
||||||
}
|
}
|
||||||
|
return renameRoutes(routes)
|
||||||
err := replaceTextWhere("routeAccountEditCriticalSubmit", "routes.AccountEditCriticalSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeAccountEditAvatar", "routes.AccountEditAvatar")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeAccountEditAvatarSubmit", "routes.AccountEditAvatarSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeAccountEditUsername", "routes.AccountEditUsername")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeAccountEditUsernameSubmit", "routes.AccountEditUsernameSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func patch2(scanner *bufio.Scanner) error {
|
func patch2(scanner *bufio.Scanner) error {
|
||||||
// ! Don't reuse this function blindly, it doesn't escape apostrophes
|
var routes = map[string]string{
|
||||||
var replaceTextWhere = func(replaceThis string, withThis string) error {
|
"routeLogout": "routes.AccountLogout",
|
||||||
return execStmt(qgen.Builder.SimpleUpdate("viewchunks", "route = '"+withThis+"'", "route = '"+replaceThis+"'"))
|
"routeShowAttachment": "routes.ShowAttachment",
|
||||||
|
"routeChangeTheme": "routes.ChangeTheme",
|
||||||
|
"routeProfileReplyCreateSubmit": "routes.ProfileReplyCreateSubmit",
|
||||||
|
"routeLikeTopicSubmit": "routes.LikeTopicSubmit",
|
||||||
|
"routeReplyLikeSubmit": "routes.ReplyLikeSubmit",
|
||||||
|
"routeDynamic": "routes.DynamicRoute",
|
||||||
|
"routeUploads": "routes.UploadedFile",
|
||||||
|
"BadRoute": "routes.BadRoute",
|
||||||
}
|
}
|
||||||
|
return renameRoutes(routes)
|
||||||
err := replaceTextWhere("routeLogout", "routes.AccountLogout")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeShowAttachment", "routes.ShowAttachment")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeChangeTheme", "routes.ChangeTheme")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeProfileReplyCreateSubmit", "routes.ProfileReplyCreateSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeLikeTopicSubmit", "routes.LikeTopicSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeReplyLikeSubmit", "routes.ReplyLikeSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeDynamic", "routes.DynamicRoute")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeUploads", "routes.UploadedFile")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("BadRoute", "routes.BadRoute")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func patch3(scanner *bufio.Scanner) error {
|
func patch3(scanner *bufio.Scanner) error {
|
||||||
|
@ -241,187 +180,45 @@ func patch3(scanner *bufio.Scanner) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func patch4(scanner *bufio.Scanner) error {
|
func patch4(scanner *bufio.Scanner) error {
|
||||||
// ! Don't reuse this function blindly, it doesn't escape apostrophes
|
var routes = map[string]string{
|
||||||
var replaceTextWhere = func(replaceThis string, withThis string) error {
|
"routeReportSubmit": "routes.ReportSubmit",
|
||||||
return execStmt(qgen.Builder.SimpleUpdate("viewchunks", "route = '"+withThis+"'", "route = '"+replaceThis+"'"))
|
"routeAccountEditEmail": "routes.AccountEditEmail",
|
||||||
|
"routeAccountEditEmailTokenSubmit": "routes.AccountEditEmailTokenSubmit",
|
||||||
|
"routePanelLogsRegs": "panel.LogsRegs",
|
||||||
|
"routePanelLogsMod": "panel.LogsMod",
|
||||||
|
"routePanelLogsAdmin": "panel.LogsAdmin",
|
||||||
|
"routePanelDebug": "panel.Debug",
|
||||||
|
"routePanelAnalyticsViews": "panel.AnalyticsViews",
|
||||||
|
"routePanelAnalyticsRouteViews": "panel.AnalyticsRouteViews",
|
||||||
|
"routePanelAnalyticsRouteViews": "panel.AnalyticsRouteViews",
|
||||||
|
"routePanelAnalyticsAgentViews": "panel.AnalyticsAgentViews",
|
||||||
|
"routePanelAnalyticsForumViews": "panel.AnalyticsForumViews",
|
||||||
|
"routePanelAnalyticsSystemViews": "panel.AnalyticsSystemViews",
|
||||||
|
"routePanelAnalyticsLanguageViews": "panel.AnalyticsLanguageViews",
|
||||||
|
"routePanelAnalyticsReferrerViews": "panel.AnalyticsReferrerViews",
|
||||||
|
"routePanelAnalyticsTopics": "panel.AnalyticsTopics",
|
||||||
|
"routePanelAnalyticsPosts": "panel.AnalyticsPosts",
|
||||||
|
"routePanelAnalyticsForums": "panel.AnalyticsForums",
|
||||||
|
"routePanelAnalyticsRoutes": "panel.AnalyticsRoutes",
|
||||||
|
"routePanelAnalyticsAgents": "panel.AnalyticsAgents",
|
||||||
|
"routePanelAnalyticsSystems": "panel.AnalyticsSystems",
|
||||||
|
"routePanelAnalyticsLanguages": "panel.AnalyticsLanguages",
|
||||||
|
"routePanelAnalyticsReferrers": "panel.AnalyticsReferrers",
|
||||||
|
"routePanelSettings": "panel.Settings",
|
||||||
|
"routePanelSettingEdit": "panel.SettingEdit",
|
||||||
|
"routePanelSettingEditSubmit": "panel.SettingEditSubmit",
|
||||||
|
"routePanelForums": "panel.Forums",
|
||||||
|
"routePanelForumsCreateSubmit": "panel.ForumsCreateSubmit",
|
||||||
|
"routePanelForumsDelete": "panel.ForumsDelete",
|
||||||
|
"routePanelForumsDeleteSubmit": "panel.ForumsDeleteSubmit",
|
||||||
|
"routePanelForumsEdit": "panel.ForumsEdit",
|
||||||
|
"routePanelForumsEditSubmit": "panel.ForumsEditSubmit",
|
||||||
|
"routePanelForumsEditPermsSubmit": "panel.ForumsEditPermsSubmit",
|
||||||
|
"routePanelForumsEditPermsAdvance": "panel.ForumsEditPermsAdvance",
|
||||||
|
"routePanelForumsEditPermsAdvanceSubmit": "panel.ForumsEditPermsAdvanceSubmit",
|
||||||
|
"routePanelBackups": "panel.Backups",
|
||||||
}
|
}
|
||||||
|
err = renameRoutes(routes)
|
||||||
err := replaceTextWhere("routeReportSubmit", "routes.ReportSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeAccountEditEmail", "routes.AccountEditEmail")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routeAccountEditEmailTokenSubmit", "routes.AccountEditEmailTokenSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelLogsRegs", "panel.LogsRegs")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelLogsMod", "panel.LogsMod")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelLogsAdmin", "panel.LogsAdmin")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelDebug", "panel.Debug")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsViews", "panel.AnalyticsViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsRouteViews", "panel.AnalyticsRouteViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsRouteViews", "panel.AnalyticsRouteViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsAgentViews", "panel.AnalyticsAgentViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsForumViews", "panel.AnalyticsForumViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsSystemViews", "panel.AnalyticsSystemViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsLanguageViews", "panel.AnalyticsLanguageViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsReferrerViews", "panel.AnalyticsReferrerViews")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsTopics", "panel.AnalyticsTopics")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsPosts", "panel.AnalyticsPosts")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsForums", "panel.AnalyticsForums")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsRoutes", "panel.AnalyticsRoutes")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsAgents", "panel.AnalyticsAgents")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsSystems", "panel.AnalyticsSystems")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsLanguages", "panel.AnalyticsLanguages")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelAnalyticsReferrers", "panel.AnalyticsReferrers")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelSettings", "panel.Settings")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelSettingEdit", "panel.SettingEdit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelSettingEditSubmit", "panel.SettingEditSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForums", "panel.Forums")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsCreateSubmit", "panel.ForumsCreateSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsDelete", "panel.ForumsDelete")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsDeleteSubmit", "panel.ForumsDeleteSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsEdit", "panel.ForumsEdit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsEditSubmit", "panel.ForumsEditSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsEditPermsSubmit", "panel.ForumsEditPermsSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsEditPermsAdvance", "panel.ForumsEditPermsAdvance")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelForumsEditPermsAdvanceSubmit", "panel.ForumsEditPermsAdvanceSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelBackups", "panel.Backups")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -452,32 +249,14 @@ func patch4(scanner *bufio.Scanner) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func patch5(scanner *bufio.Scanner) error {
|
func patch5(scanner *bufio.Scanner) error {
|
||||||
// ! Don't reuse this function blindly, it doesn't escape apostrophes
|
var routes = map[string]string{
|
||||||
var replaceTextWhere = func(replaceThis string, withThis string) error {
|
"routePanelUsers": "panel.Users",
|
||||||
return execStmt(qgen.Builder.SimpleUpdate("viewchunks", "route = '"+withThis+"'", "route = '"+replaceThis+"'"))
|
"routePanelUsersEdit": "panel.UsersEdit",
|
||||||
|
"routePanelUsersEditSubmit": "panel.UsersEditSubmit",
|
||||||
|
"routes.AccountEditCritical": "routes.AccountEditPassword",
|
||||||
|
"routes.AccountEditCriticalSubmit": "routes.AccountEditPasswordSubmit",
|
||||||
}
|
}
|
||||||
|
err = renameRoutes(routes)
|
||||||
err := replaceTextWhere("routePanelUsers", "panel.Users")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelUsersEdit", "panel.UsersEdit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routePanelUsersEditSubmit", "panel.UsersEditSubmit")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routes.AccountEditCritical", "routes.AccountEditPassword")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = replaceTextWhere("routes.AccountEditCriticalSubmit", "routes.AccountEditPasswordSubmit")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -536,3 +315,65 @@ func patch7(scanner *bufio.Scanner) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func renameRoutes(routes map[string]string) error {
|
||||||
|
// ! Don't reuse this function blindly, it doesn't escape apostrophes
|
||||||
|
var replaceTextWhere = func(replaceThis string, withThis string) error {
|
||||||
|
return execStmt(qgen.Builder.SimpleUpdate("viewchunks", "route = '"+withThis+"'", "route = '"+replaceThis+"'"))
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value := range routes {
|
||||||
|
err := replaceTextWhere(key,value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func patch8(scanner *bufio.Scanner) error {
|
||||||
|
var routes = map[string]string{
|
||||||
|
"routePanelWordFilter": "panel.WordFilters",
|
||||||
|
"routePanelWordFiltersCreateSubmit": "panel.WordFiltersCreateSubmit",
|
||||||
|
"routePanelWordFiltersEdit": "panel.WordFiltersEdit",
|
||||||
|
"routePanelWordFiltersEditSubmit": "panel.WordFiltersEditSubmit",
|
||||||
|
"routePanelWordFiltersDeleteSubmit": "panel.WordFiltersDeleteSubmit",
|
||||||
|
"routePanelPlugins": "panel.Plugins",
|
||||||
|
"routePanelPluginsActivate": "panel.PluginsActivate",
|
||||||
|
"routePanelPluginsDeactivate": "panel.PluginsDeactivate",
|
||||||
|
"routePanelPluginsInstall": "panel.PluginsInstall",
|
||||||
|
"routePanelGroups": "panel.Groups",
|
||||||
|
"routePanelGroupsEdit":"panel.GroupsEdit",
|
||||||
|
"routePanelGroupsEditPerms":"panel.GroupsEditPerms",
|
||||||
|
"routePanelGroupsEditSubmit":"panel.GroupsEditSubmit",
|
||||||
|
"routePanelGroupsEditPermsSubmit":"panel.GroupsEditPermsSubmit",
|
||||||
|
"routePanelGroupsCreateSubmit":"panel.GroupsCreateSubmit",
|
||||||
|
"routePanelThemes","panel.Themes",
|
||||||
|
"routePanelThemesSetDefault":"panel.ThemesSetDefault",
|
||||||
|
"routePanelThemesMenus":"panel.ThemesMenus",
|
||||||
|
"routePanelThemesMenusEdit":"panel.ThemesMenusEdit",
|
||||||
|
"routePanelThemesMenuItemEdit":"panel.ThemesMenuItemEdit",
|
||||||
|
"routePanelThemesMenuItemEditSubmit":"panel.ThemesMenuItemEditSubmit",
|
||||||
|
"routePanelThemesMenuItemCreateSubmit":"panel.ThemesMenuItemCreateSubmit",
|
||||||
|
"routePanelThemesMenuItemDeleteSubmit":"panel.ThemesMenuItemDeleteSubmit",
|
||||||
|
"routePanelThemesMenuItemOrderSubmit":"panel.ThemesMenuItemOrderSubmit",
|
||||||
|
"routePanelDashboard":"panel.Dashboard",
|
||||||
|
}
|
||||||
|
err := renameRoutes(routes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = execStmt(qgen.Builder.CreateTable("updates", "", "",
|
||||||
|
[]qgen.DBTableColumn{
|
||||||
|
qgen.DBTableColumn{"dbVersion", "int", 0, false, false, "0"},
|
||||||
|
},
|
||||||
|
[]qgen.DBTableKey{},
|
||||||
|
))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import "../query_gen/lib"
|
import "github.com/Azareal/Gosora/query_gen"
|
||||||
|
|
||||||
func execStmt(stmt *sql.Stmt, err error) error {
|
func execStmt(stmt *sql.Stmt, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
4
pgsql.go
4
pgsql.go
|
@ -8,8 +8,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
"./query_gen/lib"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// WIP - Experimental adventure plugin, this might find a new home soon, but it's here to stress test Gosora's extensibility for now
|
// WIP - Experimental adventure plugin, this might find a new home soon, but it's here to stress test Gosora's extensibility for now
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "./common"
|
import "github.com/Azareal/Gosora/common"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.Plugins.Add(&common.Plugin{
|
common.Plugins.Add(&common.Plugin{
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"./common"
|
"github.com/Azareal/Gosora/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bbcodeRandom *rand.Rand
|
var bbcodeRandom *rand.Rand
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "./common"
|
import "github.com/Azareal/Gosora/common"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.Plugins.Add(&common.Plugin{UName: "heythere", Name: "Hey There", Author: "Azareal", URL: "https://github.com/Azareal", Init: initHeythere, Deactivate: deactivateHeythere})
|
common.Plugins.Add(&common.Plugin{UName: "heythere", Name: "Hey There", Author: "Azareal", URL: "https://github.com/Azareal", Init: initHeythere, Deactivate: deactivateHeythere})
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue