Skip to content

Commit 934864a

Browse files
committed
change: remove nanoid
1 parent ea78345 commit 934864a

File tree

1 file changed

+57
-58
lines changed

1 file changed

+57
-58
lines changed

src/backend/Backend.ts

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Env, PID } from 'src/api'
88
import { GistrSettings } from 'src/settings/settings'
99
import { lng } from 'src/lang'
1010
import { SaturynHandleSyntax } from 'src/api/Saturyn'
11-
import { nanoid } from 'nanoid'
1211

1312
/*
1413
Basic Declrations
@@ -177,7 +176,7 @@ zoom: ${n_zoom}
177176
compile url to gist
178177
*/
179178

180-
let gistSrcURL = !bIsEmpty( file ) ? `https://${host}${username}/${uuid}.json?file=${file}` : `https://${host}${username}/${uuid}.json`
179+
let gistSrcURL = !bIsEmpty( file ) ? `https://${ host }${ username }/${ uuid }.json?file=${ file }` : `https://${ host }${ username }/${ uuid }.json`
181180

182181
/*
183182
This should be a theme specified by the user in the codeblock; NOT their theme setting
@@ -206,11 +205,11 @@ zoom: ${n_zoom}
206205
const req = await request( reqUrlParams )
207206
const json = JSON.parse( req ) as ItemJSON
208207

209-
return this.GistGenerate( el, host, uuid, json, bMatchGithub, styles )
208+
return this.GistGenerate( plugin, el, host, uuid, json, bMatchGithub, styles )
210209
}
211210
catch ( err )
212211
{
213-
return this.ThrowError( el, data, `Invalid gist url ${gistSrcURL} ( ${err} )` )
212+
return this.ThrowError( el, data, `Invalid gist url ${ gistSrcURL } ( ${ err } )` )
214213
}
215214
}
216215

@@ -243,14 +242,14 @@ zoom: ${n_zoom}
243242
create new iframe for each gist, assign it a uid, set the needed attributes, and generate the css, js
244243
*/
245244

