Skip to content

Commit 093efa9

Browse files
committed
[Doc] HTML example code done
1 parent 7a402bf commit 093efa9

File tree

7 files changed

+23
-4
lines changed

7 files changed

+23
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ make tests
4747

4848
### Config
4949

50-
[Config your markus.conf](https://github.com/sudo-dog/Markus/wiki/Admin-Testing-API)
50+
[Config your markus.conf](https://github.com/sudo-dog/Markus/wiki/Config)
5151

5252
### APIS
5353

assets/code/android-get-image-from-url.template

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="${path}">

src/doc/template/components/table_card.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { EXPRESS_EXAMPLE_CODE, EXPRESS_SPECIAL_MARK, IExpressRoute, IText } from '../../../service/interface';
88
import LanguageTextProcessor from '../../../service/language';
99
import { IDocTableElement, IDocTemplateRenderer } from '../../interface';
10-
import { fetchMarkusFormData, nodeMarkusFormData } from '../../util/code';
10+
import { fetchMarkusFormData, nodeMarkusFormData, htmlMarkusImage } from '../../util/code';
1111
import { convertObjectToHTMLFriendlyJson, convertRouteToTemplate } from '../../util/covert';
1212
import StyleBuilder from '../style';
1313

@@ -31,6 +31,7 @@ export default class DocTableCardTemplateRenderer implements IDocTemplateRendere
3131
this.getExampleCode = this.getExampleCode.bind(this);
3232
this.getNodeCode = this.getNodeCode.bind(this);
3333
this.getFetchCode = this.getFetchCode.bind(this);
34+
this.getHTMLCode = this.getHTMLCode.bind(this);
3435
}
3536

3637
public build(): string {
@@ -77,7 +78,7 @@ export default class DocTableCardTemplateRenderer implements IDocTemplateRendere
7778
current = this.getFetchCode();
7879
break;
7980
case EXPRESS_EXAMPLE_CODE.HTML:
80-
current = '';
81+
current = this.getHTMLCode();
8182
break;
8283
case EXPRESS_EXAMPLE_CODE.NODEJS_FORM_DATA:
8384
current = this.getNodeCode();
@@ -105,6 +106,13 @@ export default class DocTableCardTemplateRenderer implements IDocTemplateRendere
105106
});
106107
}
107108

109+
protected getHTMLCode(): string {
110+
return this.getRow({
111+
name: 'HTML',
112+
value: `<pre class="prettyprint"><code class="lang-js">${htmlMarkusImage(this._url + this._route.path, this._route)}</code></pre>`,
113+
});
114+
}
115+
108116
protected getBadge(marks: EXPRESS_SPECIAL_MARK[]): string {
109117
const badgeStyle = new StyleBuilder()
110118
.add('font-size', '18px')

src/doc/util/code.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import * as Path from 'path';
99
// tslint:disable-next-line
1010
import { ExpressAssertionType, EXPRESS_ASSERTION_TYPES_END, EXPRESS_ASSERTION_TYPES_UNION, IExpressRoute } from "../../service/interface";
1111

12+
export const htmlMarkusImage = (domain: string, route: IExpressRoute): string => {
13+
const data: string = readAndReplaceTemplateFromAssets('html-get-image-from-url', {
14+
path: domain,
15+
});
16+
return data;
17+
};
18+
1219
export const nodeMarkusFormData = (domain: string, route: IExpressRoute): string => {
1320
const append: string[] = [];
1421
if (route.authorization) {

src/service/interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export enum EXPRESS_EXAMPLE_CODE {
8585
NODEJS_FORM_DATA = "NODEJS_FORM_DATA",
8686
FETCH_FORM_DATA = "FETCH_FORM_DATA",
8787
HTML = "HTML",
88+
ANDROID = "ANDROID",
89+
IOS_SWIFT = "IOS_SWIFT",
8890
}
8991

9092
export interface IExpressRoute {

src/service/routes/image/get_image.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IImageCallback } from "../../../database/interface/image";
1010
import * as Direct from "../../../direct/import";
1111
import { concatSuffix } from "../../../util/data/path";
1212
// tslint:disable-next-line
13-
import { ExpressNextFunction, EXPRESS_ASSERTION_TYPES_END, IDocInformation, IExpressAssertionJSONType, IExpressRoute, ROUTE_MODE } from '../../interface';
13+
import { ExpressNextFunction, EXPRESS_ASSERTION_TYPES_END, IDocInformation, IExpressAssertionJSONType, IExpressRoute, ROUTE_MODE, EXPRESS_EXAMPLE_CODE } from '../../interface';
1414
import LodgeableExpressRoute from "../../lodgeable";
1515

1616
export default class RouteGetImageByPath extends LodgeableExpressRoute implements IExpressRoute {
@@ -29,6 +29,7 @@ export default class RouteGetImageByPath extends LodgeableExpressRoute implement
2929
public readonly assertQuery: IExpressAssertionJSONType = {
3030
id: { type: EXPRESS_ASSERTION_TYPES_END.OBJECT_ID },
3131
};
32+
public readonly exampleCode: EXPRESS_EXAMPLE_CODE[] = [EXPRESS_EXAMPLE_CODE.HTML];
3233

3334
private _emptyPath: string;
3435

0 commit comments

Comments
 (0)