From 9a2097183d09900aa0554c4b2e33edf474f8a765 Mon Sep 17 00:00:00 2001 From: Austin Date: Sun, 18 Feb 2018 15:34:20 -0600 Subject: [PATCH 1/2] fix(stackblitz): fix svg path getting extra /app --- src/app/shared/stackblitz/stackblitz-writer.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/shared/stackblitz/stackblitz-writer.ts b/src/app/shared/stackblitz/stackblitz-writer.ts index e159910f9..956d994ce 100644 --- a/src/app/shared/stackblitz/stackblitz-writer.ts +++ b/src/app/shared/stackblitz/stackblitz-writer.ts @@ -87,7 +87,7 @@ export class StackblitzWriter { // TODO(josephperrott): Prevent including assets to be manually checked. if (data.selectorName === 'icon-svg-example') { - this._readFile(form, data, 'assets/img/examples/thumbup-icon.svg', ''); + this._readFile(form, data, 'assets/img/examples/thumbup-icon.svg', '', false); } Promise.all(templateContents.concat(exampleContents)).then(() => { @@ -115,9 +115,13 @@ export class StackblitzWriter { } /** Reads the file and adds its text to the form */ - _readFile(form: HTMLFormElement, data: ExampleData, filename: string, path: string): void { + _readFile(form: HTMLFormElement, + data: ExampleData, + filename: string, + path: string, + prependApp = true): void { this._http.get(path + filename).toPromise().then( - response => this._addFileToForm(form, data, response.text(), filename, path), + response => this._addFileToForm(form, data, response.text(), filename, path, prependApp), error => console.log(error)); } @@ -126,10 +130,11 @@ export class StackblitzWriter { data: ExampleData, content: string, filename: string, - path: string) { + path: string, + prependApp = true) { if (path == TEMPLATE_PATH) { content = this._replaceExamplePlaceholderNames(data, filename, content); - } else { + } else if (prependApp) { filename = 'app/' + filename; } this._appendFormInput(form, `files[${filename}]`, this._appendCopyright(filename, content)); From f2f9af418786cb2f638f28b424e2fee3f59a4183 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 26 Feb 2018 18:08:59 -0600 Subject: [PATCH 2/2] chore: add comments --- .../shared/stackblitz/stackblitz-writer.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/shared/stackblitz/stackblitz-writer.ts b/src/app/shared/stackblitz/stackblitz-writer.ts index 956d994ce..6506170c6 100644 --- a/src/app/shared/stackblitz/stackblitz-writer.ts +++ b/src/app/shared/stackblitz/stackblitz-writer.ts @@ -114,7 +114,14 @@ export class StackblitzWriter { form.appendChild(input); } - /** Reads the file and adds its text to the form */ + /** + * Reads the file and adds its text to the form + * @param form the html form you are appending to + * @param data example metadata about the example + * @param filename file name of the example + * @param path path to the src + * @param prependApp whether to prepend the 'app' prefix to the path + */ _readFile(form: HTMLFormElement, data: ExampleData, filename: string, @@ -125,7 +132,15 @@ export class StackblitzWriter { error => console.log(error)); } - /** Adds the file text to the form. */ + /** + * Adds the file text to the form. + * @param form the html form you are appending to + * @param data example metadata about the example + * @param content file contents + * @param filename file name of the example + * @param path path to the src + * @param prependApp whether to prepend the 'app' prefix to the path + */ _addFileToForm(form: HTMLFormElement, data: ExampleData, content: string,