构建索引页
This commit is contained in:
parent
3ef65d13e8
commit
ff7b9d7e7a
|
@ -66,6 +66,8 @@ int main(int argc, char* argv[]) {
|
||||||
for (auto& node : tool.volume_defines)
|
for (auto& node : tool.volume_defines)
|
||||||
html_output(node);
|
html_output(node);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_print =
|
std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_print =
|
||||||
[&](std::shared_ptr<const ast_gen::ElementAccess> node, int intend) {
|
[&](std::shared_ptr<const ast_gen::ElementAccess> node, int intend) {
|
||||||
auto name = node->element()->signature();
|
auto name = node->element()->signature();
|
||||||
|
@ -80,6 +82,70 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
QFile tfile("./index.html");
|
||||||
|
if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QDomDocument doc_inst(QDomImplementation().createDocumentType(u8"html", QString(), QString()));
|
||||||
|
auto html = doc_inst.createElement(u8"html");
|
||||||
|
doc_inst.appendChild(html);
|
||||||
|
|
||||||
|
auto body = doc_inst.createElement(u8"body");
|
||||||
|
html.appendChild(body);
|
||||||
|
|
||||||
|
auto dom_storyline = doc_inst.createElement("div");
|
||||||
|
auto dom_storyline_title = doc_inst.createElement("h2");
|
||||||
|
dom_storyline_title.appendChild(doc_inst.createTextNode(u8"故事脉络"));
|
||||||
|
dom_storyline.appendChild(dom_storyline_title);
|
||||||
|
body.appendChild(dom_storyline);
|
||||||
|
|
||||||
|
for (auto& inst_line : tool.storyline_defines) {
|
||||||
|
auto dom_line = doc_inst.createElement("p");
|
||||||
|
dom_storyline.appendChild(dom_line);
|
||||||
|
|
||||||
|
auto line_href = doc_inst.createElement("a");
|
||||||
|
line_href.setAttribute(u8"href", u8"file:///"+inst_line->pageRefers());
|
||||||
|
line_href.appendChild(doc_inst.createTextNode(inst_line->accessPeers()->element()->signature()));
|
||||||
|
dom_line.appendChild(line_href);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dom_volume = doc_inst.createElement("div");
|
||||||
|
auto dom_volume_title = doc_inst.createElement("h2");
|
||||||
|
dom_volume_title.appendChild(doc_inst.createTextNode(u8"分卷内容"));
|
||||||
|
dom_volume.appendChild(dom_volume_title);
|
||||||
|
body.appendChild(dom_volume);
|
||||||
|
|
||||||
|
for (auto& inst_volume : tool.volume_defines) {
|
||||||
|
auto dom_volume_ref = doc_inst.createElement("p");
|
||||||
|
dom_volume.appendChild(dom_volume_ref);
|
||||||
|
|
||||||
|
auto volume_href = doc_inst.createElement("a");
|
||||||
|
volume_href.setAttribute(u8"href", u8"file:///" + inst_volume->pageRefers());
|
||||||
|
volume_href.appendChild(doc_inst.createTextNode(inst_volume->accessPeers()->element()->signature()));
|
||||||
|
dom_volume_ref.appendChild(volume_href);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dom_fragment = doc_inst.createElement("div");
|
||||||
|
auto dom_fragment_title = doc_inst.createElement("h2");
|
||||||
|
dom_fragment_title.appendChild(doc_inst.createTextNode(u8"情节集合"));
|
||||||
|
dom_fragment.appendChild(dom_fragment_title);
|
||||||
|
body.appendChild(dom_fragment);
|
||||||
|
|
||||||
|
for (auto &inst_frag : tool.fragment_defines) {
|
||||||
|
auto dom_fragment_ref = doc_inst.createElement("p");
|
||||||
|
dom_fragment.appendChild(dom_fragment_ref);
|
||||||
|
|
||||||
|
auto frag_href = doc_inst.createElement("a");
|
||||||
|
frag_href.setAttribute(u8"href", u8"file:///" + inst_frag->pageRefers());
|
||||||
|
frag_href.appendChild(doc_inst.createTextNode(inst_frag->accessPeers()->element()->signature()));
|
||||||
|
dom_fragment_ref.appendChild(frag_href);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream tout(&tfile);
|
||||||
|
doc_inst.save(tout, 2);
|
||||||
|
tout.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tnode_print(novel_accesstree, 0);
|
tnode_print(novel_accesstree, 0);
|
||||||
}
|
}
|
||||||
catch (lib_syntax::SyntaxException* e) {
|
catch (lib_syntax::SyntaxException* e) {
|
||||||
|
|
Loading…
Reference in New Issue