@@ -25,30 +25,19 @@ const humanReadablePane = {
2525 return icons . iconBase + 'markdown.svg'
2626 }
2727
28- // Dokieli files detected by RDF metadata (synchronous)
28+ // Dokieli files detected by content check
2929 if ( subject ) {
3030 const kb = context . session . store
3131
32- // Check RDF for dokieli stylesheets
33- const stylesheets = kb . each ( subject , ns . link ( 'stylesheet' ) )
34- const isDokieliByRDF = stylesheets . some ( s =>
35- s . uri && s . uri . includes ( 'dokie.li/media/css/dokieli.css' )
36- )
37-
38- if ( isDokieliByRDF ) {
39- dokieliCache . set ( subject . uri , 'dokieli' )
40- return icons . iconBase + 'dokieli-logo.png'
41- }
42-
43- // Check cache from previous content detection
32+ // Check cache from previous detection
4433 const cachedResult = dokieliCache . get ( subject . uri )
4534 if ( cachedResult === 'dokieli' ) {
4635 return icons . iconBase + 'dokieli-logo.png'
4736 } else if ( cachedResult === 'html' ) {
4837 return icons . originalIconBase + 'tango/22-text-x-generic.png'
4938 }
5039
51- // Not in RDF or cache - check if content already fetched
40+ // Check if content already fetched (synchronous)
5241 const responseText = kb . fetcher . getHeader ( subject . doc ( ) , 'content' )
5342 if ( responseText && responseText . length > 0 ) {
5443 const text = responseText [ 0 ]
@@ -59,6 +48,27 @@ const humanReadablePane = {
5948 ? icons . iconBase + 'dokieli-logo.png'
6049 : icons . originalIconBase + 'tango/22-text-x-generic.png'
6150 }
51+
52+ // Content not yet fetched - return a promise (async detection)
53+ const cts = kb . fetcher . getHeader ( subject . doc ( ) , 'content-type' )
54+ const ct = cts ? cts [ 0 ] . split ( ';' , 1 ) [ 0 ] . trim ( ) : null
55+
56+ if ( ct === 'text/html' ) {
57+ return kb . fetcher . _fetch ( subject . uri )
58+ . then ( response => response . text ( ) )
59+ . then ( text => {
60+ const isDokieli = text . includes ( '<script src="https://dokie.li/scripts/dokieli.js">' ) ||
61+ text . includes ( 'dokieli.css' )
62+ dokieliCache . set ( subject . uri , isDokieli ? 'dokieli' : 'html' )
63+ return isDokieli
64+ ? icons . iconBase + 'dokieli-logo.png'
65+ : icons . originalIconBase + 'tango/22-text-x-generic.png'
66+ } )
67+ . catch ( ( ) => {
68+ dokieliCache . set ( subject . uri , 'html' )
69+ return icons . originalIconBase + 'tango/22-text-x-generic.png'
70+ } )
71+ }
6272 }
6373
6474 // Default for all other human-readable content
@@ -201,7 +211,7 @@ const humanReadablePane = {
201211
202212 // Apply sandbox for HTML/XHTML
203213 if ( ct === 'text/html' || ct === 'application/xhtml+xml' ) {
204- frame . setAttribute ( 'sandbox' , 'allow-scripts allow-same-origin' )
214+ frame . setAttribute ( 'sandbox' , 'allow-scripts allow-same-origin allow-forms ' )
205215 }
206216
207217 // Fetch content to calculate lines dynamically
0 commit comments