Added an installer which automatically populates the configuration file with information you provide. It also seeds the database with the necessary tables and data.

Added the likes table. This is a sign of what's to come.
Improved the installation instructions in README.md
Fixed the SQL in data.sql so that it no longer errors out.
The Admin user now has a default password.
Fixed a status indicator which I overlooked in the previous commit.
The Status field for topics is now deprecated.
Improved the efficiency of plugin_bbcode
Added more bat and shell files to make it easier for you to get things done.
This commit is contained in:
Azareal 2017-01-10 06:51:28 +00:00
parent 7833ad72fc
commit e835ca4148
20 changed files with 374 additions and 74 deletions

View File

@ -14,75 +14,71 @@ If you dislike it, please give us some feedback on how to make it better! We're
# Features # Features
Basic Forum Functionality. All of the little things you would expect of any forum software. E.g. Moderation, Custom Themes, Avatars, and so on. Basic Forum Functionality. All of the little things you would expect of any forum software. E.g. Moderation, Custom Themes, Avatars, and so on.
Custom Pages. Under development. Mainly the Control Panel portion to come, but you can create them by hand today. Custom Pages. Under development. The Control Panel portion is incomplete, but you can create them by hand today. They're basically html/templates templates in the /pages/ folder.
Emojis. Allow your users to express themselves without resorting to serving tons upon tons of image files. Emojis. Allow your users to express themselves without resorting to serving tons upon tons of image files.
In-memory static file, forum and group caches. We're pondering over extending this solution over to topics, users, etc. to some extent. In-memory static file, forum and group caches. We're pondering over extending this solution over to topics, users, etc.
A profile system including profile comments and moderation tools for the profile owner. A profile system including profile comments and moderation tools for the profile owner.
A template engine which compiles templates down into machine code. Over ten times faster than html/templates. Compatible with templates written for html/templates, you don't need to learn any new templating language. A template engine which compiles templates down into machine code. Over ten times faster than html/templates. Compatible with templates written for html/templates, you don't need to learn any new templating language.
A plugin system. Under development. A plugin system. More on this to come.
A responsive design. Looks great on mobile phones, tablets, laptops, desktops and more! A responsive design. Looks great on mobile phones, tablets, laptops, desktops and more!
# Dependencies # Dependencies
Go 1.7. The programming language this program is written in, and the compiler which it requires. You will need to install this. https://golang.org/doc/install Go 1.7. 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
MySQL Database. You will need to setup a MySQL Database somewhere. A MariaDB Database works equally well, and is much faster than MySQL. MySQL Database. You will need to setup a MySQL Database somewhere. A MariaDB Database works equally well and is much faster than MySQL.
If you're curious about how to install this, you might want to try the WNMP or XAMPP bundles on Windows. Download the .msi installer from ![MariaDB](https://mariadb.com/downloads) and run that. You may want to set it up as a service to avoid running it every-time the computer starts up.
We recommend changing the root password (that is the password for the user 'root'). Remember that password, you will need it for the installation process. Of course, we would advise using a user other than root for maximum security, although that adds additional steps to the process of getting everything setup.
Instructions on how to do so on Linux: https://downloads.mariadb.org/mariadb/repositories/ Instructions on how to do so on Linux: https://downloads.mariadb.org/mariadb/repositories/
It's entirely possible that your host might already have MySQL, so you might be able to skip this step, particularly if it's a managed VPS or a shared host (contrary to popular belief, it is possible, although the ecosystem in this regard is extremely immature). Or they might have a quicker and easier method of setting up MySQL.
# Installation Instructions # Installation Instructions
**Run the following commands:** *Linux*
go get -u github.com/go-sql-driver/mysql cd to the directory / folder the code is in. In other words, type cd followed by the location of the code and it should jump there.
go get -u golang.org/x/crypto/bcrypt Run ./install-gosora-linux
Tweak the config.go file and put your database details in there. Import data.sql into the same database. Comment out the first line (put /* and */ around it), if you've already made a database, and don't want the script to generate it for you. Follow the instructions shown on the screen.
Set the password column of your user account in the database to what you want your password to be. The system will encrypt your password when you login for the first time. *Windows*
Run install.bat
Follow the instructions shown on the screen.
You can run these commands again at any time to update these dependencies to their latest versions.
# Run the program # Run the program
*Linux* *Linux*
cd to the directory / folder the code is in. In the same directory you installed it, you simply have to type: ./run-gosora-linux
go build
./gosora
*Windows* *Windows*
Open up cmd.exe Run run.bat
cd to the directory / folder the code is in. E.g. `cd /Users/Blah/Documents/gosora` *Updating Dependencies*
You can update the dependencies which Gosora relies on by running update-deps.bat on Windows or ./update-deps-linux on Linux. These dependencies do not include Go or MySQL.
go build
./gosora.exe
Alternatively, you could run the run.bat batch file on Windows.
We're also looking into ways to distribute ready made executables for Windows. While this is not a complicated endeavour, the configuration settings currently get built with the rest of the program for speed, and we will likely have to change this. We're also looking into ways to distribute ready made executables for Windows. While this is not a complicated endeavour, the configuration settings currently get built with the rest of the program for speed, and we will likely have to change this.
With the introduction of the new settings system, we will begin moving some of the less critical settings out of the configuration file, and will likely have a config.xml or config.ini in the future to store the critical settings in. With the introduction of the new settings system, we will begin moving some of the less critical settings out of the configuration file, and will likely have a config.xml or config.ini in the future to store the critical settings in.
You might have to go build, run the executable, and then go build and then run the executable again to make sure the templates are compiled properly. We'll be resolving this issue while we roll out the new compiled templates system to the rest of the routes. You might have to run run.bat or ./run-gosora-linux twice after changing a template to make sure the templates are compiled properly. We'll be resolving this issue while rolling out the new compiled templates system to the rest of the routes.
Several important features for saving memory in the templates system may have to be implemented before the new compiled template system is rolled out to every route. These features are coming fairly soon, but not before the other more high priority items. Several important features for saving memory in the templates system may have to be implemented before the new compiled template system is rolled out to every route. These features are coming fairly soon, but not before the higher priority items.
# How do I install plugins? # How do I install plugins?
@ -117,7 +113,7 @@ More moderation features. E.g. Move, Approval Queue (Posts made by users in cert
Add a simple anti-spam measure. I have quite a few ideas in mind, but it'll take a while to implement the more advanced ones, so I'd like to put off some of those to a later date and focus on the basics. E.g. CAPTCHAs, hidden fields, etc. Add a simple anti-spam measure. I have quite a few ideas in mind, but it'll take a while to implement the more advanced ones, so I'd like to put off some of those to a later date and focus on the basics. E.g. CAPTCHAs, hidden fields, etc.
Add an alert system. Add a modern alert system.
Add per-forum permissions to finish up the foundations of the permissions system. Add per-forum permissions to finish up the foundations of the permissions system.
@ -125,13 +121,19 @@ Add a *better* plugin system. E.g. Allow for plugins written in Javascript and o
I will need to ponder over implementing an even faster router. We don't need one immediately, although it would be nice if we could get one in the near future. It really depends. Ideally, it would be one which can easily integrate with the current structure without much work, although I'm not beyond making some alterations to faciliate it, assuming that we don't get too tightly bound to that specific router. I will need to ponder over implementing an even faster router. We don't need one immediately, although it would be nice if we could get one in the near future. It really depends. Ideally, it would be one which can easily integrate with the current structure without much work, although I'm not beyond making some alterations to faciliate it, assuming that we don't get too tightly bound to that specific router.
Allow themes to define their own templates. Allow themes to define their own templates and to override core templates with their own.
Add a friend system. Add a friend system.
Improve profile customisability.
Implement all the common BBCode tags in plugin_bbcode
Implement all the common Markdown codes in plugin_markdown
Add more administration features. Add more administration features.
Add more features for improving user engagement. I have quite a few of these in mind, but I'm mostly occupied with implementing the essentials right now. Add more features for improving user engagement. E.g. A like system. I have a few of these in mind, but I've been pre-occupied with implementing other features.
Add a widget system. Add a widget system.

2
build-gosora-linux Normal file
View File

@ -0,0 +1,2 @@
go build
go build ./install

View File

@ -1,2 +1,3 @@
go build go build
go build ./install
pause pause

View File

@ -1,7 +1,7 @@
package main package main
// Database details // Database details
var dbhost = "127.0.0.1" var dbhost = "localhost"
var dbuser = "root" var dbuser = "root"
var dbpassword = "password" var dbpassword = "password"
var dbname = "gosora" var dbname = "gosora"

View File

@ -1,5 +1,3 @@
CREATE DATABASE grosolo;
CREATE TABLE `users`( CREATE TABLE `users`(
`uid` int not null AUTO_INCREMENT, `uid` int not null AUTO_INCREMENT,
`name` varchar(100) not null, `name` varchar(100) not null,
@ -92,6 +90,14 @@ CREATE TABLE `users_replies`(
primary key(`rid`) primary key(`rid`)
) CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; ) CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
CREATE TABLE `likes`(
`weight` int DEFAULT 1 not null,
`type` int not null, /* Regular Post = 1, Big Post = 2, Mega Post = 3, etc.*/
`targetItem` int not null,
`sentBy` int not null,
`recalc` tinyint DEFAULT 0 not null
);
CREATE TABLE `settings`( CREATE TABLE `settings`(
`name` varchar(200) not null, `name` varchar(200) not null,
`content` varchar(250) not null, `content` varchar(250) not null,
@ -113,11 +119,11 @@ CREATE TABLE `themes`(
); );
INSERT INTO settings(`name`,`content`,`type`) VALUES ('url_tags','1','bool'); INSERT INTO settings(`name`,`content`,`type`) VALUES ('url_tags','1','bool');
INSERT INTO settings(`name`,`content`,`type`,`constraints`) VALUES ('activation_type','1','list','1-3',); INSERT INTO settings(`name`,`content`,`type`,`constraints`) VALUES ('activation_type','1','list','1-3');
INSERT INTO themes(`uname`,`default`) VALUES ('tempra-simple',1); INSERT INTO themes(`uname`,`default`) VALUES ('tempra-simple',1);
INSERT INTO users(`name`,`email`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`,`message`) INSERT INTO users(`name`,`password`,`email`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`,`message`)
VALUES ('Admin','admin@localhost',1,1,NOW(),NOW(),''); VALUES ('Admin','password','admin@localhost',1,1,NOW(),NOW(),'');
INSERT INTO emails(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1); INSERT INTO emails(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
/* /*
@ -148,11 +154,11 @@ PinTopic
CloseTopic CloseTopic
*/ */
INSERT INTO users_groups(`name`,`permissions`,`active`,`is_mod`,`is_admin`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewIPs":true,"ViewTopic":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,1,1,"Admin"); INSERT INTO users_groups(`name`,`permissions`,`is_mod`,`is_admin`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewIPs":true,"ViewTopic":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,1,"Admin");
INSERT INTO users_groups(`name`,`permissions`,`is_mod`,`tag`) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":false,"EditUser":true,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":true,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":true,"ViewTopic":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,"Mod"); INSERT INTO users_groups(`name`,`permissions`,`is_mod`,`tag`) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":false,"EditUser":true,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":true,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":true,"ViewTopic":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,"Mod");
INSERT INTO users_groups(`name`,`permissions`) VALUES ('Member','{"BanUsers":false,"ActivateUsers":false,"EditUser":false,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":false,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":false,"ViewTopic":true,"CreateTopic":true,"EditTopic":false,"DeleteTopic":false,"CreateReply":true,"EditReply":false,"DeleteReply":false,"PinTopic":false,"CloseTopic":false}'); INSERT INTO users_groups(`name`,`permissions`) VALUES ('Member','{"BanUsers":false,"ActivateUsers":false,"EditUser":false,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":false,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":false,"ViewTopic":true,"CreateTopic":true,"EditTopic":false,"DeleteTopic":false,"CreateReply":true,"EditReply":false,"DeleteReply":false,"PinTopic":false,"CloseTopic":false}');
INSERT INTO users_groups(`name`,`permissions`,`is_banned`) VALUES ('Banned','{"BanUsers":false,"ActivateUsers":false,"EditUser":false,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":false,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":false,"ViewTopic":true,"CreateTopic":false,"EditTopic":false,"DeleteTopic":false,"CreateReply":false,"EditReply":false,"DeleteReply":false,"PinTopic":false,"CloseTopic":false}',1); INSERT INTO users_groups(`name`,`permissions`,`is_banned`) VALUES ('Banned','{"BanUsers":false,"ActivateUsers":false,"EditUser":false,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":false,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":false,"ViewTopic":true,"CreateTopic":false,"EditTopic":false,"DeleteTopic":false,"CreateReply":false,"EditReply":false,"DeleteReply":false,"PinTopic":false,"CloseTopic":false}',1);
INSERT INTO users_groups(`name`,`permissions`,`is_banned`) VALUES ('Awaiting Activation','{"BanUsers":false,"ActivateUsers":false,"EditUser":false,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":false,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":false,"ViewTopic":true,"CreateTopic":false,"EditTopic":false,"DeleteTopic":false,"CreateReply":false,"EditReply":false,"DeleteReply":false,"PinTopic":false,"CloseTopic":false}'); INSERT INTO users_groups(`name`,`permissions`) VALUES ('Awaiting Activation','{"BanUsers":false,"ActivateUsers":false,"EditUser":false,"EditUserEmail":false,"EditUserPassword":false,"EditUserGroup":false,"EditUserGroupSuperMod":false,"EditUserGroupAdmin":false,"ManageForums":false,"EditSettings":false,"ManageThemes":false,"ManagePlugins":false,"ViewIPs":false,"ViewTopic":true,"CreateTopic":false,"EditTopic":false,"DeleteTopic":false,"CreateReply":false,"EditReply":false,"DeleteReply":false,"PinTopic":false,"CloseTopic":false}');
INSERT INTO forums(`name`,`lastTopicTime`) VALUES ('General',NOW()); INSERT INTO forums(`name`,`lastTopicTime`) VALUES ('General',NOW());
INSERT INTO topics(`title`,`content`,`createdAt`,`lastReplyAt`,`createdBy`,`parentID`) INSERT INTO topics(`title`,`content`,`createdAt`,`lastReplyAt`,`createdBy`,`parentID`)

View File

@ -1,2 +0,0 @@
go build
./Gosora

BIN
images/installer.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

5
install-gosora-linux Normal file
View File

@ -0,0 +1,5 @@
go get -u github.com/go-sql-driver/mysql
go get -u golang.org/x/crypto/bcrypt
go build
go build ./install
./Install

5
install.bat Normal file
View File

@ -0,0 +1,5 @@
go get -u github.com/go-sql-driver/mysql
go get -u golang.org/x/crypto/bcrypt
go build
go build ./install
install.exe

294
install/install.go Normal file
View File

@ -0,0 +1,294 @@
/* Copyright Azareal 2017 - 2018 */
package main
import "fmt"
import "os"
import "bytes"
import "bufio"
import "strconv"
import "io/ioutil"
import "database/sql"
import _ "github.com/go-sql-driver/mysql"
var scanner *bufio.Scanner
var db_host string
var db_username string
var db_password string
var db_name string
//var db_collation string = "utf8mb4_general_ci"
var db_port string = "3306"
var site_name string
var site_url string
var server_port string
var default_host string = "localhost"
var default_username string = "root"
var default_dbname string = "gosora2"
var default_site_name string = "Site Name"
var default_site_url string = "localhost"
var default_server_port string = "80" // 8080's a good one, if you're testing and don't want it to clash with port 80
func main() {
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 :)")
if !get_database_details() {
err := scanner.Err()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Something went wrong!")
}
fmt.Println("Aborting installation...")
press_any_key()
return
}
if !get_site_details() {
err := scanner.Err()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Something went wrong!")
}
fmt.Println("Aborting installation...")
press_any_key()
return
}
_db_password := db_password
if(_db_password != ""){
_db_password = ":" + _db_password
}
db, err := sql.Open("mysql",db_username + _db_password + "@tcp(" + db_host + ":" + db_port + ")/")
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
// Make sure that the connection is alive..
err = db.Ping()
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
fmt.Println("Successfully connected to the database")
fmt.Println("Opening the database seed file")
sqlContents, err := ioutil.ReadFile("./data.sql")
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
var waste string
err = db.QueryRow("SHOW DATABASES LIKE '" + db_name + "'").Scan(&waste)
if err != nil && err != sql.ErrNoRows {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
if err == sql.ErrNoRows {
fmt.Println("Unable to find the database. Attempting to create it")
_,err = db.Exec("CREATE DATABASE IF NOT EXISTS " + db_name + "")
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
fmt.Println("The database was successfully created")
}
fmt.Println("Switching to database " + db_name)
_, err = db.Exec("USE " + db_name)
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
fmt.Println("Preparing installation queries")
sqlContents = bytes.TrimSpace(sqlContents)
statements := bytes.Split(sqlContents, []byte(";"))
for key, statement := range statements {
if len(statement) == 0 {
continue
}
fmt.Println("Executing query #" + strconv.Itoa(key) + " " + string(statement))
_, err = db.Exec(string(statement))
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
}
fmt.Println("Finished inserting the database data")
configContents := []byte(`package main
// Database details
var dbhost = "` + db_host + `"
var dbuser = "` + db_username + `"
var dbpassword = "` + db_password + `"
var dbname = "` + db_name + `"
var dbport = "` + db_port + `" // You probably won't need to change this
// Limiters
var max_request_size = 5 * megabyte
// Misc
var default_route = route_topics
var default_group = 3 // Should be a setting
var activation_group = 5 // Should be a setting
var staff_css = " background-color: #ffeaff;"
var uncategorised_forum_visible = true
var enable_emails = false
var site_name = "` + site_name + `" // Should be a setting
var site_email = "" // Should be a setting
var smtp_server = ""
//var noavatar = "https://api.adorable.io/avatars/{width}/{id}@{site_url}.png"
var noavatar = "https://api.adorable.io/avatars/285/{id}@" + site_url + ".png"
var items_per_page = 40 // Should be a setting
var site_url = "` + site_url + `"
var server_port = "` + server_port + `"
var enable_ssl = false
var ssl_privkey = ""
var ssl_fullchain = ""
// Developer flag
var debug = false
`)
fmt.Println("Opening the configuration file")
configFile, err := os.Create("./config.go")
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
return
}
fmt.Println("Writing to the configuration file...")
_, err = configFile.Write(configContents)
if err != nil {
fmt.Println(err)
fmt.Println("Aborting installation...")
press_any_key()
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.")
press_any_key()
}
func get_database_details() bool {
fmt.Println("Database Host? Default: " + default_host)
if !scanner.Scan() {
return false
}
db_host = scanner.Text()
if db_host == "" {
db_host = default_host
}
fmt.Println("Set database host to " + db_host)
fmt.Println("Database Username? Default: " + default_username)
if !scanner.Scan() {
return false
}
db_username = scanner.Text()
if db_username == "" {
db_username = default_username
}
fmt.Println("Set database username to " + db_username)
fmt.Println("Database Password? Default: ''")
if !scanner.Scan() {
return false
}
db_password = scanner.Text()
if len(db_password) == 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.\n")
} else {
fmt.Println("Set password to " + obfuscate_password(db_password))
}
fmt.Println("Database Name? Pick a name you like or one provided to you. Default: " + default_dbname)
if !scanner.Scan() {
return false
}
db_name = scanner.Text()
if db_name == "" {
db_name = default_dbname
}
fmt.Println("Set database name to " + db_name)
return true
}
func get_site_details() bool {
fmt.Println("Okay. We also need to know some actual information about your site!")
fmt.Println("What's your site's name? Default: " + default_site_name)
if !scanner.Scan() {
return false
}
site_name = scanner.Text()
if site_name == "" {
site_name = default_site_name
}
fmt.Println("Set the site name to " + site_name)
fmt.Println("What's your site's url? Default: " + default_site_url)
if !scanner.Scan() {
return false
}
site_url = scanner.Text()
if site_url == "" {
site_url = default_site_url
}
fmt.Println("Set the site url to " + site_url)
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: " + default_server_port)
if !scanner.Scan() {
return false
}
server_port = scanner.Text()
if server_port == "" {
server_port = default_server_port
}
fmt.Println("Set the server port to " + server_port)
return true
}
func obfuscate_password(password string) (out string) {
for i := 0; i < len(password); i++ {
out += "*"
}
return out
}
func press_any_key() {
//fmt.Println("Press any key to exit...")
fmt.Println("Please press enter to exit...")
for scanner.Scan() {
_ = scanner.Text()
return
}
}

