update
This commit is contained in:
parent
d977a765e2
commit
a9787bff56
|
@ -56,8 +56,7 @@ open System
|
|||
new(page_hrefs, volume) = VolumePage(page_hrefs, volume, [])
|
||||
|
||||
interface IDomUnit with
|
||||
member this.name():string =
|
||||
volume.name()
|
||||
member this.name():string = volume.name()
|
||||
member this.object() =
|
||||
volume.object()
|
||||
member this.getHtmlWith(p: XmlElement): XmlElement =
|
||||
|
@ -75,8 +74,7 @@ open System
|
|||
new(page_hrefs, story) = StoryPage(page_hrefs, story, [])
|
||||
|
||||
interface IDomUnit with
|
||||
member this.name():string =
|
||||
story.name()
|
||||
member this.name():string = story.name()
|
||||
member this.object() =
|
||||
story.object()
|
||||
member this.getHtmlWith(p: XmlElement): XmlElement =
|
||||
|
@ -94,10 +92,8 @@ open System
|
|||
new(page_hrefs, point) = PointPage(page_hrefs, point, [])
|
||||
|
||||
interface IDomUnit with
|
||||
member this.name():string =
|
||||
point.name()
|
||||
member this.object() =
|
||||
point.object()
|
||||
member this.name():string = point.name()
|
||||
member this.object() = point.object()
|
||||
member this.getHtmlWith(p: XmlElement): XmlElement =
|
||||
raise (System.NotImplementedException())
|
||||
|
||||
|
@ -128,8 +124,7 @@ open System
|
|||
let lines = refs.children() |> List.map (fun x->x.content())
|
||||
|
||||
interface Present.IDomUnit with
|
||||
member this.name(): string =
|
||||
ref_signature
|
||||
member this.name(): string = ref_signature
|
||||
member this.object() = refs
|
||||
member this.getHtmlWith(pnode: XmlElement): XmlElement =
|
||||
raise (System.NotImplementedException())
|
||||
|
@ -151,8 +146,7 @@ open System
|
|||
let lines = defs.children() |> List.map (fun x->x.content())
|
||||
|
||||
interface Present.IDomUnit with
|
||||
member this.name(): string =
|
||||
defs.name()
|
||||
member this.name(): string = defs.name()
|
||||
member this.object() = defs
|
||||
member this.getHtmlWith(pnode: XmlElement): XmlElement =
|
||||
raise (System.NotImplementedException())
|
||||
|
@ -168,20 +162,18 @@ open System
|
|||
|
||||
|
||||
/// 具有回退功能的元素
|
||||
type AssemblePoint<'T when 'T :> Present.Forwards and 'T :> Present.IDomUnit and 'T:> Present.IContainer>(item: 'T, page: Present.PageAccess) =
|
||||
type AssembleRefer<'T when 'T :> Present.Forwards and 'T :> Present.IDomUnit and 'T:> Present.IContainer>(item: 'T, page: Present.PageAccess) =
|
||||
class
|
||||
inherit Present.Backwards(item, page)
|
||||
|
||||
interface Present.IDomUnit with
|
||||
member this.name(): string =
|
||||
item.name()
|
||||
member this.name(): string = item.name()
|
||||
member this.object() = item.object()
|
||||
member this.getHtmlWith(pnode: XmlElement): XmlElement =
|
||||
raise (System.NotImplementedException())
|
||||
|
||||
interface Present.IContainer with
|
||||
member this.children(): Present.IDomUnit list =
|
||||
item.children()
|
||||
member this.children(): Present.IDomUnit list = item.children()
|
||||
member this.append(childs: Present.IDomUnit list): Present.IContainer =
|
||||
raise (System.NotImplementedException())
|
||||
end
|
||||
|
@ -190,8 +182,7 @@ open System
|
|||
type SliceDefine(defs: AstImport.SliceDef, items: Present.IDomUnit list) =
|
||||
class
|
||||
interface Present.IDomUnit with
|
||||
member this.name(): string =
|
||||
defs.name()
|
||||
member this.name(): string = defs.name()
|
||||
member this.object() = defs
|
||||
member this.getHtmlWith(pnode: XmlElement): XmlElement =
|
||||
raise (System.NotImplementedException())
|
||||
|
@ -333,7 +324,7 @@ open System
|
|||
module Assemble =
|
||||
/// 构建页面名称
|
||||
let page_address_make(node: Present.IDomUnit): string =
|
||||
let name_seqs = node.name().ToCharArray() |> Array.map(fun c-> string(uint16(c)))
|
||||
let name_seqs = $"{node.name()}_{node.object().address()}".ToCharArray() |> Array.map(fun c-> string(uint16(c)))
|
||||
name_seqs |> Array.reduce(fun a b-> a+b)
|
||||
|
||||
/// 构建所有卷宗页面
|
||||
|
@ -359,7 +350,7 @@ open System
|
|||
| _ -> story_page_build(nodes.Tail)
|
||||
|
||||
/// 提取point-define和point-refer
|
||||
let rec point_peers_extract(nodes: Present.IDomUnit list):(Present.IDomUnit option*Present.IDomUnit option)list =
|
||||
let rec private point_peers_extract(nodes: Present.IDomUnit list):(Present.IDomUnit option*Present.IDomUnit option*Present.IDomUnit option)list =
|
||||
match nodes with
|
||||
| [] -> []
|
||||
| _ ->
|
||||
|
@ -369,46 +360,82 @@ open System
|
|||
let con = story_e :> Present.IContainer
|
||||
let items = point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
items |> List.map(
|
||||
fun (x,y)->
|
||||
fun (x, y, z)->
|
||||
match x with
|
||||
| None -> (Some(story_e :> Present.IDomUnit), y)
|
||||
| _ -> (x, y)
|
||||
| None -> (Some(story_e :> Present.IDomUnit), y, z)
|
||||
| _ -> (x, y, z)
|
||||
)
|
||||
| :? Present.StoryPage as story_e ->
|
||||
let con = story_e :> Present.IContainer
|
||||
let items = point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
items |> List.map(
|
||||
fun (x,y)->
|
||||
fun (x, y, z)->
|
||||
match x with
|
||||
| None -> (Some(story_e :> Present.IDomUnit), y)
|
||||
| _ -> (x, y)
|
||||
| None -> (Some(story_e :> Present.IDomUnit), y, z)
|
||||
| _ -> (x, y, z)
|
||||
)
|
||||
|
||||
| :? Content.VolumeDefine as volume_e ->
|
||||
let con = volume_e :> Present.IContainer
|
||||
let items = point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
items |> List.map (
|
||||
fun (x,y) ->
|
||||
fun (x, y, z) ->
|
||||
match x with
|
||||
| None -> (Some(volume_e), y)
|
||||
| _ -> (x, y)
|
||||
| None -> (Some(volume_e), y, z)
|
||||
| _ -> (x, y, z)
|
||||
)
|
||||
| :? Present.VolumePage as volume_e ->
|
||||
let con = volume_e :> Present.IContainer
|
||||
let items = point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
items |> List.map (
|
||||
fun (x,y) ->
|
||||
fun (x, y, z) ->
|
||||
match x with
|
||||
| None -> (Some(volume_e), y)
|
||||
| _ -> (x, y)
|
||||
| None -> (Some(volume_e), y, z)
|
||||
| _ -> (x, y, z)
|
||||
)
|
||||
|
||||
| :? Content.SliceDefine as slice_e ->
|
||||
let con = slice_e :> Present.IContainer
|
||||
point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
let items = point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
items |> List.map(
|
||||
fun (x, y, z) ->
|
||||
match y with
|
||||
| None -> (x, Some(slice_e:> Present.IDomUnit), z)
|
||||
| _ -> (x, y, z)
|
||||
)
|
||||
|
||||
| :? Content.ArticleDefine as article_e ->
|
||||
let con = article_e :> Present.IContainer
|
||||
point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
let items = point_peers_extract(con.children())@point_peers_extract(nodes.Tail)
|
||||
items |> List.map(
|
||||
fun (x, y, z) ->
|
||||
match y with
|
||||
| None -> (x, Some(article_e), z)
|
||||
| _ -> (x, y, z)
|
||||
)
|
||||
|
||||
| :? Content.PointRefer as refer_e ->
|
||||
(None, Some(refer_e :> Present.IDomUnit))::point_peers_extract(nodes.Tail)
|
||||
let ast_obj = refer_e :> Present.IDomUnit
|
||||
let refer = ast_obj.object() :?> AstImport.PointRef
|
||||
(None, None, Some(refer_e :> Present.IDomUnit))::point_peers_extract(nodes.Tail)
|
||||
| :? Content.PointDefine as define_e ->
|
||||
(None, Some(define_e))::point_peers_extract(nodes.Tail)
|
||||
let ast_obj = define_e :> Present.IDomUnit
|
||||
(None, None, Some(define_e))::point_peers_extract(nodes.Tail)
|
||||
| _ -> point_peers_extract(nodes.Tail)
|
||||
|
||||
/// 构建节点汇总页面
|
||||
/// param nodes volume-pages@story-pages
|
||||
let rec point_assemble_page_build(nodes: Present.IDomUnit list) =
|
||||
let refers_about = point_peers_extract(nodes)
|
||||
let pages = refers_about |> List.map (
|
||||
fun (page_defs, _, dc) ->
|
||||
match dc.Value with
|
||||
| :? Content.PointDefine as defs ->
|
||||
let page_x = page_defs.Value :?> Present.StoryPage
|
||||
let copy_pt = Content.AssembleRefer<Content.PointDefine>(defs, page_x)
|
||||
Some(Present.PointPage(page_address_make(defs), copy_pt))
|
||||
| _ -> None
|
||||
)
|
||||
|> List.filter (fun d -> d <> None)
|
||||
for p in pages do
|
||||
Console.WriteLine((p.Value :> Present.IDomUnit).object().address())
|
||||
|
|
|
@ -18,7 +18,4 @@ entry.visitWith(visitor) |> ignore
|
|||
let volume_pages = volume_page_build(visitor.contents()) |> List.map<VolumePage, IDomUnit> (fun x->x)
|
||||
let story_pages = story_page_build(visitor.contents()) |> List.map<StoryPage, IDomUnit> (fun x->x)
|
||||
|
||||
let refers = point_peers_extract(volume_pages @ story_pages)
|
||||
for it in refers do
|
||||
let (x,y)= it
|
||||
printfn $"{x.Value.name()}&{y.Value.name()}"
|
||||
let refers = point_assemble_page_build(volume_pages @ story_pages)
|
||||
|
|
Loading…
Reference in New Issue