JuliaPluto / PlutoSliderServer.jl

Web server to run just the `@bind` parts of a Pluto.jl notebook
https://computationalthinking.mit.edu/
The Unlicense
130 stars 17 forks source link

deterministic ordering of notebook creation #133

Closed clarkevans closed 6 months ago

clarkevans commented 6 months ago

For those of us who have one notebook that must run before others, it would be great if the notebooks were generated in the order as specified by "[frontmatter] order=n", as a fallback, use of alphabetic sort would also be helpful.

fonsp commented 6 months ago

Hey Clark! Right now they run in reverse alphabetical order, in the order listed in the index, e.g. https://mit-c25-fall22.netlify.app/ . I like the suggestion to use the order frontmatter!

(It's reversed because in one case I needed week9 to be online quicker than week1 🙈)

clarkevans commented 6 months ago

@fonsp looks like this is configurable externally...

function notebook_order(path)
    fm = PlutoSliderServer.Pluto.frontmatter(joinpath(source_dir[], path))
    order_s = get(fm, "order", nothing)
    order = typemax(Int)
    if order_s isa String
        order = something(tryparse(Int, order_s), order)
    end
    order
end

const notebook_paths =
    [path
     for (order, path) in sort([(notebook_order(path), path)
                                for path in PlutoSliderServer.find_notebook_files_recursive(source_dir[])])]

export_directory(
    source_dir[],
    notebook_paths = notebook_paths,
    Export_ignore_cache = ignore_cache[] ? ["*"] : String[],
    Export_output_dir = output_dir[],
    Export_cache_dir = cache_dir[],
    Export_create_pluto_featured_index = true,
    Export_offer_binder = false)
clarkevans commented 6 months ago

So, let me close this ticket.