chore: remove 6.x source code

This commit is contained in:
Julien Neuhart
2021-08-22 12:50:17 +02:00
parent 5a98790dd3
commit e457155950
168 changed files with 0 additions and 15298 deletions

View File

@@ -1,20 +0,0 @@
package main
import (
"github.com/thecodingmachine/gotenberg/internal/pkg/chrome"
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
)
func main() {
const op string = "main"
config, err := conf.FromEnv()
systemLogger := xlog.New(config.LogLevel(), "system")
if err != nil {
systemLogger.FatalOp(op, err)
}
// start Google Chrome headless.
if err := chrome.Start(systemLogger, config.GoogleChromeIgnoreCertificateErrors()); err != nil {
systemLogger.FatalOp(op, err)
}
}

View File

@@ -1,29 +0,0 @@
package test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/labstack/echo/v4"
)
// DummyEchoContext creates a
// echo.Context without anything.
func DummyEchoContext() echo.Context {
e := echo.New()
req := httptest.NewRequest(http.MethodGet, "/", nil)
rec := httptest.NewRecorder()
return e.NewContext(req, rec)
}
// EchoContextMultipart creates a
// echo.Context with form files.
func EchoContextMultipart(t *testing.T) echo.Context {
e := echo.New()
body, contentType := MergeMultipartForm(t, nil)
req := httptest.NewRequest(http.MethodPost, "/", body)
req.Header.Set(echo.HeaderContentType, contentType)
rec := httptest.NewRecorder()
return e.NewContext(req, rec)
}

View File

@@ -1,3 +0,0 @@
// Package test contains useful
// functions used across tests.
package test

View File

@@ -1,17 +0,0 @@
package test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
// AssertStatusCode checks if the given request
// returns the expected status code.
func AssertStatusCode(t *testing.T, expectedStatusCode int, srv http.Handler, req *http.Request) {
rec := httptest.NewRecorder()
srv.ServeHTTP(rec, req)
assert.Equal(t, expectedStatusCode, rec.Code)
}

View File

@@ -1,90 +0,0 @@
package test
import (
"bytes"
"io"
"mime/multipart"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
/*
MergeMultipartForm returns the body
for a multipart/form-data request with all
files under "testdata/pdf" folder.
*/
func MergeMultipartForm(t *testing.T, formValues map[string]string) (*bytes.Buffer, string) {
fpaths := MergeFpaths(t)
return multipartForm(t, "pdf", formValues, fpaths)
}
/*
HTMLMultipartForm returns the body
for a multipart/form-data request with all
files under "testdata/html" folder.
*/
func HTMLMultipartForm(t *testing.T, formValues map[string]string) (*bytes.Buffer, string) {
fpaths := HTMLFpaths(t)
return multipartForm(t, "html", formValues, fpaths)
}
/*
URLMultipartForm returns the body
for a multipart/form-data request with all
files under "testdata/url" folder.
*/
func URLMultipartForm(t *testing.T, formValues map[string]string) (*bytes.Buffer, string) {
fpaths := URLFpaths(t)
return multipartForm(t, "url", formValues, fpaths)
}
/*
MarkdownMultipartForm returns the body
for a multipart/form-data request with all
files under "testdata/markdown" folder.
*/
func MarkdownMultipartForm(t *testing.T, formValues map[string]string) (*bytes.Buffer, string) {
fpaths := MarkdownFpaths(t)
return multipartForm(t, "markdown", formValues, fpaths)
}
/*
OfficeMultipartForm returns the body
for a multipart/form-data request with all
files under "testdata/office" folder.
*/
func OfficeMultipartForm(t *testing.T, formValues map[string]string) (*bytes.Buffer, string) {
fpaths := OfficeFpaths(t)
return multipartForm(t, "office", formValues, fpaths)
}
func multipartForm(
t *testing.T,
kind string,
formValues map[string]string,
formFilePaths []string,
) (*bytes.Buffer, string) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
defer writer.Close()
for _, fpath := range formFilePaths {
file, err := os.Open(fpath)
require.Nil(t, err)
part, err := writer.CreateFormFile("foo", filepath.Base(fpath))
require.Nil(t, err)
_, err = io.Copy(part, file)
require.Nil(t, err)
}
if kind == "url" {
err := writer.WriteField("remoteURL", "https://google.com")
require.Nil(t, err)
}
for k, v := range formValues {
err := writer.WriteField(k, v)
require.Nil(t, err)
}
return body, writer.FormDataContentType()
}

View File

@@ -1,88 +0,0 @@
package test
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/thecodingmachine/gotenberg/internal/pkg/xrand"
)
/*
testdataDirectoryPath should be
the absolute of the testdata INSIDE
the Docker image.
*/
const testdataDirectoryPath string = "/gotenberg/tests/test/testdata"
// GenerateDestination simply generates
// a path for a resulting PDF file.
func GenerateDestination() string {
return fmt.Sprintf("/tmp/%s.pdf", xrand.Get())
}
// MergeFpaths return the paths of all
// files under "testdata/pdf" folder.
func MergeFpaths(t *testing.T) []string {
return []string{
fpath(t, "pdf", "gotenberg.pdf"),
fpath(t, "pdf", "gotenberg_bis.pdf"),
}
}
// HTMLFpaths return the paths of all
// files under "testdata/html" folder.
func HTMLFpaths(t *testing.T) []string {
return []string{
fpath(t, "html", "index.html"),
fpath(t, "html", "header.html"),
fpath(t, "html", "footer.html"),
fpath(t, "html", "style.css"),
fpath(t, "html", "img.gif"),
fpath(t, "html", "font.woff"),
}
}
// URLFpaths return the paths of all
// files under "testdata/url" folder.
func URLFpaths(t *testing.T) []string {
return []string{
fpath(t, "url", "header.html"),
fpath(t, "url", "footer.html"),
}
}
// MarkdownFpaths return the paths of all
// files under "testdata/markdown" folder.
func MarkdownFpaths(t *testing.T) []string {
return []string{
fpath(t, "markdown", "index.html"),
fpath(t, "markdown", "header.html"),
fpath(t, "markdown", "footer.html"),
fpath(t, "markdown", "style.css"),
fpath(t, "markdown", "img.gif"),
fpath(t, "markdown", "font.woff"),
fpath(t, "markdown", "paragraph1.md"),
fpath(t, "markdown", "paragraph2.md"),
fpath(t, "markdown", "paragraph3.md"),
}
}
// OfficeFpaths return the paths of all
// files under "testdata/office" folder.
func OfficeFpaths(t *testing.T) []string {
return []string{
fpath(t, "office", "document.docx"),
fpath(t, "office", "document.rtf"),
fpath(t, "office", "document.txt"),
fpath(t, "office", "document_with_special_éà.txt"),
}
}
func fpath(t *testing.T, kind, filename string) string {
require.NotEmpty(t, kind)
require.NotEmpty(t, filename)
fpath := fmt.Sprintf("%s/%s/%s", testdataDirectoryPath, kind, filename)
require.FileExists(t, fpath)
return fpath
}

Binary file not shown.

View File

@@ -1,15 +0,0 @@
<html>
<head>
<style>
body {
font-size: 8rem;
margin: 4rem auto;
}
</style>
</head>
<body>
<p>
<span class="pageNumber"></span> of <span class="totalPages"></span>
</p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<html>
<head>
<style>
body {
font-size: 8rem;
margin: 4rem auto;
}
</style>
</head>
<body>
<span class="title"></span>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -1,38 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<title>Gutenberg</title>
</head>
<body>
<div class="page-break-after">
<div class="center">
<h1>Gutenberg</h1>
<img src="img.gif">
</div>
<blockquote cite="https://sites.google.com/site/johanngutenbergper5/q">
<p>It is a press, certainly, but a press from which shall flow in inexhaustible streams...Through it, God will spread His Word. A spring of truth shall flow from it: like a new star it shall scatter the darkness of ignorance, and cause a light heretofore unknown to shine amongst men.</p>
<footer><a href="https://sites.google.com/site/johanngutenbergper5/q">Johannes Gutenberg</a></cite></footer>
</blockquote>
</div>
<div class="page-break-after">
<h2>This paragraph use the default font</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<h2>This paragraph use a Google font</h2>
<p class="google-font">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<h2>This paragraph use a local font</h2>
<p class="local-font">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="center">
<h1>This image is loaded from a URL</h1>
<img src="https://gutendev.com/wp-content/uploads/2018/10/01_03-1.jpg">
</div>
</body>
</html>

View File

@@ -1,28 +0,0 @@
body {
font-family: Arial, Helvetica, sans-serif;
}
.center {
text-align: center;
}
.google-font {
font-family: 'Montserrat', sans-serif;
}
@font-face {
font-family: 'Local';
src: url('font.woff') format('woff');
font-weight: normal;
font-style: normal;
}
.local-font {
font-family: 'Local'
}
@media print {
.page-break-after {
page-break-after: always;
}
}

Binary file not shown.

View File

@@ -1,15 +0,0 @@
<html>
<head>
<style>
body {
font-size: 8rem;
margin: 4rem auto;
}
</style>
</head>
<body>
<p>
<span class="pageNumber"></span> of <span class="totalPages"></span>
</p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<html>
<head>
<style>
body {
font-size: 8rem;
margin: 4rem auto;
}
</style>
</head>
<body>
<span class="title"></span>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -1,34 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<title>Gutenberg</title>
</head>
<body>
<div class="page-break-after">
<div class="center">
<h1>Gutenberg</h1>
<img src="img.gif">
</div>
<blockquote cite="https://sites.google.com/site/johanngutenbergper5/q">
<p>It is a press, certainly, but a press from which shall flow in inexhaustible streams...Through it, God will spread His Word. A spring of truth shall flow from it: like a new star it shall scatter the darkness of ignorance, and cause a light heretofore unknown to shine amongst men.</p>
<footer><a href="https://sites.google.com/site/johanngutenbergper5/q">Johannes Gutenberg</a></cite></footer>
</blockquote>
</div>
<div class="page-break-after">
{{ toHTML .DirPath "paragraph1.md" }}
<div class="google-font">
{{ toHTML .DirPath "paragraph2.md" }}
</div>
<div class="local-font">
{{ toHTML .DirPath "paragraph3.md" }}
</div>
</div>
</body>
</html>

View File

@@ -1,3 +0,0 @@
## This paragraph use the default font and has been generated from a markdown file
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@@ -1,3 +0,0 @@
## This paragraph use a Google font and has been generated from a markdown file
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@@ -1,3 +0,0 @@
## This paragraph use a local font and has been generated from a markdown file
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@@ -1,28 +0,0 @@
body {
font-family: Arial, Helvetica, sans-serif;
}
.center {
text-align: center;
}
.google-font {
font-family: 'Montserrat', sans-serif;
}
@font-face {
font-family: 'Local';
src: url('font.woff') format('woff');
font-weight: normal;
font-style: normal;
}
.local-font {
font-family: 'Local'
}
@media print {
.page-break-after {
page-break-after: always;
}
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
Gutenberg
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@@ -1,3 +0,0 @@
Gutenberg
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Binary file not shown.

Binary file not shown.

View File

@@ -1,15 +0,0 @@
<html>
<head>
<style>
body {
font-size: 8rem;
margin: 4rem auto;
}
</style>
</head>
<body>
<p>
<span class="pageNumber"></span> of <span class="totalPages"></span>
</p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<html>
<head>
<style>
body {
font-size: 8rem;
margin: 4rem auto;
}
</style>
</head>
<body>
<span class="title"></span>
</body>
</html>

View File

@@ -1,18 +0,0 @@
package test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
)
// AssertError validates that given error
// is of an instance of xerror.Error.
// If so, returns the instance of xerror.Error.
func AssertError(t *testing.T, err error) *xerror.Error {
assert.NotNil(t, err)
standardized, ok := err.(*xerror.Error)
assert.Equal(t, true, ok)
return standardized
}

View File

@@ -1,23 +0,0 @@
package test
import (
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
)
// DebugLogger creates a xlog.Logger
// with xlog.DebugLevel for our tests.
func DebugLogger() xlog.Logger {
return xlog.New(xlog.DebugLevel, "tests")
}
// InfoLogger creates a xlog.Logger
// with xlog.InfoLevel for our tests.
func InfoLogger() xlog.Logger {
return xlog.New(xlog.DebugLevel, "tests")
}
// ErrorLogger creates a xlog.Logger
// with xlog.ErrorLevel for our tests.
func ErrorLogger() xlog.Logger {
return xlog.New(xlog.ErrorLevel, "tests")
}