From eb41fcbc982d8ee421dea4812724b6fcf7a79254 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Thu, 18 May 2017 20:15:43 +0200 Subject: [PATCH] Themes: Add experimental material theme --- .../Model/Elements/ObjectStructureElement.php | 2 +- src/PHPDraft/Out/HTML/default.phtml | 9 +- src/PHPDraft/Out/HTML/material.css | 53 ++++ src/PHPDraft/Out/HTML/material.js | 3 + src/PHPDraft/Out/HTML/material.phtml | 259 ++++++++++++++++++ tests/statics/drafter/apib | 12 +- tests/statics/drafter/index.apib | 12 +- 7 files changed, 336 insertions(+), 14 deletions(-) create mode 100644 src/PHPDraft/Out/HTML/material.css create mode 100644 src/PHPDraft/Out/HTML/material.js create mode 100644 src/PHPDraft/Out/HTML/material.phtml diff --git a/src/PHPDraft/Model/Elements/ObjectStructureElement.php b/src/PHPDraft/Model/Elements/ObjectStructureElement.php index 887b6f02..a4930f25 100644 --- a/src/PHPDraft/Model/Elements/ObjectStructureElement.php +++ b/src/PHPDraft/Model/Elements/ObjectStructureElement.php @@ -214,7 +214,7 @@ function __toString() if (is_array($this->value)) { - $return = ''; + $return = '
'; foreach ($this->value as $object) { if (is_string($object) || in_array(get_class($object), [ diff --git a/src/PHPDraft/Out/HTML/default.phtml b/src/PHPDraft/Out/HTML/default.phtml index 224a55ff..727276b4 100644 --- a/src/PHPDraft/Out/HTML/default.phtml +++ b/src/PHPDraft/Out/HTML/default.phtml @@ -6,11 +6,6 @@ * @author Sean Molenaar */ use PHPDraft\Out\Minifier; - -/** - * @var \PHPDraft\Model\HierarchyElement[] - */ -$base = $this->categories; ?> @@ -54,7 +49,7 @@ $base = $this->categories;
- + categories as $category): ?> children !== []): ?>
@@ -121,7 +116,7 @@ $base = $this->categories;
base_data['HOST']; ?>
- + categories as $category): ?> title)): ?>

title; ?>

diff --git a/src/PHPDraft/Out/HTML/material.css b/src/PHPDraft/Out/HTML/material.css new file mode 100644 index 00000000..d0061132 --- /dev/null +++ b/src/PHPDraft/Out/HTML/material.css @@ -0,0 +1,53 @@ +.demo-layout-transparent { + background: rgba(0,0,0,0) center / cover; +} +.demo-layout-transparent .mdl-layout__header, +.demo-layout-transparent .mdl-layout__drawer-button { + /* This background is dark, so we set text to white. Use 87% black instead if + your background is light. */ + color: white; +} +main { + width: 100%; +} + +.demo-card-wide.mdl-card { + width: 100%; + margin-bottom: 30px; +} +.demo-card-wide > .mdl-card__title { + color: #fff; + height: 176px; + background: #cccccc center / cover; +} +.demo-card-wide > .mdl-card__menu { + color: #fff; +} +h2.mdl-card__title-text { + display: inline-block; + width: 100%; +} +.page-content { + width: 80%; + margin: 0px auto; +} +.pull-right { + text-align: right !important; + float: right !important; +} + +.text-success { + color: #3c763d; +} + +.text-warning { + color: #8a6d3b; +} + +.text-error { + color: #761c19; +} + +table.table p { + margin-bottom: 0px; +} \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material.js b/src/PHPDraft/Out/HTML/material.js new file mode 100644 index 00000000..5f0b24d1 --- /dev/null +++ b/src/PHPDraft/Out/HTML/material.js @@ -0,0 +1,3 @@ +/** + * Created by smillernl on 18-5-17. + */ diff --git a/src/PHPDraft/Out/HTML/material.phtml b/src/PHPDraft/Out/HTML/material.phtml new file mode 100644 index 00000000..2f749204 --- /dev/null +++ b/src/PHPDraft/Out/HTML/material.phtml @@ -0,0 +1,259 @@ + + */ +use PHPDraft\Out\Minifier; +?> + + + + <?= $this->base_data['TITLE']; ?> + + + + + css as $style): ?> + + + + + +
+
+
+ + base_data['TITLE']; ?> +
+
+ +
+ +
+
+
+
+
+ base_data['TITLE']; ?> + +
+
+
+ categories as $category): ?> + title)): ?> +

title; ?>

+ + description)): ?> +

description; ?>

+ + children as $resource): ?> +

+ title; ?> + href; ?> +

+

description; ?>

+ children as $transition): ?> +
+
+

get_method(); ?> + href; ?> + title; ?>

+
+
+ description; ?> + requests) || !empty($transition->responses)): ?> +
+
+ requests)): ?> + Request + + responses)): ?> + responses as $key => $response): ?> + statuscode; ?> + + +
+ requests)): ?> + requests as $key => $request): ?> +
+ description; ?> + url_variables !== []): ?> +
Example URI
+ base_data['HOST']; ?>build_url(); ?> + + headers !== []): ?> +
Headers
+
    + headers as $name => $value): ?> +
  • + + : + +
  • + +
+ + body)): ?> +
Body
+ body as $value): ?> + + + + headers['Content-Type'])) ? $request->headers['Content-Type'] : null; ?> + print_request($type); ?> + + + + + struct)): ?> +
Structure
+ struct ?> + + url_variables !== null): ?> +
URI Parameters
+ url_variables; ?> + + data_variables !== null): ?> +
Data object
+ data_variables ?> + +
+ + + responses)): ?> + responses as $key => $response): ?> +
+ description; ?> + headers !== []): ?> +
Headers
+
    + headers as $name => $value): ?> +
  • + + : + +
  • + +
+ + structure !== []): ?> +
Data Structure
+
+ structure as $value): ?> + + +
+ + content as $key => $value): ?> +
+ get_href() . '-' . $response->statuscode . '-' . str_replace([ + '/', + '+', + ], '-', $key); ?> +
+ + + +
+ +
+ +
+
+ + + +
+
+ +
+ get_curl_command($this->base_data['HOST'], []); ?> +
+
+
+ + + + base_structures) > 0): ?> +

Data structures

+ base_structures as $key => $structure): ?> +
+
+

+
+
+ +
+
+ + +
+
+
+base_data, function ($value) { + return !in_array($value, ['HOST', 'TITLE', 'ALT_HOST', 'FORMAT', 'DESC']); +}, ARRAY_FILTER_USE_KEY); +if (!empty($extras)): + $extras['host'] = $this->base_data['HOST']; ?> + + +js as $js): ?> + + + + + + \ No newline at end of file diff --git a/tests/statics/drafter/apib b/tests/statics/drafter/apib index 1c33b02e..88078435 100644 --- a/tests/statics/drafter/apib +++ b/tests/statics/drafter/apib @@ -1,5 +1,7 @@ FORMAT: 1A HOST: https://owner-api.teslamotors.com +EXTRA_HOSTS: https://test.owner-api.teslamotors.com +SOMETHING: INFO # Tesla Model S JSON API This is unofficial documentation of the Tesla Model S JSON API used by the iOS and Android apps. It features functionality to monitor and control the Model S remotely. @@ -289,11 +291,13 @@ locations in navigation. Authorization: Bearer {access_token} ++ Attributes + + on: true (boolean) - Whether to enable or disable valet mode. + + password: 1234 (number) - (optional) A 4 digit PIN code to unlock the car. + + Parameters + vehicle_id: `1` (number) - The id of the Vehicle. - + on: true (boolean) - Whether to enable or disable valet mode. - + password: 1234 (number) - (optional) A 4 digit PIN code to unlock the car. + Response 200 (application/json) @@ -695,10 +699,12 @@ Open the trunk or frunk. Currently inoperable. Authorization: Bearer {access_token} ++ Attributes + + which_trunk: `rear` (string) - The trunk to open. `rear` is the only one known currently. + + Parameters + vehicle_id: `1` (number) - The id of the Vehicle. - + which_trunk: `rear` (string) - The trunk to open. `rear` is the only one known currently. + Response 200 (application/json) diff --git a/tests/statics/drafter/index.apib b/tests/statics/drafter/index.apib index 1c33b02e..88078435 100644 --- a/tests/statics/drafter/index.apib +++ b/tests/statics/drafter/index.apib @@ -1,5 +1,7 @@ FORMAT: 1A HOST: https://owner-api.teslamotors.com +EXTRA_HOSTS: https://test.owner-api.teslamotors.com +SOMETHING: INFO # Tesla Model S JSON API This is unofficial documentation of the Tesla Model S JSON API used by the iOS and Android apps. It features functionality to monitor and control the Model S remotely. @@ -289,11 +291,13 @@ locations in navigation. Authorization: Bearer {access_token} ++ Attributes + + on: true (boolean) - Whether to enable or disable valet mode. + + password: 1234 (number) - (optional) A 4 digit PIN code to unlock the car. + + Parameters + vehicle_id: `1` (number) - The id of the Vehicle. - + on: true (boolean) - Whether to enable or disable valet mode. - + password: 1234 (number) - (optional) A 4 digit PIN code to unlock the car. + Response 200 (application/json) @@ -695,10 +699,12 @@ Open the trunk or frunk. Currently inoperable. Authorization: Bearer {access_token} ++ Attributes + + which_trunk: `rear` (string) - The trunk to open. `rear` is the only one known currently. + + Parameters + vehicle_id: `1` (number) - The id of the Vehicle. - + which_trunk: `rear` (string) - The trunk to open. `rear` is the only one known currently. + Response 200 (application/json)