Skip to content

Commit

Permalink
Merge pull request #23 from synyx/fix-blurry-svg
Browse files Browse the repository at this point in the history
Fix blurry SVG
  • Loading branch information
fheft authored Jun 2, 2021
2 parents 266d8c3 + 93e2560 commit 0f9060c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions js/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ export function notFound() {
return h("div", "Unwritten tale…");
}

function poster(url) {
return h("img.poster", {
attrs: { src: url },
function poster(url, type) {
return h("object.poster", {
attrs: { data: url, type },
});
}

Expand Down Expand Up @@ -239,7 +239,7 @@ let navigator = (tale, transformMatrix, cameraPosition, activeSlide) => {
},
},
[
poster(`/editor/${tale.slug}/${tale["file-path"]}`),
poster(`/editor/${tale.slug}/${tale["file-path"]}`, tale.fileType),
layer(
{
on: {
Expand Down
1 change: 1 addition & 0 deletions js/editor/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export let uploader = tale => {
h("input", {
attrs: {
type: "file",
accept: "image/*",
},
on: {
change: ev => {
Expand Down
5 changes: 3 additions & 2 deletions js/presenter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export let presenter = tale => {
},
},
},
h("img", {
h("object", {
attrs: {
src: `/editor/${tale.slug}/${tale["file-path"]}`,
data: `/editor/${tale.slug}/${tale["file-path"]}`,
type: tale.fileType,
},
}),
),
Expand Down
1 change: 1 addition & 0 deletions pkg/project/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func (fr *FilesystemRepository) SaveImage(slug, contentType string, data []byte)
return Project{}, err
}
project.FilePath = filename
project.FileType = contentType
project, err = fr.SaveProject(slug, project)
if err != nil {
return Project{}, err
Expand Down
1 change: 1 addition & 0 deletions pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Project struct {
Slug string `json:"slug"`
Name string `json:"name"`
FilePath string `json:"file-path" edn:"file-path"`
FileType string `json:"fileType" edn:"fileType"`
Dimensions Dimensions `json:"dimensions"`
Slides []Slide `json:"slides"`
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/web/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ func TestAPI_updateProjectImage(t *testing.T) {
header.Add("Content-Type", "image/bmp")
resp := tc.RequestWithHeaders("PUT", "/api/tales/foo/image", data, header)

AssertProjectResponse(t, resp, project.Project{Slug: "foo", Name: "Bar", FilePath: "foo.bmp"}, 202)
AssertProjectResponse(t, resp, project.Project{Slug: "foo", Name: "Bar", FilePath: "foo.bmp",
FileType: "image/bmp"}, 202)
})
t.Run("invalid content type", func(t *testing.T) {
tc := NewTestClient(t)
Expand Down

0 comments on commit 0f9060c

Please sign in to comment.