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:
parent
7833ad72fc
commit
e835ca4148
66
README.md
66
README.md
|
@ -14,75 +14,71 @@ If you dislike it, please give us some feedback on how to make it better! We're
|
|||
# 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.
|
||||
|
||||
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.
|
||||
|
||||
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 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!
|
||||
|
||||
|
||||
# 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.
|
||||
If you're curious about how to install this, you might want to try the WNMP or XAMPP bundles on Windows.
|
||||
MySQL Database. You will need to setup a MySQL Database somewhere. A MariaDB Database works equally well and is much faster than MySQL.
|
||||
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/
|
||||
|
||||
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
|
||||
|
||||
**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
|
||||
|
||||
*Linux*
|
||||
|
||||
cd to the directory / folder the code is in.
|
||||
|
||||
go build
|
||||
|
||||
./gosora
|
||||
|
||||
In the same directory you installed it, you simply have to type: ./run-gosora-linux
|
||||
|
||||
*Windows*
|
||||
|
||||
Open up cmd.exe
|
||||
Run run.bat
|
||||
|
||||
cd to the directory / folder the code is in. E.g. `cd /Users/Blah/Documents/gosora`
|
||||
|
||||
go build
|
||||
|
||||
./gosora.exe
|
||||
|
||||
|
||||
Alternatively, you could run the run.bat batch file on Windows.
|
||||
*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.
|
||||
|
||||
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.
|
||||
|
||||
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?
|
||||
|
@ -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 an alert system.
|
||||
Add a modern alert 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.
|
||||
|
||||
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.
|
||||
|
||||
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 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.
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
go build
|
||||
go build ./install
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
// Database details
|
||||
var dbhost = "127.0.0.1"
|
||||
var dbhost = "localhost"
|
||||
var dbuser = "root"
|
||||
var dbpassword = "password"
|
||||
var dbname = "gosora"
|
||||
|
|
20
data.sql
20
data.sql
|
@ -1,5 +1,3 @@
|
|||
CREATE DATABASE grosolo;
|
||||
|
||||
CREATE TABLE `users`(
|
||||
`uid` int not null AUTO_INCREMENT,
|
||||
`name` varchar(100) not null,
|
||||
|
@ -92,6 +90,14 @@ CREATE TABLE `users_replies`(
|
|||
primary key(`rid`)
|
||||
) 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`(
|
||||
`name` varchar(200) 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`,`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 users(`name`,`email`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`,`message`)
|
||||
VALUES ('Admin','admin@localhost',1,1,NOW(),NOW(),'');
|
||||
INSERT INTO users(`name`,`password`,`email`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`,`message`)
|
||||
VALUES ('Admin','password','admin@localhost',1,1,NOW(),NOW(),'');
|
||||
INSERT INTO emails(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
|
||||
|
||||
/*
|
||||
|
@ -148,11 +154,11 @@ PinTopic
|
|||
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`) 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 ('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 topics(`title`,`content`,`createdAt`,`lastReplyAt`,`createdBy`,`parentID`)
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
go build
|
||||
./Gosora
|
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
}
|
||||
}
|
2
pages.go
2
pages.go
|
@ -5,7 +5,7 @@ import "regexp"
|
|||
type Page struct
|
||||
{
|
||||
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
|
||||
NoticeList map[int]string
|
||||
ItemList []interface{}
|
||||
|
|
|
@ -248,7 +248,7 @@ func bbcode_full_parse(data interface{}) interface{} {
|
|||
if complex_bbc {
|
||||
var start int
|
||||
var lastTag int
|
||||
var outbytes []byte
|
||||
outbytes := make([]byte, len(msgbytes))
|
||||
for i := 0; i < len(msgbytes); i++ {
|
||||
MainLoop:
|
||||
if msgbytes[i] == '[' {
|
||||
|
|
23
routes.go
23
routes.go
|
@ -108,11 +108,6 @@ func route_topics(w http.ResponseWriter, r *http.Request){
|
|||
return
|
||||
}
|
||||
|
||||
if topicItem.Is_Closed {
|
||||
topicItem.Status = "closed"
|
||||
} else {
|
||||
topicItem.Status = "open"
|
||||
}
|
||||
if topicItem.Avatar != "" {
|
||||
if topicItem.Avatar[0] == '.' {
|
||||
topicItem.Avatar = "/uploads/avatar_" + strconv.Itoa(topicItem.CreatedBy) + topicItem.Avatar
|
||||
|
@ -182,11 +177,6 @@ func route_forum(w http.ResponseWriter, r *http.Request){
|
|||
return
|
||||
}
|
||||
|
||||
if topicItem.Is_Closed {
|
||||
topicItem.Status = "closed"
|
||||
} else {
|
||||
topicItem.Status = "open"
|
||||
}
|
||||
if topicItem.Avatar != "" {
|
||||
if topicItem.Avatar[0] == '.' {
|
||||
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.ContentLines = strings.Count(content,"\n")
|
||||
|
||||
if topic.Is_Closed {
|
||||
topic.Status = "closed"
|
||||
|
||||
// We don't want users posting in locked topics...
|
||||
if !user.Is_Mod {
|
||||
user.Perms.CreateReply = false
|
||||
}
|
||||
} else {
|
||||
topic.Status = "open"
|
||||
// We don't want users posting in locked topics...
|
||||
if topic.Is_Closed && !user.Is_Mod {
|
||||
user.Perms.CreateReply = false
|
||||
}
|
||||
|
||||
if topic.Avatar != "" {
|
||||
if topic.Avatar[0] == '.' {
|
||||
topic.Avatar = "/uploads/avatar_" + strconv.Itoa(topic.CreatedBy) + topic.Avatar
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
go build
|
||||
go build ./install
|
||||
./Gosora
|
|
@ -86,13 +86,9 @@ w.Write([]byte(`background-color: #eaeaea;`))
|
|||
w.Write([]byte(`">
|
||||
<a href="/topic/` + strconv.Itoa(item.ID) + `">` + item.Title + `</a> `))
|
||||
if item.Is_Closed {
|
||||
w.Write([]byte(`<span class="username topic_status_e topic_status_closed" style="float: right;">closed</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(`<span class="username topic_status_e topic_status_closed" title="Status: Closed" style="float: right;">🔒︎</span>`))
|
||||
}
|
||||
w.Write([]byte(`
|
||||
<span class="username hide_on_micro" style="border-right: 0;float: right;">Status</span>
|
||||
</div>
|
||||
`))
|
||||
}
|
||||
|
|
|
@ -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. */
|
||||
package main
|
||||
import "io"
|
||||
import "strconv"
|
||||
import "html/template"
|
||||
import "io"
|
||||
|
||||
func init() {
|
||||
template_topic_alt_handle = template_topic_alt
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
</div>
|
||||
<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}}">
|
||||
<a href="/topic/{{.ID}}">{{.Title}}</a> {{if .Is_Closed}}<span class="username topic_status_e topic_status_closed" style="float: right;">closed</span>
|
||||
{{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>
|
||||
<a href="/topic/{{.ID}}">{{.Title}}</a> {{if .Is_Closed}}<span class="username topic_status_e topic_status_closed" title="Status: Closed" style="float: right;">🔒︎</span>{{end}}
|
||||
</div>
|
||||
{{else}}<div class="rowitem passive">There aren't any topics in this forum yet.</div>{{end}}
|
||||
</div>
|
||||
|
|
4
topic.go
4
topic.go
|
@ -11,7 +11,7 @@ type Topic struct
|
|||
Sticky bool
|
||||
CreatedAt string
|
||||
ParentID int
|
||||
Status string
|
||||
Status string // Deprecated. Marked for removal.
|
||||
}
|
||||
|
||||
type TopicUser struct
|
||||
|
@ -24,7 +24,7 @@ type TopicUser struct
|
|||
Sticky bool
|
||||
CreatedAt string
|
||||
ParentID int
|
||||
Status string
|
||||
Status string // Deprecated. Marked for removal.
|
||||
|
||||
CreatedByName string
|
||||
Avatar string
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
go get -u github.com/go-sql-driver/mysql
|
||||
go get -u golang.org/x/crypto/bcrypt
|
|
@ -0,0 +1,3 @@
|
|||
go get -u github.com/go-sql-driver/mysql
|
||||
go get -u golang.org/x/crypto/bcrypt
|
||||
pause
|
Loading…
Reference in New Issue