What a post's content says about it, worked out once, when the content is written — reading a
post works out neither:
content_components— the components its markers name (MishkaCmsCore.Runtime.ContentComponents.names/1),nilwhen it names none. A site's stylesheet is built from them — seeMishkaBlog.Plugins.ContentComponents.content_icons— the icon classes it names, in a marker's attribute or in its HTML (MishkaCmsCore.Runtime.ContentComponents.icons/1),nilwhen it names none. The site's stylesheet carries a rule for each — seeMishkaBlog.Plugins.ContentComponents.content_classes— the classes it writes: its HTML's class lists, a marker'sclassand*_classattributes, and the attributes its component takes a class string in (MishkaCmsCore.Runtime.ContentComponents.site_classes/2),nilwhen it writes none. The site's stylesheet is built with each — seeMishkaBlog.Plugins.ContentComponents.reading_time_minutes— its words at 200 a minute, rounded up, never under 1.
All four are worked out in a before_action hook, which runs after every change an action lists
— the guardedstruct sanitizer and MishkaBlog.Resources.Changes.HighlightCode included — so
they are read off the content that is stored. A write that leaves content alone leaves them
alone, unless the post has no reading time yet — a row this change never saw — which any save
fills.
The stylesheet
A write that makes a name, an icon or a class live on its site — a published post names it now and
did not before, and no other published post of the site names it — rebuilds the site's
stylesheet, through MishkaCmsCore.Runtime.Compilers.TailwindCompiler.schedule/1. The job is
enqueued in the write's own transaction, so a write rolled back asks for nothing. A name, an icon
or a class dropped, or a post unpublished, rebuilds nothing.
Usage
update :update do
change MishkaBlog.Resources.Changes.HighlightCode
change MishkaBlog.Resources.Changes.ContentFacts
endOn an action that writes no content — :publish — only the stylesheet half has anything to do.
Summary
Functions
What post makes live of fact that was did not — its component names
(:content_components, the default), its icons (:content_icons) or its classes
(:content_classes): what a published post lists, less what the post published before the write
already listed.
Minutes content takes to read: its words at 200 a minute, rounded up, never under 1.
Functions
@spec newly_live( map(), map(), :content_components | :content_icons | :content_classes ) :: [String.t()]
What post makes live of fact that was did not — its component names
(:content_components, the default), its icons (:content_icons) or its classes
(:content_classes): what a published post lists, less what the post published before the write
already listed.
@spec reading_time(String.t()) :: pos_integer()
Minutes content takes to read: its words at 200 a minute, rounded up, never under 1.