Skip to content

Commit 1fc5ef4

Browse files
author
Ian Lai
committed
Initial OS commit
0 parents  commit 1fc5ef4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+15027
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build/
2+
logs
3+
*.log
4+
npm-debug.log*
5+
node_modules
6+
.npm
7+
.DS_STORE
8+
*.env
9+
!sample.env

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright © 2016 Arachnys Information Services Ltd and individual contributors.
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the “Software”), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.

Makefile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
CLI_DIR ?= cli
2+
CLI_IMAGE ?= "arachnysdocker/athenapdf"
3+
CLI_DOCKER_ARTIFACT_DIR ?= "/athenapdf/build/"
4+
5+
SERVICE_DIR ?= weaver
6+
SERVICE_IMAGE ?= "arachnysdocker/athenapdf-service"
7+
SERVICE_DOCKER_ARTIFACT_FILE ?= "/go/src/github.com/arachnys/athenapdf/weaver"
8+
9+
P="\\033[34m[+]\\033[0m"
10+
11+
help:
12+
@echo
13+
@echo " \033[34mbuildcli\033[0m – builds athenapdf (cli) docker image"
14+
@echo " \033[34mbuildservice\033[0m – builds athenapdf-service docker image"
15+
@echo " \033[34mbuild\033[0m – builds both the cli, and service docker image"
16+
@echo
17+
18+
buildcli:
19+
@echo " $(P) buildcli"
20+
@rm -rf $(CLI_DIR)/build/
21+
@docker build --rm -t $(CLI_IMAGE)-build -f $(CLI_DIR)/Dockerfile.build $(CLI_DIR)/
22+
@docker run -t $(CLI_IMAGE)-build /bin/true
23+
@docker cp `docker ps -q -n=1`:$(CLI_DOCKER_ARTIFACT_DIR) $(CLI_DIR)/build/
24+
@docker rm -f `docker ps -q -n=1`
25+
@docker build --rm -t $(CLI_IMAGE) -f $(CLI_DIR)/Dockerfile $(CLI_DIR)/
26+
@rm -rf $(CLI_DIR)/build/
27+
28+
buildservice:
29+
@echo " $(P) buildservice"
30+
@rm -rf $(SERVICE_DIR)/build/
31+
@docker build --rm -t $(SERVICE_IMAGE)-build -f $(SERVICE_DIR)/Dockerfile.build $(SERVICE_DIR)/
32+
@docker run -t $(SERVICE_IMAGE)-build /bin/true
33+
@docker cp `docker ps -q -n=1`:$(SERVICE_DOCKER_ARTIFACT_FILE) $(SERVICE_DIR)/build/
34+
@docker rm -f `docker ps -q -n=1`
35+
@chmod +x $(SERVICE_DIR)/build/weaver
36+
@docker build --rm -t $(SERVICE_IMAGE) -f $(SERVICE_DIR)/Dockerfile $(SERVICE_DIR)/
37+
@rm -rf $(SERVICE_DIR)/build/
38+
39+
build:
40+
@echo " $(P) build"
41+
@make buildcli
42+
@make buildservice
43+
44+
.PHONY: help buildcli buildservice build

