update
This commit is contained in:
parent
872f874d22
commit
779c822741
|
@ -8,15 +8,13 @@ open System
|
||||||
/// 可访问元素
|
/// 可访问元素
|
||||||
type Access(hrefs: string) =
|
type Access(hrefs: string) =
|
||||||
class
|
class
|
||||||
member this.accessLink(): string =
|
member this.accessLink(): string = hrefs
|
||||||
hrefs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
/// 回退访问元素
|
/// 回退访问元素
|
||||||
type Backward(hrefs: string) =
|
type Backward(hrefs: string) =
|
||||||
class
|
class
|
||||||
member this.backwardLink(): string =
|
member this.backwardLink(): string = hrefs
|
||||||
hrefs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
/// 内容元素:分卷、章节、引用节点、故事线、情节、定义节点、引用节点
|
/// 内容元素:分卷、章节、引用节点、故事线、情节、定义节点、引用节点
|
||||||
|
@ -29,11 +27,12 @@ open System
|
||||||
/// 容器节点:分卷、章节、故事线、情节
|
/// 容器节点:分卷、章节、故事线、情节
|
||||||
type IContainer =
|
type IContainer =
|
||||||
interface
|
interface
|
||||||
abstract member append:List<IDomUnit> -> IContainer
|
abstract member append:IDomUnit list -> IContainer
|
||||||
|
abstract member children:unit -> IDomUnit list
|
||||||
end
|
end
|
||||||
|
|
||||||
/// 访问页面:概括页面、卷宗页面、故事线页面、节点汇总 =================================================
|
/// 访问页面:概括页面、卷宗页面、故事线页面、节点汇总 =================================================
|
||||||
type VolumePage(page_hrefs: string, volume: IDomUnit, childs: List<IDomUnit>) =
|
type VolumePage(page_hrefs: string, volume: IDomUnit, childs: IDomUnit list) =
|
||||||
class
|
class
|
||||||
inherit Access(page_hrefs)
|
inherit Access(page_hrefs)
|
||||||
new(page_hrefs, volume) = VolumePage(page_hrefs, volume, [])
|
new(page_hrefs, volume) = VolumePage(page_hrefs, volume, [])
|
||||||
|
@ -45,11 +44,12 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface IContainer with
|
interface IContainer with
|
||||||
member this.append(childs: List<IDomUnit>): IContainer =
|
member this.children(): IDomUnit list = childs
|
||||||
|
member this.append(childs: IDomUnit list): IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
|
|
||||||
type StoryPage(page_hrefs: string, story: IDomUnit, childs: List<IDomUnit>) =
|
type StoryPage(page_hrefs: string, story: IDomUnit, childs: IDomUnit list) =
|
||||||
class
|
class
|
||||||
inherit Access(page_hrefs)
|
inherit Access(page_hrefs)
|
||||||
new(page_hrefs, story) = StoryPage(page_hrefs, story, [])
|
new(page_hrefs, story) = StoryPage(page_hrefs, story, [])
|
||||||
|
@ -61,11 +61,12 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface IContainer with
|
interface IContainer with
|
||||||
member this.append(childs: List<IDomUnit>): IContainer =
|
member this.children(): IDomUnit list = childs
|
||||||
|
member this.append(childs: IDomUnit list): IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
|
|
||||||
type PointPage(page_hrefs: string, point: IDomUnit, refer_list: List<IDomUnit>) =
|
type PointPage(page_hrefs: string, point: IDomUnit, refer_list: IDomUnit list) =
|
||||||
class
|
class
|
||||||
inherit Access(page_hrefs)
|
inherit Access(page_hrefs)
|
||||||
new(page_hrefs, point) = PointPage(page_hrefs, point, [])
|
new(page_hrefs, point) = PointPage(page_hrefs, point, [])
|
||||||
|
@ -77,7 +78,8 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface IContainer with
|
interface IContainer with
|
||||||
member this.append(childs: List<IDomUnit>): IContainer =
|
member this.children(): IDomUnit list = refer_list
|
||||||
|
member this.append(childs: IDomUnit list): IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,7 +95,7 @@ open System
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
type PointRefer(refs: AstImport.PointRef, items: List<Present.IDomUnit>) =
|
type PointRefer(refs: AstImport.PointRef, items: Present.IDomUnit list) =
|
||||||
class
|
class
|
||||||
let ref_signature = $"@{refs.storyRef()}&{refs.sliceRef()}&{refs.pointRef()}"
|
let ref_signature = $"@{refs.storyRef()}&{refs.sliceRef()}&{refs.pointRef()}"
|
||||||
let lines = refs.children() |> List.map (fun x->x.content())
|
let lines = refs.children() |> List.map (fun x->x.content())
|
||||||
|
@ -105,7 +107,8 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface Present.IContainer with
|
interface Present.IContainer with
|
||||||
member this.append(childs: List<Present.IDomUnit>): Present.IContainer =
|
member this.children(): Present.IDomUnit list = items
|
||||||
|
member this.append(childs: Present.IDomUnit list): Present.IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
let refer_assemble (refn: AstImport.PointRef) : PointRefer =
|
let refer_assemble (refn: AstImport.PointRef) : PointRefer =
|
||||||
|
@ -113,7 +116,7 @@ open System
|
||||||
PointRefer(refn, texts)
|
PointRefer(refn, texts)
|
||||||
|
|
||||||
|
|
||||||
type PointDefine(defs: AstImport.PointDef, items: List<Present.IDomUnit>) =
|
type PointDefine(defs: AstImport.PointDef, items: Present.IDomUnit list) =
|
||||||
class
|
class
|
||||||
let lines = defs.children() |> List.map (fun x->x.content())
|
let lines = defs.children() |> List.map (fun x->x.content())
|
||||||
|
|
||||||
|
@ -124,7 +127,8 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface Present.IContainer with
|
interface Present.IContainer with
|
||||||
member this.append(childs: List<Present.IDomUnit>): Present.IContainer =
|
member this.children(): Present.IDomUnit list = items
|
||||||
|
member this.append(childs: Present.IDomUnit list): Present.IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
let point_assemble (defs: AstImport.PointDef) : PointDefine =
|
let point_assemble (defs: AstImport.PointDef) : PointDefine =
|
||||||
|
@ -132,7 +136,7 @@ open System
|
||||||
PointDefine(defs, texts)
|
PointDefine(defs, texts)
|
||||||
|
|
||||||
|
|
||||||
type SliceDefine(defs: AstImport.SliceDef, items: List<Present.IDomUnit>) =
|
type SliceDefine(defs: AstImport.SliceDef, items: Present.IDomUnit list) =
|
||||||
class
|
class
|
||||||
interface Present.IDomUnit with
|
interface Present.IDomUnit with
|
||||||
member this.name(): string =
|
member this.name(): string =
|
||||||
|
@ -141,7 +145,8 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface Present.IContainer with
|
interface Present.IContainer with
|
||||||
member this.append(childs: List<Present.IDomUnit>): Present.IContainer =
|
member this.children(): Present.IDomUnit list = items
|
||||||
|
member this.append(childs: Present.IDomUnit list): Present.IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
let slice_assemble (defs: AstImport.SliceDef) : SliceDefine =
|
let slice_assemble (defs: AstImport.SliceDef) : SliceDefine =
|
||||||
|
@ -156,7 +161,7 @@ open System
|
||||||
SliceDefine(defs, childs)
|
SliceDefine(defs, childs)
|
||||||
|
|
||||||
|
|
||||||
type StoryDefine(defs: AstImport.StoryDef, childs: List<Present.IDomUnit>) =
|
type StoryDefine(defs: AstImport.StoryDef, childs: Present.IDomUnit list) =
|
||||||
class
|
class
|
||||||
interface Present.IDomUnit with
|
interface Present.IDomUnit with
|
||||||
member this.name(): string =
|
member this.name(): string =
|
||||||
|
@ -165,7 +170,8 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface Present.IContainer with
|
interface Present.IContainer with
|
||||||
member this.append(childs: List<Present.IDomUnit>): Present.IContainer =
|
member this.children(): Present.IDomUnit list = childs
|
||||||
|
member this.append(childs: Present.IDomUnit list): Present.IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
let story_assemble (defs: AstImport.StoryDef): StoryDefine =
|
let story_assemble (defs: AstImport.StoryDef): StoryDefine =
|
||||||
|
@ -179,7 +185,7 @@ open System
|
||||||
StoryDefine(defs, childs)
|
StoryDefine(defs, childs)
|
||||||
|
|
||||||
|
|
||||||
type ArticleDefine(defs: AstImport.ArticleDef, childs: List<Present.IDomUnit>) =
|
type ArticleDefine(defs: AstImport.ArticleDef, childs: Present.IDomUnit list) =
|
||||||
class
|
class
|
||||||
interface Present.IDomUnit with
|
interface Present.IDomUnit with
|
||||||
member this.name(): string =
|
member this.name(): string =
|
||||||
|
@ -188,7 +194,8 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface Present.IContainer with
|
interface Present.IContainer with
|
||||||
member this.append(childs: List<Present.IDomUnit>): Present.IContainer =
|
member this.children(): Present.IDomUnit list = childs
|
||||||
|
member this.append(childs: Present.IDomUnit list): Present.IContainer =
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
end
|
end
|
||||||
let article_assemble (defs: AstImport.ArticleDef) : ArticleDefine =
|
let article_assemble (defs: AstImport.ArticleDef) : ArticleDefine =
|
||||||
|
@ -202,7 +209,7 @@ open System
|
||||||
ArticleDefine(defs, childs)
|
ArticleDefine(defs, childs)
|
||||||
|
|
||||||
|
|
||||||
type VolumeDefine(defs: AstImport.VolumeDef, childs: List<Present.IDomUnit>) =
|
type VolumeDefine(defs: AstImport.VolumeDef, childs: Present.IDomUnit list) =
|
||||||
class
|
class
|
||||||
interface Present.IDomUnit with
|
interface Present.IDomUnit with
|
||||||
member this.name(): string =
|
member this.name(): string =
|
||||||
|
@ -211,8 +218,9 @@ open System
|
||||||
raise (System.NotImplementedException())
|
raise (System.NotImplementedException())
|
||||||
|
|
||||||
interface Present.IContainer with
|
interface Present.IContainer with
|
||||||
member this.append(childs: List<Present.IDomUnit>): Present.IContainer =
|
member this.children(): Present.IDomUnit list = childs
|
||||||
raise (System.NotImplementedException())
|
member this.append(news: Present.IDomUnit list): Present.IContainer =
|
||||||
|
VolumeDefine(defs, childs@news)
|
||||||
end
|
end
|
||||||
let volume_assemble (defs: AstImport.VolumeDef): VolumeDefine =
|
let volume_assemble (defs: AstImport.VolumeDef): VolumeDefine =
|
||||||
let childs = defs.children()
|
let childs = defs.children()
|
||||||
|
@ -263,4 +271,33 @@ open System
|
||||||
|
|
||||||
member this.contents() =
|
member this.contents() =
|
||||||
result_nodes |> List.map(fun (_, obj) -> obj)
|
result_nodes |> List.map(fun (_, obj) -> obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
module Assemble =
|
||||||
|
/// 构建页面名称
|
||||||
|
let page_address_make(node: Present.IDomUnit): string =
|
||||||
|
let name_seqs = node.name().ToCharArray() |> Array.map(fun c-> string(uint16(c)))
|
||||||
|
name_seqs |> Array.reduce(fun a b-> a+b)
|
||||||
|
|
||||||
|
/// 构建所有卷宗页面
|
||||||
|
let rec volume_page_build (nodes: Present.IDomUnit list): Present.VolumePage list =
|
||||||
|
match nodes with
|
||||||
|
| [] -> []
|
||||||
|
| _ ->
|
||||||
|
match nodes.Head with
|
||||||
|
| :? Content.VolumeDefine as vole ->
|
||||||
|
let con: Present.IContainer = vole
|
||||||
|
Present.VolumePage(page_address_make(vole), vole, con.children())::volume_page_build(nodes.Tail)
|
||||||
|
| _ -> volume_page_build(nodes.Tail)
|
||||||
|
|
||||||
|
/// 构建所有故事线页面
|
||||||
|
let rec story_page_build (nodes: Present.IDomUnit list): Present.StoryPage list =
|
||||||
|
match nodes with
|
||||||
|
| [] -> []
|
||||||
|
| _ ->
|
||||||
|
match nodes.Head with
|
||||||
|
| :? Content.StoryDefine as storye ->
|
||||||
|
let con: Present.IContainer = storye
|
||||||
|
Present.StoryPage(page_address_make(storye), storye, con.children())::story_page_build(nodes.Tail)
|
||||||
|
| _ -> story_page_build(nodes.Tail)
|
Loading…
Reference in New Issue