Copy Wikipedia intros as basic summary, for additional details/flavour
after guessing in future quizzes?
+input, textarea, select {
box-sizing: border-box;
flex-grow: 1;
}
box-sizing: border-box;
flex-grow: 1;
}
-input:not([type=submit]) {
+input:not([type=submit]), textarea {
padding: .4rem;
font-family: monospace;
}
padding: .4rem;
font-family: monospace;
}
source text CHECK (source ~ '^https?://'),
thumb text[],
wptitle text,
source text CHECK (source ~ '^https?://'),
thumb text[],
wptitle text,
creator integer REFERENCES login (id),
created timestamptz DEFAULT now(),
updated timestamptz,
creator integer REFERENCES login (id),
created timestamptz DEFAULT now(),
updated timestamptz,
COMMENT ON COLUMN word.source IS 'URI of downloaded image';
COMMENT ON COLUMN word.thumb IS 'ImageMagick convert options to create thumbnail from source image';
COMMENT ON COLUMN word.wptitle IS 'reference Wikipedia article';
COMMENT ON COLUMN word.source IS 'URI of downloaded image';
COMMENT ON COLUMN word.thumb IS 'ImageMagick convert options to create thumbnail from source image';
COMMENT ON COLUMN word.wptitle IS 'reference Wikipedia article';
+COMMENT ON COLUMN word.story IS 'paragraph defining or describing the entity, wikipedia intro';
COMMENT ON COLUMN word.updated IS 'last significant change';
COMMENT ON COLUMN word.creator IS 'user responsible for initial submit';
COMMENT ON COLUMN word.updated IS 'last significant change';
COMMENT ON COLUMN word.creator IS 'user responsible for initial submit';
coalesce(r.source, w.source ) source,
coalesce(r.thumb, w.thumb ) thumb,
coalesce(r.wptitle, w.wptitle) wptitle,
coalesce(r.source, w.source ) source,
coalesce(r.thumb, w.thumb ) thumb,
coalesce(r.wptitle, w.wptitle) wptitle,
+ coalesce(r.story, w.story ) story,
r.creator, r.created, r.updated,
CASE WHEN r.source IS NULL THEN w.id ELSE r.id END id -- image id
FROM word r
r.creator, r.created, r.updated,
CASE WHEN r.source IS NULL THEN w.id ELSE r.id END id -- image id
FROM word r
+ // copy first paragraph to story
+ let wptext = json.parse.text['*'];
+ let storyinput = document.getElementById('story');
+ if (storyinput && wptext) {
+ storyinput.innerHTML = wptext
+ .replace(/<h2.*/s, '') // prefix
+ .replace(/<table.*?<\/table>/sg, '') // ignore infobox
+ .match(/<p>(.*?)<\/p>/s)[0] // first paragraph
+ .replace(/<[^>]*>/g, '') // strip html tags
+ }
+
// list images in article html
let imginput = document.getElementById('source');
if (!imginput || imginput.value) return;
// list images in article html
let imginput = document.getElementById('source');
if (!imginput || imginput.value) return;
- let wpimages = json.parse.text['*'].match(/<img\s[^>]+>/g);
+ let wpimages = wptext.match(/<img\s[^>]+>/g);
let wpselect = wpinput.parentNode.appendChild(document.createElement('ul'));
wpselect.className = 'popup';
wpimages.forEach(img => {
let wpselect = wpinput.parentNode.appendChild(document.createElement('ul'));
wpselect.className = 'popup';
wpimages.forEach(img => {
wptitle => {-label => 'Wikipedia'},
source => {-label => 'Image'},
thumb => {-label => 'Convert options', -multiple => 1},
wptitle => {-label => 'Wikipedia'},
source => {-label => 'Image'},
thumb => {-label => 'Convert options', -multiple => 1},
+ story => {-label => 'Story', type => 'textarea'},
);
if (my $search = $fields{q}) {
);
if (my $search = $fields{q}) {
+ elsif ($attr->{type} eq 'textarea') {
+ return (
+ (map {
+ sprintf('<label for="%s">%s</label>', $col, $_)
+ } $attr->{-label} // ()),
+ sprintf('<textarea id="%s" name="%1$s"%s>%s</textarea>',
+ $col, $html, EscapeHTML($val)
+ ),
+ );
+ }
elsif ($attr->{type} eq 'checkbox') {
$html .= ' checked' if $val;
return sprintf(
elsif ($attr->{type} eq 'checkbox') {
$html .= ' checked' if $val;
return sprintf(