Skip to content
This repository was archived by the owner on Feb 10, 2020. It is now read-only.

Commit 2164249

Browse files
committed
Rationalize required metadata in all tutorials, now enforced with a new metadata linter
1 parent 5ebffab commit 2164249

File tree

39 files changed

+306
-113
lines changed

39 files changed

+306
-113
lines changed

examples/example-tutorial.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ categories: category
55
tags: tutorial, guidelines, guide, write, contribute
66
difficulty: 2
77
status: draft
8-
feedback-link: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
8+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
99
published: 2017-01-01
1010
author: Canonical Web Team <webteam@canonical.com>
1111

@@ -75,10 +75,10 @@ summary: Learn how to create, write and publish tutorials on tutorials.ubuntu.co
7575
categories: community
7676
tags: guidelines, guide, write, contribute
7777
difficulty: 2
78-
status: Published
79-
feedback-url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
80-
author: Canonical Web Team <webteam@canonical.com>
78+
status: published
79+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
8180
published: 2017-01-13
81+
author: Canonical Web Team <webteam@canonical.com>
8282
8383
---
8484
```
@@ -97,8 +97,8 @@ Let's have a look at each field:
9797
* **4**: Advanced user - has experience running Ubuntu for many years, but may be unfamiliar with some sysadmin/programming topics
9898
* **5**: Ubuntu sysadmin/developer- very familiar with most aspects of the operating system and can be expected to know details about its inner workings
9999

100-
* **status**: `Draft` or `Published`
101-
* **feedback-url**: where to report bugs and give feedback about this tutorial. Unless you have very specific requirements, this should be: `https://github.com/canonical-websites/tutorials.ubuntu.com/issues`.
100+
* **status**: `draft` or `published`
101+
* **feedback_url**: where to report bugs and give feedback about this tutorial. Unless you have very specific requirements, this should be: `https://github.com/canonical-websites/tutorials.ubuntu.com/issues`.
102102
* **author**: the name and email address between brackets of the author of the tutorial. If you don't intend to maintain this tutorial after publication, please use `Canonical Web Team <webteam@canonical.com>`
103103
* **published**: a date in YYYY-MM-DD format, to be updated after any major change to the tutorial
104104

@@ -142,10 +142,10 @@ summary: This is my tutorial, there are many like it but this one is mine
142142
categories: community
143143
tags: beginner, some, other, tags
144144
difficulty: 1
145-
status: Published
146-
feedback-url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
147-
author: Javier Lopez <javier.lopez@example.com>
145+
status: published
146+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
148147
published: 2017-01-13
148+
author: Javier Lopez <javier.lopez@example.com>
149149

