Commit 8c980928 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

validReff now always come from the backend, so we can cache them there

parent f76d2f67
{
"name": "mcClient",
"version": "0.2.0",
"version": "0.2.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
......
......@@ -84,24 +84,23 @@ export class CorpusDetailPage {
let urnLastPart: string = relevantCitationLabels.map(x => x.toString()).join(".");
let fullUrn: string = this.corpusProvider.currentCorpus.source_urn + (urnLastPart ? ":" + urnLastPart : "");
return new Promise(resolve => {
this.corpusProvider.getCTSvalidReff(fullUrn).subscribe((result: string | object) => {
this.corpusProvider.getCTSvalidReff(fullUrn).subscribe((result: string[] | object) => {
let newCitations: Citation[] = [];
if (typeof result === "object") {
if (!Array.isArray(result)) {
// this is a custom corpus
let textparts: object[] = result["textparts"];
newCitations = textparts.map(x => x["citation"]) as Citation[];
}
else {
this.corpusProvider.xml2jsParser.parseString(result, (err, resultObject: object) => {
let gvr: GetValidReff = this.corpusProvider.ctsJson2mc(resultObject);
let replaceString: string = fullUrn + (urnLastPart ? "." : ":");
gvr.reply.reff.urn.forEach((urn) => {
newCitations.push(new Citation({
level: targetCitationLevel,
label: urn.replace(replaceString, ""),
value: +urn.replace(replaceString, "")
}));
});
// this is a CTS corpus
let urnList: string[] = result as string[];
let replaceString: string = fullUrn + (urnLastPart ? "." : ":");
urnList.forEach((urn) => {
newCitations.push(new Citation({
level: targetCitationLevel,
label: urn.replace(replaceString, ""),
value: +urn.replace(replaceString, "")
}));
});
}
newCitations.forEach((citation) => {
......@@ -128,14 +127,6 @@ export class CorpusDetailPage {
});
});
});
// , (error: HttpErrorResponse) => {
// // no further references available, go to text display
// this.corpusProvider.currentUrn = urn;
// let urnParts = this.corpusProvider.currentUrn.split(":");
// this.corpusProvider.currentLastUrnPart = urnParts[urnParts.length - 1];
// this.corpusProvider.currentText = "";
// this.navCtrl.push(ShowTextPage).then();
// }
}
checkTextRange(citationLabelsStart: string[], citationLabelsEnd: string[]) {
......@@ -206,7 +197,7 @@ export class CorpusDetailPage {
});
}
async showFurtherReferences(value: string) { // urn: string, currentCitationLevel: number, isStart: boolean
async showFurtherReferences(value: string) {
if (!value) {
return;
}
......
......@@ -19,8 +19,6 @@ export class HomePage {
window = window;
public isCorpusUpdateInProgress: boolean = false;
listValues: any = ['1', '2', '3'];
constructor(public navCtrl: NavController, public navParams: NavParams,
public http: HttpClient,
public exerciseProvider: ExerciseProvider,
......
......@@ -16,7 +16,6 @@ import {QueryMC} from "../../models/queryMC";
import {AnnisResponse} from "../../models/annisResponse";
import {NodeMC} from "../../models/nodeMC";
import {LinkMC} from "../../models/linkMC";
import {nonPageFileManipulation} from "@ionic/app-scripts/dist/generators/util";
/**
* Generated class for the ShowTextPage page.
......
......@@ -140,12 +140,8 @@ export class CorpusProvider {
getCTSvalidReff(urn: string) {
let config: object = HelperProvider.config;
if (urn.includes(config["vivaURN"])) {
let fullUrl: string = config["backendBaseUrl"] + config["backendApiValidReffPath"];
return this.http.get(fullUrl, {params: {"urn": urn}});
}
let fullUrl: string = config["perseidsCTSapiBaseUrl"] + config["perseidsCTSapiGetValidReff"] + config["perseidsCTSapiUrnSnippet"] + urn;
return this.http.get(fullUrl, {responseType: 'text'});
let fullUrl: string = config["backendBaseUrl"] + config["backendApiValidReffPath"];
return this.http.get(fullUrl, {params: {"urn": urn}});
}
getCorpora(fromServer: boolean = false) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment