pub struct Prose {
pub text: String,
pub url: String,
pub lang: String,
pub licence: String,
}Expand description
A piece of prose taken from somewhere, with what its licence obliges.
One value, not four fields. Wikipedia is CC BY-SA: the text may be
reused, and attribution has to travel with it. A text field beside a
separate optional url would make it possible — and therefore eventually
certain — to hold the words without the credit: one code path that fills
the first and forgets the second, one export that copies one and not the
other, and the project is quietly out of compliance.
So they are the same value. There is no way to store the sentence without storing where it came from, in which language, and under what terms, because the type does not offer one.
Fields§
§text: StringThe words themselves.
url: StringThe page they came from, which is the attribution a reader can follow.
lang: StringLanguage code of that page, so a reader knows what they are getting.
licence: StringThe licence, named as the source names it — CC BY-SA 4.0.
Stored per record, not looked up from a constant. It is the same string for every Wikipedia article today, so carrying a copy on each row looks like waste — about twenty-four bytes, ten kilobytes over a large library. It buys two things that a constant read at display time cannot.
It is a fact about the fetch, like SourceRecord::fetched_at: it
says what these words were taken under, not what the current build
believes they would be taken under now. Wikimedia has already moved once
— CC BY-SA 3.0 to 4.0 — and with a constant that upgrade silently
relabels every paragraph fetched before it.
And Prose is not Wikipedia’s. It is prose with its terms, so the next
source of a biography — a plugin, a label, a discography site under
quite different terms — files it in this same field, and the record says
which. Moving the licence out to the source that usually supplies it
would make the second source a special case of the first.
Implementations§
Source§impl Prose
impl Prose
Sourcepub fn credit(&self) -> String
pub fn credit(&self) -> String
The line that has to appear wherever the text does.
The language is named, and that is not decoration. This text is
fetched in one language and kept in one language, so a reader who wanted
French and is reading English has no way to tell whether their
preference was ignored, whether the article does not exist in French, or
whether the prose was fetched before they expressed a preference at all.
The field was stored from the first version and displayed nowhere — the
same dead end source_id and the fingerprints had. Now the screen says
which language it is, and the way to ask for another is one line below.