diff --git a/example/content.jl b/example/content.jl index f8c18c9..6595c23 100644 --- a/example/content.jl +++ b/example/content.jl @@ -174,16 +174,16 @@ page( # publications.html # option 1: background for the page is set to start with white to emphasize the items ###################################### -page( - title="publications", - background=bg_white, - sections=[ - Section( - title="Publications", - items=Publications("publications.bib") - ) - ] -) +# page( +# title="publications", +# background=bg_white, +# sections=[ +# Section( +# title="Publications", +# items=Publications("publications.bib") +# ) +# ] +# ) ###################################### # research.html diff --git a/src/StaticWebPages.jl b/src/StaticWebPages.jl index ccc5852..9923322 100644 --- a/src/StaticWebPages.jl +++ b/src/StaticWebPages.jl @@ -25,6 +25,8 @@ export GitRepo export TimeLine export TimeLineColor +export ui + function load_example() include(joinpath(@__DIR__,"..","example","content.jl")) end diff --git a/src/ui.jl b/src/ui.jl index e088da4..d5608b2 100644 --- a/src/ui.jl +++ b/src/ui.jl @@ -1,18 +1,40 @@ -module UI - -using Gtk -# using GtkReactive +function make_tree!(ts, item::Item, parent) + str = replace(String(Symbol(typeof(item))), "StaticWebPages." => "") + push!(ts, (str,), parent) +end -import ..content +function make_tree!(ts, nest::Nest, parent) + nest = push!(ts, ("Nest",), parent) + foreach(item -> make_tree!(ts, item, nest), nest.list) +end -export ui +function make_tree!(ts, s::Section, parent) + section = push!(ts, (s.title,), parent) + make_tree!(ts, s.items, section) +end -tree_dict(content, dict) = nothing +function make_tree!(ts, s::Double, parent) + double = push!(ts, ("Double",), parent) + make_tree!(ts, s.first, double) + make_tree!(ts, s.second, double) +end -tree_dict(x) = tree_dict(x, Dict{String, Any}()) +function make_tree!(ts, x) + for (key, val) in x + page = push!(ts, (val.title,)) + foreach(section -> make_tree!(ts, section, page), val.sections) + end +end set_subtitle!(widget, str) = set_gtk_property!(widget, :subtitle, str) +function choose_project_folder(win) + dir = open_dialog("Select content.jl folder", win, action=GtkFileChooserAction.SELECT_FOLDER) + if isdir(dir) + set_subtitle!(header, "$(pwd())") + end +end + function ui() ts = GtkTreeStore(String) info = push!(ts,("Informations",)) @@ -21,10 +43,6 @@ function ui() c1 = GtkTreeViewColumn("Content", r1, Dict([("text",0)])) push!(tv,c1) - for page in keys(content) - push!(ts, (page,)) - end - uifile = joinpath(@__DIR__, "builder", "StaticWebPages.glade") builder = GtkBuilder(filename=uifile) @@ -42,11 +60,9 @@ function ui() push!(shokupan, tv) - set_subtitle!(header, "$(pwd())") - showall(win) + # make_tree!(ts, content) + return win end - -end \ No newline at end of file