From a11a44db97fcf3e447de9afbb311ac688e705d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Richter?= Date: Fri, 18 Jan 2019 15:41:58 +0100 Subject: [PATCH] Fun with symlinks, adding API v2 --- _api | 1 + _config.yml | 18 ++++++++++++++++-- _layouts/api.json | 1 + _vendors/all.json | 23 +++++++++++++++++++++++ _vendors/general.md | 1 - _vendors/htc.md | 1 - _vendors/huawei.md | 1 - _vendors/lenovo.md | 1 - _vendors/meizu.md | 1 - _vendors/nokia.md | 1 - _vendors/oneplus.md | 1 - _vendors/samsung.md | 1 - _vendors/sony.md | 1 - _vendors/stock_android.md | 1 - _vendors/xiaomi.md | 1 - output.json | 23 +++++++++++++++++++++++ 16 files changed, 64 insertions(+), 13 deletions(-) create mode 120000 _api create mode 100644 _layouts/api.json create mode 100644 _vendors/all.json create mode 100644 output.json diff --git a/_api b/_api new file mode 120000 index 00000000..6204546b --- /dev/null +++ b/_api @@ -0,0 +1 @@ +_vendors \ No newline at end of file diff --git a/_config.yml b/_config.yml index bee5dd7e..9a1221cf 100644 --- a/_config.yml +++ b/_config.yml @@ -34,8 +34,22 @@ plugins: collections: vendors: output: true - permalink: :title - badges: + api: + output: true + +defaults: + - + scope: + path: "_vendors" + values: + layout: vendor + permalink: :title + - + scope: + path: "_api" + values: + layout: api + permalink: /api/v2/:title/ # Exclude from processing. # The following items will not be processed, by default. Create a custom list diff --git a/_layouts/api.json b/_layouts/api.json new file mode 100644 index 00000000..5bd36149 --- /dev/null +++ b/_layouts/api.json @@ -0,0 +1 @@ +Testing that funny JSON API \ No newline at end of file diff --git a/_vendors/all.json b/_vendors/all.json new file mode 100644 index 00000000..a511be44 --- /dev/null +++ b/_vendors/all.json @@ -0,0 +1,23 @@ +--- +limit: 100 +--- +{"vendors": [ + {% assign sorted_vendors = site.vendors | sort: "award" | reverse %} + {% for vendor in sorted_vendors limit: page.limit %} + { + "name": {{ vendor.name | jsonify }}, + "manufacturer": [{% for v in vendor.manufacturer %}"{{ v }}"{% unless forloop.last %},{% endunless %}{% endfor %}], + "url": {{ vendor.url | jsonify }}, + "award": {{ vendor.award | jsonify }}, + "position": {{ vendor.position | jsonify }}, + "explanation": {{ vendor.explanation | markdownify | replace: 'src="/assets/img/', + 'src="https://dontkillmyapp.com/assets/img/' | jsonify }}, + "user_solution": {{ vendor.user_solution | markdownify | replace: 'src="/assets/img/', + 'src="https://dontkillmyapp.com/assets/img/' | jsonify }}, + "developer_solution": {{ vendor.developer_solution | markdownify | replace: 'src="/assets/img/', + 'src="https://dontkillmyapp.com/assets/img/' | jsonify }} + } + {% unless forloop.last %},{% endunless %} + {% endfor %} + ] +} \ No newline at end of file diff --git a/_vendors/general.md b/_vendors/general.md index d6c67639..e7227279 100644 --- a/_vendors/general.md +++ b/_vendors/general.md @@ -1,6 +1,5 @@ --- name: Other vendors -layout: vendor explanation: " Whatever device you are using, don't blame the developers as the first thing when something goes wrong. First check your phone settings whether some background processing is not restricted on your device. diff --git a/_vendors/htc.md b/_vendors/htc.md index 1bb887e5..54a9c05d 100644 --- a/_vendors/htc.md +++ b/_vendors/htc.md @@ -1,6 +1,5 @@ --- name: HTC -layout: vendor manufacturer: - htc position: 8 diff --git a/_vendors/huawei.md b/_vendors/huawei.md index a283cabf..c3641143 100644 --- a/_vendors/huawei.md +++ b/_vendors/huawei.md @@ -1,6 +1,5 @@ --- name: Huawei -layout: vendor manufacturer: - huawei redirect_from: /vendors/huawei.html diff --git a/_vendors/lenovo.md b/_vendors/lenovo.md index fb04a637..50c40b36 100644 --- a/_vendors/lenovo.md +++ b/_vendors/lenovo.md @@ -2,7 +2,6 @@ name: Lenovo manufacturer: - lenovo -layout: vendor position: 10 award: 1 explanation: "We're still gathering more information on battery saving features on Lenovo phones." diff --git a/_vendors/meizu.md b/_vendors/meizu.md index 5561019a..e21814e7 100644 --- a/_vendors/meizu.md +++ b/_vendors/meizu.md @@ -1,6 +1,5 @@ --- name: Meizu -layout: vendor manufacturer: - meizu award: 3 diff --git a/_vendors/nokia.md b/_vendors/nokia.md index fd41e26b..c4eedbb2 100644 --- a/_vendors/nokia.md +++ b/_vendors/nokia.md @@ -3,7 +3,6 @@ name: Nokia manufacturer: - nokia - hmd global -layout: vendor redirect_from: - /vendors/nokia.html - /hmd%20global diff --git a/_vendors/oneplus.md b/_vendors/oneplus.md index afcb386b..0c010c51 100644 --- a/_vendors/oneplus.md +++ b/_vendors/oneplus.md @@ -2,7 +2,6 @@ name: OnePlus manufacturer: - oneplus -layout: vendor award: 4 position: 2 redirect_from: /vendors/oneplus.html diff --git a/_vendors/samsung.md b/_vendors/samsung.md index a49544b1..b2147138 100644 --- a/_vendors/samsung.md +++ b/_vendors/samsung.md @@ -2,7 +2,6 @@ name: Samsung manufacturer: - samsung -layout: vendor award: 2 position: 7 redirect_from: /vendors/samsung.html diff --git a/_vendors/sony.md b/_vendors/sony.md index dfae3f9c..c7bde8a1 100644 --- a/_vendors/sony.md +++ b/_vendors/sony.md @@ -2,7 +2,6 @@ name: Sony manufacturer: - sony -layout: vendor award: 3 position: 6 redirect_from: /vendors/sony.html diff --git a/_vendors/stock_android.md b/_vendors/stock_android.md index 28866db0..2c0be516 100644 --- a/_vendors/stock_android.md +++ b/_vendors/stock_android.md @@ -2,7 +2,6 @@ name: Google (Pixel, Nexus) manufacturer: - google -layout: vendor award: 1 position: 9 redirect_from: /vendors/stock_android.html diff --git a/_vendors/xiaomi.md b/_vendors/xiaomi.md index 38e417f4..25190c82 100644 --- a/_vendors/xiaomi.md +++ b/_vendors/xiaomi.md @@ -2,7 +2,6 @@ name: Xiaomi manufacturer: - xiaomi -layout: vendor position: 3 award: 3 redirect_from: /vendors/xiaomi.html diff --git a/output.json b/output.json new file mode 100644 index 00000000..a511be44 --- /dev/null +++ b/output.json @@ -0,0 +1,23 @@ +--- +limit: 100 +--- +{"vendors": [ + {% assign sorted_vendors = site.vendors | sort: "award" | reverse %} + {% for vendor in sorted_vendors limit: page.limit %} + { + "name": {{ vendor.name | jsonify }}, + "manufacturer": [{% for v in vendor.manufacturer %}"{{ v }}"{% unless forloop.last %},{% endunless %}{% endfor %}], + "url": {{ vendor.url | jsonify }}, + "award": {{ vendor.award | jsonify }}, + "position": {{ vendor.position | jsonify }}, + "explanation": {{ vendor.explanation | markdownify | replace: 'src="/assets/img/', + 'src="https://dontkillmyapp.com/assets/img/' | jsonify }}, + "user_solution": {{ vendor.user_solution | markdownify | replace: 'src="/assets/img/', + 'src="https://dontkillmyapp.com/assets/img/' | jsonify }}, + "developer_solution": {{ vendor.developer_solution | markdownify | replace: 'src="/assets/img/', + 'src="https://dontkillmyapp.com/assets/img/' | jsonify }} + } + {% unless forloop.last %},{% endunless %} + {% endfor %} + ] +} \ No newline at end of file