150150
---
151151

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"lint-polymer": "polymer lint -i src/*.html -i src/elements/*",
2121
"lint-style": "npm-run-all lint-style-*",
2222
"lint-style-html": "stylelint 'src/**/*.html' --extract",
23+
"lint-content": "mocha",
2324
"polymer": "./bin/polymer",
2425
"polymer-build": "npm-run-all 'polymer build {@}' --",
2526
"polymer-lint": "npm-run-all 'polymer lint {@}' --",
@@ -28,12 +29,15 @@
2829
"serve": "npm-run-all 'serve-examples {@}' --",
2930
"serve-examples": "./bin/serve $(if [ -z \"$*\" ]; then echo \"examples\"; fi)",
3031
"serve-live": "./bin/serve",
31-
"test": "npm-run-all lint-js lint-polymer lint-style"
32+
"test": "npm-run-all lint-js lint-polymer lint-style lint-content"
3233
},
3334
"devDependencies": {
3435
"eslint": "^3.14.1",
3536
"eslint-config-google": "^0.7.1",
3637
"eslint-plugin-html": "^2.0.0",
38+
"find": "^0.2.7",
39+
"gray-matter": "^3.1.1",
40+
"mocha": "^4.0.1",
3741
"npm-run-all": "^4.0.2",
3842
"polymer-cli": "^1.5.7",
3943
"prpl-server": "^1.0.0",

test/lint-metadata.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
var assert = require('assert');
2+
var gm = require('gray-matter');
3+
var find = require('find');
4+
5+
var required_keys = [ 'id',
6+
'summary',
7+
'categories',
8+
'tags',
9+
'difficulty',
10+
'status',
11+
'feedback_url',
12+
'published',
13+
'author']
14+
15+
var files = find.fileSync(/\.md$/,"tutorials");
16+
for(var i=0, len=files.length; i < len; i++){
17+
var f = gm.read(files[i]);
18+
validate(f, files[i].split("/").slice(-1)[0]);
19+
}
20+
21+
// Validates metadata for each tutorial
22+
function validate(f, fn) {
23+
describe('Metadata for ' + fn, function() {
24+
it('contains all required keys', function(done) {
25+
required_keys.forEach(contains)
26+
function contains(item){
27+
assert(Object.keys(f.data).includes(item), `does not contain "${item}"`);
28+
}
29+
done();
30+
});
31+
describe('id', function() {
32+
it('only contains alpha-numerical characters and dashes', function(done) {
33+
assert(f.data.id.match('^[a-zA-Z0-9-]+$'));
34+
done();
35+
});
36+
});
37+
describe('summary', function() {
38+
it('has no more than 40 words', function(done) {
39+
assert(f.data.summary.split(" ").length <= 40);
40+
done();
41+
});
42+
});
43+
describe('tags', function() {
44+
it('contains at least two comma-separated strings', function(done) {
45+
assert(f.data.tags.split(',').length >= 2);
46+
done();
47+
});
48+
});
49+
describe('difficulty', function() {
50+
it('is between 1 and 5', function(done) {
51+
assert(f.data.difficulty <= 5 && f.data.difficulty >= 1);
52+
done();
53+
});
54+
});
55+
describe('status', function() {
56+
it('is "published" or "draft"', function(done) {
57+
assert(['published', 'draft'].includes(f.data.status));
58+
done();
59+
});
60+
});
61+
describe('published', function() {
62+
it('is a date in the YYYY-MM-DD format', function(done) {
63+
assert(f.data.published instanceof Date);
64+
done();
65+
});
66+
});
67+
describe('feedback_url', function() {
68+
it('is a URL', function(done) {
69+
assert(f.data.feedback_url.match('^https?:\/\/.*$'));
70+
done();
71+
});
72+
});
73+
describe('author', function() {
74+
it('is in the "name <email>" format', function(done) {
75+
assert(f.data.author.match('^.*<.*@.*>$'));
76+
done();
77+
});
78+
});
79+
});
80+
}

tutorials/cloud/get-started-hadoop-spark/get-started-hadoop-spark.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ summary: Learn how to operate a big data cluster, to analyse batch data with Map
55
categories: cloud
66
tags: hadoop, spark, juju, jaas, big data
77
difficulty: 2
8-
status: Published
9-
Published: 2017-07-07
8+
status: published
9+
published: 2017-07-07
10+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
11+
author: Canonical Web Team <webteam@canonical.com>
1012

1113
---
1214

tutorials/community/tutorial-guidelines.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ summary: Learn how to create, write and publish tutorials on tutorials.ubuntu.co
44
categories: community
55
tags: tutorial, guidelines, guide, write, contribute
66
difficulty: 2
7-
status: Published
8-
feedback-link: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
7+
status: published
8+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
99
published: 2017-11-23
1010
author: Canonical Web Team <webteam@canonical.com>
1111

@@ -75,10 +75,10 @@ summary: Learn how to create, write and publish tutorials on tutorials.ubuntu.co
7575
categories: community
7676
tags: guidelines, guide, write, contribute
7777
difficulty: 2
78-
status: Published
79-
feedback-url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
80-
author: Canonical Web Team <webteam@canonical.com>
78+
status: published
79+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
8180
published: 2017-01-13
81+
author: Canonical Web Team <webteam@canonical.com>
8282
8383
---
8484
```
@@ -97,8 +97,8 @@ Let's have a look at each field:
9797
* **4**: Advanced user - has experience running Ubuntu for many years, but may be unfamiliar with some sysadmin/programming topics
9898
* **5**: Ubuntu sysadmin/developer- very familiar with most aspects of the operating system and can be expected to know details about its inner workings
9999

100-
* **status**: `Draft` or `Published`
101-
* **feedback-url**: where to report bugs and give feedback about this tutorial. Unless you have very specific requirements, this should be: `https://github.com/canonical-websites/tutorials.ubuntu.com/issues`.
100+
* **status**: `draft` or `published`
101+
* **feedback_url**: where to report bugs and give feedback about this tutorial. Unless you have very specific requirements, this should be: `https://github.com/canonical-websites/tutorials.ubuntu.com/issues`.
102102
* **author**: the name and email address between brackets of the author of the tutorial. If you don't intend to maintain this tutorial after publication, please use `Canonical Web Team <webteam@canonical.com>`
103103
* **published**: a date in YYYY-MM-DD format, to be updated after any major change to the tutorial
104104

@@ -142,10 +142,10 @@ summary: This is my tutorial, there are many like it but this one is mine
142142
categories: community
143143
tags: beginner, some, other, tags
144144
difficulty: 1
145-
status: Published
146-
feedback-url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
147-
author: Javier Lopez <javier.lopez@example.com>
145+
status: published
146+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
148147
published: 2017-01-13
148+
author: Javier Lopez <javier.lopez@example.com>
149149

150150
---
151151

tutorials/containers/get-started-canonical-kubernetes/get-started-canonical-kubernetes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ summary: Learn how to operate a production-ready Kubernetes cluster. Kubernetes
44
categories: containers
55
tags: jaas, juju, kubernetes, beginner, container, docker, cloud
66
difficulty: 3
7-
status: Published
8-
Published: 2017-07-21
7+
status: published
8+
published: 2017-07-21
99
author: Canonical Web Team <webteam@canonical.com>
10+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
1011

1112
---
1213

@@ -42,7 +43,7 @@ To substantiate these claims, we're going to build a highly available (HA) produ
4243
## Deploying with JAAS
4344
Duration: 8:00
4445

45-
To kick off, **[open a Canonical distribution of Kubernetes][charmstorek8s]**.
46+
To kick off, **[open a Canonical distribution of Kubernetes][charmstorek8s]**.
4647

4748
![Kubernetes Direct Deploy](./images/k8-directdeploy.png)
4849

tutorials/containers/install-kubernetes-with-conjure-up.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
id: install-kubernetes-with-conjure-up
33
summary: This tutorial will guide you through the installation of the Canonical Distribution of Kubernetes with a few simple commands using conjure-up.
44
categories: containers
5-
status: Published
6-
feedback-link: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
5+
status: published
76
tags: kubernetes, conjure-up
87
difficulty: 2
98
published: 2017-08-21
109
author: Karl Williams <karl.williams@canonical.com>
10+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
1111

1212
---
1313

tutorials/containers/setting-up-lxd-1604/setting-up-lxd-1604-tutorial.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ summary: Deploying fast, lightweight containers on Ubuntu is easy with LXD. We'l
44
categories: containers
55
tags: tutorial,installation,ubuntu,desktop,server,lxd,lxc
66
difficulty: 2
7-
status: Published
8-
author: Alberto Donato
7+
status: published
8+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
99
published: 2017-06-29
10+
author: Alberto Donato <alberto.donato@canonical.com>
1011

1112
---
1213

tutorials/containers/use-cuda-within-lxd/use-cuda-within-lxd.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ summary: Accelerate data processing within LXD containers by enabling direct acc
44
categories: containers
55
tags: lxd, cuda, nvidia, gpu, big data, lxc
66
difficulty: 4
7+
status: published
78
published: 2017-07-12
89
author: Graham Morrison <graham.morrison@canonical.com>
10+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
911

1012
---
1113

tutorials/containers/windows-ubuntu-hyperv-containers/windows-ubuntu-hyperv-containers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ summary: Run Ubuntu containers with Hyper-V isolation on Windows 10 and Windows
44
categories: containers
55
tags: tutorial,installation,windows,ubuntu,terminal,docker,containers,hyper-v
66
difficulty: 5
7-
status: Published
7+
status: published
88
published: 2017-09-13
99
author: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
10+
feedback_url: https://github.com/canonical-websites/tutorials.ubuntu.com/issues
1011

1112
---
1213

0 commit comments

Comments
 (0)