diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b677ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +config/config.json +config/about_page.htmlbody + +# nano +.swp diff --git a/README.md b/README.md index c34c0c8..4b7754f 100644 --- a/README.md +++ b/README.md @@ -4,104 +4,49 @@ This is the source code for the ThreadR Forum Engine, rewritten in Go. ThreadR i ## Project Overview -Originally started as a school project in 2019 with the aim of creating a hybrid between a forum and a social media platform, ThreadR was temporarily abandoned after school ended. Revived in 2020, the project shifted focus to become a fully functional, portable, and open-source forum engine under the Apache 2.0 license. +ThreadR was originally started as a school project in 2019 with the aim of creating a hybrid between a forum and a social media platform. It was built with PHP and (back then still) MySQL. +After we finished school, it was temporarily abandoned. An attempt was made to revive it in 2020, open-sourcing the code and making some things configurable, but not much else happened. +Here we are now, with a full rewrite in Go started in 2025. -### Current Goals -- [ ] Bring ThreadR back online (see issue #2) -- [ ] Go FOSS by making the source code publicly available (see issue #5) -- [ ] Ensure portability for easy setup of personal instances -- [ ] Implement core forum features (sign-up, board creation, threads, messages, profiles) +## Project Setup -### Future Features -- Anonymous posting with unique per-thread identifiers for registered users -- Thread subscription and notifications for new messages (opt-out available) -- "Split thread here" functionality for focused discussions -- Automatic loading of new messages in threads (opt-out in settings) -- Question threads with an "accept answer" feature -- Nuanced like/dislike system (limited functionality, inspired by StackExchange) - -**Note:** ThreadR is now technically host-independent with configurable settings, though it remains a work in progress (WIP). - -## Installation - -ThreadR is in early development, and setup is currently manual. Automated setup scripts will be added in the future. +This is for development only. Currently, ThreadR is not ready for production use. ### Prerequisites -This guide assumes you are on a UNIX-like system with the following installed: -- Apache with PHP (may work with other web servers) -- MySQL or MariaDB -- Python 3 -- Bash + +- UNIX-like OS +- Go (golang) +- Mariadb ### Setup Steps -1. Clone this repository into a directory accessible by your web server but outside any web root. -2. Create a MySQL/MariaDB database with the tables listed below. -3. Add a dedicated MySQL/MariaDB user for ThreadR and grant usage privileges for the tables. -4. Symlink the `build/` directory to your desired web root location (ThreadR does not support direct web root linking). -5. Adjust configuration files in the `config/` directory to match your setup. -6. Run `./deployment-script.sh` to apply the configuration. -7. Optionally, symlink `build/redirect_home.html` to redirect specific locations to ThreadR. -### Database Schema -- **boards** - - `id` (int, primary key, auto increment) - - `name` (varchar) - - `user_friendly_name` (varchar) - - `private` (boolean or tinyint(1)) - - `public_visible` (boolean or tinyint(1)) -- **posts** - - `id` (int, primary key, auto increment) - - `board_id` (int) - - `user_id` (int) - - `post_time` (timestamp, default current_timestamp()) - - `edit_time` (timestamp, nullable, default null, on update current_timestamp()) - - `content` (text, nullable, default null) - - `attachment_hash` (bigint(20), nullable, default null) - - `attachment_name` (varchar, nullable, default null) - - `title` (varchar) - - `reply_to` (int, default -1) -- **profiles** (usage TBD) - - `id` (smallint, primary key, index) - - `email` (varchar, index, likely unique) - - `display_name` (varchar) - - `status` (varchar) - - `about` (long varchar) - - `website` (varchar) -- **users** - - `id` (smallint, primary key) - - `name` (varchar, index, likely unique) - - `authentication_string` (varchar(128)) - - `authentication_salt` (varchar) - - `authentication_algorithm` (varchar) - - `time_created` (timestamp, default current_timestamp()) - - `time_altered` (timestamp, default current_timestamp(), on update current_timestamp()) - - `verified` (boolean or tinyint(1), default 0) +1. Create a mariadb user and database for ThreadR (the names can be changed): +```sql +CREATE USER threadr IDENTIFIED BY 'super secure password'; +CREATE DATABASE `threadr`; +GRANT ALL PRIVILEGES ON `threadr`.* TO 'threadr'; +``` +2. Create a config file: In the `config` subdirectory, `cp config.json.sample config.json` and edit it to suit your needs. +3. Create an about page: Also in the `config` subdirectory, `cp about_page.htmlbody.sample about_page.htmlbody` and edit it to suit your needs. ## Running the Application -To start the ThreadR server, run the following command after configuration: + +After configuration, run the following command once to initialize the DB: ``` -go run ./main.go +go run main.go --initialize +``` +To start the ThreadR server, run this: +``` +go run main.go ``` The server will start on port 8080 by default. -## Project Structure -- **src/**: Core ThreadR source files -- **build/**: Placeholder for deployment, contains a working instance after running the deployment script -- **config/**: Configuration files for specific ThreadR instances -- **macros/**: Files for use with the variable grabbler script -- **static/**: Static assets (CSS, images) for the web interface -- **templates/**: HTML templates for rendering pages -- **handlers/**: HTTP request handlers for various routes -- **models/**: Database models and interaction logic -- **deployment_script.sh**: Script for code variable replacement and deployment tasks -- **variable_grabbler.py**: Custom macro processor for configuration -- **LICENSE.md**: Apache 2.0 license details -- **NOTICE**: Copyright notice in plain text - ## Contributing -We welcome contributions! Please discuss ideas or issues in the GitHub issues section or join our Discord server for real-time communication: [discord.gg/r3w3zSkEUE](https://discord.gg/r3w3zSkEUE). + +We welcome contributions! Please join our Discord server to get in touch: [discord.gg/r3w3zSkEUE](https://discord.gg/r3w3zSkEUE). ## License + ThreadR is licensed under the Apache 2.0 License. See [LICENSE.md](./LICENSE.md) for details. -**Authors:** BodgeMaster, Jocadbz \ No newline at end of file +**Authors:** BodgeMaster, Jocadbz diff --git a/config/about.template b/config/about.template deleted file mode 100644 index ac6a59b..0000000 --- a/config/about.template +++ /dev/null @@ -1,25 +0,0 @@ -

- Hello there! This is the official ThreadR instance provided by the ThreadR development team. -

-

- What is ThreadR? -

-

- ThreadR is a free and open-source forum engine. That means you can download - it and host an instance of ThreadR on your own web server to run your own forum. -

-

- The project originated as a school project in 2019 with the goal of building - a forum. When we finished school, the project was abandoned and eventually taken down. - A year later, we decided to revive it and started working on it again. Now that school - is over and we don't necessarily have a a reason to run our own forum anymore, - we shifted the project goal to building a FOSS forum engine. -

-

- Who are we? -

-

- We are a small group of (hobby) developers working on ThreadR in our free time. - To get in touch, ... uhh ... There will be a way once ThreadR is fully functional. - For now, you can find us on Discord: discord.gg/r3w3zSkEUE -

\ No newline at end of file diff --git a/config/about_page.htmlbody.sample b/config/about_page.htmlbody.sample new file mode 100644 index 0000000..a0c7f29 --- /dev/null +++ b/config/about_page.htmlbody.sample @@ -0,0 +1,31 @@ +
+
+

About ThreadR

+
+
+

+ This is a ThreadR development instance. Beep beep. Boop boop. +

+

+ If you see this message in a production environment (aka. a Forum that is actually being used), kindly tell the admin that they forgot to change the about page. :) +

+

+ What is ThreadR? +

+

+ ThreadR is a free and open-source forum engine. That means you can download + it and host an instance of ThreadR on your own web server to run your own forum. + It originated in 2019 as a school project and has died twice since. + Currently, the project is being rewritten in Go with (hopefully) less ugly hacks. +

+

+ Who dis? +

+

+ Depends.
+ If this site is hosted on a LostCave domain, then it's probably us, the developers. + For now, you can find us on Discord: discord.gg/r3w3zSkEUE
+ If it isn't on a LostCave domain, then this site belongs to some lazy admin who forgot to change the about page. +

+
+
diff --git a/config/config-skeleton.json b/config/config.json.sample similarity index 100% rename from config/config-skeleton.json rename to config/config.json.sample diff --git a/handlers/about.go b/handlers/about.go index 856761b..47df6f6 100644 --- a/handlers/about.go +++ b/handlers/about.go @@ -14,9 +14,9 @@ func AboutHandler(app *App) http.HandlerFunc { loggedIn := session.Values["user_id"] != nil cookie, _ := r.Cookie("threadr_cookie_banner") - aboutContent, err := ioutil.ReadFile("config/about.template") + aboutContent, err := ioutil.ReadFile("config/about_page.htmlbody") if err != nil { - log.Printf("Error reading about.template: %v", err) + log.Printf("Error reading about_page.htmlbody: %v", err) http.Error(w, "Internal Server Error", http.StatusInternalServerError) return } @@ -43,4 +43,4 @@ func AboutHandler(app *App) http.HandlerFunc { return } } -} \ No newline at end of file +} diff --git a/templates/pages/about.html b/templates/pages/about.html index 6802192..afc1193 100644 --- a/templates/pages/about.html +++ b/templates/pages/about.html @@ -7,15 +7,8 @@ {{template "navbar" .}} -
-
-

About ThreadR

-
-
- {{.AboutContent}} -
-
+ {{.AboutContent}} {{template "cookie_banner" .}} -{{end}} \ No newline at end of file +{{end}}