Insect template

5 views
Skip to first unread message

Declan McCabe

unread,
Oct 10, 2015, 9:35:30 PM10/10/15
to WikiEducator Technical Discussion
Hi Jim

In response to requests from our teacher/collaborators, I'm adding common names to the stream insects pages.  In hopes of attracting a wider audience for the resource I'm also adding tied fly names to the pages.

So, I edited the two fields here: http://wikieducator.org/Template:InsectSection

My question: is there an efficient way to push the new blank fields out to all of the existing templates?  Or should I plan on editing them one at a time....which is fine if that's the way it needs to be done.  The fields need to be optional....because not all bugs have common names or tied flies.

I'm revisiting this because we have a new team of programmers redesigning our Iphone app.

Cheers

Declan

Jim Tittsler

unread,
Oct 10, 2015, 11:19:48 PM10/10/15
to wikieducator-tech
On Sun, Oct 11, 2015 at 10:35 AM, Declan McCabe <declan...@gmail.com> wrote:
> So, I edited the two fields here:
> http://wikieducator.org/Template:InsectSection
>
> My question: is there an efficient way to push the new blank fields out to
> all of the existing templates? Or should I plan on editing them one at a
> time....which is fine if that's the way it needs to be done. The fields
> need to be optional....because not all bugs have common names or tied flies.

I think there are a few options (but I'm not certain I've understood
the real question, so it might be best to chat a bit on IRC,
CollabOERate, or Google Hangouts to explore a bit).

1. The Mediawiki template language is quite ugly to "program" but it
does have the ability to deal with unspecified parameters.
{{foo|altstring}} will return the value of the foo parameter if it has
been defined, or the wikitext altstring if it hasn't. And the
altstring can be empty, so {{foo|}} is a construct you see a lot when
you just want to ignore unspecified parameters.
2. There are a number of parser functions that allow you to wrap
conditionals around sections of wikitext, and #if and #ifeq come in
really handy when dealing with optional parameters.
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23if

So given that, you could just edit the downstream (pardon the pun)
insect templates that actually have common names... and the presence
of the parameters would trigger conditional rendering in the parent
Template:InsectSection. That is probably the "right" way of attacking
the problem.

I was tempted to prototype this for you by adding the common name (and
tied fly name) to the Template:OrderFamilyGenus so they would all
render in that same column... but it is probably best to wait to (a)
see if I've actually understood the problem and (b) find out how you
were planning to render the new fields in the output.

But there is another way that would be quick-and-dirty but probably
not scale well in the long term. You could put a #switch parser
function in Template:InsectSection that would derive the common name
based on the genus/species of the child templates. This would work
great for existing templates, but would require touching two places as
new insects were added (unless you combined it with the conditional
method mentioned in 2. above).
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23switch
Example of something similar:
http://wikieducator.org/Template:IDevice/line

> I'm revisiting this because we have a new team of programmers redesigning
> our Iphone app.

Cool to see work continuing on the Streams project.

Jim

Jim Tittsler

unread,
Oct 11, 2015, 1:00:50 AM10/11/15
to wikieducator-tech
I notice you are also manually adding taxonomy categories to some of
the insect templates. For at least the top Order category... you could
change Template:InsectSection to always put an insect in the correct
category. Add something like:
[[Category:{{Order}}]]
and then each insect will be in the correct category automagically.

Jim

Luis Miguel Morillas

unread,
Oct 11, 2015, 3:10:48 AM10/11/15
to wikieducator-tech
If you want to add the info to your insects, it can be done by a bot
if you have a table with the name, the Common Name and the Tied Fly
Name.

For this kind of projects we could add some extension to WE (such as
wikidata or Cargo) to deal with structured data.

-- luismiguel (@lmorillas)
> --
> You received this message because you are subscribed to the Google Groups "WikiEducator Technical Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wikieducator-t...@googlegroups.com.
> To post to this group, send email to wikieduc...@googlegroups.com.
> Visit this group at http://groups.google.com/group/wikieducator-tech.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages