Skip to content

Commit fb193ce

Browse files
authored
Merge pull request #148 from documize/draw
Draw.io integration
2 parents b839a07 + 2298ac3 commit fb193ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+11956
-778
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Documize - author, track and deliver documentation
21

32
## The mission
43

@@ -52,9 +51,9 @@ Space view.
5251

5352
## Latest version
5453

55-
[Community edition: v1.63.1](https://github.com/documize/community/releases)
54+
[Community edition: v1.64.0](https://github.com/documize/community/releases)
5655

57-
[Enterprise edition: v1.65.1](https://documize.com/downloads)
56+
[Enterprise edition: v1.66.0](https://documize.com/downloads)
5857

5958
## OS support
6059

build.bat

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ cd ..
1313
rd /s /q embed\bindata\public
1414
mkdir embed\bindata\public
1515
echo "Copying Ember assets folder"
16-
robocopy /e /NFL /NDL /NJH gui\dist-prod\assets embed\bindata\public\assets
16+
robocopy /e /NFL /NDL /NJH gui\dist-prod\assets embed\bindata\public\assets
1717
echo "Copying Ember codemirror folder"
1818
robocopy /e /NFL /NDL /NJH gui\dist-prod\codemirror embed\bindata\public\codemirror
1919
echo "Copying Ember tinymce folder"
20-
robocopy /e /NFL /NDL /NJH gui\dist-prod\tinymce embed\bindata\public\tinymce
20+
robocopy /e /NFL /NDL /NJH gui\dist-prod\tinymce embed\bindata\public\tinymce
2121
echo "Copying Ember sections folder"
2222
robocopy /e /NFL /NDL /NJH gui\dist-prod\sections embed\bindata\public\sections
2323

@@ -40,7 +40,7 @@ echo "Generating in-memory static assets..."
4040
go get -u github.com/jteeuwen/go-bindata/...
4141
go get -u github.com/elazarl/go-bindata-assetfs/...
4242
cd embed
43-
go generate
43+
go generate
4444
cd ..
4545

4646
echo "Compiling Windows"
@@ -53,4 +53,4 @@ go build -gcflags=-trimpath=%GOPATH% -asmflags=-trimpath=%GOPATH% -o bin/documiz
5353

5454
echo "Compiling Darwin"
5555
set GOOS=darwin
56-
go build -gcflags=-trimpath=%GOPATH% -asmflags=-trimpath=%GOPATH% -o bin/documize-community-darwin-amd64 edition/community.go
56+
go build -gcflags=-trimpath=%GOPATH% -asmflags=-trimpath=%GOPATH% -o bin/documize-community-darwin-amd64 edition/community.go

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ echo "Finished."
5454

5555
# CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo
5656
# go build -ldflags '-d -s -w' -a -tags netgo -installsuffix netgo test.go
57-
# ldd test
57+
# ldd test

core/stringutil/initials.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ func MakeInitials(firstname, lastname string) string {
2323
b := ""
2424

2525
if len(firstname) > 0 {
26-
a = firstname[:1]
26+
a = string([]rune(firstname)[:1])
2727
}
2828

2929
if len(lastname) > 0 {
30-
b = lastname[:1]
30+
b = string([]rune(lastname)[:1])
3131
}
3232

3333
return strings.ToUpper(a + b)

core/stringutil/initials_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ package stringutil
1313

1414
import "testing"
1515

16+
// go test github.com/documize/community/core/stringutil -run TestInitials
1617
func TestInitials(t *testing.T) {
1718
in(t, "Harvey", "Kandola", "HK")
1819
in(t, "Harvey", "", "H")
1920
in(t, "", "Kandola", "K")
2021
in(t, "", "", "")
22+
in(t, "Иванов", "Иванов", "ИИ")
2123
}
2224

2325
func in(t *testing.T, firstname, lastname, expecting string) {

domain/mail/document.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ import (
2020
)
2121

2222
// DocumentApprover notifies user who has just been granted document approval rights.
23-
func (m *Mailer) DocumentApprover(recipient, inviter, url, document string) {
23+
func (m *Mailer) DocumentApprover(recipient, inviterName, inviterEmail, url, document string) {
2424
method := "DocumentApprover"
2525
m.Initialize()
2626

2727
// check inviter name
28-
if inviter == "Hello You" || len(inviter) == 0 {
29-
inviter = "Your colleague"
28+
if inviterName == "Hello You" || len(inviterName) == 0 {
29+
inviterName = "Your colleague"
3030
}
3131

3232
em := smtp.EmailMessage{}
33-
em.Subject = fmt.Sprintf("%s has granted you document approval", inviter)
33+
em.Subject = fmt.Sprintf("%s has granted you document approval", inviterName)
3434
em.ToEmail = recipient
3535
em.ToName = recipient
36+
em.ReplyTo = inviterEmail
37+
em.ReplyName = inviterName
3638

3739
parameters := struct {
3840
Subject string
@@ -41,7 +43,7 @@ func (m *Mailer) DocumentApprover(recipient, inviter, url, document string) {
4143
Document string
4244
}{
4345
em.Subject,
44-
inviter,
46+
inviterName,
4547
url,
4648
document,
4749
}

domain/mail/space.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ import (
1818
)
1919

2020
// ShareSpaceExistingUser provides an existing user with a link to a newly shared space.
21-
func (m *Mailer) ShareSpaceExistingUser(recipient, inviter, url, folder, intro string) {
21+
func (m *Mailer) ShareSpaceExistingUser(recipient, inviterName, inviterEmail, url, folder, intro string) {
2222
method := "ShareSpaceExistingUser"
2323
m.Initialize()
2424

2525
// check inviter name
26-
if inviter == "Hello You" || len(inviter) == 0 {
27-
inviter = "Your colleague"
26+
if inviterName == "Hello You" || len(inviterName) == 0 {
27+
inviterName = "Your colleague"
2828
}
2929

3030
em := smtp.EmailMessage{}
31-
em.Subject = fmt.Sprintf("%s has shared %s with you", inviter, folder)
31+
em.Subject = fmt.Sprintf("%s has shared %s with you", inviterName, folder)
3232
em.ToEmail = recipient
3333
em.ToName = recipient
34+
em.ReplyTo = inviterEmail
35+
em.ReplyName = inviterName
3436

3537
parameters := struct {
3638
Subject string
@@ -40,7 +42,7 @@ func (m *Mailer) ShareSpaceExistingUser(recipient, inviter, url, folder, intro s
4042
Intro string
4143
}{
4244
em.Subject,
43-
inviter,
45+
inviterName,
4446
url,
4547
folder,
4648
intro,
@@ -63,19 +65,21 @@ func (m *Mailer) ShareSpaceExistingUser(recipient, inviter, url, folder, intro s
6365
}
6466

6567
// ShareSpaceNewUser invites new user providing Credentials, explaining the product and stating who is inviting them.
66-
func (m *Mailer) ShareSpaceNewUser(recipient, inviter, url, space, invitationMessage string) {
68+
func (m *Mailer) ShareSpaceNewUser(recipient, inviterName, inviterEmail, url, space, invitationMessage string) {
6769
method := "ShareSpaceNewUser"
6870
m.Initialize()
6971

7072
// check inviter name
71-
if inviter == "Hello You" || len(inviter) == 0 {
72-
inviter = "Your colleague"
73+
if inviterName == "Hello You" || len(inviterName) == 0 {
74+
inviterName = "Your colleague"
7375
}
7476

7577
em := smtp.EmailMessage{}
76-
em.Subject = fmt.Sprintf("%s has shared %s with you on Documize", inviter, space)
78+
em.Subject = fmt.Sprintf("%s has shared %s with you on Documize", inviterName, space)
7779
em.ToEmail = recipient
7880
em.ToName = recipient
81+
em.ReplyTo = inviterEmail
82+
em.ReplyName = inviterName
7983

8084
parameters := struct {
8185
Subject string
@@ -85,7 +89,7 @@ func (m *Mailer) ShareSpaceNewUser(recipient, inviter, url, space, invitationMes
8589
Folder string
8690
}{
8791
em.Subject,
88-
inviter,
92+
inviterName,
8993
url,
9094
invitationMessage,
9195
space,

domain/mail/user.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ import (
1818
)
1919

2020
// InviteNewUser invites someone new providing credentials, explaining the product and stating who is inviting them.
21-
func (m *Mailer) InviteNewUser(recipient, inviter, url, username, password string) {
21+
func (m *Mailer) InviteNewUser(recipient, inviterName, inviterEmail, url, username, password string) {
2222
method := "InviteNewUser"
2323
m.Initialize()
2424

2525
// check inviter name
26-
if inviter == "Hello You" || len(inviter) == 0 {
27-
inviter = "Your colleague"
26+
if inviterName == "Hello You" || len(inviterName) == 0 {
27+
inviterName = "Your colleague"
2828
}
2929

3030
em := smtp.EmailMessage{}
31-
em.Subject = fmt.Sprintf("%s has invited you to Documize", inviter)
31+
em.Subject = fmt.Sprintf("%s has invited you to Documize", inviterName)
3232
em.ToEmail = recipient
3333
em.ToName = recipient
34+
em.ReplyTo = inviterEmail
35+
em.ReplyName = inviterName
3436

3537
parameters := struct {
3638
Subject string
@@ -40,7 +42,7 @@ func (m *Mailer) InviteNewUser(recipient, inviter, url, username, password strin
4042
Password string
4143
}{
4244
em.Subject,
43-
inviter,
45+
inviterName,
4446
url,
4547
recipient,
4648
password,
@@ -63,27 +65,29 @@ func (m *Mailer) InviteNewUser(recipient, inviter, url, username, password strin
6365
}
6466

6567
// InviteExistingUser invites a known user to an organization.
66-
func (m *Mailer) InviteExistingUser(recipient, inviter, url string) {
68+
func (m *Mailer) InviteExistingUser(recipient, inviterName, inviterEmail, url string) {
6769
method := "InviteExistingUser"
6870
m.Initialize()
6971

7072
// check inviter name
71-
if inviter == "Hello You" || len(inviter) == 0 {
72-
inviter = "Your colleague"
73+
if inviterName == "Hello You" || len(inviterName) == 0 {
74+
inviterName = "Your colleague"
7375
}
7476

7577
em := smtp.EmailMessage{}
76-
em.Subject = fmt.Sprintf("%s has invited you to their Documize account", inviter)
78+
em.Subject = fmt.Sprintf("%s has invited you to their Documize account", inviterName)
7779
em.ToEmail = recipient
7880
em.ToName = recipient
81+
em.ReplyTo = inviterEmail
82+
em.ReplyName = inviterName
7983

8084
parameters := struct {
8185
Subject string
8286
Inviter string
8387
URL string
8488
}{
8589
em.Subject,
86-
inviter,
90+
inviterName,
8791
url,
8892
}
8993

domain/permission/endpoint.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (h *Handler) SetSpacePermissions(w http.ResponseWriter, r *http.Request) {
200200
}
201201

202202
mailer := mail.Mailer{Runtime: h.Runtime, Store: h.Store, Context: ctx}
203-
go mailer.ShareSpaceExistingUser(existingUser.Email, inviter.Fullname(), url, sp.Name, model.Message)
203+
go mailer.ShareSpaceExistingUser(existingUser.Email, inviter.Fullname(), inviter.Email, url, sp.Name, model.Message)
204204
h.Runtime.Log.Info(fmt.Sprintf("%s is sharing space %s with existing user %s", inviter.Email, sp.Name, existingUser.Email))
205205
}
206206
}
@@ -701,7 +701,7 @@ func (h *Handler) SetDocumentPermissions(w http.ResponseWriter, r *http.Request)
701701
}
702702

703703
mailer := mail.Mailer{Runtime: h.Runtime, Store: h.Store, Context: ctx}
704-
go mailer.DocumentApprover(existingUser.Email, inviter.Fullname(), url, doc.Title)
704+
go mailer.DocumentApprover(existingUser.Email, inviter.Fullname(), inviter.Email, url, doc.Title)
705705
h.Runtime.Log.Info(fmt.Sprintf("%s has made %s document approver for: %s", inviter.Email, existingUser.Email, doc.Title))
706706
}
707707
}

domain/section/flowchart/flowchart.go

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2016 Documize Inc. <[email protected]>. All rights reserved.
2+
//
3+
// This software (Documize Community Edition) is licensed under
4+
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
5+
//
6+
// You can operate outside the AGPL restrictions by purchasing
7+
// Documize Enterprise Edition and obtaining a commercial license
8+
// by contacting <[email protected]>.
9+
//
10+
// https://documize.com
11+
12+
package flowchart
13+
14+
import (
15+
"net/http"
16+
17+
"github.com/documize/community/core/env"
18+
"github.com/documize/community/domain"
19+
"github.com/documize/community/domain/section/provider"
20+
)
21+
22+
// Provider represents Draw.io
23+
type Provider struct {
24+
Runtime *env.Runtime
25+
Store *domain.Store
26+
}
27+
28+
// Meta describes us
29+
func (*Provider) Meta() provider.TypeMeta {
30+
section := provider.TypeMeta{}
31+
32+
section.ID = "d46a18f6-49fb-11e8-842f-0ed5f89f718b"
33+
section.Title = "Draw.io Diagram"
34+
section.Description = "Draw.io powered flowcharts and diagrams"
35+
section.ContentType = "flowchart"
36+
section.PageType = "tab"
37+
section.Order = 9991
38+
39+
return section
40+
}
41+
42+
// Command stub.
43+
func (p *Provider) Command(ctx *provider.Context, w http.ResponseWriter, r *http.Request) {
44+
}
45+
46+
// Render returns data as-is (HTML).
47+
func (p *Provider) Render(ctx *provider.Context, config, data string) string {
48+
return data
49+
}
50+
51+
// Refresh just sends back data as-is.
52+
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
53+
return data
54+
}

domain/section/plantuml/plantuml.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/documize/community/domain/section/provider"
2626
)
2727

28-
// Provider represents Mermaid Diagram
28+
// Provider represents PlantUML Text Diagram
2929
type Provider struct {
3030
Runtime *env.Runtime
3131
Store *domain.Store

domain/section/register.go

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/documize/community/domain"
1919
"github.com/documize/community/domain/section/airtable"
2020
"github.com/documize/community/domain/section/code"
21+
"github.com/documize/community/domain/section/flowchart"
2122
"github.com/documize/community/domain/section/gemini"
2223
"github.com/documize/community/domain/section/markdown"
2324
"github.com/documize/community/domain/section/papertrail"
@@ -41,6 +42,7 @@ func Register(rt *env.Runtime, s *domain.Store) {
4142
provider.Register("wysiwyg", &wysiwyg.Provider{Runtime: rt, Store: s})
4243
provider.Register("airtable", &airtable.Provider{Runtime: rt, Store: s})
4344
provider.Register("plantuml", &plantuml.Provider{Runtime: rt, Store: s})
45+
provider.Register("flowchart", &flowchart.Provider{Runtime: rt, Store: s})
4446

4547
p := provider.List()
4648
rt.Log.Info(fmt.Sprintf("Registered %d sections", len(p)))

domain/smtp/send.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ func Connect(c Config) (d *mail.Dialer, err error) {
8888

8989
// EmailMessage represents email to be sent.
9090
type EmailMessage struct {
91-
ToEmail string
92-
ToName string
93-
Subject string
94-
BodyHTML string
91+
ToEmail string
92+
ToName string
93+
Subject string
94+
BodyHTML string
95+
ReplyTo string
96+
ReplyName string
9597
}
9698

9799
// SendMessage sends email using specified SMTP connection
@@ -102,6 +104,17 @@ func SendMessage(d *mail.Dialer, c Config, em EmailMessage) (b bool, err error)
102104
m.SetHeader("From", m.FormatAddress(c.SenderEmail, c.SenderName))
103105
m.SetHeader("To", m.FormatAddress(em.ToEmail, em.ToName))
104106

107+
// Where do replies go?
108+
reply := c.SenderEmail
109+
replyName := c.SenderName
110+
if len(em.ReplyTo) > 0 {
111+
reply = em.ReplyTo
112+
}
113+
if len(em.ReplyName) > 0 {
114+
replyName = em.ReplyName
115+
}
116+
m.SetAddressHeader("Reply-To", reply, replyName)
117+
105118
// content
106119
m.SetHeader("Subject", em.Subject)
107120
m.SetBody("text/html", em.BodyHTML)

domain/space/endpoint.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ func (h *Handler) Invite(w http.ResponseWriter, r *http.Request) {
868868

869869
url := ctx.GetAppURL(fmt.Sprintf("s/%s/%s", sp.RefID, stringutil.MakeSlug(sp.Name)))
870870
mailer := mail.Mailer{Runtime: h.Runtime, Store: h.Store, Context: ctx}
871-
go mailer.ShareSpaceExistingUser(email, inviter.Fullname(), url, sp.Name, model.Message)
871+
go mailer.ShareSpaceExistingUser(email, inviter.Fullname(), inviter.Email, url, sp.Name, model.Message)
872872

873873
h.Runtime.Log.Info(fmt.Sprintf("%s is sharing space %s with existing user %s", inviter.Email, sp.Name, email))
874874
} else {

0 commit comments

Comments
 (0)