From 4e4d7d323f5a634e4c78126c0dc9739b5e687bf5 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 1 Jun 2016 11:33:07 +0200 Subject: [PATCH 01/34] added more files to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b25c15b..34662c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *~ +.idea/ +*.iml +atlassian-ide-plugin.xml From 788f8652257ebe3a77a83be08c52d9c85ce4a3fb Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 6 Jun 2016 14:50:30 +0200 Subject: [PATCH 02/34] added package.json and updated .gitignore --- .gitignore | 1 + package.json | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 34662c8..09d1d0a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea/ *.iml atlassian-ide-plugin.xml +node_modules/ diff --git a/package.json b/package.json new file mode 100644 index 0000000..0884547 --- /dev/null +++ b/package.json @@ -0,0 +1,56 @@ +{ + "name": "dencode.org", + "version": "1.0.0-alpha.1", + "description": "Convert to and fro!", + "keywords": [ + "dencode" + ], + "author": { + "name": "Manuel Friedli", + "email": "manuel@fritteli.ch" + }, + "license": "MIT", + "homepage": "https://test.friedli.info/~manuel/dencode", + "dependencies": { + "bootstrap": "^3.3.6", + "angular2": "2.0.0-beta.17", + "es6-shim": "^0.35.0", + "rxjs": "5.0.0-beta.2", + "core-js": "^2.2.2" + }, + "devDependencies": { + "awesome-typescript-loader": "^0.17.0", + "babel-core": "^5.4.2", + "babel-loader": "^5.0.0", + "browser-sync": "^2.10.0", + "browser-sync-webpack-plugin": "^1.0.0", + "concurrently": "^2.0.0", + "css-loader": "^0.19.0", + "docco": "^0.7.0", + "file-loader": "^0.8.4", + "gulp": "^3.9.0", + "gulp-esdoc": "^0.1.0", + "ip": "^1.0.2", + "isparta-loader": "^1.0.0", + "jasmine-core": "^2.3.4", + "json-loader": "^0.5.3", + "karma": "^0.13.9", + "karma-coverage": "^0.5.3", + "karma-jasmine": "~0.3.5", + "karma-junit-reporter": "^0.3.8", + "karma-phantomjs-launcher": "^0.2.1", + "karma-sourcemap-loader": "^0.3.4", + "karma-webdriver-launcher": "^1.0.4", + "karma-webpack": "^1.5.1", + "ng-annotate-webpack-plugin": "^0.1.2", + "node-libs-browser": "^0.5.0", + "node.extend": "^1.1.5", + "phantomjs": "^1.9.18", + "phantomjs-polyfill": "0.0.1", + "raw-loader": "^0.5.1", + "style-loader": "^0.13.0", + "typescript": "^1.8.9", + "typings": "^0.7.12", + "url-loader": "^0.5.6" + } +} From 325b361a1552fd88041f4e45ceec2facef74aba6 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 6 Jun 2016 15:03:14 +0200 Subject: [PATCH 03/34] updated package.json --- package.json | 58 +++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 0884547..6b1bf66 100644 --- a/package.json +++ b/package.json @@ -11,46 +11,34 @@ }, "license": "MIT", "homepage": "https://test.friedli.info/~manuel/dencode", + "repository": "https://gittr.ch/manuel/dencode.org.git", "dependencies": { + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/upgrade": "2.0.0-rc.1", "bootstrap": "^3.3.6", - "angular2": "2.0.0-beta.17", - "es6-shim": "^0.35.0", - "rxjs": "5.0.0-beta.2", - "core-js": "^2.2.2" + "core-js": "^2.4.0", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.6", + "systemjs": "^0.19.27", + "zone.js": "^0.6.12" }, "devDependencies": { - "awesome-typescript-loader": "^0.17.0", - "babel-core": "^5.4.2", - "babel-loader": "^5.0.0", - "browser-sync": "^2.10.0", - "browser-sync-webpack-plugin": "^1.0.0", "concurrently": "^2.0.0", - "css-loader": "^0.19.0", - "docco": "^0.7.0", - "file-loader": "^0.8.4", "gulp": "^3.9.0", - "gulp-esdoc": "^0.1.0", - "ip": "^1.0.2", - "isparta-loader": "^1.0.0", - "jasmine-core": "^2.3.4", - "json-loader": "^0.5.3", - "karma": "^0.13.9", - "karma-coverage": "^0.5.3", - "karma-jasmine": "~0.3.5", - "karma-junit-reporter": "^0.3.8", - "karma-phantomjs-launcher": "^0.2.1", - "karma-sourcemap-loader": "^0.3.4", - "karma-webdriver-launcher": "^1.0.4", - "karma-webpack": "^1.5.1", - "ng-annotate-webpack-plugin": "^0.1.2", - "node-libs-browser": "^0.5.0", - "node.extend": "^1.1.5", - "phantomjs": "^1.9.18", - "phantomjs-polyfill": "0.0.1", - "raw-loader": "^0.5.1", - "style-loader": "^0.13.0", - "typescript": "^1.8.9", - "typings": "^0.7.12", - "url-loader": "^0.5.6" + "lite-server": "^2.2.0", + "typescript": "^1.8.10", + "typings": "^1.0.4" + }, + "scripts": { + "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"", + "lite": "lite-server", + "postinstall": "typings install", + "tsc": "tsc", + "tsc:w": "tsc -w", + "typings": "typings" } } From 4fa442e2622935c9075f06ad1433396f0be9308c Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 6 Jun 2016 15:56:19 +0200 Subject: [PATCH 04/34] set up a first draft of the angular2 scaffold --- .gitignore | 3 +++ app/app.component.ts | 11 +++++++++++ app/main.ts | 5 +++++ index.html | 39 ++++++++++++++++++++++++------------ systemjs.config.js | 47 ++++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 12 +++++++++++ typings.json | 7 +++++++ 7 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 app/app.component.ts create mode 100644 app/main.ts create mode 100644 systemjs.config.js create mode 100644 tsconfig.json create mode 100644 typings.json diff --git a/.gitignore b/.gitignore index 09d1d0a..d22d33e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ *.iml atlassian-ide-plugin.xml node_modules/ +typings/ +app/**/*.js +app/**/*.js.map \ No newline at end of file diff --git a/app/app.component.ts b/app/app.component.ts new file mode 100644 index 0000000..0ea17ab --- /dev/null +++ b/app/app.component.ts @@ -0,0 +1,11 @@ +import { Component } from "@angular/core"; + +@Component({ + "selector":"dencode-app", + "template": ` +

dencode.org

+ ` +}) +export class AppComponent { + +} diff --git a/app/main.ts b/app/main.ts new file mode 100644 index 0000000..04cabf1 --- /dev/null +++ b/app/main.ts @@ -0,0 +1,5 @@ +import {bootstrap} from "@angular/platform-browser-dynamic"; + +import {AppComponent} from "./app.component"; + +bootstrap(AppComponent); diff --git a/index.html b/index.html index dadf298..d469d4c 100644 --- a/index.html +++ b/index.html @@ -1,19 +1,32 @@ - - - Decode? Encode? DENcode! - - - - - + + + Decode? Encode? DENcode! + + + + + + + + + + + + -

Decode? Encode? DENcode!

- +

Decode? Encode? DENcode!

+ +Please hold on, we're starting the turbines ... - \ No newline at end of file + diff --git a/systemjs.config.js b/systemjs.config.js new file mode 100644 index 0000000..4ea7cf2 --- /dev/null +++ b/systemjs.config.js @@ -0,0 +1,47 @@ +/** + * System configuration for Angular 2 samples + * Adjust as necessary for your application needs. + */ +(function(global) { + // map tells the System loader where to look for things + var map = { + 'app': 'app', // 'dist', + '@angular': 'node_modules/@angular', +// 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', + 'rxjs': 'node_modules/rxjs' + }; + // packages tells the System loader how to load when no filename and/or no extension + var packages = { + 'app': { main: 'main.js', defaultExtension: 'js' }, + 'rxjs': { defaultExtension: 'js' }, +// 'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }, + }; + var ngPackageNames = [ + 'common', + 'compiler', + 'core', + 'http', + 'platform-browser', + 'platform-browser-dynamic', + 'router', + 'router-deprecated', + 'upgrade', + ]; + // Individual files (~300 requests): + function packIndex(pkgName) { + packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' }; + } + // Bundled (~40 requests): + function packUmd(pkgName) { + packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' }; + }; + // Most environments should use UMD; some (Karma) need the individual index files + var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; + // Add package entries for angular packages + ngPackageNames.forEach(setPackageConfig); + var config = { + map: map, + packages: packages + } + System.config(config); +})(this); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e6a6eac --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false, + "noImplicitAny": false + } +} diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..192935f --- /dev/null +++ b/typings.json @@ -0,0 +1,7 @@ +{ + "globalDependencies": { + "core-js": "registry:dt/core-js#0.0.0+20160317120654", + "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", + "node": "registry:dt/node#4.0.0+20160509154515" + } +} \ No newline at end of file From a59ab194c33fdabbf481696cd7931eba0243cb88 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 15 Aug 2016 17:12:11 +0200 Subject: [PATCH 05/34] intermediate commit --- app/app.component.ts | 19 ++++++++++--- app/conversioninput.ts | 6 ++++ app/conversiontype.ts | 28 +++++++++++++++++++ app/inputarea.component.ts | 54 ++++++++++++++++++++++++++++++++++++ app/option.component._t_s_ | 12 ++++++++ app/selector.component._t_s_ | 19 +++++++++++++ index.html | 4 ++- 7 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 app/conversioninput.ts create mode 100644 app/conversiontype.ts create mode 100644 app/inputarea.component.ts create mode 100644 app/option.component._t_s_ create mode 100644 app/selector.component._t_s_ diff --git a/app/app.component.ts b/app/app.component.ts index 0ea17ab..7799baf 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,11 +1,22 @@ import { Component } from "@angular/core"; +import { InputareaComponent } from "./inputarea.component"; +import {ConversionType} from "./conversiontype"; +//import { SelectorComponent } from "./selector.component"; + @Component({ - "selector":"dencode-app", - "template": ` -

dencode.org

- ` + selector: "den-app", + template: ` +
+ +
+ `, + directives: [InputareaComponent] }) export class AppComponent { + private inputAreas:InputareaComponent[] = []; + constructor() { + this.inputAreas.push(new InputareaComponent()); + } } diff --git a/app/conversioninput.ts b/app/conversioninput.ts new file mode 100644 index 0000000..0380c28 --- /dev/null +++ b/app/conversioninput.ts @@ -0,0 +1,6 @@ +import { ConversionType} from "./conversiontype"; + +export class ConversionInput { + public content:string; + public type:ConversionType; +} \ No newline at end of file diff --git a/app/conversiontype.ts b/app/conversiontype.ts new file mode 100644 index 0000000..4f34586 --- /dev/null +++ b/app/conversiontype.ts @@ -0,0 +1,28 @@ +export enum ConversionType { + ENCODE_BASE64, + DECODE_BASE64 +} + +export namespace ConversionType { + export function getName(type:ConversionType):string { + switch (type) { + case ConversionType.DECODE_BASE64: + return "Decode BASE64"; + case ConversionType.ENCODE_BASE64: + return "Encode BASE64"; + default: + return "Unknown"; + } + } + + export function of(id:number):ConversionType { + switch (id) { + case 0: + return ConversionType.ENCODE_BASE64; + case 1: + return ConversionType.DECODE_BASE64; + default: + return undefined; + } + } +} diff --git a/app/inputarea.component.ts b/app/inputarea.component.ts new file mode 100644 index 0000000..290175d --- /dev/null +++ b/app/inputarea.component.ts @@ -0,0 +1,54 @@ +import { Component } from "@angular/core"; +import { ConversionInput } from "./conversioninput"; +import { ConversionType } from "./conversiontype"; + + +@Component({ + selector: "den-inputarea", + template: ` +
+ + +
+ ` +}) +export class InputareaComponent { + public index:number = 0; + public conversions:ConversionType[] = [ConversionType.ENCODE_BASE64, ConversionType.DECODE_BASE64]; + private conversion:ConversionInput; + private ConversionType:ConversionType = ConversionType; + + constructor() { + console.log("Aloha, " + this.index); + this.conversion = new ConversionInput(); + this.conversion.content = ""; + this.conversion.type = ConversionType.DECODE_BASE64; + } + + public update():void { + console.log(this.conversion.content); + } + + public convert(e):void { + this.conversion.type = ConversionType.of(+e.target.selectedOptions[0].id); + console.log(this.conversion.type); + switch (this.conversion.type) { + case ConversionType.DECODE_BASE64: + this.conversion.content = "Base64 decode"; + break; + case ConversionType.ENCODE_BASE64: + this.conversion.content = "Base 64 encode"; + break; + default: + this.conversion.content = "Unknown: " + this.conversion.type; + break; + } + } + + public setIndex(index:number):void { + this.index = index; + } +} diff --git a/app/option.component._t_s_ b/app/option.component._t_s_ new file mode 100644 index 0000000..1398f21 --- /dev/null +++ b/app/option.component._t_s_ @@ -0,0 +1,12 @@ +//import {Component} from "@angular/core"; +// +//@Component({ +// selector: "den-option", +// template: ` +// +// ` +//}) +//export class OptionComponent { +// public id:string; +// public displayName:string; +//} \ No newline at end of file diff --git a/app/selector.component._t_s_ b/app/selector.component._t_s_ new file mode 100644 index 0000000..0c17a7e --- /dev/null +++ b/app/selector.component._t_s_ @@ -0,0 +1,19 @@ +//import {Component} from "@angular/core"; +// +//import {OptionComponent} from "./option.component"; +// +//@Component({ +// selector: "den-selector", +// template: ` +// +// `, +// directives: [OptionComponent] +//}) +//export class SelectorComponent { +// private options:OptionComponent[]; +// +//} \ No newline at end of file diff --git a/index.html b/index.html index d469d4c..f27b6d9 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,8 @@ it requires you to enable Javascript to do so. So please turn it on in your Browser. You won't regret it! -Please hold on, we're starting the turbines ... + +
Please hold on, we're starting the turbines ...
+
From 0cf6eeaedfdad5f7151c1ea4867dbc3b2b27e601 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 12:40:13 +0200 Subject: [PATCH 06/34] updated to angular-2.0.0 (final) --- .gitignore | 2 +- app/app.component.ts | 19 +++++---- app/app.module.ts | 20 ++++++++++ app/conversioninput.ts | 2 +- app/inputarea.component.ts | 10 ++--- app/main.ts | 7 ++-- package.json | 23 +++++------ systemjs.config.js | 80 ++++++++++++++++++-------------------- typings.json | 8 ++-- 9 files changed, 94 insertions(+), 77 deletions(-) create mode 100644 app/app.module.ts diff --git a/.gitignore b/.gitignore index d22d33e..a74b159 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ atlassian-ide-plugin.xml node_modules/ typings/ app/**/*.js -app/**/*.js.map \ No newline at end of file +app/**/*.js.map diff --git a/app/app.component.ts b/app/app.component.ts index 7799baf..805b8f6 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,7 +1,7 @@ -import { Component } from "@angular/core"; +import {Component} from "@angular/core"; -import { InputareaComponent } from "./inputarea.component"; -import {ConversionType} from "./conversiontype"; +import {InputareaComponent} from "./inputarea.component"; +// import {ConversionType} from "./conversiontype"; //import { SelectorComponent } from "./selector.component"; @Component({ @@ -10,13 +10,12 @@ import {ConversionType} from "./conversiontype";
- `, - directives: [InputareaComponent] + ` }) export class AppComponent { - private inputAreas:InputareaComponent[] = []; - - constructor() { - this.inputAreas.push(new InputareaComponent()); - } + // private inputAreas:InputareaComponent[] = []; + // + // constructor() { + // this.inputAreas.push(new InputareaComponent()); + // } } diff --git a/app/app.module.ts b/app/app.module.ts new file mode 100644 index 0000000..4cf0a38 --- /dev/null +++ b/app/app.module.ts @@ -0,0 +1,20 @@ +import {NgModule} from '@angular/core' +import {BrowserModule} from '@angular/platform-browser' +import {FormsModule} from '@angular/forms' + +import {AppComponent} from './app.component' +import {InputareaComponent} from "./inputarea.component"; + +@NgModule({ + imports: [ + BrowserModule, + FormsModule + ], + declarations: [ + AppComponent, + InputareaComponent + ], + bootstrap: [AppComponent] +}) +export class AppModule { +} diff --git a/app/conversioninput.ts b/app/conversioninput.ts index 0380c28..be417ef 100644 --- a/app/conversioninput.ts +++ b/app/conversioninput.ts @@ -3,4 +3,4 @@ import { ConversionType} from "./conversiontype"; export class ConversionInput { public content:string; public type:ConversionType; -} \ No newline at end of file +} diff --git a/app/inputarea.component.ts b/app/inputarea.component.ts index 290175d..5f7a4b2 100644 --- a/app/inputarea.component.ts +++ b/app/inputarea.component.ts @@ -20,18 +20,18 @@ export class InputareaComponent { public conversions:ConversionType[] = [ConversionType.ENCODE_BASE64, ConversionType.DECODE_BASE64]; private conversion:ConversionInput; private ConversionType:ConversionType = ConversionType; - + constructor() { console.log("Aloha, " + this.index); this.conversion = new ConversionInput(); this.conversion.content = ""; this.conversion.type = ConversionType.DECODE_BASE64; } - + public update():void { console.log(this.conversion.content); } - + public convert(e):void { this.conversion.type = ConversionType.of(+e.target.selectedOptions[0].id); console.log(this.conversion.type); @@ -40,14 +40,14 @@ export class InputareaComponent { this.conversion.content = "Base64 decode"; break; case ConversionType.ENCODE_BASE64: - this.conversion.content = "Base 64 encode"; + this.conversion.content = "Base64 encode"; break; default: this.conversion.content = "Unknown: " + this.conversion.type; break; } } - + public setIndex(index:number):void { this.index = index; } diff --git a/app/main.ts b/app/main.ts index 04cabf1..af2e54a 100644 --- a/app/main.ts +++ b/app/main.ts @@ -1,5 +1,6 @@ -import {bootstrap} from "@angular/platform-browser-dynamic"; +import {platformBrowserDynamic} from "@angular/platform-browser-dynamic"; -import {AppComponent} from "./app.component"; +import {AppModule} from "./app.module"; -bootstrap(AppComponent); +const platform = platformBrowserDynamic(); +platform.bootstrapModule(AppModule); diff --git a/package.json b/package.json index 6b1bf66..923c954 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0-alpha.1", "description": "Convert to and fro!", "keywords": [ - "dencode" + "dencode", "conversion", "converter", "convert" ], "author": { "name": "Manuel Friedli", @@ -13,25 +13,26 @@ "homepage": "https://test.friedli.info/~manuel/dencode", "repository": "https://gittr.ch/manuel/dencode.org.git", "dependencies": { - "@angular/common": "2.0.0-rc.1", - "@angular/compiler": "2.0.0-rc.1", - "@angular/core": "2.0.0-rc.1", - "@angular/platform-browser": "2.0.0-rc.1", - "@angular/platform-browser-dynamic": "2.0.0-rc.1", - "@angular/upgrade": "2.0.0-rc.1", + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/upgrade": "2.0.0", "bootstrap": "^3.3.6", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "5.0.0-beta.6", + "rxjs": "5.0.0-beta.12", "systemjs": "^0.19.27", "zone.js": "^0.6.12" }, "devDependencies": { - "concurrently": "^2.0.0", + "concurrently": "^2.2.0", "gulp": "^3.9.0", "lite-server": "^2.2.0", - "typescript": "^1.8.10", - "typings": "^1.0.4" + "typescript": "^2.0.2", + "typings": "^1.3.2" }, "scripts": { "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"", diff --git a/systemjs.config.js b/systemjs.config.js index 4ea7cf2..5ac6290 100644 --- a/systemjs.config.js +++ b/systemjs.config.js @@ -2,46 +2,42 @@ * System configuration for Angular 2 samples * Adjust as necessary for your application needs. */ -(function(global) { - // map tells the System loader where to look for things - var map = { - 'app': 'app', // 'dist', - '@angular': 'node_modules/@angular', -// 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', - 'rxjs': 'node_modules/rxjs' - }; - // packages tells the System loader how to load when no filename and/or no extension - var packages = { - 'app': { main: 'main.js', defaultExtension: 'js' }, - 'rxjs': { defaultExtension: 'js' }, -// 'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }, - }; - var ngPackageNames = [ - 'common', - 'compiler', - 'core', - 'http', - 'platform-browser', - 'platform-browser-dynamic', - 'router', - 'router-deprecated', - 'upgrade', - ]; - // Individual files (~300 requests): - function packIndex(pkgName) { - packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' }; - } - // Bundled (~40 requests): - function packUmd(pkgName) { - packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' }; - }; - // Most environments should use UMD; some (Karma) need the individual index files - var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; - // Add package entries for angular packages - ngPackageNames.forEach(setPackageConfig); - var config = { - map: map, - packages: packages - } - System.config(config); +(function (global) { + System.config({ + paths: { + // paths serve as alias + 'npm:': 'node_modules/' + }, + // map tells the System loader where to look for things + map: { + // our app is within the app folder + app: 'app', + // angular bundles + '@angular/core': 'npm:@angular/core/bundles/core.umd.js', + '@angular/common': 'npm:@angular/common/bundles/common.umd.js', + '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', + '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', + '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', +// '@angular/http': 'npm:@angular/http/bundles/http.umd.js', +// '@angular/router': 'npm:@angular/router/bundles/router.umd.js', + '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', + // other libraries + 'rxjs': 'npm:rxjs'//, +// 'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api', + }, + // packages tells the System loader how to load when no filename and/or no extension + packages: { + app: { + main: './main.js', + defaultExtension: 'js' + }, + rxjs: { + defaultExtension: 'js' + }, + 'angular2-in-memory-web-api': { + main: './index.js', + defaultExtension: 'js' + } + } + }); })(this); \ No newline at end of file diff --git a/typings.json b/typings.json index 192935f..7da31ca 100644 --- a/typings.json +++ b/typings.json @@ -1,7 +1,7 @@ { "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", - "node": "registry:dt/node#4.0.0+20160509154515" + "core-js": "registry:dt/core-js#0.0.0+20160725163759", + "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", + "node": "registry:dt/node#6.0.0+20160909174046" } -} \ No newline at end of file +} From dd4ffd998915d2a407f8ebc8fa15be3c33b5b837 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 12:55:13 +0200 Subject: [PATCH 07/34] externalized templates and styles (styles are still empty) --- app/app.component.css | 0 app/app.component.html | 3 +++ app/app.component.ts | 8 +++----- app/conversioninput.ts | 2 +- app/inputarea.component.css | 0 app/inputarea.component.html | 8 ++++++++ app/inputarea.component.ts | 26 ++++++++++---------------- 7 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 app/app.component.css create mode 100644 app/app.component.html create mode 100644 app/inputarea.component.css create mode 100644 app/inputarea.component.html diff --git a/app/app.component.css b/app/app.component.css new file mode 100644 index 0000000..e69de29 diff --git a/app/app.component.html b/app/app.component.html new file mode 100644 index 0000000..47161cb --- /dev/null +++ b/app/app.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/app/app.component.ts b/app/app.component.ts index 805b8f6..450620b 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -5,12 +5,10 @@ import {InputareaComponent} from "./inputarea.component"; //import { SelectorComponent } from "./selector.component"; @Component({ + moduleId: module.id, selector: "den-app", - template: ` -
- -
- ` + templateUrl: "app.component.html", + styleUrls: ["app.component.css"] }) export class AppComponent { // private inputAreas:InputareaComponent[] = []; diff --git a/app/conversioninput.ts b/app/conversioninput.ts index be417ef..9f52cca 100644 --- a/app/conversioninput.ts +++ b/app/conversioninput.ts @@ -1,4 +1,4 @@ -import { ConversionType} from "./conversiontype"; +import {ConversionType} from "./conversiontype"; export class ConversionInput { public content:string; diff --git a/app/inputarea.component.css b/app/inputarea.component.css new file mode 100644 index 0000000..e69de29 diff --git a/app/inputarea.component.html b/app/inputarea.component.html new file mode 100644 index 0000000..da0a65a --- /dev/null +++ b/app/inputarea.component.html @@ -0,0 +1,8 @@ +
+ + +
diff --git a/app/inputarea.component.ts b/app/inputarea.component.ts index 5f7a4b2..e413835 100644 --- a/app/inputarea.component.ts +++ b/app/inputarea.component.ts @@ -1,37 +1,31 @@ -import { Component } from "@angular/core"; -import { ConversionInput } from "./conversioninput"; -import { ConversionType } from "./conversiontype"; +import {Component} from "@angular/core"; +import {ConversionInput} from "./conversioninput"; +import {ConversionType} from "./conversiontype"; @Component({ + moduleId: module.id, selector: "den-inputarea", - template: ` -
- - -
- ` + templateUrl: "inputarea.component.html", + styleUrls: ["inputarea.component.css"] }) export class InputareaComponent { public index:number = 0; public conversions:ConversionType[] = [ConversionType.ENCODE_BASE64, ConversionType.DECODE_BASE64]; private conversion:ConversionInput; private ConversionType:ConversionType = ConversionType; - + constructor() { console.log("Aloha, " + this.index); this.conversion = new ConversionInput(); this.conversion.content = ""; this.conversion.type = ConversionType.DECODE_BASE64; } - + public update():void { console.log(this.conversion.content); } - + public convert(e):void { this.conversion.type = ConversionType.of(+e.target.selectedOptions[0].id); console.log(this.conversion.type); @@ -47,7 +41,7 @@ export class InputareaComponent { break; } } - + public setIndex(index:number):void { this.index = index; } From b30c6985468fd4472ac5202aa43434444b13c9a3 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 20:43:37 +0200 Subject: [PATCH 08/34] added the ConverterregistryService and two converters (base64 de- and encoder) --- app/app.component.ts | 27 +++++++++++++-------- app/base64decoder.ts | 15 ++++++++++++ app/base64encoder.ts | 15 ++++++++++++ app/converter.ts | 5 ++++ app/converterregistry.service.ts | 41 ++++++++++++++++++++++++++++++++ app/main.ts | 3 +-- 6 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 app/base64decoder.ts create mode 100644 app/base64encoder.ts create mode 100644 app/converter.ts create mode 100644 app/converterregistry.service.ts diff --git a/app/app.component.ts b/app/app.component.ts index 450620b..dc913bf 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,19 +1,26 @@ import {Component} from "@angular/core"; +import {OnInit}from "@angular/core"; -import {InputareaComponent} from "./inputarea.component"; -// import {ConversionType} from "./conversiontype"; -//import { SelectorComponent } from "./selector.component"; +import {ConverterregistryService} from "./converterregistry.service"; +import {Converter} from "./converter"; @Component({ moduleId: module.id, selector: "den-app", templateUrl: "app.component.html", - styleUrls: ["app.component.css"] + styleUrls: ["app.component.css"], + providers: [ConverterregistryService] }) -export class AppComponent { - // private inputAreas:InputareaComponent[] = []; - // - // constructor() { - // this.inputAreas.push(new InputareaComponent()); - // } +export class AppComponent extends OnInit { + constructor(private converterregistryService:ConverterregistryService) { + super(); + } + + ngOnInit():void { + let converters:Converter[] = this.converterregistryService.getConverters(); + console.log("Number of registered converters: " + converters.length); + for (let i = 0; i < converters.length; i++) { + console.log("Converter " + converters[i].getId() + ": " + converters[i].getDisplayname()); + } + } } diff --git a/app/base64decoder.ts b/app/base64decoder.ts new file mode 100644 index 0000000..eba3379 --- /dev/null +++ b/app/base64decoder.ts @@ -0,0 +1,15 @@ +import {Converter} from './converter'; + +export class Base64Decoder implements Converter { + getDisplayname():string { + return "Decode Base 64"; + } + + getId():string { + return "base64decode"; + } + + convert(input:string):string { + return atob(input); + } +} diff --git a/app/base64encoder.ts b/app/base64encoder.ts new file mode 100644 index 0000000..bb9de8f --- /dev/null +++ b/app/base64encoder.ts @@ -0,0 +1,15 @@ +import {Converter} from './converter'; + +export class Base64Encoder implements Converter { + getDisplayname():string { + return "Encode Base 64"; + } + + getId():string { + return "base64encode"; + } + + convert(input:string):string { + return btoa(input); + } +} diff --git a/app/converter.ts b/app/converter.ts new file mode 100644 index 0000000..66706f9 --- /dev/null +++ b/app/converter.ts @@ -0,0 +1,5 @@ +export interface Converter { + getDisplayname():string; + getId():string; + convert(input:string):string; +} diff --git a/app/converterregistry.service.ts b/app/converterregistry.service.ts new file mode 100644 index 0000000..44ad46d --- /dev/null +++ b/app/converterregistry.service.ts @@ -0,0 +1,41 @@ +import {Injectable} from '@angular/core'; + +import {Converter} from './converter'; +import {Base64Encoder} from "./base64encoder"; +import {Base64Decoder} from "./base64decoder"; + +@Injectable() +export class ConverterregistryService { + private converters:Converter[] = []; + + constructor() { + this.init(); + } + + public getConverters():Converter[] { + return this.converters; + } + + public getConverter(id:string):Converter { + for (let i = 0; i < this.converters.length; i++) { + if (this.converters[i].getId() == id) { + return this.converters[i]; + } + } + return undefined; + } + + private init():void { + this.registerConverter(new Base64Encoder()); + this.registerConverter(new Base64Decoder()); + } + + private registerConverter(converter:Converter):void { + this.converters.forEach((c:Converter) => { + if (c.getId() == converter.getId()) { + throw new Error("Converter-ID " + converter.getId() + " is already registered!"); + } + }); + this.converters.push(converter); + } +} diff --git a/app/main.ts b/app/main.ts index af2e54a..244ca48 100644 --- a/app/main.ts +++ b/app/main.ts @@ -2,5 +2,4 @@ import {platformBrowserDynamic} from "@angular/platform-browser-dynamic"; import {AppModule} from "./app.module"; -const platform = platformBrowserDynamic(); -platform.bootstrapModule(AppModule); +platformBrowserDynamic().bootstrapModule(AppModule); From 0b3a38af3c35972c8cca32fdd704d6c9b39c9c62 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 21:32:14 +0200 Subject: [PATCH 09/34] adapted CI config and deploy script to the new angular/systemjs build environment --- .gitlab-ci.yml | 73 +++++++++++++++++++++++++------------------------- deploy.sh | 11 +++++++- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 916c442..a3d953d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,42 +1,43 @@ -#variables: -# NPMPATH: "node_modules/.bin" - stages: -# - build -# - cleanup_build + - build + - cleanup_build - deploy -# - cleanup + - cleanup .run_deploy: &run_deploy script: - chmod +x ./deploy.sh - ./deploy.sh -#build_job: -# stage: build -# script: -# - npm install -# - $NPMPATH/bower install -# - $NPMPATH/grunt -# tags: -# - javascript -# except: -# - tags -# artifacts: -# paths: -# - dist/*.min.* -# - info/ -# - resources/ -# - index.html -# - manifest.appcache +build_job: + stage: build + script: + - npm install + tags: + - javascript + except: + - tags + artifacts: + paths: + - app/*.css + - app/*.html + - app/*.js + - app/*.js.map + - node_modules/core-js/client/shim.js + - node_modules/zone.js/dist/zone.js + - node_modules/reflect-metadata/Reflect.js + - node_modules/systemjs/dist/system.src.js + - dencode.css + - index.html + - package.json + - systemjs.config.js -#cleanup_build_job: -# stage: cleanup_build -# script: -# - rm -rf node_modules -# - rm -rf bower_components -# - rm -rf dist -# when: on_failure +cleanup_build_job: + stage: cleanup_build + script: + - rm -rf node_modules + - rm -rf typings + when: on_failure develop: stage: deploy @@ -70,9 +71,9 @@ production: ENVIRON: production TARGET: $WWW_DEPLOY_ROOT_PRODUCTION -#cleanup_job: -# stage: cleanup -# script: -# - rm -rf node_modules -# - rm -rf bower_components -# when: always +cleanup_job: + stage: cleanup + script: + - rm -rf node_modules + - rm -rf typings + when: always diff --git a/deploy.sh b/deploy.sh index ab6faf6..528f257 100644 --- a/deploy.sh +++ b/deploy.sh @@ -20,6 +20,15 @@ fi rm -rf "${destination}/*" rm -rf "${destination}/.??*" -cp -a dencode.css dencode.js index.html quoted-printable.js utf8.js "${destination}" + +cp -a dencode.css index.html package.json systemjs.config.js "${destination}" + +mkdir "${destination}/app" +cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" + +mkdir -p "${destination}/node_modules/{core-js/client,zone.js/dist,reflect-metadata,systemjs/dist}" +cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/zone.js/dist" +cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata" +cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist" echo "Deployment successful." From c3dfc5393a1a14c5aa084e91695629e889a3871b Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 21:43:03 +0200 Subject: [PATCH 10/34] run "npm run tsc" after "npm install" in order to actually compile the javascript files --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3d953d..b200abe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,7 @@ build_job: stage: build script: - npm install + - npm run tsc tags: - javascript except: From a77509e6781629d70d35a2ef82b1a42fe9f13fb4 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:06:01 +0200 Subject: [PATCH 11/34] updated typings, commented error provoking line --- app/inputarea.component.ts | 2 +- index.html | 4 ---- package.json | 1 - typings.json | 6 ++++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/inputarea.component.ts b/app/inputarea.component.ts index e413835..c07a4da 100644 --- a/app/inputarea.component.ts +++ b/app/inputarea.component.ts @@ -13,7 +13,7 @@ export class InputareaComponent { public index:number = 0; public conversions:ConversionType[] = [ConversionType.ENCODE_BASE64, ConversionType.DECODE_BASE64]; private conversion:ConversionInput; - private ConversionType:ConversionType = ConversionType; + // private ConversionType:ConversionType = ConversionType; constructor() { console.log("Aloha, " + this.index); diff --git a/index.html b/index.html index f27b6d9..5f08ba3 100644 --- a/index.html +++ b/index.html @@ -5,10 +5,6 @@ Decode? Encode? DENcode! - - - - diff --git a/package.json b/package.json index 923c954..94833bd 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "devDependencies": { "concurrently": "^2.2.0", - "gulp": "^3.9.0", "lite-server": "^2.2.0", "typescript": "^2.0.2", "typings": "^1.3.2" diff --git a/typings.json b/typings.json index 7da31ca..c43d8b7 100644 --- a/typings.json +++ b/typings.json @@ -1,7 +1,9 @@ { + "name": "dencode.org", + "dependencies": {}, "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759", + "core-js": "registry:dt/core-js#0.0.0+20160914114559", "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", - "node": "registry:dt/node#6.0.0+20160909174046" + "node": "registry:dt/node#6.0.0+20160915134512" } } From 002062ba573c72baf598996a80042856c61c532f Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:14:17 +0200 Subject: [PATCH 12/34] try to fix deploy.sh --- deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 528f257..09c27e1 100644 --- a/deploy.sh +++ b/deploy.sh @@ -23,10 +23,10 @@ rm -rf "${destination}/.??*" cp -a dencode.css index.html package.json systemjs.config.js "${destination}" -mkdir "${destination}/app" +mkdir -p "${destination}/app" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" -mkdir -p "${destination}/node_modules/{core-js/client,zone.js/dist,reflect-metadata,systemjs/dist}" +mkdir -p "${destination}/node_modules/core-js/client" "${destination}node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/zone.js/dist" cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata" cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist" From 11f098d18e260aeb9dde5d5404060bd6e66cde2c Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:22:45 +0200 Subject: [PATCH 13/34] added some debug info to deploy.sh and fixed directory creation/copying bug --- deploy.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index 09c27e1..fb6a578 100644 --- a/deploy.sh +++ b/deploy.sh @@ -18,8 +18,14 @@ if [[ ! -d "${destination}" ]] ; then mkdir -p "${destination}" || echo "Failed to create target directory for deployment!" fi +echo "Before any deletion:" +ls "${destination}" rm -rf "${destination}/*" +echo "After rm -rf dest/*:" +ls "${destination}" rm -rf "${destination}/.??*" +echo "After rm -rf dest/.??:" +ls "${destination}" cp -a dencode.css index.html package.json systemjs.config.js "${destination}" @@ -27,8 +33,9 @@ mkdir -p "${destination}/app" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" mkdir -p "${destination}/node_modules/core-js/client" "${destination}node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" -cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/zone.js/dist" -cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata" -cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist" +cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" +cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" +cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" +cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" echo "Deployment successful." From 1608a354cfe97a70a02c068bc7661a8db63e926f Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:31:08 +0200 Subject: [PATCH 14/34] hopefully added enought debug stuff to diagnose the source of the deploy error --- deploy.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/deploy.sh b/deploy.sh index fb6a578..2228e7d 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,6 +1,11 @@ #!/bin/sh -declare destination +function die() { + echo $* + exit 1 +} + +}declare destination case "${TARGET}" in "${WWW_DEPLOY_ROOT_DEVELOP}") destination="${TARGET}/${CI_BUILD_REF_NAME}" @@ -9,33 +14,32 @@ case "${TARGET}" in destination="${TARGET}" ;; *) - echo "Invalid TARGET specified. Aborting deployment." - exit 1 + die "Invalid TARGET specified. Aborting deployment." ;; esac if [[ ! -d "${destination}" ]] ; then - mkdir -p "${destination}" || echo "Failed to create target directory for deployment!" + mkdir -p "${destination}" || die "Failed to create target directory for deployment!" fi echo "Before any deletion:" ls "${destination}" -rm -rf "${destination}/*" +rm -rf "${destination}/*" || die "Failed to clean destination directory (step 1)" echo "After rm -rf dest/*:" ls "${destination}" -rm -rf "${destination}/.??*" +rm -rf "${destination}/.??*" || die "Failed to clean destination directory (step 2)" echo "After rm -rf dest/.??:" ls "${destination}" -cp -a dencode.css index.html package.json systemjs.config.js "${destination}" +cp -a dencode.css index.html package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" -mkdir -p "${destination}/app" -cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" +mkdir -p "${destination}/app" || die "Failed to create dest/app directory" +cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" -mkdir -p "${destination}/node_modules/core-js/client" "${destination}node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" -cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" -cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" -cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" -cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" +mkdir -p "${destination}/node_modules/core-js/client" "${destination}node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/* directories" +cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" || die "Failed to copy core-js" +cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js" +cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js" +cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" || die "Failed to copy system.src.js" echo "Deployment successful." From 3b0868c61eef2a97574e4a0e1b63e28f3559078f Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:35:26 +0200 Subject: [PATCH 15/34] stupid, STUPID escaping mistake. D'OH! --- deploy.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/deploy.sh b/deploy.sh index 2228e7d..3930937 100644 --- a/deploy.sh +++ b/deploy.sh @@ -5,7 +5,7 @@ function die() { exit 1 } -}declare destination +declare destination case "${TARGET}" in "${WWW_DEPLOY_ROOT_DEVELOP}") destination="${TARGET}/${CI_BUILD_REF_NAME}" @@ -22,14 +22,8 @@ if [[ ! -d "${destination}" ]] ; then mkdir -p "${destination}" || die "Failed to create target directory for deployment!" fi -echo "Before any deletion:" -ls "${destination}" -rm -rf "${destination}/*" || die "Failed to clean destination directory (step 1)" -echo "After rm -rf dest/*:" -ls "${destination}" -rm -rf "${destination}/.??*" || die "Failed to clean destination directory (step 2)" -echo "After rm -rf dest/.??:" -ls "${destination}" +rm -rf "${destination}"/* || die "Failed to clean destination directory (step 1)" +rm -rf "${destination}"/.??* || die "Failed to clean destination directory (step 2)" cp -a dencode.css index.html package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" From 7eb57eb1aedc2d972bee8916ccefadaed28424cb Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:39:48 +0200 Subject: [PATCH 16/34] okay ... probably squashed the last bug. HOPEFULLY! --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 3930937..a8662e5 100644 --- a/deploy.sh +++ b/deploy.sh @@ -30,7 +30,7 @@ cp -a dencode.css index.html package.json systemjs.config.js "${destination}" || mkdir -p "${destination}/app" || die "Failed to create dest/app directory" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" -mkdir -p "${destination}/node_modules/core-js/client" "${destination}node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/* directories" +mkdir -p "${destination}/node_modules/core-js/client" "${destination}/node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/* directories" cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" || die "Failed to copy core-js" cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js" cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js" From 992a07d93a239bf0df6a5866e2ffaea62af5a82d Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 22:47:14 +0200 Subject: [PATCH 17/34] copy all @angular resources --- deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index a8662e5..aa21a60 100644 --- a/deploy.sh +++ b/deploy.sh @@ -30,7 +30,8 @@ cp -a dencode.css index.html package.json systemjs.config.js "${destination}" || mkdir -p "${destination}/app" || die "Failed to create dest/app directory" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" -mkdir -p "${destination}/node_modules/core-js/client" "${destination}/node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/* directories" +mkdir -p "${destination}/node_modules/@angular" "${destination}/node_modules/core-js/client" "${destination}/node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/* directories" +cp -a node_modules/@angular/* "${destination}/node_modules/@angular/" || die "Failed to copy @angular" cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" || die "Failed to copy core-js" cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js" cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js" From e9697aa88b9e80944c85eb854603580202669fce Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 23:35:55 +0200 Subject: [PATCH 18/34] split creation of dirs and copying of resources into single steps for easier debugging --- deploy.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index aa21a60..9eb3dd9 100644 --- a/deploy.sh +++ b/deploy.sh @@ -30,11 +30,15 @@ cp -a dencode.css index.html package.json systemjs.config.js "${destination}" || mkdir -p "${destination}/app" || die "Failed to create dest/app directory" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" -mkdir -p "${destination}/node_modules/@angular" "${destination}/node_modules/core-js/client" "${destination}/node_modules/zone.js/dist" "${destination}/node_modules/reflect-metadata" "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/* directories" +mkdir -p "${destination}/node_modules/@angular" || die "Failed to create dest/node_modules/@angular" cp -a node_modules/@angular/* "${destination}/node_modules/@angular/" || die "Failed to copy @angular" +mkdir -p "${destination}/node_modules/core-js/client" || die "Failed to create dest/node_modules/core-js" cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" || die "Failed to copy core-js" +mkdir -p "${destination}/node_modules/zone.js/dist" || die "Failed to create dest/node_modules/zone.js" cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js" +mkdir -p "${destination}/node_modules/reflect-metadata" || die "Failed to create dest/node_modules/reflect-metadata" cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js" +mkdir -p "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/systemjs" cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" || die "Failed to copy system.src.js" echo "Deployment successful." From 8acddfe548d7ed5c74b57e20f37587b53d86c867 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 15 Sep 2016 23:40:44 +0200 Subject: [PATCH 19/34] don't cleanup: this should enable me to spot the bug. --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b200abe..ea41a5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: - build - cleanup_build - deploy - - cleanup +# - cleanup .run_deploy: &run_deploy script: @@ -72,9 +72,9 @@ production: ENVIRON: production TARGET: $WWW_DEPLOY_ROOT_PRODUCTION -cleanup_job: - stage: cleanup - script: - - rm -rf node_modules - - rm -rf typings - when: always +#cleanup_job: +# stage: cleanup +# script: +# - rm -rf node_modules +# - rm -rf typings +# when: always From 4197bca2996135a225fd351d1c8c72d84479a7af Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 20 Sep 2016 20:30:39 +0200 Subject: [PATCH 20/34] First usable version based on AngularJS 2! Almost no converters yet, though. --- .gitignore | 1 + app/InputcomponentmanagerService.ts | 41 +++++++++++++++++++ app/app.component.html | 10 ++++- app/app.component.ts | 53 +++++++++++++++++++----- app/app.module.ts | 9 ++-- app/{ => converter}/base64decoder.ts | 2 +- app/{ => converter}/base64encoder.ts | 2 +- app/{ => converter}/converter.ts | 0 app/converterregistry.service.ts | 11 +++-- app/inputarea.component.html | 23 +++++++---- app/inputarea.component.ts | 61 ++++++++++++++-------------- app/main.ts | 1 - dencode.css | 7 ++++ 13 files changed, 155 insertions(+), 66 deletions(-) create mode 100644 app/InputcomponentmanagerService.ts rename app/{ => converter}/base64decoder.ts (86%) rename app/{ => converter}/base64encoder.ts (86%) rename app/{ => converter}/converter.ts (100%) diff --git a/.gitignore b/.gitignore index a74b159..7404c57 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules/ typings/ app/**/*.js app/**/*.js.map +npm-debug.log diff --git a/app/InputcomponentmanagerService.ts b/app/InputcomponentmanagerService.ts new file mode 100644 index 0000000..a1717b8 --- /dev/null +++ b/app/InputcomponentmanagerService.ts @@ -0,0 +1,41 @@ +import {Injectable} from "@angular/core"; +@Injectable() +export class InputcomponentmanagerService { + private components:any[] = []; + + public constructor() { + } + + public register(component:any):void { + this.components.push(component); + } + + public getAllComponents():any[] { + return this.components; + } + + public getNext(component:any):any { + let index:number = component.index; + if (index == this.components.length - 1) { + this.addComponent(); + } + return this.components[index + 1]; + } + + public getFirst():any { + if (this.components.length == 0) { + this.addComponent(); + } + return this.components[0]; + } + + private addComponent():void { + this.register({ + content: "", + selectedConverter: undefined, + index: this.components.length, + error: false, + message: "" + }); + } +} \ No newline at end of file diff --git a/app/app.component.html b/app/app.component.html index 47161cb..13f8984 100644 --- a/app/app.component.html +++ b/app/app.component.html @@ -1,3 +1,9 @@ -
- +
+ + +
{{step.message}}
diff --git a/app/app.component.ts b/app/app.component.ts index dc913bf..2c8f5a1 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,26 +1,57 @@ -import {Component} from "@angular/core"; -import {OnInit}from "@angular/core"; - +import {Component, OnInit} from "@angular/core"; import {ConverterregistryService} from "./converterregistry.service"; -import {Converter} from "./converter"; +import {InputcomponentmanagerService} from "./InputcomponentmanagerService"; +import {Converter} from "./converter/converter"; @Component({ moduleId: module.id, selector: "den-app", templateUrl: "app.component.html", styleUrls: ["app.component.css"], - providers: [ConverterregistryService] + providers: [ConverterregistryService, InputcomponentmanagerService] }) export class AppComponent extends OnInit { - constructor(private converterregistryService:ConverterregistryService) { + public steps:any[] = []; + public converters:Converter[] = []; + + constructor(private converterregistryService:ConverterregistryService, private inputcomponentmanagerService:InputcomponentmanagerService) { super(); } - ngOnInit():void { - let converters:Converter[] = this.converterregistryService.getConverters(); - console.log("Number of registered converters: " + converters.length); - for (let i = 0; i < converters.length; i++) { - console.log("Converter " + converters[i].getId() + ": " + converters[i].getDisplayname()); + convert(step:any, $event:any):void { + step.selectedConverter = this.converterregistryService.getConverter($event.target.selectedOptions[0].id); + this.update(step); + } + + update(step:any):void { + let converter:Converter = step.selectedConverter; + + if (converter !== undefined) { + let content:string = step.content; + let result:string; + try { + result = converter.convert(content); + } catch (error) { + result = null; + } + if (result === null) { + step.message = "Error converting. Not applicable?"; + step.error = true; + } else { + step.message = ""; + step.error = false; + if (result !== "") { + let nextComponent:any = this.inputcomponentmanagerService.getNext(step); + nextComponent.content = result; + this.update(nextComponent); + } + } } } + + ngOnInit():void { + this.converters = this.converterregistryService.getAllConverters(); + this.steps = this.inputcomponentmanagerService.getAllComponents(); + this.inputcomponentmanagerService.getFirst(); + } } diff --git a/app/app.module.ts b/app/app.module.ts index 4cf0a38..8988169 100644 --- a/app/app.module.ts +++ b/app/app.module.ts @@ -1,8 +1,7 @@ -import {NgModule} from '@angular/core' -import {BrowserModule} from '@angular/platform-browser' -import {FormsModule} from '@angular/forms' - -import {AppComponent} from './app.component' +import {NgModule} from "@angular/core"; +import {BrowserModule} from "@angular/platform-browser"; +import {FormsModule} from "@angular/forms"; +import {AppComponent} from "./app.component"; import {InputareaComponent} from "./inputarea.component"; @NgModule({ diff --git a/app/base64decoder.ts b/app/converter/base64decoder.ts similarity index 86% rename from app/base64decoder.ts rename to app/converter/base64decoder.ts index eba3379..1b4e5b1 100644 --- a/app/base64decoder.ts +++ b/app/converter/base64decoder.ts @@ -1,4 +1,4 @@ -import {Converter} from './converter'; +import {Converter} from "./converter"; export class Base64Decoder implements Converter { getDisplayname():string { diff --git a/app/base64encoder.ts b/app/converter/base64encoder.ts similarity index 86% rename from app/base64encoder.ts rename to app/converter/base64encoder.ts index bb9de8f..409636d 100644 --- a/app/base64encoder.ts +++ b/app/converter/base64encoder.ts @@ -1,4 +1,4 @@ -import {Converter} from './converter'; +import {Converter} from "./converter"; export class Base64Encoder implements Converter { getDisplayname():string { diff --git a/app/converter.ts b/app/converter/converter.ts similarity index 100% rename from app/converter.ts rename to app/converter/converter.ts diff --git a/app/converterregistry.service.ts b/app/converterregistry.service.ts index 44ad46d..8bd7f7f 100644 --- a/app/converterregistry.service.ts +++ b/app/converterregistry.service.ts @@ -1,8 +1,7 @@ -import {Injectable} from '@angular/core'; - -import {Converter} from './converter'; -import {Base64Encoder} from "./base64encoder"; -import {Base64Decoder} from "./base64decoder"; +import {Injectable} from "@angular/core"; +import {Converter} from "./converter/converter"; +import {Base64Encoder} from "./converter/base64encoder"; +import {Base64Decoder} from "./converter/base64decoder"; @Injectable() export class ConverterregistryService { @@ -12,7 +11,7 @@ export class ConverterregistryService { this.init(); } - public getConverters():Converter[] { + public getAllConverters():Converter[] { return this.converters; } diff --git a/app/inputarea.component.html b/app/inputarea.component.html index da0a65a..d8e65ee 100644 --- a/app/inputarea.component.html +++ b/app/inputarea.component.html @@ -1,8 +1,15 @@ -
- - -
+ + + + + + + + + + + diff --git a/app/inputarea.component.ts b/app/inputarea.component.ts index c07a4da..d3a3e1e 100644 --- a/app/inputarea.component.ts +++ b/app/inputarea.component.ts @@ -1,6 +1,7 @@ -import {Component} from "@angular/core"; -import {ConversionInput} from "./conversioninput"; -import {ConversionType} from "./conversiontype"; +import {Component, OnInit} from "@angular/core"; +import {ConverterregistryService} from "./converterregistry.service"; +import {Converter} from "./converter/converter"; +import {InputcomponentmanagerService} from "./InputcomponentmanagerService"; @Component({ @@ -9,40 +10,38 @@ import {ConversionType} from "./conversiontype"; templateUrl: "inputarea.component.html", styleUrls: ["inputarea.component.css"] }) -export class InputareaComponent { - public index:number = 0; - public conversions:ConversionType[] = [ConversionType.ENCODE_BASE64, ConversionType.DECODE_BASE64]; - private conversion:ConversionInput; - // private ConversionType:ConversionType = ConversionType; +export class InputareaComponent extends OnInit { + public converters:Converter[] = []; + public content:string = ''; + private selectedConverter:Converter; - constructor() { - console.log("Aloha, " + this.index); - this.conversion = new ConversionInput(); - this.conversion.content = ""; - this.conversion.type = ConversionType.DECODE_BASE64; - } - - public update():void { - console.log(this.conversion.content); + constructor(private converterregistryService:ConverterregistryService, private inputcomponentmanagerService:InputcomponentmanagerService) { + super(); } public convert(e):void { - this.conversion.type = ConversionType.of(+e.target.selectedOptions[0].id); - console.log(this.conversion.type); - switch (this.conversion.type) { - case ConversionType.DECODE_BASE64: - this.conversion.content = "Base64 decode"; - break; - case ConversionType.ENCODE_BASE64: - this.conversion.content = "Base64 encode"; - break; - default: - this.conversion.content = "Unknown: " + this.conversion.type; - break; + this.selectedConverter = this.converterregistryService.getConverter(e.target.selectedOptions[0].id); + this.update(); + } + + public update():void { + if (this.selectedConverter !== undefined) { + let result:string = this.selectedConverter.convert(this.content); + let nextComponent:InputareaComponent = this.inputcomponentmanagerService.getNext(this); + if (nextComponent !== undefined) { + nextComponent.setContent(result); + } } } - public setIndex(index:number):void { - this.index = index; + public setContent(content:string):void { + this.content = content; + this.update(); + } + + ngOnInit():void { + this.converters = this.converterregistryService.getAllConverters(); + this.selectedConverter = undefined; + this.inputcomponentmanagerService.register(this); } } diff --git a/app/main.ts b/app/main.ts index 244ca48..c31c26f 100644 --- a/app/main.ts +++ b/app/main.ts @@ -1,5 +1,4 @@ import {platformBrowserDynamic} from "@angular/platform-browser-dynamic"; - import {AppModule} from "./app.module"; platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/dencode.css b/dencode.css index 8fadfda..261f217 100644 --- a/dencode.css +++ b/dencode.css @@ -59,6 +59,13 @@ div.wrapper { padding: 0.5em; } +div.wrapper div.message { + display: inline-block; + color: #f00; + background-color: #fff; + border: 1px solid #f00; +} + textarea.input { border-style: solid; border-width: 1px; From 5a1ca42f0d699df9cf8371a014fe4a7427b09ef0 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 20 Sep 2016 20:45:04 +0200 Subject: [PATCH 21/34] added URI{Component,}{De,En}coder --- app/converter/uricomponentdecoder.ts | 15 +++++ app/converter/uricomponentencoder.ts | 17 ++++++ app/converter/uridecoder.ts | 15 +++++ app/converter/uriencoder.ts | 15 +++++ app/converterregistry.service.ts | 8 +++ dencode.js | 83 ---------------------------- 6 files changed, 70 insertions(+), 83 deletions(-) create mode 100644 app/converter/uricomponentdecoder.ts create mode 100644 app/converter/uricomponentencoder.ts create mode 100644 app/converter/uridecoder.ts create mode 100644 app/converter/uriencoder.ts diff --git a/app/converter/uricomponentdecoder.ts b/app/converter/uricomponentdecoder.ts new file mode 100644 index 0000000..ee96e28 --- /dev/null +++ b/app/converter/uricomponentdecoder.ts @@ -0,0 +1,15 @@ +import {Converter} from "./converter"; + +export class URIComponentDecoder implements Converter { + getDisplayname():string { + return "Decode URI component"; + } + + getId():string { + return "uricomponentdecode"; + } + + convert(input:string):string { + return decodeURIComponent(input); + } +} diff --git a/app/converter/uricomponentencoder.ts b/app/converter/uricomponentencoder.ts new file mode 100644 index 0000000..b4fb478 --- /dev/null +++ b/app/converter/uricomponentencoder.ts @@ -0,0 +1,17 @@ +import {Converter} from "./converter"; + +export class URIComponentEncoder implements Converter { + getDisplayname():string { + return "Encode URI component"; + } + + getId():string { + return "uricomponentencode"; + } + + convert(input:string):string { + return encodeURIComponent(input).replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16); + }); + } +} diff --git a/app/converter/uridecoder.ts b/app/converter/uridecoder.ts new file mode 100644 index 0000000..1949940 --- /dev/null +++ b/app/converter/uridecoder.ts @@ -0,0 +1,15 @@ +import {Converter} from "./converter"; + +export class URIDecoder implements Converter { + getDisplayname():string { + return "Decode URI"; + } + + getId():string { + return "uridecode"; + } + + convert(input:string):string { + return decodeURI(input); + } +} diff --git a/app/converter/uriencoder.ts b/app/converter/uriencoder.ts new file mode 100644 index 0000000..b56c747 --- /dev/null +++ b/app/converter/uriencoder.ts @@ -0,0 +1,15 @@ +import {Converter} from "./converter"; + +export class URIEncoder implements Converter { + getDisplayname():string { + return "Encode URI"; + } + + getId():string { + return "uriencode"; + } + + convert(input:string):string { + return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']'); + } +} diff --git a/app/converterregistry.service.ts b/app/converterregistry.service.ts index 8bd7f7f..7b89416 100644 --- a/app/converterregistry.service.ts +++ b/app/converterregistry.service.ts @@ -2,6 +2,10 @@ import {Injectable} from "@angular/core"; import {Converter} from "./converter/converter"; import {Base64Encoder} from "./converter/base64encoder"; import {Base64Decoder} from "./converter/base64decoder"; +import {URIEncoder} from "./converter/uriencoder"; +import {URIDecoder} from "./converter/uridecoder"; +import {URIComponentEncoder} from "./converter/uricomponentencoder"; +import {URIComponentDecoder} from "./converter/uricomponentdecoder"; @Injectable() export class ConverterregistryService { @@ -27,6 +31,10 @@ export class ConverterregistryService { private init():void { this.registerConverter(new Base64Encoder()); this.registerConverter(new Base64Decoder()); + this.registerConverter(new URIEncoder()); + this.registerConverter(new URIDecoder()); + this.registerConverter(new URIComponentEncoder()); + this.registerConverter(new URIComponentDecoder()); } private registerConverter(converter:Converter):void { diff --git a/dencode.js b/dencode.js index a076423..7c73642 100644 --- a/dencode.js +++ b/dencode.js @@ -10,57 +10,6 @@ }; } }, - { - "id": "base64decode", - "name": "Decode Base64", - "convert": function (input) { - try { - return { - "status": "OK", - "content": atob(input) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid base64 input string." - }; - } - } - }, - { - "id": "decodeuri", - "name": "Decode URI", - "convert": function (input) { - try { - return { - "status": "OK", - "content": decodeURI(input) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid URI input string." - }; - } - } - }, - { - "id": "decodeuricomponent", - "name": "Decode URI component", - "convert": function (input) { - try { - return { - "status": "OK", - "content": decodeURIComponent(input) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid URI component input string." - }; - } - } - }, { "id": "decodehtmlentities", "name": "Decode HTML entities", @@ -133,38 +82,6 @@ } } }, - { - "id": "base64encode", - "name": "Encode Base64", - "convert": function (input) { - return { - "status": "OK", - "content": btoa(input) - }; - } - }, - { - "id": "encodeuri", - "name": "Encode URI", - "convert": function (input) { - return { - "status": "OK", - "content": encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']') - }; - } - }, - { - "id": "encodeuricomponent", - "name": "Encode URI component", - "convert": function (input) { - return { - "status": "OK", - "content": encodeURIComponent(input).replace(/[!'()*]/g, function(c) { - return '%' + c.charCodeAt(0).toString(16); - }) - }; - } - }, { "id": "encodehtmlentities", "name": "Encode HTML entities", From 01df7ac29c8af23cf1e74650c14294074d46e0ec Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 20 Sep 2016 21:12:13 +0200 Subject: [PATCH 22/34] added 6 more converters: - dec <-> bin - dec <-> hex - htmlentities de- and encode --- app/converter/bintodecconverter.ts | 14 ++++ app/converter/dectobinconverter.ts | 14 ++++ app/converter/dectohexconverter.ts | 14 ++++ app/converter/hextodecconverter.ts | 14 ++++ app/converter/htmlentitiesdecoder.ts | 19 +++++ app/converter/htmlentitiesencoder.ts | 19 +++++ app/converterregistry.service.ts | 12 ++++ dencode.js | 103 --------------------------- 8 files changed, 106 insertions(+), 103 deletions(-) create mode 100644 app/converter/bintodecconverter.ts create mode 100644 app/converter/dectobinconverter.ts create mode 100644 app/converter/dectohexconverter.ts create mode 100644 app/converter/hextodecconverter.ts create mode 100644 app/converter/htmlentitiesdecoder.ts create mode 100644 app/converter/htmlentitiesencoder.ts diff --git a/app/converter/bintodecconverter.ts b/app/converter/bintodecconverter.ts new file mode 100644 index 0000000..2c73959 --- /dev/null +++ b/app/converter/bintodecconverter.ts @@ -0,0 +1,14 @@ +import {Converter} from "./converter"; +export class BinToDecConverter implements Converter { + getDisplayname():string { + return "Convert binary to decimal"; + } + + getId():string { + return "bintodec"; + } + + convert(input:string):string { + return parseInt(input, 2).toString(10); + } +} diff --git a/app/converter/dectobinconverter.ts b/app/converter/dectobinconverter.ts new file mode 100644 index 0000000..8cc2b0d --- /dev/null +++ b/app/converter/dectobinconverter.ts @@ -0,0 +1,14 @@ +import {Converter} from "./converter"; +export class DecToBinConverter implements Converter { + getDisplayname():string { + return "Convert decimal to binary"; + } + + getId():string { + return "dectobin"; + } + + convert(input:string):string { + return parseInt(input, 10).toString(2); + } +} diff --git a/app/converter/dectohexconverter.ts b/app/converter/dectohexconverter.ts new file mode 100644 index 0000000..c0be47f --- /dev/null +++ b/app/converter/dectohexconverter.ts @@ -0,0 +1,14 @@ +import {Converter} from "./converter"; +export class DecToHexConverter implements Converter { + getDisplayname():string { + return "Convert decimal to heximal"; + } + + getId():string { + return "dectohex"; + } + + convert(input:string):string { + return parseInt(input, 10).toString(16); + } +} diff --git a/app/converter/hextodecconverter.ts b/app/converter/hextodecconverter.ts new file mode 100644 index 0000000..c6b3dba --- /dev/null +++ b/app/converter/hextodecconverter.ts @@ -0,0 +1,14 @@ +import {Converter} from "./converter"; +export class HexToDecConverter implements Converter { + getDisplayname():string { + return "Convert heximal to decimal"; + } + + getId():string { + return "hextodec"; + } + + convert(input:string):string { + return parseInt(input, 16).toString(10); + } +} diff --git a/app/converter/htmlentitiesdecoder.ts b/app/converter/htmlentitiesdecoder.ts new file mode 100644 index 0000000..2a793ce --- /dev/null +++ b/app/converter/htmlentitiesdecoder.ts @@ -0,0 +1,19 @@ +import {Converter} from "./converter"; + +export class HTMLEntitiesDecoder implements Converter { + getDisplayname():string { + return "Decode HTML entities"; + } + + getId():string { + return "decodehtmlentities"; + } + + convert(input:string):string { + return input + .replace(/\"\;/g, "\"") + .replace(/\>\;/g, ">") + .replace(/\<\;/g, "<") + .replace(/\&\;/g, "&"); + } +} diff --git a/app/converter/htmlentitiesencoder.ts b/app/converter/htmlentitiesencoder.ts new file mode 100644 index 0000000..cf626b6 --- /dev/null +++ b/app/converter/htmlentitiesencoder.ts @@ -0,0 +1,19 @@ +import {Converter} from "./converter"; + +export class HTMLEntitiesEncoder implements Converter { + getDisplayname():string { + return "Encode HTML entities"; + } + + getId():string { + return "encodehtmlentities"; + } + + convert(input:string):string { + return input + .replace(/\&/g, "&") + .replace(/\/g, ">") + .replace(/\"/g, """); + } +} diff --git a/app/converterregistry.service.ts b/app/converterregistry.service.ts index 7b89416..d1212b3 100644 --- a/app/converterregistry.service.ts +++ b/app/converterregistry.service.ts @@ -6,6 +6,12 @@ import {URIEncoder} from "./converter/uriencoder"; import {URIDecoder} from "./converter/uridecoder"; import {URIComponentEncoder} from "./converter/uricomponentencoder"; import {URIComponentDecoder} from "./converter/uricomponentdecoder"; +import {HTMLEntitiesEncoder} from "./converter/htmlentitiesencoder"; +import {HTMLEntitiesDecoder} from "./converter/htmlentitiesdecoder"; +import {DecToHexConverter} from "./converter/dectohexconverter"; +import {HexToDecConverter} from "./converter/hextodecconverter"; +import {DecToBinConverter} from "./converter/dectobinconverter"; +import {BinToDecConverter} from "./converter/bintodecconverter"; @Injectable() export class ConverterregistryService { @@ -35,6 +41,12 @@ export class ConverterregistryService { this.registerConverter(new URIDecoder()); this.registerConverter(new URIComponentEncoder()); this.registerConverter(new URIComponentDecoder()); + this.registerConverter(new HTMLEntitiesEncoder()); + this.registerConverter(new HTMLEntitiesDecoder()); + this.registerConverter(new DecToHexConverter()); + this.registerConverter(new HexToDecConverter()); + this.registerConverter(new DecToBinConverter()); + this.registerConverter(new BinToDecConverter()); } private registerConverter(converter:Converter):void { diff --git a/dencode.js b/dencode.js index 7c73642..73607b3 100644 --- a/dencode.js +++ b/dencode.js @@ -10,27 +10,6 @@ }; } }, - { - "id": "decodehtmlentities", - "name": "Decode HTML entities", - "convert": function (input) { - try { - return { - "status": "OK", - "content": input - .replace(/\"\;/g, "\"") - .replace(/\>\;/g, ">") - .replace(/\<\;/g, "<") - .replace(/\&\;/g, "&") - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid HTML entity string." - }; - } - } - }, { "id": "decodequotedprintable", "name": "Decode quoted printable", @@ -48,54 +27,6 @@ } } }, - { - "id": "hextodec", - "name": "Decode hex as decimal", - "convert": function (input) { - try { - return { - "status": "OK", - "content": parseInt(input, 16).toString(10) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid number (integer) string." - }; - } - } - }, - { - "id": "bintodec", - "name": "Decode binary as decimal", - "convert": function (input) { - try { - return { - "status": "OK", - "content": parseInt(input, 2).toString(10) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid number (integer) string." - }; - } - } - }, - { - "id": "encodehtmlentities", - "name": "Encode HTML entities", - "convert": function (input) { - return { - "status": "OK", - "content": input - .replace(/\&/g, "&") - .replace(/\/g, ">") - .replace(/\"/g, """) - }; - } - }, { "id": "encodequotedprintable", "name": "Encode quoted printable", @@ -105,40 +36,6 @@ "content": quotedPrintable.encode(utf8.encode(input)) }; } - }, - { - "id": "dectohex", - "name": "Encode decimal as hex", - "convert": function (input) { - try { - return { - "status": "OK", - "content": parseInt(input).toString(16) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid number (integer) string." - }; - } - } - }, - { - "id": "dectobin", - "name": "Encode decimal as binary", - "convert": function (input) { - try { - return { - "status": "OK", - "content": parseInt(input).toString(2) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid number (integer) string." - }; - } - } } ]; From 02735ff4a17563a40a57d64eb136f9dbcc88633d Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 20 Sep 2016 22:02:38 +0200 Subject: [PATCH 23/34] added QuotedPrintable{De,En}coder. --- app/app.component.ts | 3 ++ app/converter/quotedprintabledecoder.ts | 42 +++++++++++++++++++++++++ app/converter/quotedprintableencoder.ts | 18 +++++++++++ app/converterregistry.service.ts | 4 +++ dencode.js | 27 ---------------- index.html | 2 ++ package.json | 4 ++- 7 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 app/converter/quotedprintabledecoder.ts create mode 100644 app/converter/quotedprintableencoder.ts diff --git a/app/app.component.ts b/app/app.component.ts index 2c8f5a1..7cde15f 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -32,6 +32,9 @@ export class AppComponent extends OnInit { try { result = converter.convert(content); } catch (error) { + if (typeof console === "object" && typeof console.log === "function") { + console.log(error); + } result = null; } if (result === null) { diff --git a/app/converter/quotedprintabledecoder.ts b/app/converter/quotedprintabledecoder.ts new file mode 100644 index 0000000..834b048 --- /dev/null +++ b/app/converter/quotedprintabledecoder.ts @@ -0,0 +1,42 @@ +import {Converter} from "./converter"; + +declare var window:any; + +export class QuotedPrintableDecoder implements Converter { + + private utf8:any = window.utf8; + private quotedPrintable:any = window.quotedPrintable; + + getDisplayname():string { + return "Decode quoted printable"; + } + + getId():string { + return "decodequotedprintable"; + } + + convert(input:string):string { + return this.utf8.decode(this.quotedPrintable.decode(input)); + } +} + +/* + { + "id": "decodequotedprintable", + "name": "Decode quoted printable", + "convert": function (input) { + try { + return { + "status": "OK", + "content": utf8.decode(quotedPrintable.decode(input)) + }; + } catch (exception) { + return { + "status": "ERROR", + "content": "Invalid quoted printable string." + }; + } + } + }, + + */ \ No newline at end of file diff --git a/app/converter/quotedprintableencoder.ts b/app/converter/quotedprintableencoder.ts new file mode 100644 index 0000000..9276161 --- /dev/null +++ b/app/converter/quotedprintableencoder.ts @@ -0,0 +1,18 @@ +import {Converter} from "./converter"; + +declare var window:any; + +export class QuotedPrintableEncoder implements Converter { + + getDisplayname():string { + return "Encode quoted printable"; + } + + getId():string { + return "encodequotedprintable"; + } + + convert(input:string):string { + return window.quotedPrintable.encode(window.utf8.encode(input)); + } +} diff --git a/app/converterregistry.service.ts b/app/converterregistry.service.ts index d1212b3..a3fa684 100644 --- a/app/converterregistry.service.ts +++ b/app/converterregistry.service.ts @@ -12,6 +12,8 @@ import {DecToHexConverter} from "./converter/dectohexconverter"; import {HexToDecConverter} from "./converter/hextodecconverter"; import {DecToBinConverter} from "./converter/dectobinconverter"; import {BinToDecConverter} from "./converter/bintodecconverter"; +import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder"; +import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder"; @Injectable() export class ConverterregistryService { @@ -47,6 +49,8 @@ export class ConverterregistryService { this.registerConverter(new HexToDecConverter()); this.registerConverter(new DecToBinConverter()); this.registerConverter(new BinToDecConverter()); + this.registerConverter(new QuotedPrintableEncoder()); + this.registerConverter(new QuotedPrintableDecoder()); } private registerConverter(converter:Converter):void { diff --git a/dencode.js b/dencode.js index 73607b3..2cce239 100644 --- a/dencode.js +++ b/dencode.js @@ -9,33 +9,6 @@ "content": "" }; } - }, - { - "id": "decodequotedprintable", - "name": "Decode quoted printable", - "convert": function (input) { - try { - return { - "status": "OK", - "content": utf8.decode(quotedPrintable.decode(input)) - }; - } catch (exception) { - return { - "status": "ERROR", - "content": "Invalid quoted printable string." - }; - } - } - }, - { - "id": "encodequotedprintable", - "name": "Encode quoted printable", - "convert": function (input) { - return { - "status": "OK", - "content": quotedPrintable.encode(utf8.encode(input)) - }; - } } ]; diff --git a/index.html b/index.html index 5f08ba3..3ecebde 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,8 @@ + + @@ -18,6 +17,29 @@ console.log(err); }); +

Decode? Encode? DENcode!

From 0944cdb9990323f084eb1958d0f4bb2bc1a99353 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 21 Sep 2016 02:06:18 +0200 Subject: [PATCH 29/34] Update deploy.sh --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 9eb3dd9..105c351 100644 --- a/deploy.sh +++ b/deploy.sh @@ -25,7 +25,7 @@ fi rm -rf "${destination}"/* || die "Failed to clean destination directory (step 1)" rm -rf "${destination}"/.??* || die "Failed to clean destination directory (step 2)" -cp -a dencode.css index.html package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" +cp -a index.html package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" mkdir -p "${destination}/app" || die "Failed to create dest/app directory" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" From c9c1e09a97c78e976572cef08f5e4bbaf34c3001 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 21 Sep 2016 02:31:42 +0200 Subject: [PATCH 30/34] will it deploy with this configuration? --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8489cf7..e26a095 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,8 @@ stages: script: - chmod +x ./deploy.sh - ./deploy.sh + dependencies: + - build_job build_job: stage: build @@ -26,6 +28,7 @@ build_job: - app/*.js.map - app/converter/*.js - app/converter/*.js.map + - node_modules/@angular/** - node_modules/core-js/client/shim.js - node_modules/zone.js/dist/zone.js - node_modules/reflect-metadata/Reflect.js @@ -40,6 +43,7 @@ build_job: - index.html - package.json - systemjs.config.js + expire_in: 30 min cleanup_build_job: stage: cleanup_build From eb5af06ffc2e6a0b5d6c1dd74be3b8a6c11a563f Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 21 Sep 2016 02:40:05 +0200 Subject: [PATCH 31/34] hmm, is the syntax now correct? --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e26a095..8e3f441 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ build_job: - app/*.js.map - app/converter/*.js - app/converter/*.js.map - - node_modules/@angular/** + - node_modules/@angular/ - node_modules/core-js/client/shim.js - node_modules/zone.js/dist/zone.js - node_modules/reflect-metadata/Reflect.js From 8b1455169eadf4cc2d48652b8b5cdb4fd3036ddd Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 21 Sep 2016 02:51:41 +0200 Subject: [PATCH 32/34] added more resources --- .gitlab-ci.yml | 1 + deploy.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e3f441..faf8a09 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,7 @@ build_job: - node_modules/core-js/client/shim.js - node_modules/zone.js/dist/zone.js - node_modules/reflect-metadata/Reflect.js + - node_modules/rxjs/ - node_modules/systemjs/dist/system.src.js - node_modules/utf8/utf8.js - node_modules/quoted-printable/quoted-printable.js diff --git a/deploy.sh b/deploy.sh index 105c351..5052c17 100644 --- a/deploy.sh +++ b/deploy.sh @@ -38,6 +38,8 @@ mkdir -p "${destination}/node_modules/zone.js/dist" || die "Failed to create des cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js" mkdir -p "${destination}/node_modules/reflect-metadata" || die "Failed to create dest/node_modules/reflect-metadata" cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js" +mkdir -p "${destination}/node_modules/rxjs" || die "Failed to create dest/node_modules/rxjs" +cp -a node_modules/rxjs/* "${destination}/node_modules/rxjs/" || die "Failed to copy rxjs" mkdir -p "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/systemjs" cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" || die "Failed to copy system.src.js" From cb21aafcb530826ef6ef63ecf5cac2fd47219a82 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 21 Sep 2016 02:58:11 +0200 Subject: [PATCH 33/34] also deploy converter files --- deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 5052c17..f2b19b8 100644 --- a/deploy.sh +++ b/deploy.sh @@ -27,8 +27,9 @@ rm -rf "${destination}"/.??* || die "Failed to clean destination directory (step cp -a index.html package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" -mkdir -p "${destination}/app" || die "Failed to create dest/app directory" +mkdir -p "${destination}/app/converter" || die "Failed to create dest/app/converter directory" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" +cp -a app/converter/*.js app/converter/*.js.map "${destination}/app/converter" || die "Failed to copy resources to dest/app/converter" mkdir -p "${destination}/node_modules/@angular" || die "Failed to create dest/node_modules/@angular" cp -a node_modules/@angular/* "${destination}/node_modules/@angular/" || die "Failed to copy @angular" From a0bc772bf8050d81f7d3bd4ee727673b659c33bb Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 21 Sep 2016 03:04:58 +0200 Subject: [PATCH 34/34] added fonts and js libraries --- deploy.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index f2b19b8..06374f3 100644 --- a/deploy.sh +++ b/deploy.sh @@ -25,7 +25,7 @@ fi rm -rf "${destination}"/* || die "Failed to clean destination directory (step 1)" rm -rf "${destination}"/.??* || die "Failed to clean destination directory (step 2)" -cp -a index.html package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" +cp -a index.html abeezee-regular.woff freemono.* package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/" mkdir -p "${destination}/app/converter" || die "Failed to create dest/app/converter directory" cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app" @@ -33,15 +33,26 @@ cp -a app/converter/*.js app/converter/*.js.map "${destination}/app/converter" | mkdir -p "${destination}/node_modules/@angular" || die "Failed to create dest/node_modules/@angular" cp -a node_modules/@angular/* "${destination}/node_modules/@angular/" || die "Failed to copy @angular" + mkdir -p "${destination}/node_modules/core-js/client" || die "Failed to create dest/node_modules/core-js" cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" || die "Failed to copy core-js" + mkdir -p "${destination}/node_modules/zone.js/dist" || die "Failed to create dest/node_modules/zone.js" cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js" + mkdir -p "${destination}/node_modules/reflect-metadata" || die "Failed to create dest/node_modules/reflect-metadata" cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js" + mkdir -p "${destination}/node_modules/rxjs" || die "Failed to create dest/node_modules/rxjs" cp -a node_modules/rxjs/* "${destination}/node_modules/rxjs/" || die "Failed to copy rxjs" + mkdir -p "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/systemjs" cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" || die "Failed to copy system.src.js" +mkdir -p "${destination}/node_modules/utf8" || die "Failed to create dest/node_modules/utf8" +cp -a node_modules/utf8/utf8.js "${destination}/node_modules/utf8/" || die "Failed to copy utf8.js" + +mkdir -p "${destination}/node_modules/quoted-printable" || die "Failed to create dest/node_modules/quoted-printable" +cp -a node_modules/quoted-printable/quoted-printable.js "${destination}/node_modules/quoted-printable/" || die "Failed to copy quoted-printable.js" + echo "Deployment successful."