fix: change v2's link to v2.angular.cn

This commit is contained in:
Zhicheng Wang 2017-08-03 15:30:35 +08:00
parent 2a0c436347
commit 8f950c26f2
4 changed files with 24 additions and 26 deletions

View File

@ -441,7 +441,7 @@
], ],
"docVersions": [ "docVersions": [
{ "title": "v2", "url": "https://v2.angular.io" }, { "title": "v2", "url": "https://v2.angular.cn" },
{ "title": "AngularDart", "url": "https://webdev.dartlang.org/angular" } { "title": "AngularDart", "url": "https://webdev.dartlang.org/angular" }
] ]

View File

@ -911,7 +911,7 @@ class TestHttp {
static versionFull = '4.0.0-local+sha.73808dd'; static versionFull = '4.0.0-local+sha.73808dd';
static docVersions: NavigationNode[] = [ static docVersions: NavigationNode[] = [
{ title: 'v2', url: 'https://v2.angular.io' } { title: 'v2', url: 'https://v2.angular.cn' }
]; ];
// tslint:disable:quotemark // tslint:disable:quotemark

View File

@ -1,18 +1,18 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http'; import { Http, Response } from '@angular/http';
import { LocationService } from 'app/shared/location.service';
import { Observable } from 'rxjs/Observable'; import { Logger } from 'app/shared/logger.service';
import { AsyncSubject } from 'rxjs/AsyncSubject';
import { of } from 'rxjs/observable/of';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap'; import 'rxjs/add/operator/switchMap';
import { AsyncSubject } from 'rxjs/AsyncSubject';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { DocumentContents } from './document-contents'; import { DocumentContents } from './document-contents';
export { DocumentContents } from './document-contents';
import { LocationService } from 'app/shared/location.service'; export { DocumentContents } from './document-contents';
import { Logger } from 'app/shared/logger.service';
export const FILE_NOT_FOUND_ID = 'file-not-found'; export const FILE_NOT_FOUND_ID = 'file-not-found';
export const FETCHING_ERROR_ID = 'fetching-error'; export const FETCHING_ERROR_ID = 'fetching-error';
@ -23,10 +23,9 @@ const FETCHING_ERROR_CONTENTS = `
<div class="nf-container l-flex-wrap flex-center"> <div class="nf-container l-flex-wrap flex-center">
<div class="nf-icon material-icons">error_outline</div> <div class="nf-icon material-icons">error_outline</div>
<div class="nf-response l-flex-wrap"> <div class="nf-response l-flex-wrap">
<h1 class="no-toc">Request for document failed.</h1> <h1 class="no-toc"></h1>
<p> <p>
We are unable to retrieve the "<current-location></current-location>" page at this time. "<current-location></current-location>"
Please check your connection and try again later.
</p> </p>
</div> </div>
</div> </div>
@ -39,10 +38,9 @@ export class DocumentService {
currentDocument: Observable<DocumentContents>; currentDocument: Observable<DocumentContents>;
constructor( constructor(private logger: Logger,
private logger: Logger, private http: Http,
private http: Http, location: LocationService) {
location: LocationService) {
// Whenever the URL changes we try to get the appropriate doc // Whenever the URL changes we try to get the appropriate doc
this.currentDocument = location.currentPath.switchMap(path => this.getDocument(path)); this.currentDocument = location.currentPath.switchMap(path => this.getDocument(path));
} }
@ -50,7 +48,7 @@ export class DocumentService {
private getDocument(url: string) { private getDocument(url: string) {
const id = url || 'index'; const id = url || 'index';
this.logger.log('getting document', id); this.logger.log('getting document', id);
if ( !this.cache.has(id)) { if (!this.cache.has(id)) {
this.cache.set(id, this.fetchDocument(id)); this.cache.set(id, this.fetchDocument(id));
} }
return this.cache.get(id); return this.cache.get(id);
@ -61,12 +59,12 @@ export class DocumentService {
this.logger.log('fetching document from', requestPath); this.logger.log('fetching document from', requestPath);
const subject = new AsyncSubject(); const subject = new AsyncSubject();
this.http this.http
.get(requestPath) .get(requestPath)
.map(response => response.json()) .map(response => response.json())
.catch((error: Response) => { .catch((error: Response) => {
return error.status === 404 ? this.getFileNotFoundDoc(id) : this.getErrorDoc(id, error); return error.status === 404 ? this.getFileNotFoundDoc(id) : this.getErrorDoc(id, error);
}) })
.subscribe(subject); .subscribe(subject);
return subject.asObservable(); return subject.asObservable();
} }
@ -78,7 +76,7 @@ export class DocumentService {
} else { } else {
return of({ return of({
id: FILE_NOT_FOUND_ID, id: FILE_NOT_FOUND_ID,
contents: 'Document not found' contents: '文档未找到',
}); });
} }
} }
@ -88,7 +86,7 @@ export class DocumentService {
this.cache.delete(id); this.cache.delete(id);
return Observable.of({ return Observable.of({
id: FETCHING_ERROR_ID, id: FETCHING_ERROR_ID,
contents: FETCHING_ERROR_CONTENTS contents: FETCHING_ERROR_CONTENTS,
}); });
} }
} }

View File

@ -250,7 +250,7 @@ describe('NavigationService', () => {
actualDocVersions = []; actualDocVersions = [];
docVersions = [ docVersions = [
{ title: 'v4.0.0' }, { title: 'v4.0.0' },
{ title: 'v2', url: 'https://v2.angular.io' } { title: 'v2', url: 'https://v2.angular.cn' }
]; ];
expectedDocVersions = docVersions.map(v => ( expectedDocVersions = docVersions.map(v => (