Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature: users are now able to provide more file types to convert by adding entries in their configuration file #3

Merged
merged 4 commits into from May 3, 2018

Conversation

gulien
Copy link
Collaborator

@gulien gulien commented May 3, 2018

This PR implements a solution for allowing users to provide more / less file types to convert by adding / removing entries in their configuration file.

New gotenberg.yml format:

# The port the application will listen to.
port: 3000

logs:
  # Accepted values, in order of severity: DEBUG, INFO, WARN, ERROR, FATAL, PANIC.
  # Messages at and above the selected level will be logged.
  level: "DEBUG"

  # Accepted values: text, json.
  # When a TTY is not attached, the output will be in the defined format.
  formatter: "text"

# You don't like a library which is used for a conversion? You want to handle a new file type?
# You may provide here your own implementation!
commands:

  # Unlike others commands' templates, you have access to FilesPaths instead of FilePath: it gathers all PDF files which should be merged.
  merge:
    template: "pdftk {{ range $filePath := .FilesPaths }} {{ $filePath }} {{ end }} cat output {{ .ResultFilePath }}"
    timeout: 30
  
  conversions:

      # The command template: you have access to FilePath and ResultFilePath variables.
    - template: "markdown-pdf {{ .FilePath }} -o {{ .ResultFilePath }}"
      # Duration in seconds after which the command will be killed if it has not finished.
      timeout: 30
      # Files with the following extensions will be converted by the current command.
      extensions:
        - ".md"

    - template: "xvfb-run -e /dev/stdout wkhtmltopdf {{ .FilePath }} {{ .ResultFilePath }}"
      timeout: 30
      extensions:
        - ".html"
        - ".htm"

    - template: "unoconv --format pdf --output \"{{ .ResultFilePath }}\" \"{{ .FilePath }}\""
      timeout: 30
      extensions:
        - ".doc"
        - ".docx"
        - ".odt"
        - ".xls"
        - ".xlsx"
        - ".ods"
        - ".ppt"
        - ".pptx"
        - ".odp"

Checklist

  • Have you followed the guidelines in our CONTRIBUTING guide?
  • Have you lint your code locally prior to submission (orbit run fmt)?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally (orbit run ci)?
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code

… by adding entries in their configuration file
@gulien gulien added the enhancement New feature or request label May 3, 2018
@gulien gulien added this to the 2.0.0 milestone May 3, 2018
@codecov
Copy link

codecov bot commented May 3, 2018

Codecov Report

Merging #3 into master will decrease coverage by 1.16%.
The diff coverage is 94.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #3      +/-   ##
==========================================
- Coverage   92.04%   90.87%   -1.17%     
==========================================
  Files           7        8       +1     
  Lines         327      307      -20     
==========================================
- Hits          301      279      -22     
- Misses         15       16       +1     
- Partials       11       12       +1
Impacted Files Coverage Δ
app/http/http.go 100% <ø> (ø) ⬆️
app/converter/file/file.go 77.77% <100%> (-3.18%) ⬇️
app/converter/converter.go 90.47% <100%> (ø) ⬆️
app/config/config.go 100% <100%> (ø) ⬆️
app/config/parser.go 100% <100%> (ø)
app/converter/process/process.go 80.39% <50%> (-8.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef9801b...35c164e. Read the comment docs.

@gulien gulien mentioned this pull request May 3, 2018
4 tasks
@gulien gulien merged commit 4997b73 into master May 3, 2018
@gulien gulien deleted the ext-config branch May 3, 2018 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant