@@ -25,7 +25,9 @@ export async function ipfsAdd(coll, downloaderOpts = {}, replayOpts = {}, progre
25
25
downloaderOpts . markers = { ZIP , WARC_PAYLOAD , WARC_GROUP } ;
26
26
}
27
27
28
- const dl = new Downloader ( { ...downloaderOpts , coll, filename, gzip : false } ) ;
28
+ const gzip = replayOpts . gzip !== undefined ? replayOpts . gzip : true ;
29
+
30
+ const dl = new Downloader ( { ...downloaderOpts , coll, filename, gzip} ) ;
29
31
const dlResponse = await dl . download ( progress ) ;
30
32
31
33
if ( ! coll . config . metadata . ipfsPins ) {
@@ -53,8 +55,16 @@ export async function ipfsAdd(coll, downloaderOpts = {}, replayOpts = {}, progre
53
55
UnixFS . withCapacity ( capacity )
54
56
) ;
55
57
56
- const swContent = await fetchBuffer ( "sw.js" , replayOpts . replayBaseUrl ) ;
57
- const uiContent = await fetchBuffer ( "ui.js" , replayOpts . replayBaseUrl ) ;
58
+ const swContent = await fetchBuffer ( "sw.js" , replayOpts . replayBaseUrl || self . location . href ) ;
59
+ const uiContent = await fetchBuffer ( "ui.js" , replayOpts . replayBaseUrl || self . location . href ) ;
60
+
61
+ let favicon = null ;
62
+
63
+ try {
64
+ favicon = await fetchBuffer ( "https://replayweb.page/build/icon.png" ) ;
65
+ } catch ( e ) {
66
+ console . warn ( "Couldn't load favicon" ) ;
67
+ }
58
68
59
69
let url , cid ;
60
70
@@ -74,7 +84,7 @@ export async function ipfsAdd(coll, downloaderOpts = {}, replayOpts = {}, progre
74
84
writable ,
75
85
dlResponse . filename , dlResponse . body ,
76
86
swContent , uiContent , replayOpts ,
77
- downloaderOpts . markers ,
87
+ downloaderOpts . markers , favicon ,
78
88
) ;
79
89
80
90
await p ;
@@ -90,8 +100,14 @@ export async function ipfsAdd(coll, downloaderOpts = {}, replayOpts = {}, progre
90
100
91
101
export async function ipfsRemove ( coll ) {
92
102
if ( coll . config . metadata . ipfsPins ) {
93
- //TODO: need remove support in auto-js-ipfs
94
- //await ipfsUnpinAll(this, coll.config.metadata.ipfsPins);
103
+
104
+ for ( const { url} of coll . config . metadata . ipfsPins ) {
105
+ try {
106
+ await autoipfs . clear ( url ) ;
107
+ } catch ( e ) {
108
+ console . log ( "Removal from this IPFS backend not yet implemented" ) ;
109
+ }
110
+ }
95
111
96
112
coll . config . metadata . ipfsPins = null ;
97
113
return true ;
@@ -100,7 +116,7 @@ export async function ipfsRemove(coll) {
100
116
return false ;
101
117
}
102
118
103
- async function fetchBuffer ( filename , replayBaseUrl = self . location . href ) {
119
+ async function fetchBuffer ( filename , replayBaseUrl ) {
104
120
const resp = await fetch ( new URL ( filename , replayBaseUrl ) . href ) ;
105
121
106
122
return new Uint8Array ( await resp . arrayBuffer ( ) ) ;
@@ -121,7 +137,7 @@ async function ipfsWriteBuff(writer, name, content, dir) {
121
137
122
138
// ===========================================================================
123
139
export async function ipfsGenerateCar ( writable , waczPath ,
124
- waczContent , swContent , uiContent , replayOpts , markers ) {
140
+ waczContent , swContent , uiContent , replayOpts , markers , favicon ) {
125
141
126
142
const writer = UnixFS . createWriter ( { writable } ) ;
127
143
@@ -141,6 +157,10 @@ export async function ipfsGenerateCar(writable, waczPath,
141
157
await ipfsWriteBuff ( writer , "sw.js" , swContent , rootDir ) ;
142
158
}
143
159
160
+ if ( favicon ) {
161
+ await ipfsWriteBuff ( writer , "favicon.ico" , favicon , rootDir ) ;
162
+ }
163
+
144
164
await ipfsWriteBuff ( writer , "index.html" , encoder . encode ( htmlContent ) , rootDir ) ;
145
165
146
166
if ( ! markers ) {
@@ -354,7 +374,7 @@ export async function encodeBlocks(blocks, root) {
354
374
}
355
375
356
376
function getReplayHtml ( waczPath , replayOpts = { } ) {
357
- const { showEmbed, pageUrl, pageTitle } = replayOpts ;
377
+ const { showEmbed, pageUrl, pageTitle, deepLink } = replayOpts ;
358
378
359
379
return `
360
380
<!doctype html>
@@ -375,7 +395,7 @@ function getReplayHtml(waczPath, replayOpts = {}) {
375
395
</style>
376
396
</head>
377
397
<body>${ showEmbed ? `
378
- <replay-web-page deepLink="true" url="${ pageUrl } " embed="replay-with-info" src="${ waczPath } "></replay-web-page>` : `
398
+ <replay-web-page ${ deepLink ? `deepLink ="true" ` : "" } url="${ pageUrl } " embed="replay-with-info" src="${ waczPath } "></replay-web-page>` : `
379
399
<replay-app-main source="${ waczPath } "></replay-app-main>`
380
400
}
381
401
</body>
0 commit comments