View File

@ -5,7 +5,7 @@ import "regexp"
type Page struct type Page struct
{ {
Title string Title string
Name string // What's the point of this field? If we're not going to use it, remove it. Name string // Deprecated. Marked for removal.
CurrentUser User CurrentUser User
NoticeList map[int]string NoticeList map[int]string
ItemList []interface{} ItemList []interface{}

View File

@ -248,7 +248,7 @@ func bbcode_full_parse(data interface{}) interface{} {
if complex_bbc { if complex_bbc {
var start int var start int
var lastTag int var lastTag int
var outbytes []byte outbytes := make([]byte, len(msgbytes))
for i := 0; i < len(msgbytes); i++ { for i := 0; i < len(msgbytes); i++ {
MainLoop: MainLoop:
if msgbytes[i] == '[' { if msgbytes[i] == '[' {

View File

@ -108,11 +108,6 @@ func route_topics(w http.ResponseWriter, r *http.Request){
return return
} }
if topicItem.Is_Closed {
topicItem.Status = "closed"
} else {
topicItem.Status = "open"
}
if topicItem.Avatar != "" { if topicItem.Avatar != "" {
if topicItem.Avatar[0] == '.' { if topicItem.Avatar[0] == '.' {
topicItem.Avatar = "/uploads/avatar_" + strconv.Itoa(topicItem.CreatedBy) + topicItem.Avatar topicItem.Avatar = "/uploads/avatar_" + strconv.Itoa(topicItem.CreatedBy) + topicItem.Avatar
@ -182,11 +177,6 @@ func route_forum(w http.ResponseWriter, r *http.Request){
return return
} }
if topicItem.Is_Closed {
topicItem.Status = "closed"
} else {
topicItem.Status = "open"
}
if topicItem.Avatar != "" { if topicItem.Avatar != "" {
if topicItem.Avatar[0] == '.' { if topicItem.Avatar[0] == '.' {
topicItem.Avatar = "/uploads/avatar_" + strconv.Itoa(topicItem.CreatedBy) + topicItem.Avatar topicItem.Avatar = "/uploads/avatar_" + strconv.Itoa(topicItem.CreatedBy) + topicItem.Avatar
@ -296,16 +286,11 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
topic.Content = template.HTML(parse_message(content)) topic.Content = template.HTML(parse_message(content))
topic.ContentLines = strings.Count(content,"\n") topic.ContentLines = strings.Count(content,"\n")
if topic.Is_Closed { // We don't want users posting in locked topics...
topic.Status = "closed" if topic.Is_Closed && !user.Is_Mod {
user.Perms.CreateReply = false
// We don't want users posting in locked topics...
if !user.Is_Mod {
user.Perms.CreateReply = false
}
} else {
topic.Status = "open"
} }
if topic.Avatar != "" { if topic.Avatar != "" {
if topic.Avatar[0] == '.' { if topic.Avatar[0] == '.' {
topic.Avatar = "/uploads/avatar_" + strconv.Itoa(topic.CreatedBy) + topic.Avatar topic.Avatar = "/uploads/avatar_" + strconv.Itoa(topic.CreatedBy) + topic.Avatar

3
run-gosora-linux Normal file
View File

@ -0,0 +1,3 @@
go build
go build ./install
./Gosora

View File

@ -86,13 +86,9 @@ w.Write([]byte(`background-color: #eaeaea;`))
w.Write([]byte(`"> w.Write([]byte(`">
<a href="/topic/` + strconv.Itoa(item.ID) + `">` + item.Title + `</a> `)) <a href="/topic/` + strconv.Itoa(item.ID) + `">` + item.Title + `</a> `))
if item.Is_Closed { if item.Is_Closed {
w.Write([]byte(`<span class="username topic_status_e topic_status_closed" style="float: right;">closed</span> w.Write([]byte(`<span class="username topic_status_e topic_status_closed" title="Status: Closed" style="float: right;">&#x1F512;&#xFE0E</span>`))
`))
} else {
w.Write([]byte(`<span class="username hide_on_micro topic_status_e topic_status_open" style="float: right;">open</span>`))
} }
w.Write([]byte(` w.Write([]byte(`
<span class="username hide_on_micro" style="border-right: 0;float: right;">Status</span>
</div> </div>
`)) `))
} }

View File

@ -1,8 +1,8 @@
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */ /* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main package main
import "io"
import "strconv" import "strconv"
import "html/template" import "html/template"
import "io"
func init() { func init() {
template_topic_alt_handle = template_topic_alt template_topic_alt_handle = template_topic_alt

View File

@ -4,9 +4,7 @@
</div> </div>
<div class="rowblock"> <div class="rowblock">
{{range .ItemList}}<div class="rowitem passive" style="{{ if .Avatar }}background-image: url({{ .Avatar }});background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;{{end}}{{ if .Sticky }}background-color: #FFFFCC;{{else if .Is_Closed}}background-color: #eaeaea;{{end}}"> {{range .ItemList}}<div class="rowitem passive" style="{{ if .Avatar }}background-image: url({{ .Avatar }});background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;{{end}}{{ if .Sticky }}background-color: #FFFFCC;{{else if .Is_Closed}}background-color: #eaeaea;{{end}}">
<a href="/topic/{{.ID}}">{{.Title}}</a> {{if .Is_Closed}}<span class="username topic_status_e topic_status_closed" style="float: right;">closed</span> <a href="/topic/{{.ID}}">{{.Title}}</a> {{if .Is_Closed}}<span class="username topic_status_e topic_status_closed" title="Status: Closed" style="float: right;">&#x1F512;&#xFE0E</span>{{end}}
{{else}}<span class="username hide_on_micro topic_status_e topic_status_open" style="float: right;">open</span>{{end}}
<span class="username hide_on_micro" style="border-right: 0;float: right;">Status</span>
</div> </div>
{{else}}<div class="rowitem passive">There aren't any topics in this forum yet.</div>{{end}} {{else}}<div class="rowitem passive">There aren't any topics in this forum yet.</div>{{end}}
</div> </div>

View File

@ -11,7 +11,7 @@ type Topic struct
Sticky bool Sticky bool
CreatedAt string CreatedAt string
ParentID int ParentID int
Status string Status string // Deprecated. Marked for removal.
} }
type TopicUser struct type TopicUser struct
@ -24,7 +24,7 @@ type TopicUser struct
Sticky bool Sticky bool
CreatedAt string CreatedAt string
ParentID int ParentID int
Status string Status string // Deprecated. Marked for removal.
CreatedByName string CreatedByName string
Avatar string Avatar string

2
update-deps-linux Normal file
View File

@ -0,0 +1,2 @@
go get -u github.com/go-sql-driver/mysql
go get -u golang.org/x/crypto/bcrypt

3
update-deps.bat Normal file
View File

@ -0,0 +1,3 @@
go get -u github.com/go-sql-driver/mysql
go get -u golang.org/x/crypto/bcrypt
pause