README.md

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Athena
2+
3+
[Main Website][athenapdf]
4+
5+
Simple, Docker-powered PDF conversions.
6+
7+
Athena is comprised of an [Electron][electron] command line interface (CLI) tool, and a [Go][go] microservice for converting HTML to PDF documents.
8+
9+
> Athena transformed Arachne into a spider for challenging her as a weaver and/or weaving a tapestry that insulted the gods.
10+
11+
**Examples:**
12+
13+
- Original: [Google isn’t even close as a tool for proper due diligence. Why not?][example-1] **(Converted: [PDF][example-1-pdf] | [Aggressive][example-1-aggressive])**
14+
- Original: [Panamanian Law Firm Is Gatekeeper To Vast Flow of Murky Offshore Secrets][example-2] **(Converted: [PDF][example-2-pdf] | [Aggressive][example-2-aggressive])**
15+
16+
_When [aggressive mode][aggressive] is toggled, only the essential contents of a page are kept in the generated PDF document. It is a clutter-free version of the web page, perfect for reading._
17+
18+
**HTML, PDF, PDF (Aggressive):**
19+
20+
![Conversion](https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/conversion.gif)
21+
22+
23+
## Background
24+
25+
Athena is an open source project.
26+
27+
It was designed to [do one thing and to do it well][unixphil] - PDF conversions; to work together with other programs; and to be able to handle text streams, because that is a universal interface.
28+
29+
It aims to empower individuals, and organisations with an on-demand capability to convert HTML to PDF without frills.
30+
31+
At the lowest level, its [CLI][cli] component ([`athenapdf`][cli]) was designed to be an alternative / drop-in replacement for [wkhtmltopdf], a popular CLI tool for HTML to PDF conversions.
32+
33+
There is also a [microservice][weaver] component ([`weaver`][weaver]), and it was designed to be an alternative / drop-in replacement for paid services like [CloudConvert][cloudconvert], but with more freedom, and flexibility, and without limitations, long support response times, and price plans.
34+
35+
36+
## Getting Started
37+
38+
### CLI vs Microservice
39+
40+
Our [CLI][cli] tool will suffice for most simple, and everyday HTML to PDF conversions.
41+
42+
However, for conversions at scale / PDF conversion as a service, we recommend getting started with our [microservice][weaver] component instead.
43+
44+
![CLI vs Microservice](https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/docker.png)
45+
46+
The microservice is packaged with `athenapdf`, and you can run both components independently.
47+
48+
### Docker
49+
50+
Both components are packaged, and distributed as [Docker][docker] images.
51+
52+
The only dependency you will need is Docker, and the rest will be handled for you (even if you are running in an environment without a display server - [headless environment][headless]).
53+
54+
### Quick Start
55+
56+
Before starting, ensure your [Docker][docker] environment is set up, and ready-to-use.
57+
58+
**For OSX / Windows users**, ensure your [Docker Machine][docker-machine] is prepared, and the appropriate environment variables are established.
59+
60+
#### CLI
61+
62+
[![asciicast](https://asciinema.org/a/c1fbvtdnrctfq6baipfox00ct.png)](https://asciinema.org/a/c1fbvtdnrctfq6baipfox00ct)
63+
64+
1. `docker pull arachnysdocker/athenapdf`
65+
2. `docker run --rm -v $(pwd):/converted/ arachnysdocker/athenapdf athenapdf <input_path> [output_path]`
66+
3. See [`cli`][cli] for full documentation
67+
68+
The `[output_path]` can be omitted.
69+
70+
Example: `docker run --rm -v $(pwd):/converted/ arachnysdocker/athenapdf athenapdf http://blog.arachnys.com/`
71+
72+
#### Microservice
73+
74+
[![asciicast](https://asciinema.org/a/41247.png)](https://asciinema.org/a/41247)
75+
76+
1. `docker pull arachnysdocker/athenapdf-service`
77+
2. `docker run -p 8080:8080 --rm arachnysdocker/athenapdf-service`
78+
3. Inline conversion: `http://<docker-address>:8080/convert?auth=arachnys-weaver&url=http://blog.arachnys.com/`
79+
4. OR cURL, and redirect output to file: `curl http://dockerhost:8080/convert\?auth\=arachnys-weaver\&url\=http://blog.arachnys.com/ |> out.pdf`
80+
5. See [`weaver`][weaver] for full documentation
81+
82+
The default authentication key is `arachnys-weaver`. This can be changed through the `WEAVER_AUTH_KEY` environment variable.
83+
84+
85+
## License
86+
87+
Please note `athenapdf` is NEITHER affiliated with NOR endorsed by Google Inc. and GitHub Inc.
88+
89+
See [`LICENSE`](LICENSE).
90+
91+
---
92+
93+
![Arachnys](https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/logo.png)
94+
95+
An [Arachnys][arachnys] Christmas project.
96+
97+
98+
[athenapdf]: http://www.athenapdf.com/
99+
[unixphil]: https://en.wikipedia.org/wiki/Unix_philosophy
100+
[example-1]: http://blog.arachnys.com/google-isnt-even-close-to-proper-due-diligence.-why-not?utm_campaign=athena&utm_medium=external%20website&utm_source=github&utm_content=readme
101+
[example-1-pdf]: https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/d0ae9e636bb7edceac48bd9b0780ad9dd69397cc.pdf
102+
[example-1-aggressive]: https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/d0ae9e636bb7edceac48bd9b0780ad9dd69397cc-aggressive.pdf
103+
[example-2]: https://panamapapers.icij.org/20160403-mossack-fonseca-offshore-secrets.html
104+
[example-2-pdf]: https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/f86e19ea13661e47c1f5f83bbde650eb3fe85aad.pdf
105+
[example-2-aggressive]: https://s3-eu-west-1.amazonaws.com/athena-pdf-public/examples/f86e19ea13661e47c1f5f83bbde650eb3fe85aad-aggressive.pdf
106+
[aggressive]: cli/docs/aggressive.md
107+
[electron]: http://electron.atom.io/
108+
[go]: https://golang.org/
109+
[cli]: cli/
110+
[weaver]: weaver/
111+
[wkhtmltopdf]: http://wkhtmltopdf.org/
112+
[cloudconvert]: https://cloudconvert.com/
113+
[docker]: https://www.docker.com/
114+
[docker-machine]: https://docs.docker.com/mac/step_one/
115+
[headless]: http://internetofthingsagenda.techtarget.com/definition/headless-system
116+
[arachnys]: https://www.arachnys.com/?utm_campaign=athena&utm_medium=external%20website&utm_source=github&utm_content=readme

cli/.dockerignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Node
2+
node_modules/
3+
bin/
4+
5+
# Docker
6+
.dockerfile
7+
docker-compose.yml
8+
Dockerfile
9+
Dockerfile.build
10+
11+
# Docs
12+
README.md
13+
docs/
14+
15+
# Others
16+
**/.DS_STORE
17+
**/.git*
18+
**/*.env

cli/Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM debian:8.3
2+
MAINTAINER Arachnys <[email protected]>
3+
4+
RUN echo 'deb http://debian.man.ac.uk/debian/ stable main contrib non-free' >> /etc/apt/sources.list
5+
6+
RUN apt-get -yq update && \
7+
apt-get -yq install \
8+
xvfb \
9+
libgtk2.0-0 \
10+
libgconf-2-4 \
11+
libXtst6 \
12+
libnss3 \
13+
libnotify4 \
14+
ttf-mscorefonts-installer \
15+
ttf-liberation \
16+
ttf-wqy-zenhei \
17+
ttf-unfonts-core \
18+
fonts-sil-padauk \
19+
fonts-lklug-sinhala \
20+
fonts-thai-tlwg \
21+
&& apt-get -yq autoremove \
22+
&& apt-get -yq clean \
23+
&& rm -rf /var/lib/apt/lists/* \
24+
&& truncate -s 0 /var/log/*log
25+
26+
ADD build/athenapdf-linux-x64/ /athenapdf/
27+
WORKDIR /athenapdf/
28+
29+
ENV PATH /athenapdf/:$PATH
30+
31+
ADD entrypoint.sh /athenapdf/entrypoint.sh
32+
33+
RUN mkdir -p /converted/
34+
WORKDIR /converted/
35+
36+
CMD ["athenapdf"]
37+
38+
ENTRYPOINT ["/athenapdf/entrypoint.sh"]

cli/Dockerfile.build

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM mhart/alpine-node:5.9.1
2+
MAINTAINER Arachnys <[email protected]>
3+
4+
RUN mkdir -p /athenapdf/build/artifacts/
5+
WORKDIR /athenapdf/
6+
7+
ADD package.json /athenapdf/
8+
RUN npm install
9+
10+
ADD package.json /athenapdf/build/artifacts/
11+
RUN cp -r /athenapdf/node_modules/ /athenapdf/build/artifacts/
12+
13+
ADD src /athenapdf/build/artifacts/
14+
RUN sed -i "1s/^/process.argv.unshift(\"--\");\n /" /athenapdf/build/artifacts/athenapdf.js
15+
RUN npm run build:linux
16+
17+
CMD ["/bin/sh"]

0 commit comments

Comments
 (0)