mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
refactored smart section code
This commit is contained in:
parent
5acfae3d0d
commit
3defc062bd
40 changed files with 172 additions and 306 deletions
|
@ -14,6 +14,7 @@ package convert
|
|||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/documize/community/core/api/convert/html"
|
||||
"github.com/documize/community/core/api/plugins"
|
||||
api "github.com/documize/community/core/convapi"
|
||||
|
@ -53,7 +54,7 @@ func Convert(ctx context.Context, xtn string, fileRequest *api.DocumentConversio
|
|||
/* TODO add sanitisation for body & title HTML
|
||||
var titlePolicy, bodyPolicy *bluemonday.Policy
|
||||
|
||||
func init() {
|
||||
func xxx() {
|
||||
policy := bluemonday.UGCPolicy()
|
||||
policy.RequireNoFollowOnLinks(true)
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ import (
|
|||
"github.com/documize/community/core/api/util"
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/core/section/provider"
|
||||
"github.com/documize/community/core/web"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
)
|
||||
|
||||
// Authenticate user based up HTTP Authorization header.
|
||||
|
|
|
@ -23,34 +23,6 @@ import (
|
|||
"github.com/documize/community/core/log"
|
||||
)
|
||||
|
||||
// var jwtKey string
|
||||
|
||||
// func init() {
|
||||
// env.GetString(&jwtKey, "salt", false, "the salt string used to encode JWT tokens, if not set a random value will be generated",
|
||||
// func(t *string, n string) bool {
|
||||
// if jwtKey == "" {
|
||||
// b := make([]byte, 17)
|
||||
// _, err := rand.Read(b)
|
||||
// if err != nil {
|
||||
// jwtKey = err.Error()
|
||||
// log.Error("problem using crypto/rand", err)
|
||||
// return false
|
||||
// }
|
||||
// for k, v := range b {
|
||||
// if (v >= 'a' && v <= 'z') || (v >= 'A' && v <= 'Z') || (v >= '0' && v <= '0') {
|
||||
// b[k] = v
|
||||
// } else {
|
||||
// s := fmt.Sprintf("%x", v)
|
||||
// b[k] = s[0]
|
||||
// }
|
||||
// }
|
||||
// jwtKey = string(b)
|
||||
// log.Info("Please set DOCUMIZESALT or use -salt with this value: " + jwtKey)
|
||||
// }
|
||||
// return true
|
||||
// })
|
||||
// }
|
||||
|
||||
// Generates JSON Web Token (http://jwt.io)
|
||||
func generateJWT(user, org, domain string) string {
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
|
||||
|
|
|
@ -24,9 +24,9 @@ import (
|
|||
"github.com/documize/community/core/api/request"
|
||||
"github.com/documize/community/core/api/util"
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/section/provider"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
htmldiff "github.com/documize/html-diff"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
|
|
@ -21,9 +21,9 @@ import (
|
|||
"github.com/documize/community/core/api/request"
|
||||
"github.com/documize/community/core/api/util"
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/section/provider"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
|
|
|
@ -26,30 +26,6 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// var port, certFile, keyFile, forcePort2SSL string
|
||||
|
||||
// Product details app edition and version
|
||||
// var Product env.ProdInfo
|
||||
|
||||
// func init() {
|
||||
// // Product.Major = "1"
|
||||
// // Product.Minor = "50"
|
||||
// // Product.Patch = "0"
|
||||
// // Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
|
||||
// // Product.Edition = "Community"
|
||||
// // Product.Title = fmt.Sprintf("%s Edition", Product.Edition)
|
||||
// // Product.License = env.License{}
|
||||
// // Product.License.Seats = 1
|
||||
// // Product.License.Valid = true
|
||||
// // Product.License.Trial = false
|
||||
// // Product.License.Edition = "Community"
|
||||
|
||||
// // env.GetString(&certFile, "cert", false, "the cert.pem file used for https", nil)
|
||||
// // env.GetString(&keyFile, "key", false, "the key.pem file used for https", nil)
|
||||
// // env.GetString(&port, "port", false, "http/https port number", nil)
|
||||
// // env.GetString(&forcePort2SSL, "forcesslport", false, "redirect given http port number to TLS", nil)
|
||||
// }
|
||||
|
||||
var testHost string // used during automated testing
|
||||
|
||||
// Serve the Documize endpoint.
|
||||
|
|
|
@ -31,13 +31,6 @@ import (
|
|||
var PluginFile = "DB" // this points to the database
|
||||
var insecure = "false"
|
||||
|
||||
// func init() {
|
||||
// env.GetString(&PluginFile, "plugin", false,
|
||||
// "the JSON file describing plugins, default 'DB' uses the database config table 'FILEPLUGINS' entry", nil)
|
||||
// env.GetString(&insecure, "insecure", false,
|
||||
// "if 'true' allow https endpoints with invalid certificates (only for testing)", nil)
|
||||
// }
|
||||
|
||||
type infoLog struct{}
|
||||
|
||||
func (i infoLog) Write(b []byte) (int, error) {
|
||||
|
|
|
@ -45,85 +45,6 @@ func (dr *databaseRequest) MakeTx() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
// func init() {
|
||||
// var err error
|
||||
|
||||
// env.GetString(&connectionString, "db", true,
|
||||
// `'username:password@protocol(hostname:port)/databasename" for example "fred:bloggs@tcp(localhost:3306)/documize"`,
|
||||
// func(*string, string) bool {
|
||||
|
||||
// Db, err = sqlx.Open("mysql", stdConn(connectionString))
|
||||
|
||||
// if err != nil {
|
||||
// log.Error("Unable to setup database", err)
|
||||
// }
|
||||
|
||||
// Db.SetMaxIdleConns(30)
|
||||
// Db.SetMaxOpenConns(100)
|
||||
// Db.SetConnMaxLifetime(time.Second * 14400)
|
||||
|
||||
// err = Db.Ping()
|
||||
|
||||
// if err != nil {
|
||||
// log.Error("Unable to connect to database, connection string should be of the form: '"+
|
||||
// "username:password@tcp(host:3306)/database'", err)
|
||||
// os.Exit(2)
|
||||
// }
|
||||
|
||||
// // go into setup mode if required
|
||||
// if web.SiteMode != web.SiteModeOffline {
|
||||
// if database.Check(Db, connectionString) {
|
||||
// if err := database.Migrate(true /* the config table exists */); err != nil {
|
||||
// log.Error("Unable to run database migration: ", err)
|
||||
// os.Exit(2)
|
||||
// }
|
||||
// } else {
|
||||
// log.Info("database.Check(Db) !OK, going into setup mode")
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false // value not changed
|
||||
// })
|
||||
// }
|
||||
|
||||
// var stdParams = map[string]string{
|
||||
// "charset": "utf8",
|
||||
// "parseTime": "True",
|
||||
// "maxAllowedPacket": "4194304", // 4194304 // 16777216 = 16MB
|
||||
// }
|
||||
|
||||
// func stdConn(cs string) string {
|
||||
// queryBits := strings.Split(cs, "?")
|
||||
// ret := queryBits[0] + "?"
|
||||
// retFirst := true
|
||||
// if len(queryBits) == 2 {
|
||||
// paramBits := strings.Split(queryBits[1], "&")
|
||||
// for _, pb := range paramBits {
|
||||
// found := false
|
||||
// if assignBits := strings.Split(pb, "="); len(assignBits) == 2 {
|
||||
// _, found = stdParams[strings.TrimSpace(assignBits[0])]
|
||||
// }
|
||||
// if !found { // if we can't work out what it is, put it through
|
||||
// if retFirst {
|
||||
// retFirst = false
|
||||
// } else {
|
||||
// ret += "&"
|
||||
// }
|
||||
// ret += pb
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for k, v := range stdParams {
|
||||
// if retFirst {
|
||||
// retFirst = false
|
||||
// } else {
|
||||
// ret += "&"
|
||||
// }
|
||||
// ret += k + "=" + v
|
||||
// }
|
||||
// return ret
|
||||
// }
|
||||
|
||||
type baseManager struct {
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue