1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-01 22:26:24 -07:00

Have config.verbosity be determined by gochan.json, not by Makefile

Finally add release instructions to README.md
This commit is contained in:
Joshua Merrell 2018-06-20 17:27:23 -07:00
parent b090be5b67
commit 78185e8325
16 changed files with 73 additions and 89 deletions

1
.gitignore vendored
View file

@ -8,5 +8,6 @@ log/mod.log
vagrant/.vagrant/
vagrant/ubuntu-xenial-16.04-cloudimg-console.log
html/boards.json
html/index.html
html/test/
releases/

View file

@ -1,9 +1,4 @@
GOCHAN_RELEASE=0
GOCHAN_DEBUG=1
GOCHAN_VERBOSE=2
GOCHAN_VERBOSITY=0 # This is set by "make release/debug/verbose"
GOCHAN_VERSION=1.10.1
GOCHAN_VERSION=`cat version`
GOCHAN_BUILDTIME=$(shell date +%y%m%d.%H%M)
ifeq ($(GOOS), windows)
GOCHAN_BIN=gochan.exe
@ -11,26 +6,19 @@ else
GOCHAN_BIN=gochan
endif
CGO_ENABLED=0
GOARCH=amd64
# CGO_ENABLED=0
# If you run make without any arguments, this will be used by default. \
It doesn't give any debugging info by println and only prints major errors.
release: GOCHAN_VERBOSITY=${GOCHAN_RELEASE}
# strips debugging info in the gochan executable
release: LDFLAGS=-w -s
release: build
# To give warnings and stuff, run "make debug"
debug: GOCHAN_VERBOSITY=${GOCHAN_DEBUG}
# includes debugging info in the gochan executable
debug: LDFLAGS=""
debug: build
# Used in development for benchmarking and finding issues that might not be discovered by "make debug"
verbose: GOCHAN_VERBOSITY=${GOCHAN_VERBOSE}
verbose: build
build:
ifndef GOPATH
@echo "$ GOPATH not set. Please run 'export GOPATH=\$$PWD/lib' (or wherever you prefer) and run this again."
endif
@echo ${GOCHAN_VERBOSITY}
@echo ${GOCHAN_VERBOSE}
go build -v -ldflags "-w -X main.version=${GOCHAN_VERSION} -X main.buildtimeString=${GOCHAN_BUILDTIME} -X main.verbosityString=${GOCHAN_VERBOSITY}" -o ${DIRNAME}${GOCHAN_BIN} ./src
go build -v -ldflags "${LDFLAGS} -X main.version=${GOCHAN_VERSION} -X main.buildtimeString=${GOCHAN_BUILDTIME}" -o ${DIRNAME}${GOCHAN_BIN} ./src

View file

@ -6,8 +6,16 @@ http://gochan.org
## Installation
### Basic installation
Coming soon!
### Basic installation (from a release)
1. Extract the .tar.gz or the .zip file into a directory (for example, your home directory)
2. Copy gochan.example.json to gochan.json and modify it to your liking.
1. If you want to see debugging info/noncritical warnings, set verbosity to 1. If you want to see benchmarks as well, set it to 2.
2. Make sure to set `DBname`, `DBusername`, and `DBpassword`, since these are required to connect to your MySQL database. Set `DomainRegex`,`SiteDomain`, since these are necessary in order to post and log in as a staff member without being rejected.
3. If you're using nginx, copy gochan-fastcgi.nginx, or gochan-http.nginx if `UseFastCGI` is set to true to /etc/nginx/sites-enabled/, or the appropriate folder in Windows.
4. If you're in Linux, you can optionally copy gochan.service to ~/.config/systemd/user/gochan.service and run `systemctl enable gochan.service` to have it run on login and `systemctl start gochan.service` to start it as a background service.
1. If you aren't using a distro with systemd, you can start a screen session and run `./gochan`
5. Go to http://[gochan url]/manage?action=boards, log in (default username/password is admin/password), create a board, and go to http://[gochan url]/manage?action=rebuildall
1. For security reasons, you should probably go to http://[gochan url]/manage?action=staff to create a new admin user account and delete admin.
### For developers (using Vagrant)
1. Install Vagrant and Virtualbox. Vagrant lets you create a virtual machine and run a custom setup/installation script to make installation easier and faster.

View file

@ -1,6 +1,6 @@
# Gochan Development Roadmap
This is just a very preliminary roadmap to map out what I plan to focus on with the versions
This is a rough roadmap to map out what I plan to focus on with the versions
1.x

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERSION=1.10.1
VERSION=`cat version`
GOOS_ORIG=$GOOS
function copyStuff {
@ -14,6 +14,7 @@ function copyStuff {
mkdir $DIRNAME/log
cp -r templates $DIRNAME
cp initialsetupdb.sql $DIRNAME
cp *.nginx $DIRNAME
cp README.md $DIRNAME
cp LICENSE $DIRNAME
cp gochan.example.json $DIRNAME
@ -22,6 +23,7 @@ function copyStuff {
export GOOS=linux
export DIRNAME=releases/gochan-v${VERSION}_${GOOS}64/
copyStuff
cp gochan.service $DIRNAME
cd releases
tar -zcvf gochan-v${VERSION}_${GOOS}-64.tar.gz gochan-v${VERSION}_${GOOS}64/
cd ..
@ -30,7 +32,7 @@ export GOOS=darwin
export DIRNAME=releases/gochan-v${VERSION}_macos64/
copyStuff
cd releases
tar -zcvf gochan-v${VERSION}_macos.tar.gz gochan-v${VERSION}_macos/
tar -zcvf gochan-v${VERSION}_macos64.tar.gz gochan-v${VERSION}_macos64/
cd ..
export GOOS=windows

View file

@ -1,7 +1,7 @@
{
"ListenIP": "127.0.0.1",
"Port": 8080,
"FirstPage": ["index.html","board.html"],
"FirstPage": ["index.html","board.html","firstrun.html"],
"Error404Path": "/error/404.html",
"Error500Path": "/error/500.html",
"Username": "gochan",
@ -89,8 +89,7 @@
"_comment": "set GeoIPDBlocation to cf to use Cloudflare's GeoIP",
"GeoIPDBlocation": "/usr/share/GeoIP/GeoIP.dat",
"MaxRecentPosts": 3,
"MakeRSS": true,
"MakeSitemap": true,
"verbosity": 0,
"EnableAppeals": true,
"MaxModlogDays": 14,
"_comment": "Set RandomSeed to a (preferrably large) string of letters and numbers",

View file

@ -7,6 +7,6 @@
<h1>404: File not found</h1>
<img src="/error/lol 404.gif" border="0" alt="">
<p>The requested file could not be found on this server. Are you just typing random stuff in the address bar? If you followed a link from this site here, then post <a href="/site">here</a></p>
<hr><address>http://gochan.org powered by Gochan v1.10.1</address>
<hr><address>http://gochan.org powered by Gochan v1.10.2</address>
</body>
</html>

View file

@ -7,6 +7,6 @@
<h1>500: Internal Server error</h1>
<img src="/error/derpy server.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon has he/she/it can.</p>
<hr><address>http://gochan.org powered by Gochan v1.10.1</address>
<hr><address>http://gochan.org powered by Gochan v1.10.2</address>
</body>
</html>

View file

@ -2,17 +2,10 @@ package main
import (
"os"
"strconv"
)
// set in Makefile via -ldflags
var version string
// verbose = 0 for no debugging info. Critical errors and general output only
// verbose = 1 for non-critical warnings and important info
// verbose = 2 for all debugging/benchmarks/warnings
// set in Makefile via -ldflags
var verbosityString string
var buildtimeString string // set in Makefile, format: YRMMDD.HHMM
func main() {
@ -22,7 +15,6 @@ func main() {
}
}()
initConfig()
config.Verbosity, _ = strconv.Atoi(verbosityString)
config.Version = version
printf(0, "Starting gochan v%s.%s, using verbosity level %d\n", config.Version, buildtimeString, config.Verbosity)
println(0, "Config file loaded. Connecting to database...")

View file

@ -177,8 +177,7 @@ var manage_functions = map[string]ManageFunction{
html += "<tr><td>" + handleError(1, err.Error()) + "</td></tr></table>"
return
}
// TODO: remove orphaned replies
// TODO: remove orphaned uploads
// TODO: remove orphaned replies and uploads
html += "Optimizing all tables in database.<hr />"
tableRows, tablesErr := querySQL("SHOW TABLES")
@ -399,7 +398,7 @@ var manage_functions = map[string]ManageFunction{
ban_which = "both"
}
// if none of these are true, we can assume that the page was loaded without sending anything
println(0, "ban_which"+ban_which)
println(1, "ban_which"+ban_which)
if ban_which == "user" {
//var banned_tripcode string
@ -466,6 +465,7 @@ var manage_functions = map[string]ManageFunction{
"<h2>Banned IPs</h2>\n"
rows, err = querySQL("SELECT * FROM `" + config.DBprefix + "banlist`")
defer closeRows(rows)
if err != nil {
html += "</table><br />" + handleError(1, err.Error())
return
@ -669,6 +669,7 @@ var manage_functions = map[string]ManageFunction{
default:
// put the default column values in the text boxes
rows, err = querySQL("SELECT `column_name`,`column_default` FROM `information_schema`.`columns` WHERE `table_name` = '" + config.DBprefix + "boards'")
defer closeRows(rows)
if err != nil {
html += handleError(1, "Error getting column names from boards table:"+err.Error())
return

View file

@ -614,22 +614,22 @@ func sinceLastPost(post *PostTable) int {
}
func createImageThumbnail(image_obj image.Image, size string) image.Image {
var thumb_width int
var thumb_height int
var thumbWidth int
var thumbHeight int
switch size {
case "op":
thumb_width = config.ThumbWidth
thumb_height = config.ThumbHeight
thumbWidth = config.ThumbWidth
thumbHeight = config.ThumbHeight
case "reply":
thumb_width = config.ThumbWidth_reply
thumb_height = config.ThumbHeight_reply
thumbWidth = config.ThumbWidth_reply
thumbHeight = config.ThumbHeight_reply
case "catalog":
thumb_width = config.ThumbWidth_catalog
thumb_height = config.ThumbHeight_catalog
thumbWidth = config.ThumbWidth_catalog
thumbHeight = config.ThumbHeight_catalog
}
old_rect := image_obj.Bounds()
if thumb_width >= old_rect.Max.X && thumb_height >= old_rect.Max.Y {
if thumbWidth >= old_rect.Max.X && thumbHeight >= old_rect.Max.Y {
return image_obj
}
@ -681,29 +681,29 @@ func getNewFilename() string {
// find out what out thumbnail's width and height should be, partially ripped from Kusaba X
func getThumbnailSize(w int, h int, size string) (new_w int, new_h int) {
var thumb_width int
var thumb_height int
var thumbWidth int
var thumbHeight int
switch {
case size == "op":
thumb_width = config.ThumbWidth
thumb_height = config.ThumbHeight
thumbWidth = config.ThumbWidth
thumbHeight = config.ThumbHeight
case size == "reply":
thumb_width = config.ThumbWidth_reply
thumb_height = config.ThumbHeight_reply
thumbWidth = config.ThumbWidth_reply
thumbHeight = config.ThumbHeight_reply
case size == "catalog":
thumb_width = config.ThumbWidth_catalog
thumb_height = config.ThumbHeight_catalog
thumbWidth = config.ThumbWidth_catalog
thumbHeight = config.ThumbHeight_catalog
}
if w == h {
new_w = thumb_width
new_h = thumb_height
new_w = thumbWidth
new_h = thumbHeight
} else {
var percent float32
if w > h {
percent = float32(thumb_width) / float32(w)
percent = float32(thumbWidth) / float32(w)
} else {
percent = float32(thumb_height) / float32(h)
percent = float32(thumbHeight) / float32(h)
}
new_w = int(float32(w) * percent)
new_h = int(float32(h) * percent)
@ -728,23 +728,15 @@ func parseName(name string) map[string]string {
// inserts prepared post object into the SQL table so that it can be rendered
func insertPost(post PostTable, bump bool) (sql.Result, error) {
var result sql.Result
insertString := "INSERT INTO " + config.DBprefix + "posts (`boardid`, `parentid`, `name`, `tripcode`, `email`, `subject`, `message`, `message_raw`, `password`, `filename`, `filename_original`, `file_checksum`, `filesize`, `image_w`, `image_h`, `thumb_w`, `thumb_h`, `ip`, `tag`, `timestamp`, `autosage`, `poster_authority`, `deleted_timestamp`,`bumped`,`stickied`, `locked`, `reviewed`, `sillytag`) "
insertValues := "VALUES("
numColumns := 28 // number of columns in the post table minus `id`
for i := 0; i < numColumns-1; i++ {
insertValues += "?, "
}
insertValues += " ? )"
result, err := execSQL(insertString+insertValues,
post.BoardID, post.ParentID, post.Name, post.Tripcode,
post.Email, post.Subject, post.MessageHTML, post.MessageText,
post.Password, post.Filename, post.FilenameOriginal,
post.FileChecksum, post.Filesize, post.ImageW, post.ImageH,
post.ThumbW, post.ThumbH, post.IP, post.Tag, post.Timestamp,
post.Autosage, post.PosterAuthority, post.DeletedTimestamp,
result, err := execSQL(
"INSERT INTO "+config.DBprefix+"posts "+
"(`boardid`,`parentid`,`name`,`tripcode`,`email`,`subject`,`message`,`message_raw`,`password`,`filename`,`filename_original`,`file_checksum`,`filesize`,`image_w`,`image_h`,`thumb_w`,`thumb_h`,`ip`,`tag`,`timestamp`,`autosage`,`poster_authority`,`deleted_timestamp`,`bumped`,`stickied`,`locked`,`reviewed`,`sillytag`)"+
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
post.BoardID, post.ParentID, post.Name, post.Tripcode, post.Email,
post.Subject, post.MessageHTML, post.MessageText, post.Password,
post.Filename, post.FilenameOriginal, post.FileChecksum, post.Filesize,
post.ImageW, post.ImageH, post.ThumbW, post.ThumbH, post.IP, post.Tag,
post.Timestamp, post.Autosage, post.PosterAuthority, post.DeletedTimestamp,
post.Bumped, post.Stickied, post.Locked, post.Reviewed, post.Sillytag,
)

View file

@ -182,7 +182,7 @@ type ModLogTable struct {
Timestamp time.Time
}
// PollResultsTable may or may not be used in the future for polls (duh)
// PollResultsTable may or may not be used in the future for user polls
type PollResultsTable struct {
ID uint
IP string
@ -404,13 +404,14 @@ type GochanConfig struct {
EnableGeoIP bool
GeoIPDBlocation string // set to "cf" or the path to the db
MaxRecentPosts int
MakeRSS bool
MakeSitemap bool
EnableAppeals bool
MaxModlogDays int
RandomSeed string
Version string
Verbosity int
// verbose = 0 for no debugging info. Critical errors and general output only
// verbose = 1 for non-critical warnings and important info
// verbose = 2 for all debugging/benchmarks/warnings
Verbosity int
EnableAppeals bool
MaxModlogDays int
RandomSeed string
Version string
}
func initConfig() {

View file

@ -163,7 +163,6 @@ func escapeQuotes(txt string) string {
// getBoardArr performs a query against the database, and returns an array of BoardsTables along with an error value.
// If specified, the string where is added to the query, prefaced by WHERE. An example valid value is where = "id = 1".
//func getBoardArr(where string) (boards []BoardsTable, err error) {
func getBoardArr(parameterList map[string]interface{}, extra string) (boards []BoardsTable, err error) {
queryString := "SELECT * FROM `" + config.DBprefix + "boards` "
numKeys := len(parameterList)

View file

@ -84,7 +84,7 @@ go get github.com/nyarla/go-crypt
go get github.com/go-sql-driver/mysql
go get golang.org/x/crypto/bcrypt
go get github.com/frustra/bbcode
make verbose
make debug
rm -f $GOCHAN_PATH/gochan
rm -f $GOCHAN_PATH/initialsetupdb.sql

1
version Normal file
View file

@ -0,0 +1 @@
1.10.2