Skip to content

Commit afefc4e

Browse files
committed
details and somewhat working gs scheme
SQUASHED: AUTO-COMMIT-src-components-tools-lively-container-navbar.js,
1 parent 858ac5a commit afefc4e

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/components/tools/lively-container-navbar.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ export default class LivelyContainerNavbar extends Morph {
437437
return ((a.title || a.name) >= (b.title || b.name)) ? 1 : -1;
438438
})
439439
.filter(ea => ! ea.name.match(/^\./));
440+
debugger
440441
files.unshift({name: "..", type: "directory", url: stats.parent});
441442
return files
442443
}
@@ -629,6 +630,8 @@ export default class LivelyContainerNavbar extends Morph {
629630
var container = lively.query(this, "lively-container")
630631
if (container) await container.editFile();
631632
}
633+
// non-http(s) paths are not normalized by default
634+
const href = System.normalizeSync(link.href);
632635
await this.followPath(link.href);
633636
}
634637

@@ -895,6 +898,8 @@ export default class LivelyContainerNavbar extends Morph {
895898
// console.log("show sublist md" + this.url)
896899

897900
this.showDetailsMD(sublist)
901+
} else if (this.url.match(/^gs:/)) {
902+
this.showDetailsGS(sublist)
898903
} else {
899904
if (!optionsWasHandles) {
900905
this.showDetailsOptions(sublist)
@@ -1056,6 +1061,60 @@ export default class LivelyContainerNavbar extends Morph {
10561061
})
10571062
}
10581063

1064+
async showDetailsGS(sublist) {
1065+
const category = name => {
1066+
const element = this.createDetailsItem(name);
1067+
element.classList.add("subitem", "level1");
1068+
sublist.appendChild(element);
1069+
}
1070+
1071+
const item = (name, callback) => {
1072+
const element = this.createDetailsItem(name);
1073+
element.classList.add("link", "subitem", "level2");
1074+
element.onclick = callback;
1075+
sublist.appendChild(element);
1076+
}
1077+
1078+
const isUnit = this.url.match(/^gs:docs\/units\/([-\w]+)$/);
1079+
if (isUnit) {
1080+
category('Skills');
1081+
const details = await this.url.fetchStats({ details: true });
1082+
details.skills.sortBy().forEach(skillKey => {
1083+
item(skillKey, () => this.followPath('gs:docs/skills/' + skillKey));
1084+
})
1085+
return;
1086+
}
1087+
1088+
const isSkill = this.url.match(/^gs:docs\/skills\/([-\w]+)$/);
1089+
if (isSkill) {
1090+
category('Used By');
1091+
const details = await this.url.fetchStats({ details: true });
1092+
details.usedBy.sortBy().forEach(unitKey => {
1093+
item(unitKey, () => this.followPath('gs:docs/units/' + unitKey));
1094+
})
1095+
return;
1096+
}
1097+
1098+
// fallback: just render something...
1099+
var links = {
1100+
1: 'one',
1101+
2: 'two',
1102+
3: 'three',
1103+
}
1104+
_.keys(links).forEach( name => {
1105+
var item = links[name];
1106+
var element = this.createDetailsItem(name);
1107+
element.classList.add("link");
1108+
element.classList.add("subitem");
1109+
element.classList.add("level" + (name));
1110+
// element.name = this.clearNameMD(item.name)
1111+
element.onclick = (evt) => {
1112+
this.onDetailsItemClick(element, evt)
1113+
}
1114+
sublist.appendChild(element);
1115+
});
1116+
}
1117+
10591118

10601119
async showDetailsOptions(sublist, url) {
10611120
url = url || this.url

0 commit comments

Comments
 (0)