├── .angular.json ├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── e2e ├── app.e2e-spec.ts ├── app.po.ts └── tsconfig.e2e.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── protractor.conf.js ├── src ├── app │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── components │ │ ├── content.component.spec.ts │ │ └── content.component.ts │ ├── model │ │ └── content.model.ts │ ├── services │ │ └── content.service.ts │ └── views │ │ ├── content.component.css │ │ └── content.component.html ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── typings.d.ts ├── tsconfig.json └── tslint.json /.angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "algos-ngular": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/algos-ngular", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css" 27 | ], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "fileReplacements": [ 33 | { 34 | "replace": "src/environments/environment.ts", 35 | "with": "src/environments/environment.prod.ts" 36 | } 37 | ], 38 | "optimization": true, 39 | "outputHashing": "all", 40 | "sourceMap": false, 41 | "extractCss": true, 42 | "namedChunks": false, 43 | "aot": true, 44 | "extractLicenses": true, 45 | "vendorChunk": false, 46 | "buildOptimizer": true 47 | } 48 | } 49 | }, 50 | "serve": { 51 | "builder": "@angular-devkit/build-angular:dev-server", 52 | "options": { 53 | "browserTarget": "algos-ngular:build" 54 | }, 55 | "configurations": { 56 | "production": { 57 | "browserTarget": "algos-ngular:build:production" 58 | } 59 | } 60 | }, 61 | "extract-i18n": { 62 | "builder": "@angular-devkit/build-angular:extract-i18n", 63 | "options": { 64 | "browserTarget": "algos-ngular:build" 65 | } 66 | }, 67 | "test": { 68 | "builder": "@angular-devkit/build-angular:karma", 69 | "options": { 70 | "main": "src/test.ts", 71 | "polyfills": "src/polyfills.ts", 72 | "tsConfig": "src/tsconfig.spec.json", 73 | "karmaConfig": "karma.conf.js", 74 | "styles": [ 75 | "src/styles.css" 76 | ], 77 | "scripts": [], 78 | "assets": [ 79 | "src/favicon.ico", 80 | "src/assets" 81 | ] 82 | } 83 | }, 84 | "lint": { 85 | "builder": "@angular-devkit/build-angular:tslint", 86 | "options": { 87 | "tsConfig": [ 88 | "src/tsconfig.app.json", 89 | "src/tsconfig.spec.json" 90 | ], 91 | "exclude": [ 92 | "**/node_modules/**" 93 | ] 94 | } 95 | } 96 | } 97 | } 98 | }, 99 | "defaultProject": "algos-ngular" 100 | } 101 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | *.map 40 | 41 | # System Files 42 | .DS_Store 43 | Thumbs.db 44 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "11" 5 | - "10" 6 | 7 | addons: 8 | chrome: stable 9 | 10 | cache: npm 11 | 12 | script: 13 | - npm run build 14 | - npm run lint 15 | # - npm run test 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Mohit Kumar Yadav 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # algos-ngular [](https://travis-ci.org/mohitkyadav/algos-ngular) 2 | 3 | [](https://github.com/SolidScript/algos-ngular) 4 | [](https://github.com/SolidScript/algos-ngular) 5 | 6 | 7 | ## Live Demo 8 | http://mohitkyadav.github.io/algos-ngular 9 | 10 | 11 | ## Algorithms source codes from iiitv/algos 12 | https://github.com/iiitv/algos 13 | 14 | 15 | ## Features 16 | * Uses Github public API to fetch algorithm codes. 17 | * Always Up-to-date with [iiitv/algos](https://github.com/iiitv/algos), no need to redeploy. 18 | * Built using Angular 4 and Angular Material 19 | 20 | ``` 21 | npm install -g @angular/cli 22 | git clone https://github.com/mohitkyadav/algos-ngular.git 23 | cd algos-ngular 24 | npm install 25 | ng serve --open 26 | ``` 27 | 28 | 29 | ## Author 30 | 31 | Mohit Kumar Yadav 32 | 33 | [](https://twitter.com/mukulkyadav) 34 | [](https://linkedin.com/in/mohitkyadav) 35 | [](https://github.com/mohitkyadav) 36 | 37 | ## Contribute 38 | Found a bug, please [create an issue](https://github.com/mohitkyadav/algos-ngular/issues/new) 39 | 40 | 41 | ## License 42 | 43 | [](#) 44 | 45 | > © Mohit Kumar Yadav 46 | -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AlgosNgularPage } from './app.po'; 2 | 3 | describe('algos-ngular App', () => { 4 | let page: AlgosNgularPage; 5 | 6 | beforeEach(() => { 7 | page = new AlgosNgularPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AlgosNgularPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "jasminewd2", 11 | "node" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/0.13/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | reports: [ 'html', 'lcovonly' ], 20 | fixWebpackSourcePaths: true 21 | }, 22 | angularCli: { 23 | environment: 'dev' 24 | }, 25 | reporters: ['progress', 'kjhtml'], 26 | port: 9876, 27 | colors: true, 28 | logLevel: config.LOG_INFO, 29 | autoWatch: true, 30 | browsers: ['Chrome'], 31 | singleRun: false 32 | }); 33 | }; 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "algos-ngular", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "engines": { 6 | "node": ">=10" 7 | }, 8 | "scripts": { 9 | "ng": "ng", 10 | "start": "ng serve", 11 | "build": "ng build", 12 | "test": "ng test", 13 | "lint": "ng lint", 14 | "e2e": "ng e2e", 15 | "deploy": "ng b --prod --base-href https://mohitkyadav.github.io/algos-ngular/ && ngh --no-silent --dir=dist/algos-ngular/" 16 | }, 17 | "private": true, 18 | "dependencies": { 19 | "@angular/animations": "^7.1.4", 20 | "@angular/cdk": "^7.2.0", 21 | "@angular/common": "^7.1.4", 22 | "@angular/compiler": "^7.1.4", 23 | "@angular/core": "^7.1.4", 24 | "@angular/forms": "^7.1.4", 25 | "@angular/http": "^7.1.4", 26 | "@angular/material": "^7.2.0", 27 | "@angular/platform-browser": "^7.1.4", 28 | "@angular/platform-browser-dynamic": "^7.1.4", 29 | "@angular/router": "^7.1.4", 30 | "angular": "^1.7.5", 31 | "angular-animate": "^1.7.5", 32 | "angular-aria": "^1.7.5", 33 | "angular-material": "^1.1.10", 34 | "angular-prism": "^0.1.20", 35 | "core-js": "^2.6.1", 36 | "rxjs": "^6.3.3", 37 | "zone": "^0.3.4", 38 | "zone.js": "^0.8.26", 39 | "rxjs-compat": "^6.0.0-rc.0" 40 | }, 41 | "devDependencies": { 42 | "@angular-devkit/build-angular": "^0.11.4", 43 | "@angular/cli": "^7.1.4", 44 | "@angular/compiler-cli": "^7.1.4", 45 | "@angular/language-service": "^7.1.4", 46 | "@types/jasmine": "^2.5.54", 47 | "@types/jasminewd2": "^2.0.6", 48 | "@types/node": "^6.0.118", 49 | "codelyzer": "~3.0.1", 50 | "jasmine-core": "~2.6.2", 51 | "jasmine-spec-reporter": "~4.1.0", 52 | "karma": "^3.1.4", 53 | "karma-chrome-launcher": "~2.1.1", 54 | "karma-cli": "~1.0.1", 55 | "karma-coverage-istanbul-reporter": "^1.4.3", 56 | "karma-jasmine": "^1.1.2", 57 | "karma-jasmine-html-reporter": "^0.2.2", 58 | "protractor": "^5.4.1", 59 | "ts-node": "^3.3.0", 60 | "tslint": "^5.12.0", 61 | "typescript": "~3.1.6" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './e2e/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- 1 | .example-fill-remaining-space { 2 | flex: 1 1 auto; 3 | } 4 | 5 | mat-toolbar-row { 6 | overflow: auto; 7 | } 8 | 9 | .github-buttons { 10 | padding: 0; 11 | } 12 | 13 | .button-github { 14 | padding: 0 20px; 15 | } 16 | 17 | .grow { 18 | flex: 1; 19 | } 20 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to {{title}}! 5 | 6 | 7 | 8 | 9 | Star 10 | 11 | 12 | 13 | Watch 14 | 15 | 16 | 17 | Issue 18 | 19 | 20 | 21 | Download 22 | 23 | 24 | 25 | Fork 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | }).compileComponents(); 12 | })); 13 | 14 | it('should create the app', async(() => { 15 | const fixture = TestBed.createComponent(AppComponent); 16 | const app = fixture.debugElement.componentInstance; 17 | expect(app).toBeTruthy(); 18 | })); 19 | 20 | it(`should have as title 'app'`, async(() => { 21 | const fixture = TestBed.createComponent(AppComponent); 22 | const app = fixture.debugElement.componentInstance; 23 | expect(app.title).toEqual('app'); 24 | })); 25 | 26 | it('should render title in a h1 tag', async(() => { 27 | const fixture = TestBed.createComponent(AppComponent); 28 | fixture.detectChanges(); 29 | const compiled = fixture.debugElement.nativeElement; 30 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 31 | })); 32 | }); 33 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { trigger, transition, state, style, animate } from '@angular/animations'; 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.css'], 8 | }) 9 | export class AppComponent { 10 | title = 'algos'; 11 | } 12 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { HttpModule } from '@angular/http'; 4 | import { RouterModule } from '@angular/router'; 5 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 6 | import { MatButtonModule, MatMenuModule, MatSidenavModule, MatTabsModule, 7 | MatCheckboxModule, MatToolbarModule, MatIconModule, MatCardModule, MatListModule, MatProgressSpinnerModule } from '@angular/material'; 8 | 9 | import { AppComponent } from './app.component'; 10 | import { ContentService } from './services/content.service'; 11 | import { ContentComponent } from './components/content.component'; 12 | import { LayoutModule } from '@angular/cdk/layout'; 13 | 14 | @NgModule({ 15 | declarations: [ 16 | AppComponent, 17 | ContentComponent 18 | ], 19 | imports: [ 20 | BrowserModule, 21 | HttpModule, 22 | BrowserAnimationsModule, 23 | MatButtonModule, 24 | MatCheckboxModule, 25 | MatMenuModule, 26 | MatSidenavModule, 27 | MatToolbarModule, 28 | MatTabsModule, 29 | MatIconModule, 30 | MatCardModule, 31 | MatListModule, 32 | MatProgressSpinnerModule, 33 | LayoutModule 34 | ], 35 | providers: [ 36 | ContentService 37 | ], 38 | bootstrap: [AppComponent] 39 | }) 40 | export class AppModule { } 41 | -------------------------------------------------------------------------------- /src/app/components/content.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { LayoutModule } from '@angular/cdk/layout'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 4 | import { 5 | MatButtonModule, 6 | MatIconModule, 7 | MatListModule, 8 | MatSidenavModule, 9 | MatToolbarModule, 10 | } from '@angular/material'; 11 | 12 | import { ContentComponent } from './content.component'; 13 | 14 | describe('ContentComponent', () => { 15 | let component: ContentComponent; 16 | let fixture: ComponentFixture; 17 | 18 | beforeEach(async(() => { 19 | TestBed.configureTestingModule({ 20 | declarations: [ContentComponent], 21 | imports: [ 22 | NoopAnimationsModule, 23 | LayoutModule, 24 | MatButtonModule, 25 | MatIconModule, 26 | MatListModule, 27 | MatSidenavModule, 28 | MatToolbarModule, 29 | ] 30 | }).compileComponents(); 31 | })); 32 | 33 | beforeEach(() => { 34 | fixture = TestBed.createComponent(ContentComponent); 35 | component = fixture.componentInstance; 36 | fixture.detectChanges(); 37 | }); 38 | 39 | it('should compile', () => { 40 | expect(component).toBeTruthy(); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /src/app/components/content.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; 3 | import { Observable } from 'rxjs/Observable'; 4 | import { map } from 'rxjs/operators'; 5 | import { ContentService } from '../services/content.service'; 6 | import { ContentItem } from '../model/content.model'; 7 | import { Http } from '@angular/http'; 8 | 9 | 10 | const Prism = require('prismjs'); 11 | 12 | import 'prismjs'; 13 | import 'prismjs/components/prism-java'; 14 | import 'prismjs/components/prism-go'; 15 | import 'prismjs/components/prism-csharp'; 16 | import 'prismjs/components/prism-python'; 17 | 18 | import { Links } from '../model/content.model'; 19 | 20 | @Component({ 21 | // `component-selector` is disabled because of https://github.com/mgechev/codelyzer/issues/192 22 | selector: 'content', // tslint:disable-line component-selector 23 | templateUrl: '../views/content.component.html', 24 | styleUrls: ['../views/content.component.css'] 25 | }) 26 | export class ContentComponent implements OnInit { 27 | contentItemsTemp: Observable>; 28 | contentItems: Array; 29 | folderItems: Array; 30 | detailsTemp: Observable; 31 | code_c: any; 32 | code_cpp: string; 33 | code_java: string; 34 | code_js: string; 35 | code_go: string; 36 | code_py: string; 37 | code_cs: string; 38 | download_url: string; 39 | isLoading: boolean; 40 | contentTitle: string; 41 | title: string; 42 | 43 | isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset) 44 | .pipe( 45 | map(result => result.matches) 46 | ); 47 | 48 | constructor( 49 | private breakpointObserver: BreakpointObserver, 50 | private contentService: ContentService, 51 | private http: Http 52 | ) {} 53 | 54 | ngOnInit() { 55 | this.contentItemsTemp = this.contentService.fetchContent(); 56 | this.contentItemsTemp.subscribe( 57 | (data) => this.contentItems = data.filter(elem => elem.type !== 'file' && elem.name !== '.bin') 58 | ); 59 | this.isLoading = false; 60 | this.contentTitle = ''; 61 | this.title = 'algos'; 62 | } 63 | fetchCode(item): any { 64 | console.log(item); 65 | this.isLoading = true; 66 | for (let i = 0; i < this.contentItems.length; i++) { 67 | if (item) { 68 | if (item === this.contentItems[i].name) { 69 | this.contentTitle = item; 70 | const contentsUrl = `https://api.github.com/repos/iiitv/algos/contents/${item}`; 71 | console.log(contentsUrl); 72 | this.contentItemsTemp = this.contentService.fetchFolderContent(contentsUrl); 73 | this.contentItemsTemp.subscribe( 74 | (data) => this.getCodes(data) 75 | ); 76 | break; 77 | } 78 | } 79 | if (item.originalTarget) { 80 | if (item.originalTarget.innerText === this.contentItems[i].name) { 81 | this.contentTitle = item.originalTarget.innerText; 82 | const contentsUrl = `https://api.github.com/repos/iiitv/algos/contents/${item.originalTarget.innerText}`; 83 | this.contentItemsTemp = this.contentService.fetchFolderContent(contentsUrl); 84 | this.contentItemsTemp.subscribe( 85 | (data) => this.getCodes(data) 86 | ); 87 | break; 88 | } 89 | } 90 | } 91 | } 92 | getCode(url, type) { 93 | this.detailsTemp = this.http.get(url).pipe(map( 94 | (res) => res.text() 95 | )); 96 | if (type === 'c') { 97 | this.detailsTemp.subscribe( 98 | (data) => this.code_c = Prism.highlight(data, Prism.languages.csharp) 99 | ); 100 | } 101 | if (type === 'cpp') { 102 | this.detailsTemp.subscribe( 103 | (data) => this.code_cpp = Prism.highlight(data, Prism.languages.csharp) 104 | ); 105 | } 106 | if (type === 'java') { 107 | this.detailsTemp.subscribe( 108 | (data) => this.code_java = Prism.highlight(data, Prism.languages.java) 109 | ); 110 | } 111 | if (type === 'py') { 112 | this.detailsTemp.subscribe( 113 | (data) => this.code_py = Prism.highlight(data, Prism.languages.python) 114 | ); 115 | } 116 | if (type === 'go') { 117 | this.detailsTemp.subscribe( 118 | (data) => this.code_go = Prism.highlight(data, Prism.languages.go) 119 | ); 120 | } 121 | if (type === 'js') { 122 | this.detailsTemp.subscribe( 123 | (data) => this.code_js = Prism.highlight(data, Prism.languages.javascript) 124 | ); 125 | } 126 | if (type === 'cs') { 127 | this.detailsTemp.subscribe( 128 | (data) => this.code_cs = Prism.highlight(data, Prism.languages.csharp) 129 | ); 130 | } 131 | } 132 | getCodes(data) { 133 | let jk: string; 134 | let flag, c, java, go, js, py, cpp = false; 135 | for (let i = 0; i < data.length; i++) { 136 | const fileName = data[i].name; 137 | jk = ''; 138 | flag = false; 139 | for (let j = 0; j < fileName.length; j++) { 140 | if (flag) { 141 | jk += fileName[j]; 142 | } 143 | if (fileName[j] === '.') { 144 | flag = true; 145 | } 146 | } 147 | if (jk === 'c') { c = true; } 148 | if (jk === 'java') { java = true; } 149 | if (jk === 'go') { go = true; } 150 | if (jk === 'js') { js = true; } 151 | if (jk === 'cpp') { cpp = true; } 152 | if (jk === 'py') { py = true; } 153 | this.getCode(data[i].download_url, jk); 154 | } 155 | if (!c) { this.code_c = null; } 156 | if (!cpp) { this.code_cpp = null; } 157 | if (!java) { this.code_java = null; } 158 | if (!go) { this.code_go = null; } 159 | if (!js) { this.code_js = null; } 160 | if (!py) { this.code_py = null; } 161 | this.isLoading = false; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/app/model/content.model.ts: -------------------------------------------------------------------------------- 1 | export interface Links { 2 | self: string; 3 | git: string; 4 | html: string; 5 | } 6 | 7 | export interface ContentItem { 8 | name: string; 9 | path: string; 10 | sha: string; 11 | size: number; 12 | url: string; 13 | html_url: string; 14 | git_url: string; 15 | download_url: string; 16 | type: string; 17 | _links: Links; 18 | } 19 | -------------------------------------------------------------------------------- /src/app/services/content.service.ts: -------------------------------------------------------------------------------- 1 | import { map } from 'rxjs/operators'; 2 | import { Injectable } from '@angular/core'; 3 | import {Observable} from 'rxjs/Observable'; 4 | import { Http } from '@angular/http'; 5 | 6 | 7 | import { ContentItem } from '../model/content.model'; 8 | import { Links } from '../model/content.model'; 9 | 10 | @Injectable() 11 | export class ContentService { 12 | constructor(private http: Http) {} 13 | 14 | fetchContent() { 15 | return this.http.get('https://api.github.com/repos/iiitv/algos/contents').pipe(map( 16 | (response) => response.json() 17 | )); 18 | } 19 | fetchFolderContent(content_url) { 20 | return this.http.get(content_url).pipe(map( 21 | (response) => response.json() 22 | )); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/app/views/content.component.css: -------------------------------------------------------------------------------- 1 | .sidenav-container { 2 | height: calc(100% - 128px); 3 | } 4 | 5 | .sidenav { 6 | width: 100%; 7 | } 8 | 9 | @media (min-width: 425px) { 10 | .sidenav { 11 | max-width: 300px; 12 | } 13 | } 14 | 15 | .grow { 16 | flex: 1; 17 | } 18 | 19 | mat-toolbar > .close-button { 20 | display: none; 21 | } 22 | 23 | @media (max-width: 425px) { 24 | mat-toolbar > .close-button { 25 | display: block; 26 | } 27 | } 28 | 29 | .side-nav-buttons { 30 | width: 100%; 31 | } 32 | .example-sidenav-fab-container { 33 | width: 100%; 34 | height: 90%; 35 | } 36 | 37 | .example-sidenav-fab-container md-sidenav { 38 | max-width: 100%; 39 | position: fixed; 40 | } 41 | 42 | .example-sidenav-fab-container .mat-sidenav-content, 43 | .example-sidenav-fab-container md-sidenav { 44 | display: flex; 45 | overflow: visible; 46 | } 47 | 48 | mat-spinner { 49 | position: relative; 50 | top: calc(50% - 128px); 51 | margin: 0 auto; 52 | } 53 | 54 | .example-scrolling-content { 55 | overflow: auto; 56 | height: 100%; 57 | width: 100%; 58 | } 59 | 60 | .example-fab { 61 | position: absolute; 62 | right: 20px; 63 | bottom: 10px; 64 | } 65 | 66 | pre { 67 | color: white; 68 | padding-left: 50px; 69 | } 70 | 71 | mat-sidenav { 72 | width: 20%; 73 | } 74 | 75 | mat-tab { 76 | flex: 1 1 auto; 77 | position: fixed; 78 | } 79 | 80 | -------------------------------------------------------------------------------- /src/app/views/content.component.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Menu 9 | 10 | 16 | close 17 | 18 | 19 | 20 | 21 | 22 | {{item.name}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 35 | menu 36 | 37 | {{contentTitle}} 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohitkyadav/algos-ngular/5de5c00a5fbee3a9e8f80b39361cfc35aa8da89c/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AlgosNgular 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule); 12 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** Evergreen browsers require these. **/ 41 | import 'core-js/es6/reflect'; 42 | import 'core-js/es7/reflect'; 43 | 44 | 45 | /** 46 | * Required to support Web Animations `@angular/animation`. 47 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 48 | **/ 49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 50 | 51 | 52 | 53 | /*************************************************************************************************** 54 | * Zone JS is required by Angular itself. 55 | */ 56 | import 'zone.js/dist/zone'; // Included with Angular CLI. 57 | 58 | 59 | 60 | /*************************************************************************************************** 61 | * APPLICATION IMPORTS 62 | */ 63 | 64 | /** 65 | * Date, currency, decimal and percent pipes. 66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 67 | */ 68 | // import 'intl'; // Run `npm install --save intl`. 69 | /** 70 | * Need to import at least one locale-data with intl. 71 | */ 72 | // import 'intl/locale-data/jsonp/en'; 73 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | @import '~@angular/material/prebuilt-themes/purple-green.css'; 2 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | import { getTestBed } from '@angular/core/testing'; 10 | import { 11 | BrowserDynamicTestingModule, 12 | platformBrowserDynamicTesting 13 | } from '@angular/platform-browser-dynamic/testing'; 14 | 15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 16 | declare const __karma__: any; 17 | declare const require: any; 18 | 19 | // Prevent Karma from running prematurely. 20 | __karma__.loaded = function () {}; 21 | 22 | // First, initialize the Angular testing environment. 23 | getTestBed().initTestEnvironment( 24 | BrowserDynamicTestingModule, 25 | platformBrowserDynamicTesting() 26 | ); 27 | // Then we find all the tests. 28 | const context = require.context('./', true, /\.spec\.ts$/); 29 | // And load the modules. 30 | context.keys().map(context); 31 | // Finally, start Karma to run the tests. 32 | __karma__.start(); 33 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [ 8 | "node" 9 | ] 10 | }, 11 | "exclude": [ 12 | "test.ts", 13 | "**/*.spec.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | }, 13 | "files": [ 14 | "test.ts" 15 | ], 16 | "include": [ 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ], 20 | "include": [ 21 | "**/*.spec.ts", 22 | "**/*.d.ts", 23 | "main.ts", 24 | "polyfills.ts" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "allowJs": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2016", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "eofline": true, 15 | "forin": true, 16 | "import-blacklist": [ 17 | true, 18 | "rxjs" 19 | ], 20 | "import-spacing": true, 21 | "indent": [ 22 | true, 23 | "spaces" 24 | ], 25 | "interface-over-type-literal": true, 26 | "label-position": true, 27 | "max-line-length": [ 28 | true, 29 | 140 30 | ], 31 | "member-access": false, 32 | "member-ordering": [ 33 | true, 34 | { 35 | "order": [ 36 | "static-field", 37 | "instance-field", 38 | "static-method", 39 | "instance-method" 40 | ] 41 | } 42 | ], 43 | "no-arg": true, 44 | "no-bitwise": true, 45 | "no-console": [ 46 | true, 47 | "debug", 48 | "info", 49 | "time", 50 | "timeEnd", 51 | "trace" 52 | ], 53 | "no-construct": true, 54 | "no-debugger": true, 55 | "no-duplicate-super": true, 56 | "no-empty": false, 57 | "no-empty-interface": true, 58 | "no-eval": true, 59 | "no-inferrable-types": [ 60 | true, 61 | "ignore-params" 62 | ], 63 | "no-misused-new": true, 64 | "no-non-null-assertion": true, 65 | "no-shadowed-variable": true, 66 | "no-string-literal": false, 67 | "no-string-throw": true, 68 | "no-switch-case-fall-through": true, 69 | "no-trailing-whitespace": true, 70 | "no-unnecessary-initializer": true, 71 | "no-unused-expression": true, 72 | "no-use-before-declare": true, 73 | "no-var-keyword": true, 74 | "object-literal-sort-keys": false, 75 | "one-line": [ 76 | true, 77 | "check-open-brace", 78 | "check-catch", 79 | "check-else", 80 | "check-whitespace" 81 | ], 82 | "prefer-const": true, 83 | "quotemark": [ 84 | true, 85 | "single" 86 | ], 87 | "radix": true, 88 | "semicolon": [ 89 | true, 90 | "always" 91 | ], 92 | "triple-equals": [ 93 | true, 94 | "allow-null-check" 95 | ], 96 | "typedef-whitespace": [ 97 | true, 98 | { 99 | "call-signature": "nospace", 100 | "index-signature": "nospace", 101 | "parameter": "nospace", 102 | "property-declaration": "nospace", 103 | "variable-declaration": "nospace" 104 | } 105 | ], 106 | "typeof-compare": true, 107 | "unified-signatures": true, 108 | "variable-name": false, 109 | "whitespace": [ 110 | true, 111 | "check-branch", 112 | "check-decl", 113 | "check-operator", 114 | "check-separator", 115 | "check-type" 116 | ], 117 | "directive-selector": [ 118 | true, 119 | "attribute", 120 | "app", 121 | "camelCase" 122 | ], 123 | "component-selector": [ 124 | true, 125 | "element", 126 | "app", 127 | "kebab-case" 128 | ], 129 | "use-input-property-decorator": true, 130 | "use-output-property-decorator": true, 131 | "use-host-property-decorator": true, 132 | "no-input-rename": true, 133 | "no-output-rename": true, 134 | "use-life-cycle-interface": true, 135 | "use-pipe-transform-interface": true, 136 | "component-class-suffix": true, 137 | "directive-class-suffix": true, 138 | "no-access-missing-member": true, 139 | "templates-use-public": true, 140 | "invoke-injectable": true 141 | } 142 | } 143 | --------------------------------------------------------------------------------
43 | 44 | 45 |
49 | 50 | 51 |
55 | 56 | 57 |
61 | 62 | 63 |
67 | 68 | 69 |
73 | 74 | 75 |
79 | 80 | 81 |