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

Refactor template parser #3

Merged
merged 26 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5815152
Refactors XML to template conversion
emeka Feb 12, 2020
77046ae
WIP: integrate new parser in compiler
emeka Feb 12, 2020
d6e98fe
Config tests
Mar 2, 2020
2c9e0ed
Renamed DocumentCompilerIF to DocumentCompiler
Mar 2, 2020
5eff579
FileResult test
Mar 2, 2020
d39dc6d
wip: fixed or disabled tests
emeka Mar 2, 2020
fc2a95e
Cleanup and few tests
Mar 2, 2020
0573318
Upgraded gradle wrapper
Mar 2, 2020
2965ae4
Code tests & fixes
Mar 2, 2020
41982b6
wip: xml tests run
emeka Mar 4, 2020
c4cf898
wip: delete old code and format code
emeka Mar 4, 2020
9d37567
Improved TemplateCompilerTest and removed TemplateCompilerIntegration…
emeka Mar 5, 2020
f9cceb7
Add test for AssetFile
alexblockfactory Mar 6, 2020
8e196c6
Add test for DecimalAndUnit
alexblockfactory Mar 6, 2020
9a3fe0c
Add test for ImageAdjusterRunnable
alexblockfactory Mar 6, 2020
c5c8a5f
wip: replace client app with curl
emeka Mar 10, 2020
3b7fabf
Merge branch 'refactor-template-parser' of github.com:ProxeusApp/docu…
emeka Mar 10, 2020
2ff5d3f
wip: remove DEBUG logs
emeka Mar 10, 2020
1596bf4
wip: Fix Dockerfile and README
emeka Mar 11, 2020
78f3797
wip: fix failing proxeus test-api
emeka Mar 14, 2020
5702c80
wip: PR review fixes
emeka Mar 17, 2020
a1f7776
wip: PR review fix
emeka Mar 17, 2020
c0a2b85
wip: Alex PR review fixes
emeka Mar 20, 2020
4e432a6
wip: update circleci config
emeka Mar 21, 2020
fc32da9
wip: made latest the production docker version
emeka Mar 21, 2020
3536257
wip: dummy changes to trigger circleci
emeka Mar 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
/build/
/.idea/
/logs/
out/
/data

document-service.jar
**/.DS_Store
.classpath
.project
.settings/
bin/

# Ignore Gradle GUI config
gradle-app.setting
Expand All @@ -12,5 +20,3 @@ gradle-app.setting

# Cache of project
.gradletasknamecache

.DS_Store
39 changes: 20 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
FROM eu.gcr.io/blockfactory-01/document-service-base
FROM gradle:jdk8 as build

#font configuration
COPY ./00-fontconfig.conf /etc/fonts/conf.d/

RUN mkdir /document-service /document-service/fonts /document-service/logs

COPY ./document-service.jar /document-service/
#COPY ./config.json /document-service/
COPY ./ui_service /document-service/
COPY ./run /document-service/

RUN chmod +x /document-service/ui_service
RUN chmod +x /document-service/run
COPY --chown=gradle:gradle . /home/gradle/project/
WORKDIR /home/gradle/project
RUN gradle clean test buildJar --no-daemon

FROM ubuntu:18.04
EXPOSE 2115
ENV LANG="en_US.UTF-8"

