Compare commits

..

No commits in common. "f78c55e82476c2e88e6c3a8b7ee909b163207797" and "10826e2d26f15f252ebff7e5f39ebf1851ef08a5" have entirely different histories.

7 changed files with 120 additions and 69 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
config/config.json
config/about_page.htmlbody
# nano
.swp

111
README.md
View File

@ -4,49 +4,104 @@ This is the source code for the ThreadR Forum Engine, rewritten in Go. ThreadR i
## Project Overview ## Project Overview
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. 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.
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.
## Project Setup ### 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)
This is for development only. Currently, ThreadR is not ready for production use. ### 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.
### Prerequisites ### Prerequisites
This guide assumes you are on a UNIX-like system with the following installed:
- UNIX-like OS - Apache with PHP (may work with other web servers)
- Go (golang) - MySQL or MariaDB
- Mariadb - Python 3
- Bash
### Setup Steps ### 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.
1. Create a mariadb user and database for ThreadR (the names can be changed): ### Database Schema
```sql - **boards**
CREATE USER threadr IDENTIFIED BY 'super secure password'; - `id` (int, primary key, auto increment)
CREATE DATABASE `threadr`; - `name` (varchar)
GRANT ALL PRIVILEGES ON `threadr`.* TO 'threadr'; - `user_friendly_name` (varchar)
``` - `private` (boolean or tinyint(1))
2. Create a config file: In the `config` subdirectory, `cp config.json.sample config.json` and edit it to suit your needs. - `public_visible` (boolean or tinyint(1))
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. - **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)
## Running the Application ## 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 --initialize go run ./main.go
```
To start the ThreadR server, run this:
```
go run main.go
``` ```
The server will start on port 8080 by default. The server will start on port 8080 by default.
## Contributing ## 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
We welcome contributions! Please join our Discord server to get in touch: [discord.gg/r3w3zSkEUE](https://discord.gg/r3w3zSkEUE). ## 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).
## License ## License
ThreadR is licensed under the Apache 2.0 License. See [LICENSE.md](./LICENSE.md) for details. ThreadR is licensed under the Apache 2.0 License. See [LICENSE.md](./LICENSE.md) for details.
**Authors:** BodgeMaster, Jocadbz **Authors:** BodgeMaster, Jocadbz

25
config/about.template Normal file
View File

@ -0,0 +1,25 @@
<p>
Hello there! This is the official ThreadR instance provided by the ThreadR development team.
</p>
<h2>
What is ThreadR?
</h2>
<p>
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.
</p>
<p>
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&apos;t necessarily have a a reason to run our own forum anymore,
we shifted the project goal to building a FOSS forum engine.
</p>
<h2>
Who are we?
</h2>
<p>
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: <a href="https://discord.gg/r3w3zSkEUE"> discord.gg/r3w3zSkEUE </a>
</p>

View File

@ -1,31 +0,0 @@
<main>
<header>
<h2>About ThreadR</h2>
</header>
<section>
<p>
This is a ThreadR development instance. Beep beep. Boop boop.
</p>
<p>
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. :)
</p>
<h2>
What is ThreadR?
</h2>
<p>
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.
</p>
<h2>
Who dis?
</h2>
<p>
Depends.<br />
If this site is hosted on a LostCave domain, then it&apos;s probably us, the developers.
For now, you can find us on Discord: <a href="https://discord.gg/r3w3zSkEUE">discord.gg/r3w3zSkEUE</a><br />
If it isn&apos;t on a LostCave domain, then this site belongs to some lazy admin who forgot to change the about page.
</p>
</section>
</main>

View File

@ -14,9 +14,9 @@ func AboutHandler(app *App) http.HandlerFunc {
loggedIn := session.Values["user_id"] != nil loggedIn := session.Values["user_id"] != nil
cookie, _ := r.Cookie("threadr_cookie_banner") cookie, _ := r.Cookie("threadr_cookie_banner")
aboutContent, err := ioutil.ReadFile("config/about_page.htmlbody") aboutContent, err := ioutil.ReadFile("config/about.template")
if err != nil { if err != nil {
log.Printf("Error reading about_page.htmlbody: %v", err) log.Printf("Error reading about.template: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError) http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return return
} }
@ -43,4 +43,4 @@ func AboutHandler(app *App) http.HandlerFunc {
return return
} }
} }
} }

View File

@ -7,8 +7,15 @@
</head> </head>
<body> <body>
{{template "navbar" .}} {{template "navbar" .}}
{{.AboutContent}} <main>
<header>
<h2>About ThreadR</h2>
</header>
<section>
{{.AboutContent}}
</section>
</main>
{{template "cookie_banner" .}} {{template "cookie_banner" .}}
</body> </body>
</html> </html>
{{end}} {{end}}