Skip to content

Commit b1f829b

Browse files
authored
Fixed number of documentation and API console issues. (#231)
1 parent bebca76 commit b1f829b

40 files changed

+562
-377
lines changed

src/apim.runtime.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import "./polyfills";
22
import "./bindingHandlers/scrollintoview";
3-
import "./bindingHandlers/codeSample";
43
import "./bindingHandlers/copyToClipboard";
54
import "./bindingHandlers/syntaxHighlight";
65
import "./bindingHandlers/schemaobjecttype";
@@ -17,6 +16,7 @@ import { DefaultEventManager } from "@paperbits/common/events";
1716
import { XmlHttpRequestClient } from "@paperbits/common/http";
1817
import { SettingsProvider } from "@paperbits/common/configuration";
1918
import { DefaultRouter } from "@paperbits/common/routing";
19+
import { ConsoleLogger } from "@paperbits/common/logging";
2020
import { KnockoutRegistrationLoaders } from "@paperbits/core/ko/knockout.loaders";
2121
import { ApiList, ApiListDropdown, ApiListTiles } from "./components/apis/list-of-apis/ko/runtime";
2222
import { ApiService } from "./services/apiService";
@@ -66,6 +66,7 @@ export class ApimRuntimeModule implements IInjectorModule {
6666
public register(injector: IInjector): void {
6767
injector.bindModule(new KnockoutRegistrationLoaders());
6868
injector.bindSingleton("eventManager", DefaultEventManager);
69+
injector.bindSingleton("logger", ConsoleLogger);
6970
injector.bindCollection("autostart");
7071
injector.bindToCollection("autostart", UnhandledErrorHandler);
7172
injector.bindCollection("routeGuards");

src/bindingHandlers/codesample.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/bindingHandlers/syntaxHighlight.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "prismjs/components/prism-java";
88
import "prismjs/components/prism-python";
99
import "prismjs/components/prism-ruby";
1010
import "prismjs/components/prism-markup";
11+
import "prismjs/components/prism-bash";
1112
// import "prismjs/components/prism-php"; // broken!
1213

1314

@@ -19,7 +20,7 @@ interface SyntaxHighlightConfig {
1920
ko.bindingHandlers["syntaxHighlight"] = {
2021
update: (element: HTMLElement, valueAccessor: () => SyntaxHighlightConfig): void => {
2122
const config = valueAccessor();
22-
const code = ko.unwrap(config.code);
23+
let code = ko.unwrap(config.code);
2324
const language = ko.unwrap(config.language);
2425

2526
const render = async () => {
@@ -30,6 +31,8 @@ ko.bindingHandlers["syntaxHighlight"] = {
3031
highlightLanguage = "csharp";
3132
break;
3233
case "curl":
34+
highlightLanguage = "bash";
35+
break;
3336
case "http":
3437
highlightLanguage = "http";
3538
break;
@@ -42,14 +45,14 @@ ko.bindingHandlers["syntaxHighlight"] = {
4245
case "objc":
4346
highlightLanguage = "c";
4447
break;
45-
// case "php":
46-
// highlightLanguage = "php";
47-
// break;
48+
case "php":
49+
// highlightLanguage = "php"; // broken!
50+
highlightLanguage = "ruby";
51+
break;
4852
case "python":
4953
highlightLanguage = "python";
5054
break;
5155
case "ruby":
52-
case "php":
5356
highlightLanguage = "ruby";
5457
break;
5558
case "xml":
@@ -67,7 +70,12 @@ ko.bindingHandlers["syntaxHighlight"] = {
6770
ko.applyBindingsToNode(element, { text: text }, null);
6871
}
6972
else {
70-
const html = Prism.highlight(code, Prism.languages[highlightLanguage], highlightLanguage);
73+
74+
code = code.replaceAll("/", "fwdslsh"); // workaround for PrismJS bug.
75+
let html = Prism.highlight(code, Prism.languages[highlightLanguage], highlightLanguage);
76+
html = html.replaceAll("fwdslsh", "/");
77+
78+
// const html = Prism.highlight(code, Prism.languages[highlightLanguage], highlightLanguage);
7179
ko.applyBindingsToNode(element, { html: html }, null);
7280
}
7381
};
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
import { Router } from "@paperbits/common/routing";
2+
import { Logger } from "@paperbits/common/logging";
3+
import { pageUrl500 } from "./../constants";
14

25
export class UnhandledErrorHandler {
36
constructor(
7+
private readonly logger: Logger,
8+
private readonly router: Router
49
) {
510
window.addEventListener("error", this.handlerError.bind(this), false);
611
}
712

813
public handlerError(event: ErrorEvent): void {
9-
// debugger;
10-
alert("oops, something went wrong!");
14+
this.logger.traceError(event.error);
15+
this.router.navigateTo(pageUrl500);
1116
}
1217
}

src/components/apis/list-of-apis/ko/runtime/api-list-dropdown.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<div tabindex="0" role="listbox">
2-
<div class="form-control" tabindex="0" data-bind="activate: toggle, css: { expanded: expanded }, attr: { 'aria-expanded': expanded }">
2+
<div class="form-control" tabindex="0"
3+
data-bind="activate: toggle, css: { expanded: expanded }, attr: { 'aria-expanded': expanded }">
34
<div class="input-group">
45
<div class="input" data-bind="text: selection"></div>
56
<div class="input-group-append">
@@ -30,8 +31,12 @@
3031
</div>
3132
<div class="collapsible-container">
3233
<!-- ko foreach: { data: group.items, as: 'item' } -->
33-
<a href="#" role="listitem" class="nav-link text-truncate"
34-
data-bind="attr: { href: $component.getReferenceUrl(item) }, text: item.displayName"></a>
34+
<a href="#" role="listitem" class="nav-link text-truncate" data-bind="attr: { href: $component.getReferenceUrl(item) }">
35+
<span data-bind="text: item.displayName"></span>
36+
<!-- ko if: item.apiVersion -->
37+
(<span data-bind="text: item.apiVersion"></span>)
38+
<!-- /ko -->
39+
</a>
3540
<!-- /ko -->
3641
</div>
3742
</div>

src/components/apis/list-of-apis/ko/runtime/api-list-dropdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { RouteHelper } from "./../../../../../routing/routeHelper";
21
import * as ko from "knockout";
32
import * as Constants from "../../../../../constants";
43
import template from "./api-list-dropdown.html";
54
import { Component, RuntimeComponent, OnMounted } from "@paperbits/common/ko/decorators";
5+
import { RouteHelper } from "./../../../../../routing/routeHelper";
66
import { Api } from "../../../../../models/api";
77
import { ApiService } from "../../../../../services/apiService";
88
import { TagGroup } from "../../../../../models/tagGroup";

src/components/apis/list-of-apis/ko/runtime/api-list-tiles.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
</div>
2525
<!-- /ko -->
2626

27-
<!-- ko ifnot: working -->
27+
<!-- ko ifnot: working -->
2828
<div class="cards-body animation-fade-in">
29-
29+
3030

3131
<!-- ko if: groupByTag -->
3232
<!-- ko foreach: { data: apiGroups, as: 'group' } -->
@@ -37,7 +37,12 @@
3737
<!-- ko foreach: { data: group.items, as: 'item' } -->
3838
<a href="#" data-bind="attr: { href: $component.getReferenceUrl(item) }">
3939
<div class="card card-default">
40-
<h3 data-bind="text: item.displayName"></h3>
40+
<h3>
41+
<span data-bind="text: item.displayName"></span>
42+
<!-- ko if: item.apiVersion -->
43+
(<span data-bind="text: item.apiVersion"></span>)
44+
<!-- /ko -->
45+
</h3>
4146
<div class="tile line-clamp">
4247
<p class="tile-content" data-bind="markdown: item.description"></p>
4348
</div>
@@ -58,7 +63,12 @@ <h3 data-bind="text: item.displayName"></h3>
5863
<!-- ko foreach: { data: apis, as: 'item' } -->
5964
<a href="#" data-bind="attr: { href: $component.getReferenceUrl(item) }">
6065
<div class="card card-default">
61-
<h3 data-bind="text: item.displayName"></h3>
66+
<h3>
67+
<span data-bind="text: item.displayName"></span>
68+
<!-- ko if: item.apiVersion -->
69+
(<span data-bind="text: item.apiVersion"></span>)
70+
<!-- /ko -->
71+
</h3>
6272
<div class="tile line-clamp">
6373
<p class="tile-content" data-bind="markdown: item.description"></p>
6474
</div>
@@ -74,7 +84,7 @@ <h3 data-bind="text: item.displayName"></h3>
7484
<!-- /ko -->
7585
</div>
7686
<!-- /ko -->
77-
87+
7888
<div class="cards-footer">
7989
<!-- ko if: hasPager -->
8090
<ul class="pagination">

src/components/apis/list-of-apis/ko/runtime/api-list.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@
3636
<!-- ko foreach: { data: group.items, as: 'item' } -->
3737
<div class="row">
3838
<div class="col-5">
39-
<a href="#" role="listitem" class="nav-link text-truncate"
40-
data-bind="attr: { href: $component.getReferenceUrl(item) }, text: item.displayName"></a>
39+
<a href="#" role="listitem" class="nav-link text-truncate" data-bind="attr: { href: $component.getReferenceUrl(item) }">
40+
<span data-bind="text: item.displayName"></span>
41+
<!-- ko if: item.apiVersion -->
42+
(<span data-bind="text: item.apiVersion"></span>)
43+
<!-- /ko -->
44+
</a>
4145
</div>
4246
<div class="col-7">
4347
<div data-bind="markdown: item.description"></div>
@@ -55,8 +59,12 @@
5559
<!-- ko foreach: { data: apis, as: 'item' } -->
5660
<div class="row">
5761
<div class="col-5">
58-
<a href="#" class="text-truncate"
59-
data-bind="attr: { href: $component.getReferenceUrl(item) }, text: item.displayName"></a>
62+
<a href="#" role="listitem" class="nav-link text-truncate" data-bind="attr: { href: $component.getReferenceUrl(item) }">
63+
<span data-bind="text: item.displayName"></span>
64+
<!-- ko if: item.apiVersion -->
65+
(<span data-bind="text: item.apiVersion"></span>)
66+
<!-- /ko -->
67+
</a>
6068
</div>
6169
<div class="col-7">
6270
<div data-bind="markdown: item.description"></div>

0 commit comments

Comments
 (0)