Use full path, to be compatible both on localhost and on GitHub page.
This commit is contained in:
parent
db7e719c57
commit
aebef7a60d
3 changed files with 16 additions and 10 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
// Generated file, do not edit
|
// Generated file, do not edit
|
||||||
export const screenshots = [
|
export const screenshots = [
|
||||||
["en","de",],
|
["en","de",],
|
||||||
["./tests/uitests/src/test/snapshots/images","./screenshots/de",],
|
|
||||||
["ui_S_t[f.preferences.impl.about_AboutView_null_AboutView-Day-0_1_null_0,NEXUS_5,1.0,en]",1,],
|
["ui_S_t[f.preferences.impl.about_AboutView_null_AboutView-Day-0_1_null_0,NEXUS_5,1.0,en]",1,],
|
||||||
["ui_S_t[f.login.impl.accountprovider_AccountProviderView_null_AccountProviderView-Day-0_1_null_0,NEXUS_5,1.0,en]",0,],
|
["ui_S_t[f.login.impl.accountprovider_AccountProviderView_null_AccountProviderView-Day-0_1_null_0,NEXUS_5,1.0,en]",0,],
|
||||||
["ui_S_t[f.login.impl.accountprovider_AccountProviderView_null_AccountProviderView-Day-0_1_null_1,NEXUS_5,1.0,en]",0,],
|
["ui_S_t[f.login.impl.accountprovider_AccountProviderView_null_AccountProviderView-Day-0_1_null_1,NEXUS_5,1.0,en]",0,],
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,18 @@
|
||||||
*/
|
*/
|
||||||
import { screenshots } from './data.js';
|
import { screenshots } from './data.js';
|
||||||
|
|
||||||
|
// Get the base url of the current page
|
||||||
|
const baseUrl = window.location.href.split('/').slice(0, -1).join('/');
|
||||||
|
// On localhost, get the English screenshots from the location `../tests/uitests/src/test/snapshots/images`
|
||||||
|
const isLocalHost = window.location.hostname === "localhost"
|
||||||
|
let englishBasePath
|
||||||
|
if (isLocalHost) {
|
||||||
|
englishBasePath = `../tests/uitests/src/test/snapshots/images`
|
||||||
|
} else {
|
||||||
|
englishBasePath = `en`
|
||||||
|
}
|
||||||
|
|
||||||
const dataLanguages = screenshots[0];
|
const dataLanguages = screenshots[0];
|
||||||
const dataPaths = screenshots[1];
|
|
||||||
|
|
||||||
// Read default visible languages from the fragment
|
// Read default visible languages from the fragment
|
||||||
const fragment = new URLSearchParams(window.location.hash.substring(1));
|
const fragment = new URLSearchParams(window.location.hash.substring(1));
|
||||||
|
|
@ -121,10 +131,9 @@ function addTable() {
|
||||||
languagesHeaderRow.appendChild(th);
|
languagesHeaderRow.appendChild(th);
|
||||||
}
|
}
|
||||||
const numVisibleLanguages = languagesHeaderRow.childElementCount
|
const numVisibleLanguages = languagesHeaderRow.childElementCount
|
||||||
// Second item contains the paths
|
|
||||||
// Next items are the data
|
// Next items are the data
|
||||||
var currentHeaderValue = "";
|
var currentHeaderValue = "";
|
||||||
for (let screenshotIndex = 2; screenshotIndex < screenshots.length; screenshotIndex++) {
|
for (let screenshotIndex = 1; screenshotIndex < screenshots.length; screenshotIndex++) {
|
||||||
let englishFile = screenshots[screenshotIndex][0];
|
let englishFile = screenshots[screenshotIndex][0];
|
||||||
const tr = document.createElement('tr');
|
const tr = document.createElement('tr');
|
||||||
let hasTranslatedFiles = false;
|
let hasTranslatedFiles = false;
|
||||||
|
|
@ -134,10 +143,10 @@ function addTable() {
|
||||||
}
|
}
|
||||||
const td = document.createElement('td');
|
const td = document.createElement('td');
|
||||||
if (languageIndex == 0) {
|
if (languageIndex == 0) {
|
||||||
const fullFile = `${dataPaths[0]}/${englishFile}.png`;
|
const fullFile = `${englishBasePath}/${englishFile}.png`;
|
||||||
const img = document.createElement('img');
|
const img = document.createElement('img');
|
||||||
img.className = "screenshot";
|
img.className = "screenshot";
|
||||||
img.src = `../${fullFile}`;
|
img.src = `${baseUrl}/${fullFile}`;
|
||||||
img.title = fullFile;
|
img.title = fullFile;
|
||||||
img.alt = "Missing image";
|
img.alt = "Missing image";
|
||||||
img.width = imageWidth;
|
img.width = imageWidth;
|
||||||
|
|
@ -153,10 +162,10 @@ function addTable() {
|
||||||
hasTranslatedFiles = true;
|
hasTranslatedFiles = true;
|
||||||
// Foreign file is the same as the english file, replacing the language
|
// Foreign file is the same as the english file, replacing the language
|
||||||
const foreignFile = englishFile.replace("en]", `${dataLanguages[languageIndex]}]`).replace("_S_", "_T_")
|
const foreignFile = englishFile.replace("en]", `${dataLanguages[languageIndex]}]`).replace("_S_", "_T_")
|
||||||
const fullForeignFile = `${dataPaths[languageIndex]}/${foreignFile}.png`;
|
const fullForeignFile = `${dataLanguages[languageIndex]}/${foreignFile}.png`;
|
||||||
const img = document.createElement('img');
|
const img = document.createElement('img');
|
||||||
img.className = "screenshot";
|
img.className = "screenshot";
|
||||||
img.src = `../${fullForeignFile}`;
|
img.src = `${baseUrl}/${fullForeignFile}`;
|
||||||
img.title = fullForeignFile;
|
img.title = fullForeignFile;
|
||||||
img.alt = "Missing image";
|
img.alt = "Missing image";
|
||||||
img.width = imageWidth;
|
img.width = imageWidth;
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,6 @@ def generateJavascriptFile():
|
||||||
languages = detectRecordedLanguages()
|
languages = detectRecordedLanguages()
|
||||||
# First item is the list of languages, adding "en" at the beginning
|
# First item is the list of languages, adding "en" at the beginning
|
||||||
data = [["en"] + languages]
|
data = [["en"] + languages]
|
||||||
# Second item is the path of the containing file
|
|
||||||
data.append(["./tests/uitests/src/test/snapshots/images"] + ["./screenshots/" + l for l in languages])
|
|
||||||
files = sorted(
|
files = sorted(
|
||||||
os.listdir("tests/uitests/src/test/snapshots/images/"),
|
os.listdir("tests/uitests/src/test/snapshots/images/"),
|
||||||
key=lambda file: file[file.find("_", 6):],
|
key=lambda file: file[file.find("_", 6):],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue