diff --git a/src/js/src/main/app.html b/src/js/src/main/app.html
index 810669b..5bfea9d 100644
--- a/src/js/src/main/app.html
+++ b/src/js/src/main/app.html
@@ -120,7 +120,6 @@
}
}
-
function selectTab(index) {
query("li.tab.selected").forEach(function (val) {
val.classList.remove("selected");
@@ -143,12 +142,22 @@
query("#logarea")[0].value = logs;
}
- function readyWeb() {
+ /**
+ * solitude web版でのsolitudeオブジェクトの組み立てを行う
+ */
+ function readyWeb() {
const solitude = buildWebSolitude();
const apps = window.tmp.solitudeapps;
solitude.apps = () => apps;
addProperty(solitude);
- return solitude
+ return solitude;
+
+ function buildWebSolitude(global) {
+ const solitude = {};
+ solitude.write = {}
+ solitude.write.local = (path, contents) => { append(contents) };
+ return solitude;
+ }
function addProperty(app) {
//solitude本体を設定しているような表現をしたいための回りくどい書き方
@@ -156,32 +165,52 @@
get style() { return "web"},
"write" :{
"local": writeLocal,
+ },
+
+ "read" :{
+ "local":readLocal
}
+
+
}
- app.write = solitude.write
+ //ここからsolitudeに設定したプロパティをappへうつす
+ app.write = solitude.write;
+ app.read = solitude.read;
for(prop in solitude) {
Object.defineProperty(app, prop, {
get() { return solitude[prop]}
})
}
- }
- function writeLocal(path, contents) {
- solitude.io.fs.download(path, cotents, "text/plain");
+ return;
+ function writeLocal(path, contents) {
+ solitude.io.fs.download(path, cotents, "text/plain");
+ }
+
+ function readLocal(path) {
+ // stringで解決するPromiseを返したい。
+ return fetch(path)
+ .then((response) => {
+ if(response.ok) {
+ return response.text();
+ } else {
+ throw new Error(`HTTP error, status = ${response.status}`);
+ }
+ },
+ (cause) => {
+ const error = new Error('ファイルのオープンに失敗しました。causeプロパティで原因となったオブジェクトを返します。');
+ error.cause = cause;
+ throw error
+ });
+ }
}
}
- function buildWebSolitude(global) {
- const solitude = {};
- solitude.write = {}
- solitude.write.local = (path, contents) => { append(contents) };
- return solitude;
- }
function initializeSolitudeApps(apps) {
for (const [name, conf] of Object.entries(apps)) {
@@ -295,6 +324,7 @@
const base = app.querySelector("div.main-article");
base.classList.remove("undefined");
+ /*
const staticpage = fetch(conf.src)
.then((res) => {
if(res.ok) {
@@ -309,6 +339,15 @@
base.querySelector("div.app-container").appendChild(content);
mount.appendChild(base)
});
+ */
+
+ solitude.read.local(conf.src).then((text) => {
+ const parser = new DOMParser()
+ const doc = parser.parseFromString(text, "text/html");
+ const content = doc.querySelector("div.app-body").cloneNode(true);
+ base.querySelector("div.app-container").appendChild(content);
+ mount.appendChild(base)
+ })
}
}