44** The dokeili system allows the user to edit a document including anotations
55** review. It does not use turtle, but RDF/a
66*/
7- var UI = require ( 'solid-ui' )
7+ const UI = require ( 'solid-ui' )
8+ const mime = require ( 'mime-types' )
89
910// const DOKIELI_TEMPLATE_URI = 'https://dokie.li/new' // Copy to make new dok
1011
@@ -65,17 +66,25 @@ module.exports = {
6566 // Create a new folder in a Solid system, with a dokieli editable document in it
6667 mintNew : function ( newPaneOptions ) {
6768 var kb = UI . store
68- var newInstance = newPaneOptions . newInstance || kb . sym ( newPaneOptions . newBase )
69- console . log ( 'New dok called with ' + newInstance )
70- var u = newInstance . uri
71- if ( u . endsWith ( '/' ) ) {
72- u = u + 'index.html'
69+ var newInstance = newPaneOptions . newInstance
70+ if ( ! newInstance ) {
71+ let uri = newPaneOptions . newBase
72+ if ( uri . endsWith ( '/' ) ) {
73+ uri = uri . slice ( 0 , - 1 )
74+ newPaneOptions . newBase = uri
75+ }
76+ newInstance = kb . sym ( uri )
77+ newPaneOptions . newInstance = newInstance
7378 }
74- if ( ! u . endsWith ( '.html' ) ) {
75- u = u + '.html'
79+
80+ var contentType = mime . lookup ( newInstance . uri )
81+ if ( ! contentType || ! contentType . includes ( 'html' ) ) {
82+ let msg = 'A new text file has to have an file extension like .html .htm etc.'
83+ alert ( msg )
84+ throw new Error ( msg )
7685 }
77- newPaneOptions . newInstance = newInstance = kb . sym ( u )
78- console . log ( 'New dok will make: ' + newInstance )
86+
87+ console . log ( 'New dokieli will make: ' + newInstance )
7988 /*
8089 return new Promise(function(resolve, reject){
8190 kb.fetcher.webCopy(DOKIELI_TEMPLATE_URI, newInstance.uri, 'text/html')
@@ -115,9 +124,9 @@ module.exports = {
115124 var cts = kb . fetcher . getHeader ( subject . doc ( ) , 'content-type' )
116125 var ct = cts ? cts [ 0 ] : null
117126 if ( ct ) {
118- console . log ( 'humanReadablePane : c-t:' + ct )
127+ console . log ( 'dokieliPane : c-t:' + ct )
119128 } else {
120- console . log ( 'humanReadablePane : unknown content-type?' )
129+ console . log ( 'dokieliPane : unknown content-type?' )
121130 }
122131
123132 // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
@@ -128,7 +137,7 @@ module.exports = {
128137
129138 // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
130139
131- iframe . setAttribute ( 'style' , 'resize = both; height: 120em ; width:80em ;' )
140+ iframe . setAttribute ( 'style' , 'resize = both; height: 40em ; width:40em ;' ) // @@ improve guess
132141 // iframe.setAttribute('height', '480')
133142 // iframe.setAttribute('width', '640')
134143 var tr = myDocument . createElement ( 'TR' )
0 commit comments