Skip to content

Commit d6bf759

Browse files
authored
Merge pull request #1261 from ember-learn/jw-cm-urls-versions
Make individual pages for deprecations
2 parents f4b81f6 + 2274005 commit d6bf759

File tree

214 files changed

+28607
-25926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+28607
-25926
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,19 @@ module.exports = {
5454
files: ['tests/**/*-test.{js,ts}'],
5555
extends: ['plugin:qunit/recommended'],
5656
},
57+
{
58+
// mocha tests
59+
files: ['node-tests/**/*.mjs'],
60+
env: {
61+
browser: false,
62+
node: true,
63+
mocha: true,
64+
},
65+
plugins: ['node'],
66+
extends: ['plugin:node/recommended'],
67+
rules: {
68+
'node/no-unpublished-import': 'off',
69+
},
70+
},
5771
],
5872
};

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/adapters/application.js

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
11
import JSONAPIAdapter from '@ember-data/adapter/json-api';
2-
import { inject as service } from '@ember/service';
3-
import config from 'deprecation-app/config/environment';
4-
52
export default class ApplicationAdapter extends JSONAPIAdapter {
6-
@service fastboot;
7-
8-
/**
9-
* FastBoot shouldn't know the host since we use prember
10-
* & it can't find the resources at the API host during build time.
11-
*/
12-
get host() {
13-
let isFastBoot = this.fastboot.isFastBoot;
14-
return isFastBoot ? '' : config.apiHost;
3+
urlForFindRecord(id, modelName) {
4+
return `/${modelName}/${id}.json`;
155
}
166

17-
buildURL(modelName, id, snapshot, requestType, query) {
18-
let url;
19-
20-
if (requestType === 'queryRecord') {
21-
url = [modelName, `${query.path}.json`];
22-
} else if (requestType === 'query') {
23-
url = [modelName, `${query.path}-${query.version}.json`];
24-
} else {
25-
return this.super;
26-
}
27-
28-
let host = this.host;
29-
let prefix = this.urlPrefix();
30-
31-
if (prefix) {
32-
url.unshift(prefix);
33-
}
34-
35-
url = url.join('/');
36-
if (!host && url && url.charAt(0) !== '/') {
37-
url = '/' + url;
38-
}
39-
40-
return url;
7+
urlForQuery(query, modelName) {
8+
return `/${modelName}/${query.path}-${query.version}.json`;
419
}
4210
}

app/controllers/show.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ export default class ShowController extends Controller {
2323
return PROJECTS[this.content.query.path];
2424
}
2525

26-
get renderIdOrUntil() {
27-
let version = this.content.query.version;
28-
let versionsWithoutId = ['v1.x'];
29-
30-
return !versionsWithoutId.includes(version);
31-
}
32-
3326
@action
3427
toggleToc() {
3528
this.displayMobileToc = !this.displayMobileToc;

app/models/content.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ export default class ContentModel extends Model {
66
@attr until;
77
@attr since;
88
@attr anchor;
9+
@attr displayId;
10+
11+
// v1 has different meta, so conditionally render it
12+
get renderUntil() {
13+
return !this.since.startsWith('1.');
14+
}
915
}

app/router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ Router.map(function () {
1414
this.route('show', {
1515
path: ':project/:version',
1616
});
17+
18+
this.route('id', { path: 'id/:id' });
1719
});

app/routes/id.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class IdPRoute extends Route {
5+
@service store;
6+
7+
model(params) {
8+
return this.store.findRecord('content', params.id);
9+
}
10+
}

app/serializers/application.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
import JSONAPISerializer from '@ember-data/serializer/json-api';
22

3-
export default class ApplicationSerializer extends JSONAPISerializer {}
3+
export default class ApplicationSerializer extends JSONAPISerializer {
4+
keyForAttribute(key) {
5+
return key;
6+
}
7+
}

app/templates/components/deprecation-article.hbs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
<div class="padding-vertical-small bg-light-muted rounded-sm">
2-
<h3 id="{{id-for-deprecation @model.id @model.anchor}}">
3-
<a href="#{{id-for-deprecation @model.id @model.anchor}}" title={{@model.title}} class="toc-anchor">
4-
§
5-
</a>
6-
{{markdown-to-html
7-
@model.title
8-
extensions="no-wrapper"
9-
tagName=""
10-
}}
11-
</h3>
2+
{{yield}}
123
<div class="my-2">
13-
{{#if @renderIdOrUntil}}
4+
{{#if @model.renderUntil}}
145
<div><span class="bold">until: </span>{{@model.until}}</div>
15-
{{/if}}
16-
{{#if @renderIdOrUntil}}
17-
<div><span class="bold">id: </span>{{@model.id}}</div>
6+
<div><span class="bold">id: </span>{{or @model.displayId @model.id}}</div>
187
{{/if}}
198
</div>
209
<section>

app/templates/components/main-layout.hbs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@
1010
{{#each @sortedGroupedResults as |result|}}
1111
<h2 class="anchorable-toc rounded-lg padding-small">Deprecations Added in {{result.since}} </h2>
1212
{{#each result.contents as |content|}}
13-
<DeprecationArticle @model={{content}} @renderIdOrUntil={{@renderIdOrUntil}} />
13+
<DeprecationArticle @model={{content}}>
14+
<h3 id="{{id-for-deprecation (or content.displayId content.id) content.anchor}}">
15+
<a href="#{{id-for-deprecation (or content.displayId content.id) content.anchor}}" title={{content.title}} class="toc-anchor">
16+
§
17+
</a>
18+
{{markdown-to-html
19+
content.title
20+
extensions="no-wrapper"
21+
tagName=""
22+
}}
23+
</h3>
24+
</DeprecationArticle>
1425
{{/each}}
1526
{{/each}}
1627
{{/if}}

0 commit comments

Comments
 (0)