@@ -4,6 +4,7 @@ import { languageToFontsCss } from '../components/svgs/nodes/text';
4
4
import { EdgeAttributes , GraphAttributes , NodeAttributes , NodeType } from '../constants/constants' ;
5
5
import { MiscNodeType } from '../constants/nodes' ;
6
6
import { StationType } from '../constants/stations' ;
7
+ import i18n from '../i18n/config' ;
7
8
import { FONTS_CSS , makeBase64EncodedFontsStyle } from './fonts' ;
8
9
import { findNodesExist } from './graph' ;
9
10
import { calculateCanvasSize } from './helpers' ;
@@ -46,7 +47,7 @@ export const makeRenderReadySVGElement = async (
46
47
47
48
const elem = document . getElementById ( 'canvas' ) ! . cloneNode ( true ) as SVGSVGElement ;
48
49
// append rmp info if user does not want to share rmp info
49
- if ( ! generateRMPInfo ) elem . appendChild ( generateRmpInfo ( xMax - 400 , yMax - 120 ) ) ;
50
+ if ( ! generateRMPInfo ) elem . appendChild ( await generateRmpInfo ( xMax - 400 , yMax - 120 ) ) ;
50
51
// reset svg viewBox to display all the nodes in the graph
51
52
// otherwise the later drawImage won't be able to show all of them
52
53
elem . setAttribute ( 'viewBox' , `${ xMin } ${ yMin } ${ width } ${ height } ` ) ;
@@ -228,29 +229,37 @@ const loadFacilitiesSvg = async (
228
229
}
229
230
} ;
230
231
231
- const generateRmpInfo = ( x : number , y : number ) => {
232
+ const generateRmpInfo = async ( x : number , y : number ) => {
232
233
const info = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'g' ) ;
233
234
info . setAttribute ( 'transform' , `translate(${ x } , ${ y } )scale(2)` ) ;
234
235
235
- const logo = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'image' ) ;
236
- // FIXME: return after image is loaded
237
- // logo.setAttribute('href', 'https://uat-railmapgen.github.io/rmp/logo192.png');
238
- // logo.setAttribute('href', logoImg);
239
- logo . setAttribute ( 'width' , '40' ) ;
240
- logo . setAttribute ( 'height' , '40' ) ;
241
- logo . setAttribute ( 'x' , '-50' ) ;
242
- logo . setAttribute ( 'y' , '-20' ) ;
236
+ const logoSVGRep = await fetch ( import . meta. env . BASE_URL + `/logo.svg` ) ;
237
+ const logoSVG = await logoSVGRep . text ( ) ;
238
+ const temp = document . createElement ( 'div' ) ;
239
+ temp . innerHTML = logoSVG ;
240
+ const svg = temp . querySelector ( 'svg' ) ! ;
241
+ const logo = document . createElement ( 'g' ) ;
242
+ logo . setAttribute ( 'transform' , `translate(-60, -25)scale(0.1)` ) ;
243
+ logo . setAttribute ( 'font-family' , 'Arial, sans-serif' ) ;
244
+ logo . innerHTML = svg . innerHTML ;
245
+ info . appendChild ( logo ) ;
243
246
244
247
const rmp = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'text' ) ;
245
248
rmp . setAttribute ( 'font-family' , 'Arial, sans-serif' ) ;
246
249
rmp . setAttribute ( 'font-size' , '16' ) ;
247
- rmp . appendChild ( document . createTextNode ( 'Rail Map Painter' ) ) ;
250
+ const appName = i18n . t ( 'Rail Map Painter' ) ;
251
+ rmp . appendChild ( document . createTextNode ( appName ) ) ;
248
252
249
253
const link = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'text' ) ;
250
254
link . setAttribute ( 'font-family' , 'Arial, sans-serif' ) ;
251
255
link . setAttribute ( 'font-size' , '10' ) ;
252
256
link . setAttribute ( 'y' , '10' ) ;
253
- link . appendChild ( document . createTextNode ( 'https://railmapgen.github.io/rmp/' ) ) ;
257
+ const origin = window . location . origin ;
258
+ let url = 'https://railmapgen.org/' ;
259
+ if ( origin . includes ( 'github' ) ) url = 'https://railmapgen.github.io/' ;
260
+ else if ( origin . includes ( 'gitlab' ) ) url = 'https://railmapgen.gitlab.io/' ;
261
+ url += '?app=rmp' ;
262
+ link . appendChild ( document . createTextNode ( url ) ) ;
254
263
255
264
info . appendChild ( logo ) ;
256
265
info . appendChild ( rmp ) ;
0 commit comments