Example #1
0
func handleNNTPPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("nntp")
	name := form.Get("nntp_name")

	allow_attachments := form.Get("allow_attachments")
	if allow_attachments != "1" {
		allow_attachments = "0"
	}

	allow_anon := form.Get("allow_anon")
	if allow_anon != "1" {
		allow_anon = "0"
	}

	allow_anon_attachments := form.Get("allow_anon_attachments")
	if allow_anon_attachments != "1" {
		allow_anon_attachments = "0"
	}

	require_tls := form.Get("require_tls")
	if require_tls != "1" {
		require_tls = "0"
	}

	sect.Add("instance_name", name)
	sect.Add("allow_attachments", allow_attachments)
	sect.Add("allow_anon", allow_anon)
	sect.Add("require_tls", require_tls)

	return self.children["next"], nil
}
Example #2
0
func handleFrontendPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	var next *dialogNode

	sect, _ := conf.Section("frontend")
	name := form.Get("name")
	locale := form.Get("locale")

	allow_files := form.Get("allow_files")
	if allow_files != "1" {
		allow_files = "0"
	}

	json_api := form.Get("json")
	if json_api != "1" {
		json_api = "0"
		next = self.children["next"]
	} else {
		next = self.children["json"]
	}

	sect.Add("name", name)
	sect.Add("locale", locale)
	sect.Add("allow_files", allow_files)
	sect.Add("json-api", json_api)

	err := checkLocale(locale)
	if err != nil {
		return self, err
	}

	return next, nil
}
Example #3
0
func handleBinPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("articles")
	convert := form.Get("convert")
	ffmpeg := form.Get("ffmpeg")
	sox := form.Get("sox")

	err := checkFile(convert)
	if err == nil {
		err = checkFile(ffmpeg)
		if err == nil {
			err = checkFile(sox)
		}
	}

	sect.Add("convert_bin", convert)
	sect.Add("ffmpegthumbnailer_bin", ffmpeg)
	sect.Add("sox_bin", sox)

	if err != nil {
		return self, err
	}

	return self.children["next"], nil
}
Example #4
0
func prepareNNTPModel(self *dialogNode, err error, conf *configparser.Configuration) templateModel {
	param := make(map[string]interface{})
	sect, _ := conf.Section("nntp")
	name := sect.ValueOf("instance_name")
	param["dialog"] = &NameModel{ErrorModel{err}, StepModel{self}, name}
	return param
}
Example #5
0
func prepareRedisDBModel(self *dialogNode, err error, conf *configparser.Configuration) templateModel {
	param := make(map[string]interface{})
	sect, _ := conf.Section("database")
	host := sect.ValueOf("host")
	port := sect.ValueOf("port")
	param["dialog"] = &DBModel{ErrorModel{err}, StepModel{self}, "", host, port}
	return param
}
Example #6
0
func prepareAPIModel(self *dialogNode, err error, conf *configparser.Configuration) templateModel {
	param := make(map[string]interface{})
	sect, _ := conf.Section("frontend")
	user := sect.ValueOf("json-api-username")
	secret := sect.ValueOf("api-secret")
	param["dialog"] = &APIModel{ErrorModel{err}, StepModel{self}, user, secret}
	return param
}
Example #7
0
func prepareFrontendModel(self *dialogNode, err error, conf *configparser.Configuration) templateModel {
	param := make(map[string]interface{})
	sect, _ := conf.Section("frontend")
	name := sect.ValueOf("name")
	locale := sect.ValueOf("locale")
	param["dialog"] = &FrontendModel{ErrorModel{err}, StepModel{self}, name, locale}
	return param
}
Example #8
0
func prepareCryptoModel(self *dialogNode, err error, conf *configparser.Configuration) templateModel {
	param := make(map[string]interface{})
	sect, _ := conf.Section("crypto")
	host := sect.ValueOf("tls-hostname")
	key := sect.ValueOf("tls-keyname")
	param["dialog"] = &CryptoModel{ErrorModel{err}, StepModel{self}, host, key}
	return param
}
Example #9
0
func prepareBinModel(self *dialogNode, err error, conf *configparser.Configuration) templateModel {
	param := make(map[string]interface{})
	sect, _ := conf.Section("articles")
	convert := sect.ValueOf("convert_bin")
	ffmpeg := sect.ValueOf("ffmpegthumbnailer_bin")
	sox := sect.ValueOf("sox_bin")
	param["dialog"] = &BinaryModel{ErrorModel{err}, StepModel{self}, convert, ffmpeg, sox}
	return param
}
Example #10
0
func handleKeyPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("frontend")
	public := form.Get("public")

	sect.Add("admin_key", public)
	return self.children["next"], nil
}
Example #11
0
func handleAPIPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("frontend")
	user := form.Get("user")
	pass := form.Get("pass")
	secret := form.Get("secret")

	sect.Add("json-api-username", user)
	sect.Add("json-api-password", pass)
	sect.Add("api-secret", secret)

	return self.children["next"], nil
}
Example #12
0
func handleCryptoPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("crypto")
	host := form.Get("host")
	key := form.Get("key")

	err := checkHost(host)
	if err != nil {
		return self, err
	}
	sect.Add("tls-hostname", host)
	sect.Add("tls-keyname", key)

	return self.children["next"], nil
}
Example #13
0
func handleCacheTypePost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("cache")

	cache := form.Get("cache")
	log.Println("Cache chosen: ", cache)
	sect.Add("type", cache)
	if cache == "redis" {
		return self.children["redis"], nil
	}
	if cache == "file" || cache == "null" {
		return self.children["next"], nil
	}

	return self, nil
}
Example #14
0
func handleRedisCachePost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("cache")
	host := form.Get("host")
	port := form.Get("port")
	passwd := form.Get("password")

	err := checkRedisConnection(host, port, passwd)
	if err != nil {
		return self, err
	}
	sect.Add("type", "redis")
	sect.Add("host", host)
	sect.Add("port", port)
	sect.Add("password", passwd)

	return self.children["next"], nil
}
Example #15
0
func handlePostgresDBPost(self *dialogNode, form url.Values, conf *configparser.Configuration) (*dialogNode, error) {
	if form.Get("back") == "true" {
		return self.parent, nil
	}
	sect, _ := conf.Section("database")
	host := form.Get("host")
	port := form.Get("port")
	passwd := form.Get("password")
	user := form.Get("user")

	err := checkPostgresConnection(host, port, user, passwd)
	if err != nil {
		return self, err
	}
	sect.Add("type", "postgres")
	sect.Add("schema", "srnd")
	sect.Add("host", host)
	sect.Add("port", port)
	sect.Add("password", passwd)
	sect.Add("user", user)

	return self.children["next"], nil
}