diff --git a/domain/attachment/endpoint.go b/domain/attachment/endpoint.go index 42acf82d..6e3e751d 100644 --- a/domain/attachment/endpoint.go +++ b/domain/attachment/endpoint.go @@ -14,27 +14,25 @@ package attachment import ( "bytes" "database/sql" - "fmt" "io" "mime" "net/http" "strings" - "github.com/documize/community/domain/auth" - "github.com/documize/community/model/space" - "github.com/documize/community/core/env" "github.com/documize/community/core/request" "github.com/documize/community/core/response" "github.com/documize/community/core/secrets" "github.com/documize/community/core/uniqueid" "github.com/documize/community/domain" + "github.com/documize/community/domain/auth" "github.com/documize/community/domain/organization" "github.com/documize/community/domain/permission" indexer "github.com/documize/community/domain/search" "github.com/documize/community/domain/store" "github.com/documize/community/model/attachment" "github.com/documize/community/model/audit" + "github.com/documize/community/model/space" "github.com/documize/community/model/workflow" uuid "github.com/nu7hatch/gouuid" ) @@ -89,7 +87,7 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) { return } - // Get the space for this attachment + // Get the space for this attachment. sp, err := h.Store.Space.Get(ctx, doc.SpaceID) if err == sql.ErrNoRows { response.WriteNotFoundError(w, method, a.DocumentID) @@ -101,8 +99,7 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) { return } - // Get the organization for this request - // Get the space for this attachment + // Get the organization for this request. org, err := h.Store.Organization.GetOrganization(ctx, ctx.OrgID) if err == sql.ErrNoRows { response.WriteNotFoundError(w, method, a.DocumentID) @@ -181,16 +178,20 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) { typ = "application/octet-stream" } + dataSize := len(a.Data) + w.Header().Set("Content-Type", typ) w.Header().Set("Content-Disposition", `Attachment; filename="`+a.Filename+`" ; `+`filename*="`+a.Filename+`"`) - w.Header().Set("Content-Length", fmt.Sprintf("%d", len(a.Data))) - w.WriteHeader(http.StatusOK) + if dataSize != 0 { + w.Header().Set("Content-Length", string(dataSize)) + } _, err = w.Write(a.Data) if err != nil { h.Runtime.Log.Error("write attachment", err) return } + w.WriteHeader(http.StatusOK) h.Store.Audit.Record(ctx, audit.EventTypeAttachmentDownload) } diff --git a/gui/app/pods/document/index/template.hbs b/gui/app/pods/document/index/template.hbs index 79887efd..637b3e96 100644 --- a/gui/app/pods/document/index/template.hbs +++ b/gui/app/pods/document/index/template.hbs @@ -49,6 +49,19 @@ +
+
+

{{document.name}}

+

{{document.excerpt}}

+
+ {{formatted-date document.created}} + {{#if (not-eq document.created document.revised)}} + — revised {{formatted-date document.revised}} + {{/if}} +
+
+
+ {{document/document-meta tab=tab roles=roles @@ -64,19 +77,6 @@ -
-
-

{{document.name}}

-

{{document.excerpt}}

-
- {{formatted-date document.created}} - {{#if (not-eq document.created document.revised)}} - — revised {{formatted-date document.revised}} - {{/if}} -
-
-
- {{document/view-content expandState=expandState roles=roles diff --git a/gui/app/styles/core/util.scss b/gui/app/styles/core/util.scss index eaf3a7ff..ef2d890b 100644 --- a/gui/app/styles/core/util.scss +++ b/gui/app/styles/core/util.scss @@ -15,8 +15,10 @@ a { text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + outline: none; a:focus, a:hover { + outline: none; text-decoration: underline; } } diff --git a/gui/app/styles/core/view/document/meta.scss b/gui/app/styles/core/view/document/meta.scss index 14d5b7d9..dfcbad3e 100644 --- a/gui/app/styles/core/view/document/meta.scss +++ b/gui/app/styles/core/view/document/meta.scss @@ -171,7 +171,7 @@ > .document-heading { .name { - margin: 1.5rem 0 0.5rem 0; + margin: 0; color: map-get($gray-shades, 900); font-size: 2.2rem; font-weight: 700;