WORKDIR /document-service
## Fix installation of openjdk-8-jre-headless (https://github.com/nextcloud/docker/issues/380)
RUN mkdir -p /usr/share/man/man1
RUN apt-get update && apt-get install -y \
software-properties-common \
language-pack-en-base \
openjdk-8-jre-headless \
libreoffice \
&& apt-get clean && rm -rf /var/cache/* /var/lib/apt/lists/*

#document-service
EXPOSE 2115
#UI
EXPOSE 58082
#font configuration
COPY ./00-fontconfig.conf /etc/fonts/conf.d/

RUN mkdir /document-service /document-service/fonts /document-service/logs
COPY --from=build /home/gradle/project/document-service.jar /document-service/

CMD ["./run"]
CMD ["/usr/bin/java", "-jar", "/document-service/document-service.jar"]
34 changes: 0 additions & 34 deletions Dockerfile.dev

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.PHONY: all build build-docker clean clean-docker

all: build build-docker run-docker
all: build build-docker

build:
gradle buildJar
build-docker:
docker image build -f Dockerfile.dev -t document-service .
docker image build -t document-service .
clean:
rm -rf .gradle build document-service.jar
clean-docker:
Expand Down
79 changes: 36 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,53 @@ Currently supported template format is `ODT`. Other formats like `DOCX` are not
+ gradle
+ docker

#### Building for development
#### Building
```
sudo docker build -t document-service .
```
gradle buildJar
sudo docker image build -f Dockerfile.dev -t document-service .

#run 2115 for the document-service and 58082 for the UI in case it is needed
sudo docker run -p 2115:2115 -p 58082:58082 document-service

#single cmd
gradle buildJar && sudo docker image build -t document-service -f ./Dockerfile.dev . && sudo docker run -p 2115:2115 -p 58082:58082 document-service

#for removing all dockers you can run
sudo ./rmalldockers.sh
#### Local run for development
```
sudo docker run -p 2115:2115 document-service
```
To run a development environment use this repository: https://git.proxeus.com/docker/proxeus-platform

#### Building for production
#### Use the official docker hub image from Proxeus
```
gradle buildJar
sudo docker image build -t document-service -f ./Dockerfile .
sudo docker run -p 2115:2115 proxeus/document-service:latest
```

## Commandline client
```
#compile usage:
./dsclient -t tmpl.odt -o my.pdf
./dsclient -u http://123.12.12.111:8888 -f pdf -t my/tmpl.odt -d data.json -a myImage.png -a my/images/dir -o output.pdf
#print vars usage:
./dsclient -m vars -t my/tmpl.odt -p input.

-a value
asset files, provide directory or file like -a file1 -a file2 -a dir1
-d string
JSON file path
-e embed compilation error into the returned document
-f string
result format, possible values: pdf, odt, docx or doc (default "pdf")
-m string
compile or vars (default "compile")
-o string
output path, extension will be attached if not provided (default "result")
-p string
var prefix to filter vars
-t string
ODT template path
-u string
Document-Service URL (default "http://localhost:2115")
You can simply interact with the server using `curl`.


```
# To compile a template to pdf (pdf is the default)

curl --form [email protected] --form [email protected] http://<server>/compile > result.pdf

# To compile a template to odt (available format are pdf, odt, docx or doc)

curl --form [email protected] --form [email protected] http://<server>/compile?format=odt > result.pdf

## Playground UI
If you want to get familiar with the Document-Service, you should start the docker with `-p 58082:58082` to expose the UI.
The UI provides access to the API, documentation and examples. You can play around with all available methods.
It is recommended to disable the UI under production.
# To embed the template rendering error in the pdf result (add the `error` query parameter

curl --form [email protected] --form [email protected] http://<server>/compile?error > result.pdf

# To get the variables used in a template

curl --data-binary @template.odt http://<server>/vars
curl --form [email protected] http:/<server>/vars

# To get the subset of the variable starting with a given prefix

curl --data-binary @template.odt http://<server>/vars?prefix=foo
curl --form [email protected] http:/<server>/vars?prefix=bar

# To add asset files

curl --form [email protected] --form [email protected] --form [email protected] http://<server>/compile > result.pdf

```

## API
The API documentation can be accessed by `<host>:<port>/api` or over the playground UI on the top right corner.
Expand Down
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
plugins {
id "com.github.hierynomus.license" version "0.15.0"
id "com.github.hierynomus.license" version "0.15.0j"
}
*/

apply plugin: 'groovy'
apply plugin: 'java'
Expand All @@ -9,6 +11,7 @@ version = '1.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8


allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -65,7 +68,7 @@ dependencies {
compile "javax.xml.bind:jaxb-api:2.2.11", ex
compile "commons-io:commons-io:RELEASE", ex
compile "javaxt:javaxt-core:1.7.8", ex
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'

compile "commons-codec:commons-codec:1.11", ex
compile "commons-io:commons-io:2.5", ex
Expand All @@ -80,5 +83,6 @@ dependencies {
compile "org.libreoffice:juh:6.2.3", ex
compile "org.libreoffice:ridl:6.2.3", ex

testCompile "junit:junit:4.10"
testCompile "junit:junit:4.13"
testCompile "org.mockito:mockito-core:2.+"
}
Binary file removed client/cmd/bin/dsclient
Binary file not shown.
Binary file removed client/cmd/bin/dsclient.exe
Binary file not shown.
Binary file removed client/cmd/bin/dsclient.mac
Binary file not shown.
138 changes: 0 additions & 138 deletions client/cmd/main.go

This file was deleted.

Loading