From 2dd7d2083c23fe9e79a984c534c2283fc4d7e581 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 20 Jun 2019 13:45:58 -0400 Subject: harvest reorganized --- src/doc_reform/meta/metadoc_harvests_authors.d | 255 +++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 src/doc_reform/meta/metadoc_harvests_authors.d (limited to 'src/doc_reform/meta/metadoc_harvests_authors.d') diff --git a/src/doc_reform/meta/metadoc_harvests_authors.d b/src/doc_reform/meta/metadoc_harvests_authors.d new file mode 100644 index 0000000..d780221 --- /dev/null +++ b/src/doc_reform/meta/metadoc_harvests_authors.d @@ -0,0 +1,255 @@ +module doc_reform.meta.metadoc_harvests_authors; + import + std.algorithm, + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.conv : to; + import + doc_reform.meta.defaults, + doc_reform.meta.rgx; + mixin DocReformHarvest; + mixin InternalMarkup; + mixin DocReformRgxInit; +template DocReformMetaDocHarvestsAuthors() { + auto mkup = InlineMarkup(); + void DocReformMetaDocHarvestsAuthors(H,O)( + H harvests, + O _opt_action, + ) { + string[] authors = []; + authors ~= format(q"┃ + + + + +Metadata Harvest - Authors + + + + + + + + + + + + + +

Metadata Harvest - Authors (output organised by language & filetype)

+

[ HOME ] also see Metadata Harvest - Topics

+

+
+

English   

+
+

ABCDEFGHIJKLMNOPQRSTUVWXYZ,  +┃") ~ "\n"; + string[string] _au; + string[] _auth_date_title; + string[] _author_date_title; + string _prev_auth = ""; + char _prev_k = "_".to!char; + foreach(doc_harvest; + harvests + .multiSort!( + "toUpper(a.author_surname_fn) < toUpper(b.author_surname_fn)", + "a.date_published < b.date_published", + "a.title < b.title", + SwapStrategy.unstable + ) + ) { + if (doc_harvest.author_surname_fn != _prev_auth) { + _au[doc_harvest.author_surname_fn] + = format(q"┃

%s

%s "%s" [%s]

┃", + doc_harvest.author_surname, + doc_harvest.author_surname_fn, + (doc_harvest.date_published.length > 0) + ? doc_harvest.date_published : "", + "url", + doc_harvest.title, + doc_harvest.language, + ); + _prev_auth = doc_harvest.author_surname_fn; + } else { + _au[doc_harvest.author_surname_fn] + ~= format(q"┃

%s "%s" [%s]

┃", + (doc_harvest.date_published.length > 0) + ? doc_harvest.date_published : "", + "url", + doc_harvest.title, + doc_harvest.language, + ); + } + _author_date_title ~= format(q"┃%s %s "%s" [%s]┃", + doc_harvest.author_surname_fn, + (doc_harvest.date_published.length > 0) + ? "(" ~ doc_harvest.date_published ~ ")" : "", + doc_harvest.title, + doc_harvest.language, + ); + } + foreach (k; _au.keys.sort) { + if (k.toUpper.to!(char[])[0] != _prev_k) { + authors ~= format(q"┃

%s

┃", + k.toUpper.to!(char[])[0], + k.toUpper.to!(char[])[0], + ); + _prev_k = k.toUpper.to!(char[])[0]; + } + authors ~= _au[k]; + } + authors + ~= format(q"┃ +
+ + + + + + + + +┃") ~ "\n"; + try { + auto f = File("authors.html", "w"); + foreach (o; authors) { + f.writeln(o); + } + } catch (ErrnoException ex) { + // Handle error + } + if (_opt_action.verbose + || _opt_action.very_verbose + ) { + foreach(_adt; _author_date_title.sort) { + writeln(_adt); + } + } + } +} -- cgit v1.2.3