Skip to content

Commit c8ebb12

Browse files
committed
safe commit
1 parent 8428b69 commit c8ebb12

15 files changed

+159
-105
lines changed

docs/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ <h2> How </h2>
223223
</a>
224224

225225
<details style="display: block; margin: 0 auto;">
226-
<summary style="text-align: center;" > More </summary>
226+
227+
<summary id="more-download-options" style="text-align: center;" > More </summary>
227228

228229
<table>
229230
<tr>

javascript/web/src/App.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,12 @@ input[type=range]::-webkit-slider-runnable-track {
251251
252252
253253
/* ![[Ilse]] */
254-
.file-embed {
254+
.html-embed {
255255
margin-left: 10px;
256256
border: 1px solid var( --text-color );
257257
border-radius: var( --border-radius );
258258
padding: var( --padding );
259+
border: 1px solid #000;
259260
}
260261
261262
.cloze-deletion {

javascript/web/src/classes/Commands.js

+13-44
Original file line numberDiff line numberDiff line change
@@ -877,59 +877,28 @@ class Commands {
877877
},
878878

879879
{
880-
id: "open-html-on-window",
880+
id: "open-external-website-on-window",
881881
fn: async function() {
882+
let payload = await ilse.dialog.input( "Query", "Type:" )
883+
let full_path = payload.input
884+
create_window({ title: `${full_path}(Website)`, external: true, url: full_path })
885+
},
886+
description: "Will open a new query windows based on your choice(External).",
887+
name: "Open External Website",
888+
props: {},
889+
},
882890

883-
// let payload = await ilse.dialog.input( "Query", "Type:" )
884-
// printf( "payload -> ", payload )
885-
// let name = payload.input
886-
// printf( "name -> ", name )
887-
// let file = ilse.filesystem.file.read.sync( name + ".html" )
888-
// printf( "file -> ", file )
889-
890-
// create_window({ title: name + ".html", html: file })
891-
// create_window({ title: "Vim", url: `app://${ilse.target_directories[0]}/vim/index.html` })
892-
893-
// let payload = await ilse.dialog.input( "Query", "Type:" )
894-
// let full_path = payload.input
895-
896-
// let file = ilse.filesystem.file.read.sync( full_path + ".html" )
897-
// printf( "file -> ", file )
898-
// let html = file
899-
// window.open( get_target_directory_url() + "iframe.html" )
900-
// let o = window.open(get_target_directory_url(), "lll", "popup");
901-
// printf( "o -> ", o )
902-
903-
// const windowFeatures = "left=100,top=100,width=320,height=320";
904-
// const handle = window.open( get_target_directory_url() + "iframe.html", "mozillaWindow", windowFeatures);
905-
// printf( "handle -> ", handle )
906-
// printf( "html.documentElement -> ", handle.documentElement )
907-
908-
// let html = html_to_string( handle )
909-
// printf( "html -> ", html )
910-
891+
{
892+
id: "open-html-on-window",
893+
fn: async function() {
911894

912895
let payload = await ilse.dialog.input( "Query", "Type:" )
913896
let full_path = payload.input
914897
create_window({ title: `${full_path}(HTML)`, url: full_path })
915898

916-
/*
917-
setTimeout( () => {
918-
printf( "window.frames -> ", window.frames )
919-
let frame = window.frames['ll']
920-
printf( "frame -> ", frame )
921-
frame.contentWindow.postMessage({ number: "LLL" } )
922-
printf( "frame.contentWindow -> ", frame.contentWindow )
923-
printf( "frame.document -> ", frame.document )
924-
printf( "frame.document.body -> ", frame.document.body )
925-
printf( "frame.document.body.innerHTML -> ", frame.document.body.innerHTML )
926-
}, 1000 )
927-
*/
928-
// create_window({ title: "Component", url: `app://${ilse.target_directories[0]}/${full_path}.html` })
929-
930899
},
931900
description: "Will open a new query windows based on your choice.",
932-
name: "Open new Query",
901+
name: "Open HTML",
933902
props: {},
934903
},
935904

javascript/web/src/classes/HTML_TEMPLATE.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
export default `
42
<!DOCTYPE html>
53
<html>
@@ -10,14 +8,11 @@ export default `
108
119
<link rel="icon" type="image/svg" sizes="16x16" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpY29uIGljb24tdGFibGVyIGljb24tdGFibGVyLXBob3RvIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3Ryb2tlLXdpZHRoPSIxIiBzdHJva2U9IiM0ODUzNjEiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+CiAgPHBhdGggc3Ryb2tlPSJub25lIiBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIi8+CiAgPGxpbmUgeDE9IjE1IiB5MT0iOCIgeDI9IjE1LjAxIiB5Mj0iOCIgLz4KICA8cmVjdCB4PSI0IiB5PSI0IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHJ4PSIzIiAvPgogIDxwYXRoIGQ9Ik00IDE1bDQgLTRhMyA1IDAgMCAxIDMgMGw1IDUiIC8+CiAgPHBhdGggZD0iTTE0IDE0bDEgLTFhMyA1IDAgMCAxIDMgMGwyIDIiIC8+Cjwvc3ZnPgoKCg==" >
1210
13-
<script src="ilse.js"></script>-
14-
<link rel="stylesheet" src="ilse.css" >
15-
16-
<title> @TITLE@ </title>
11+
<title> $title </title>
1712
</head>
1813
<body>
1914
<main>
20-
@BODY@
15+
<h1> $title </h1>
2116
</main>
2217
</body>
2318
</html

javascript/web/src/classes/Ilse.js

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const printf = console.log
5252
import SUPPORTED_LANGUAGES from "@/classes/SUPPORTED_LANGUAGES.js"
5353
import CORE_PLUGINS from "@/classes/CORE_PLUGINS.js"
5454
import PERMISSIONS from "@/classes/PERMISSIONS.js"
55+
import HTML_TEMPLATE from "@/classes/HTML_TEMPLATE.js"
5556

5657
// libs
5758
// import { JSFrame } from 'jsframe.js';
@@ -70,6 +71,7 @@ export default class Ilse {
7071
this.DEMO_NOTES = DEMO_NOTES
7172
this.CORE_PLUGINS = CORE_PLUGINS
7273
this.PERMISSIONS = PERMISSIONS
74+
this.HTML_TEMPLATE = HTML_TEMPLATE
7375

7476
// this.u_html = uHTML
7577
this.components = []

javascript/web/src/classes/KeyboardShortcut.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ class KeyboardShortcut {
156156
// s
157157
// { combo: "ctrl+space s s", command: "open-search-modal" },
158158
{ combo: "ctrl+space s g", command: "open-glyph-search" },
159-
{ combo: "ctrl+space s w", command: "open-website-on-window" },
159+
{ combo: "ctrl+space s w w", command: "open-website-on-window" },
160+
{ combo: "ctrl+space s w e", command: "open-external-website-on-window" },
160161
{ combo: "ctrl+space s h", command: "open-html-on-window" },
161162
{ combo: "ctrl+space s v", command: "open-vim" },
162163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
let isFunction = function(obj) {
3+
return typeof obj == 'function' || false;
4+
}
5+
6+
export default class EventEmitter {
7+
8+
constructor() {
9+
10+
// this.last_attempt = 0;
11+
// this.delay = 100;
12+
this.listeners = new Map();
13+
}
14+
15+
on(label, callback) {
16+
this.listeners.has(label) || this.listeners.set(label, []);
17+
this.listeners.get(label).push(callback);
18+
}
19+
20+
off(label, callback) {
21+
let listeners = this.listeners.get(label),
22+
index;
23+
24+
if (listeners && listeners.length) {
25+
index = listeners.reduce((i, listener, index) => {
26+
return (isFunction(listener) && listener === callback) ?
27+
i = index :
28+
i;
29+
}, -1);
30+
31+
if (index > -1) {
32+
listeners.splice(index, 1);
33+
this.listeners.set(label, listeners);
34+
return true;
35+
}
36+
}
37+
return false;
38+
}
39+
40+
emit(label, ...args) {
41+
42+
// printf( ">>>> label -> ", label, args )
43+
// let is_attempting_too_fast = this.last_attempt >= ( Date.now() - this.delay )
44+
// if( is_attempting_too_fast ) return
45+
46+
// this.last_attempt = Date.now()
47+
48+
let listeners = this.listeners.get( label )
49+
// printf( "listeners -> ", listeners )
50+
let has_listeners = listeners && listeners.length
51+
52+
// if( listeners && listeners.length ) {
53+
if( has_listeners ) {
54+
55+
listeners.forEach( listener => {
56+
listener( ...args )
57+
})
58+
59+
return true
60+
}
61+
62+
return false
63+
64+
}
65+
66+
}
67+
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default [ 'read', 'write', 'clipboard', 'notes' ]
1+
export default [ 'read', 'write', 'clipboard', 'notes', 'communication' ]

javascript/web/src/classes/create_window.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function create_window({
1212
id = Math.random().toString().replace("0.", ""),
1313
url,
1414
// is_internal_and_iframe = false,
15-
local = true,
15+
external = false,
1616
title = "Title",
1717
appearanceName = "yosemite",
1818
left = 200,
@@ -27,16 +27,21 @@ export default function create_window({
2727

2828
let frame
2929

30-
if( local ) {
30+
printf( "external -> ", external )
31+
if( external ) {
32+
3133
frame = ilse.frame.create({
3234
title: title,
3335
appearanceName: appearanceName,
3436
left: left, top: top, width: width, height: height,
3537
movable: movable, //Enable to be moved by mouse
3638
resizable: resizable, //Enable to be resized by mouse
37-
html: `<iframe src="${get_target_directory_url()}${url}" style="z-index: 15; width: 100%; height: 100%; overflow: hidden; background: #fff; " > /<iframe>`,
39+
// html: html,
40+
url: url,
41+
// html: `<iframe src="${url}" style="width: 100%; height: 100%; overflow: hidden; background: #fff; " > /<iframe>`,
3842
// url: url,
3943
})
44+
4045
} else {
4146

4247
frame = ilse.frame.create({
@@ -45,12 +50,11 @@ export default function create_window({
4550
left: left, top: top, width: width, height: height,
4651
movable: movable, //Enable to be moved by mouse
4752
resizable: resizable, //Enable to be resized by mouse
48-
html: html,
49-
url: url,
50-
// html: `<iframe src="${url}" style="width: 100%; height: 100%; overflow: hidden; background: #fff; " > /<iframe>`,
53+
html: `<iframe src="${get_target_directory_url()}${url}" style="z-index: 15; width: 100%; height: 100%; overflow: hidden; background: #fff; " > /<iframe>`,
5154
// url: url,
5255
})
5356

57+
5458
}
5559

5660
frame.show()

javascript/web/src/classes/get_plugin_api.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const printf = console.log
33
// Ilse
44
import ilse from "@/ilse.js"
55

6+
// classes
7+
import MessagerFactory from "@/classes/MessagerFactory.js"
8+
69
// functions
710
import string_to_html from "@/classes/string_to_html.js"
811
import create_window from "@/classes/create_window.js"
@@ -11,11 +14,25 @@ const printf = console.log
1114

1215
export default function get_plugin_api( name ) {
1316

17+
const Messager = new MessagerFactory()
18+
19+
Messager.on( "message", payload => {
20+
printf( "get_plugin_api -> payload -> ", payload )
21+
})
22+
1423
const api = {
1524

1625
// Messager: Messager,
1726

18-
notes: has_permission( name, 'notes' ) ? ilse.notes : null,
27+
notes: has_permission( name, 'notes' ) ? ilse.notes : null,
28+
29+
messager: {
30+
// on: has_permission( name, 'communication' ) ? Messager.on : null,
31+
// emit: has_permission( name, 'communication' ) ? Messager.emit : null,
32+
33+
on: Messager.on.bind(Messager),
34+
emit: Messager.emit.bind(Messager),
35+
},
1936

2037
clipboard: {
2138
read: has_permission( name, 'clipboard' ) ? ilse.clipboard.read : null,

javascript/web/src/classes/markdown_it_plugin_embed.js

+13-37
Original file line numberDiff line numberDiff line change
@@ -53,48 +53,24 @@ export default {
5353
return `<iframe src="${url}" frameBorder="0" style="width: 100%;" > </iframe>`
5454
} else if( is_html ) {
5555

56+
printf( "is_html -> url -> ", url )
5657
let exists = ilse.filesystem.file.exists.sync( url )
57-
if( exists ) {
58-
return `<embed src="${get_target_directory_url()}${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" /> `
59-
60-
// let html = ilse.filesystem.file.read.sync( url )
61-
// function string_to_base64( str, type = "text/html" ) {
62-
// let utf8Bytes = encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
63-
// return String.fromCharCode('0x' + p1);
64-
// })
65-
// return `data:${type};base64,` + btoa( utf8Bytes )
66-
// }
67-
68-
// in the HTML, I need to recursively go down and transform them into base64?
69-
// let base64 = string_to_base64( html )
70-
// let dom = string_to_html( html )
71-
72-
// let base = document.createElement( "base" )
73-
// base.href = target_dir + "/"
74-
// dom.head.appendChild( base )
75-
// base64 = string_to_html( dom.documentElement.innerHTML )
76-
77-
// if( is_electron ) return `<embed src="atom://${target_dir}/${url}" style="height: 100%; width: 100%; position: relative; display: inline-block; " /> `
7858

79-
// let base64 = recursively_transform_embed_url_src_into_base64( url )
80-
81-
// if( is_electron ) {
59+
if( exists ) {
60+
return `<iframe class="html-embed" src="${get_target_directory_url()}${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" > </iframe>`
8261

83-
// window.addEventListener( "storage", storage => { printf( "markdown_it_plugin_embed -> storage -> ", storage ) })
84-
// return `<embed src="${base64}" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" /> `
85-
// printf( "LLL>>>>>>>> ilse.u_html -> ", ilse.u_html )
86-
// let id = Math.random().toString().replace( "0.", "" )
87-
// setTimeout( () =>{ let dom = document.getElementById(id) ilse.u.scan( dom ) }, 1000 )
88-
// if( is_electron && is_dev() ) return `<embed src="app://${target_dir}/${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" /> `
89-
// if( is_electron && !is_dev() ) return `<embed src="atom://${target_dir}/${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" /> `
90-
// if( !is_electron ) return `<embed src="file://${target_dir}/${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" /> `
62+
} else {
63+
let has_html_template = ilse.filesystem.file.exists.sync( "html-template.html" )
9164

92-
// } else {
93-
// return `<embed src="file:///${ilse.path.join(target_dir, url)}" style="height: 100%; width: 100%; position: relative; display: inline-block; " /> `
94-
// }
65+
if( has_html_template ) {
66+
let html_template = ilse.filesystem.file.read.sync( "html-template.html" )
67+
ilse.filesystem.file.write.sync( url, html_template.replace( /\$title/gi, url ) )
68+
} else {
69+
ilse.filesystem.file.write.sync( url, ilse.HTML_TEMPLATE.replace( "@title@", url ).replace( "@body@", `<h1> ${url} </h1> ` ) )
70+
}
9571

96-
} else {
97-
return `<span> The file: ${url} does not exists ): </span>`
72+
// return `<embed class="html-embed" src="${get_target_directory_url()}${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" /> `
73+
return `<iframe class="html-embed" src="${get_target_directory_url()}${url}" data-event-click="on_click" data-prop-label="Exampleeee" style="height: ${size ? size : 30}vh; width: 100%; overflow: hidden;" > </iframe>`
9874
}
9975

10076
} else if( is_file ) {

javascript/web/src/components/Configuration.vue

+11-4
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@
9898
p( style="display: none;" ) {{set_marketplace_items()}}
9999

100100
.loop( v-for="( item, index ) in marketplace" :key="index" style="width: 30%; height: auto; overflow: hidden; border: 1px dashed var( --text-color ); border-radius: var( --border-radius ); float: left; margin-bottom: 5px; margin-left: 5px; " )
101-
p.is-centered {{item.name}}
101+
p.is-centered {{item.name}}({{item.id}})
102102
button.slick-button( style="position: relative; bottom: 1px;" @click="try_app(item)") demo
103+
button.slick-button( style="position: relative; bottom: 1px;" @click="download_app(item)") download
103104
details
104105
summary Description
105106
p {{item.description}}
@@ -181,10 +182,16 @@ export default {
181182
182183
methods: {
183184
185+
async download_app( item ) {
186+
187+
printf( "it" )
188+
// let res = await fetch( item.url )
189+
// let html = await res.text()
190+
191+
// await ilse.filesystem.file.write.async( item.name, html )
192+
},
193+
184194
async try_app( item ) {
185-
// printf( "res -> ", res )
186-
// printf( "html -> ", html )
187-
// create_window({ title: `${item.name} Demo`, url: item.url })
188195
189196
let res = await fetch( item.url)
190197
let html = await res.text()

0 commit comments

Comments
 (0)