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

Expose pcs endpoints for js and css #1214

Merged
merged 3 commits into from Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion v1/css.yaml
Expand Up @@ -22,12 +22,15 @@ paths:
Gets common CSS mobile apps need to properly display pages using Page Content Service.
In most cases all of the types are needed (preferably in this order):
* base (Common mobile CSS from ResourceLoader)
* pagelib (CSS from wikimedia-page-library)
* site (Site-specific, mobile CSS from ResourceLoader, as defined in MediaWiki\:Mobile.css)
* pcs (CSS for the Page Content Service)

The first two are the same regardless of what domain is used.
For these we suggest meta.wikimedia.org.

You can still pass pagelib for type, but this is a legacy version of the CSS for
existing app clients.

Stability: [experimental](https://www.mediawiki.org/wiki/API_versioning#Experimental)
parameters:
- name: type
Expand All @@ -38,6 +41,7 @@ paths:
enum:
- base
- pagelib
- pcs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are removing pagelib from the description, but not from the enum here. It must be one or the other :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed - pagelib is deprecated but needs to remain available for app clients that still point to that endpoint. I added some clarifying comments in the documentation

- site
required: true
responses:
Expand Down
117 changes: 19 additions & 98 deletions v1/javascript.yaml
@@ -1,7 +1,7 @@
openapi: 3.0.1
info:
version: 1.0.0-beta
title: JavaScript bundle from the wikimedia-page-library
title: JavaScript for mobile apps
description: API for retrieving JavaScript for mobile apps
termsOfService: https://www.mediawiki.org/wiki/REST_API#Terms_and_conditions
contact:
Expand All @@ -11,115 +11,36 @@ info:
name: Apache licence, v2
url: https://www.apache.org/licenses/LICENSE-2.0
paths:
/javascript/mobile/pagelib:
/javascript/mobile/{type}:
x-route-filters:
- path: lib/security_response_header_filter.js
get:
tags:
- Mobile
summary: Get JavaScript bundle from the wikimedia-page-library
summary: Get JavaScript for mobileapps
description: |
Gets the javascript bundle from the wikimedia-page-library so that clients can have
convenient access to that for consuming the content-html HTML.
Gets the JavaScript bundle so that clients can have
convenient access to that for consuming the page HTML.
Amongst other things,
* it allows to detect the platform and through that enable platform specific CSS rules,
* has code to lazy load images on the page,
* code for collapsing and expanding tables.

Stability: [experimental](https://www.mediawiki.org/wiki/API_versioning#Experimental)
responses:
200:
description: Success
headers:
ETag:
description: Different values indicate that the content has changed
schema:
type: string
content:
application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/JavaScript/1.0.0":
schema:
type: object
default:
description: Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
x-request-handler:
- get_from_pcs:
request:
method: get
uri: '{{options.host}}/{domain}/v1/data/javascript/mobile/pagelib'
return:
status: 200
headers: '{{ merge({"cache-control": options.response_cache_control},
get_from_pcs.headers) }}'
body: '{{get_from_pcs.body}}'
x-monitor: false
/javascript/mobile/pagelib_body_start:
x-route-filters:
- path: lib/security_response_header_filter.js
get:
tags:
- Mobile
summary: |
Get the JavaScript to run at the start of the body tag from the wikimedia-page-library
description: |
Gets the javascript that is intended to be run at the start of the body tag to apply
settings with the wikimedia-page-library. It reads an object from document.pcsSetupSettings
and utilizes it as the parameter for pagelib.c1.Page.setup(). It applies settings like
margins and theming that need to be applied before the page body starts rendering.
It also reads a function that takes a single parameter from document.pcsActionHandler and
utilizes it to notify the client of page events. Alternatively, clients can set a
pcsClient variable that returns a JSON string with settings from
pcsClient.getSetupSettings() and receives a JSON string to pcsClient.onReceiveMessage().

Stability: [experimental](https://www.mediawiki.org/wiki/API_versioning#Experimental)
responses:
200:
description: Success
headers:
ETag:
description: Different values indicate that the content has changed
schema:
type: string
content:
application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/JavaScript/1.0.0":
schema:
type: object
default:
description: Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
x-request-handler:
- get_from_pcs:
request:
method: get
uri: '{{options.host}}/{domain}/v1/data/javascript/mobile/pagelib_body_start'
return:
status: 200
headers: '{{ merge({"cache-control": options.response_cache_control},
get_from_pcs.headers) }}'
body: '{{get_from_pcs.body}}'
x-monitor: false
/javascript/mobile/pagelib_body_end:
x-route-filters:
- path: lib/security_response_header_filter.js
get:
tags:
- Mobile
summary: Get the JavaScript to run at the end of the body tag from the wikimedia-page-library
description: |
Gets the javascript that is intended to be run at the end of the body tag to apply
settings with the wikimedia-page-library. It reads an object from document.pcsSetupSettings
and utilizes it as the parameter for pagelib.c1.Page.setup(). It applies settings that can
wait until the document finishes loading to be applied. Alternatively, clients can set a
pcsClient variable that returns a JSON string with settings from
pcsClient.getSetupSettings().
Valid types are pagelib or pcs. Passing pcs will return the JavaScript for the
Page Content Service. Passing pagelib will return a deprecated legacy version
of the wikimedia-page-library JavaScript to support existing app clients.

Stability: [experimental](https://www.mediawiki.org/wiki/API_versioning#Experimental)
parameters:
- name: type
in: path
description: The desired JavaScript bundle
schema:
type: string
enum:
- pagelib
- pcs
required: true
responses:
200:
description: Success
Expand All @@ -142,7 +63,7 @@ paths:
- get_from_pcs:
request:
method: get
uri: '{{options.host}}/{domain}/v1/data/javascript/mobile/pagelib_body_end'
uri: '{{options.host}}/{domain}/v1/data/javascript/mobile/{type}'
return:
status: 200
headers: '{{ merge({"cache-control": options.response_cache_control},
Expand Down