Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions 0.16.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ RUN set -x; \
COPY run-restbase.sh /run-restbase.sh
RUN chmod -v +x /run-restbase.sh

COPY pdf.yaml $RB_HOME/v1/

COPY projects_docker.yaml $RB_HOME/projects/docker.yaml

EXPOSE 7231
Expand Down
79 changes: 79 additions & 0 deletions 0.16.9/pdf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
swagger: '2.0'
info:
version: '1.0.0-beta'
title: MediaWiki PDF API
description: Page PDF Render API
termsOfService: https://github.com/wikimedia/restbase#restbase
contact:
name: Services
email: services@lists.wikimedia.org
url: https://www.mediawiki.org/wiki/Services
license:
name: Apache licence, v2
url: https://www.apache.org/licenses/LICENSE-2.0
paths:
/pdf/{title}:
x-route-filters:
- path: ./lib/revision_table_access_check_filter.js
options:
redirect_cache_control: '{{options.cache_control}}'
get:
tags:
- Page content
summary: Get a page as PDF
description: |
Renders the page content as PDF.

Stability: [experimental](https://www.mediawiki.org/wiki/API_versioning#Experimental)
produces:
- application/pdf
parameters:
- name: title
in: path
description: "Page title. Use underscores instead of spaces. Example: `Main_Page`."
type: string
required: true
responses:
'200':
description: The PDF render of an article
schema:
type: file
headers:
ETag:
description: >
Syntax: "{revision}/{tid}".
Example: "701384379/154d7bca-c264-11e5-8c2f-1b51b33b59fc"
'404':
description: Unknown page title
schema:
$ref: '#/definitions/problem'
default:
description: Error
schema:
$ref: '#/definitions/problem'

x-request-handler:
- get_latest_revision:
request:
method: get
uri: /{domain}/sys/page_revisions/page/{title}
- get_pdf_from_backend:
request:
method: get
#uri: '{{options.uri}}/pdf?accessKey={options.secret}&url=http://{{domain}}/wiki/{_encodeURIComponent(title)}%3Fprintable=yes'
#uri: '{{options.uri}}/pdf?accessKey={options.secret}&url={_encodeURIComponent("http://google.com")}'
#uri: '{{options.uri}}/pdf?accessKey={options.secret}&url=http%3A%2F%2F{{domain}}%2Fwiki%2F{encodeURI(title)}%3Fprintable=yes'
uri: '{{options.uri}}/pdf?accessKey={options.secret}&url=http://{{domain}}/wiki/{title}%3Fprintable=yes'
return:
status: 200
headers:
# Firefox supports filename*= syntax while Chrome respect
# filename=. Safari is stupid and understands neither.
# TODO: Quote raw `"` chars in filename.
content-disposition: 'attachment; {{filenameParameters(request.params.title)}}'
content-type: '{{get_pdf_from_backend.headers.content-type}}'
content-length: '{{get_pdf_from_backend.headers.content-length}}'
cache-control: '{{default(options.cache_control, "s-maxage=600, max-age=600")}}'
etag: '{{get_latest_revision.headers.etag}}'
body: '{{get_pdf_from_backend.body}}'
x-monitor: false # PDF generation is expensive and it's not stored, so don't run checker script
3 changes: 0 additions & 3 deletions 0.16.9/run-restbase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,4 @@ logging:
num_workers: ${RB_CONF_NUM_WORKERS:-'0'}
EOT

# Use HTTP instead of HTTPS in pdf.yaml
sed -i -e 's#https://{{domain}}#http://{{domain}}#' v1/pdf.yaml

su -c 'npm start' $RB_USER