246-
private async GistGenerate( el: HTMLElement, host: string, uuid: string, json: ItemJSON, bGithub: boolean, style: StyleProperties )
245+
private async GistGenerate( plugin: GistrPlugin, el: HTMLElement, host: string, uuid: string, json: ItemJSON, bGithub: boolean, style: StyleProperties )
247246
{
248247

249248
/*
250249
create uuid and iframe
251250
*/
252251

253-
const gid = `${ sender }-${ uuid }-${ nanoid( ) }`
252+
const gid = `${ sender }-${ uuid }-${ plugin.generateUuid( ) }`
254253
const ct_iframe = document.createElement( 'iframe' )
255254
ct_iframe.id = gid
256255

@@ -265,26 +264,26 @@ zoom: ${n_zoom}
265264
policy directive error if certain attributes arent used. doesnt affect the plugin, but erors are bad
266265
*/
267266

268-
ct_iframe.setAttribute ( 'csp', "default-src * data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';" )
267+
ct_iframe.setAttribute ( 'csp', "default-src * data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';" )
269268

270269
/*
271270
assign css, body, js
272271
*/
273272

274-
let css_theme_ovr = ( style.theme !== "" ) ? style.theme.toLowerCase( ) : ""
275-
let css_theme_sel = ( css_theme_ovr !== "" ) ? css_theme_ovr : ( this.settings.theme.toLowerCase( ) == "dark" ) ? "dark" : ( this.settings.theme.toLowerCase( ) == "light" ) ? "light" : "light"
276-
let css_og = ""
277-
let css_gh = ""
273+
let css_theme_ovr = ( style.theme !== "" ) ? style.theme.toLowerCase( ) : ""
274+
let css_theme_sel = ( css_theme_ovr !== "" ) ? css_theme_ovr : ( this.settings.theme.toLowerCase( ) == "dark" ) ? "dark" : ( this.settings.theme.toLowerCase( ) == "light" ) ? "light" : "light"
275+
let css_og = ""
276+
let css_gh = ""
278277

279-
const content_css = await this.GetCSS( el, uuid, ( bGithub ? json.stylesheet: json.embed.css ) )
280-
const content_body = ( bGithub ? json.div : "" )
281-
const content_js = ( bGithub ? "" : await this.GetJavascript( el, uuid, ( css_theme_sel == "dark" ? json.embed.js_dark : json.embed.js ) ) )
278+
const content_css = await this.GetCSS( el, uuid, ( bGithub ? json.stylesheet: json.embed.css ) )
279+
const content_body = ( bGithub ? json.div : "" )
280+
const content_js = ( bGithub ? "" : await this.GetJavascript( el, uuid, ( css_theme_sel == "dark" ? json.embed.js_dark : json.embed.js ) ) )
282281

283282
/*
284283
Declare custom css override
285284
*/
286285

287-
const css_override = ( ( bGithub && this.settings.css_gh && this.settings.css_gh.length > 0 ) ? ( this.settings.css_gh ) : ( this.settings.css_og && this.settings.css_og.length > 0 && this.settings.css_og ) ) || ""
286+
const css_override = ( ( bGithub && this.settings.css_gh && this.settings.css_gh.length > 0 ) ? ( this.settings.css_gh ) : ( this.settings.css_og && this.settings.css_og.length > 0 && this.settings.css_og ) ) || ""
288287

289288
/*
290289
Update style theme value
@@ -348,7 +347,7 @@ zoom: ${n_zoom}
348347
349348
</head>
350349
351-
<body class="gistr-theme-${css_theme_sel}">
350+
<body class="gistr-theme-${ css_theme_sel }">
352351
${ content_body }
353352
</body>
354353
</html>
@@ -379,64 +378,64 @@ zoom: ${n_zoom}
379378
return `
380379
::-webkit-scrollbar
381380
{
382-
width: 6px;
383-
height: 10px;
381+
width: 6px;
382+
height: 10px;
384383
}
385384
386385
::-webkit-scrollbar-track
387386
{
388-
background-color: transparent;
389-
border-radius: 5px;
390-
margin: 1px;
387+
background-color: transparent;
388+
border-radius: 5px;
389+
margin: 1px;
391390
}
392391
393392
::-webkit-scrollbar-thumb
394393
{
395-
border-radius: 10px;
396-
background-color: ${css_og_sb_color};
394+
border-radius: 10px;
395+
background-color: ${ css_og_sb_color };
397396
}
398397
399398
.opengist-embed .code
400399
{
401-
padding-top: ${this.settings.blk_pad_t}px;
402-
padding-bottom: ${this.settings.blk_pad_b}px;
403-
border-top: ${css_og_bg_header_bor};
404-
background-color: ${css_og_bg_color};
405-
width: fit-content;
406-
margin-top: -1px;
407-
background: ${css_og_bg};
408-
background-size: cover;
400+
padding-top: ${ this.settings.blk_pad_t }px;
401+
padding-bottom: ${ this.settings.blk_pad_b }px;
402+
border-top: ${ css_og_bg_header_bor };
403+
background-color: ${ css_og_bg_color };
404+
width: fit-content;
405+
margin-top: -1px;
406+
background: ${ css_og_bg };
407+
background-size: cover;
409408
}
410409
411410
.opengist-embed .mb-4
412411
{
413-
margin-bottom: 1rem;
414-
backdrop-filter: opacity(0);
415-
--tw-bg-opacity: 1;
416-
background-color: ${css_og_bg_header_bg};
417-
opacity: ${css_og_opacity};
412+
margin-bottom: 1rem;
413+
backdrop-filter: opacity(0);
414+
--tw-bg-opacity: 1;
415+
background-color: ${ css_og_bg_header_bg };
416+
opacity: ${ css_og_opacity };
418417
}
419418
420419
.opengist-embed .line-code
421420
{
422-
color: #${css_og_tx_color_user};
421+
color: #${ css_og_tx_color_user };
423422
}
424423
425424
.opengist-embed .code .line-num
426425
{
427-
color: #${css_og_tx_color_user};
428-
opacity: 0.5;
426+
color: #${ css_og_tx_color_user };
427+
opacity: 0.5;
429428
}
430429
431430
.opengist-embed .code .line-num:hover
432431
{
433-
color: #${css_og_tx_color_user};
434-
opacity: 1;
432+
color: #${ css_og_tx_color_user };
433+
opacity: 1;
435434
}
436435
437436
.opengist-embed .whitespace-pre
438437
{
439-
white-space: ${css_og_wrap};
438+
white-space: ${ css_og_wrap };
440439
}
441440
`
442441
}
@@ -476,7 +475,7 @@ zoom: ${n_zoom}
476475
::-webkit-scrollbar-thumb
477476
{
478477
border-radius: 10px;
479-
background-color: ${css_gh_sb_color};
478+
background-color: ${ css_gh_sb_color };
480479
}
481480
482481
body
@@ -490,7 +489,7 @@ zoom: ${n_zoom}
490489
backdrop-filter: opacity( 0 );
491490
background-color: rgb( 35 36 41/var( --tw-bg-opacity ) );
492491
border: 2px solid rgba( 255, 255, 255, 0.1 );
493-
opacity: ${css_gh_opacity};
492+
opacity: ${ css_gh_opacity };
494493
}
495494
496495
body .gist .gist-data
@@ -499,9 +498,9 @@ zoom: ${n_zoom}
499498
padding-right: 12px;
500499
padding-top: 15px;
501500
padding-bottom: 6px;
502-
border-color: ${css_gh_bg_header_bor};
503-
background-color: ${css_gh_bg_color};
504-
background: ${css_gh_bg};
501+
border-color: ${ css_gh_bg_header_bor };
502+
background-color: ${ css_gh_bg_color };
503+
background: ${ css_gh_bg };
505504
background-size: cover;
506505
background-size: cover;
507506
}
@@ -514,7 +513,7 @@ zoom: ${n_zoom}
514513
515514
body .gist .markdown-body
516515
{
517-
color: ${css_gh_tx_color};
516+
color: ${ css_gh_tx_color };
518517
line-height: 18.2px;
519518
font-size: 0.8em;
520519
border-spacing: 0;
@@ -525,8 +524,8 @@ zoom: ${n_zoom}
525524
body .gist .gist-meta
526525
{
527526
color: #6b869f;
528-
border-top: ${css_gh_bg_header_bor};
529-
background-color: ${css_gh_bg_header_bg};
527+
border-top: ${ css_gh_bg_header_bor };
528+
background-color: ${ css_gh_bg_header_bg };
530529
padding-left: 22px;
531530
padding-right: 16px;
532531
padding-top: 8px;
@@ -541,15 +540,15 @@ zoom: ${n_zoom}
541540
542541
body .gist .gist-meta a.Link--inTextBlock:hover
543542
{
544-
color: ${css_gh_tx_color};
543+
color: ${ css_gh_tx_color };
545544
opacity: 0.5;
546545
}
547546
548547
body .gist .gist-meta a.Link--inTextBlock
549548
{
550549
padding-left: 0px;
551550
padding-right: 7px;
552-
color: ${css_gh_tx_color};
551+
color: ${ css_gh_tx_color };
553552
}
554553
555554
body .gist .gist-meta > a:nth-child( 3 )
@@ -575,29 +574,29 @@ zoom: ${n_zoom}
575574
body .gist .pl-s2, body .gist .pl-stj, body .gist .pl-vo,
576575
body .gist .pl-id, body .gist .pl-ii
577576
{
578-
color: #${css_gh_tx_color_user};
577+
color: #${ css_gh_tx_color_user };
579578
}
580579
581580
body .gist .blob-code
582581
{
583-
color: #${css_gh_tx_color_user};
582+
color: #${ css_gh_tx_color_user };
584583
}
585584
586585
body .gist .blob-num, body .gist .blob-code-inner,
587586
{
588-
color: #${css_gh_tx_color_user};
587+
color: #${ css_gh_tx_color_user };
589588
opacity: 0.5;
590589
}
591590
592591
body .gist .blob-num:hover
593592
{
594-
color: #${css_gh_tx_color_user};
593+
color: #${ css_gh_tx_color_user };
595594
opacity: 1;
596595
}
597596
598597
body .gist .blob-wrapper tr:first-child td
599598
{
600-
text-wrap: ${css_gh_wrap};
599+
text-wrap: ${ css_gh_wrap };
601600
}
602601
603602
body.gistr-theme-dark .gist .pl-s1
@@ -788,7 +787,7 @@ zoom: ${n_zoom}
788787

789788
const uuid = evn.data.gid
790789
const scrollHeight = evn.data.scrollHeight
791-
790+
792791
const gist_Container: HTMLElement = document.querySelector( 'iframe#' + uuid )
793792

794793
gist_Container.setAttribute( 'height', scrollHeight )

0 commit comments

Comments
 (0)