spanezz / staticsite

Static site generator
GNU General Public License v3.0
47 stars 7 forks source link

Allow to replace built-in features #28

Closed spanezz closed 4 years ago

spanezz commented 4 years ago

(from a conversation with @DonKult)

Is there actually a way to prevent staticsite from load say "tags" – so that I may load "tags-ng"?

I've been considering implementing something like a features_exclude setting, but so far I haven't had a need for it so I procrastinated it. You give me a good reason to have it.

Also, depending on a feature in the deny list should in theory just ignore the dependency, or possibly disable loading of the depending feature? In your case, however, you'd like to have tags-ng run instead of tags, and then series would integrate with tags-ng instead of tags, so I guess that disabling series if tags is blacklisted wouldn't work for you.

As a note: This imagined tags-ng does not exist nor do I actually plan for one. It does indeed poses a set of interesting design possibilities… In theory a tags-ng would need a way to say "I am like tags" (aka Provides: tags), but that leads eventually also to all the other dependency relations and a full-blown resolver…

There could be a possible shortcut here: features define the name they take in the feature database, as such:

FEATURES = {
    "tags": TaxonomyFeature,
}

It could be possible to say that if two features register themselves with the same name, the last one wins and the previous one get ignored.

When loading features, one can postpone instantiating the feature classes until both the built-in and the theme features have been loaded, and only then build the dependency graph, do the topological sorting, and instantiate feature classes.