The Shield-Maiden: A Foreworld SideQuest
Review:One of the better sidequests. |
Review:One of the better sidequests. |
This has been in the master branch of Nikola for a while but only now have I tried to fully integrate it, and polish all (most) of the rough edges.
By default, Nikola comes with support for search forms using Google and Duckduckgo. Some people disapprove of them for different reasons [1] so there was a request about supporting a standalone search engine.
The best of breed of those things seems to be Tipue so that's what I supported.
To use this, you need to enable a plugin, and do some configuration changes.
The plugin is called task_localsearch
and you can find it in
the Nikola source tree
Suppose your site is in a folder called mysite
then to enable this plugin you need
to create mysite/plugins
and then copy task_localsearch.plugin
and task_localsearch
in there.
Then, in your site's conf.py
find these options and change them accordingly:
SEARCH_FORM = """ <span class="navbar-form pull-left"> <input type="text" id="tipue_search_input"> </span>""" ANALYTICS = """ <script type="text/javascript" src="/assets/js/tipuesearch_set.js"></script> <script type="text/javascript" src="/assets/js/tipuesearch.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#tipue_search_input').tipuesearch({ 'mode': 'json', 'contentLocation': '/assets/js/tipuesearch_content.json', 'showUrl': false }); }); </script> """ EXTRA_HEAD_DATA = """ <link rel="stylesheet" type="text/css" href="/assets/css/tipuesearch.css"> <div id="tipue_search_content" style="margin-left: auto; margin-right: auto; padding: 20px;"></div> """
How does it work? Here's a demo site for you to try!
I would not recommend doing this for a big site, since it may load a multi-megabyte javascript file when you search, but for small to medium sites, it may be ok.
Like this one:
When your country is at risk, everything is allowed, except not defending it.
—José de San Martín
For non-argentinian readers, imagine if that was said by a combination Washington/Lincoln level figure famous for leading three countries to get rid of the spaniards and also for a list of advices for young ladies, whose biography is titled "The saint with a sword".
So, anyway, he said that. And that phrase is bad, bad, bad, unfortunate and horrible.
It's that bad because while a nice slogan to rally farmers into becoming soldiers in the army of a nation that doesn't quite exist yet, it's awful advice for people who live in an actual nation, with actual laws, an actual army, and people who worship whatever crap you happened to say, José.
It starts with the flaky premise "when your country is at risk" which means too little, or too much, depending on just how much you need an excuse to do something horrible.
If you really want to be a bad person, I am sure you can convince yourself that gays, immigrants, foreigners, muslims, jews, the young are all a danger to your country, somehow. You just need to stretch "danger" a little or maybe push "your country" somewhat.
And once you jumped that hurdle, and you are convinced your "country" is "at risk", why, then you can do anything. Unsurprisingly this stupid line is often framed in military offices, and is a tired trope in military speeches.
I quite like José de San Martín. This quote, however, is unfortunate.
Review:A satisfying conclussion to this trilogy. |
The original poster claims this is not a school homework. Accepting that, it still doesn't mean how to answer to homework requests is not worthy of discussion.
As usual in all programming lists, every once in a while someone will post a question in the Python Argentina list which is obviously his homework. To handle that there are two schools of thought.
Telling the student how to do it is helping them cheat.
Telling the student how to do it is teaching him.
I tend more towards 1) but I think I have discovered a middle road:
1.5) Tell the student a solution that's more complicated than the problem.
That way, if he figures out the solution, he has done the work, and if he doesn't figure it out, it's going to be so obviously beyond his skill the teacher will never accept it as an answer.
As an example, here's the problem for which help was requested:
Given an unsorted list of two-letter elements (une lowercase, one uppercase), for example:
['eD', 'fC', 'hC', 'iC', 'jD', 'bD', 'fH', 'mS', 'aS', 'mD']Sort it by these criteria:
Create subsets according to the uppercase letter, and sort them by the number of members in ascending order, like this:
['fH', 'mS', 'aS', 'fC', 'hC', 'iC', 'jD', 'bD', 'eD', 'mD']Then sort each subset in ascending order of the lowercase letter, like this:
['fH', 'aS', 'mS', 'fC', 'hC', 'iC', 'bD', 'eD', 'jD', 'mD']
Ignoring that the problem is not correctly written (there are at least two ways to read it, probably more), I proposed this solution, which requires python 3:
from collections import defaultdict d1 = defaultdict(list) [d1[i[1]].append(i) for i in ['eD', 'fC', 'hC', 'iC', 'jD', 'bD', 'fH', 'mS', 'aS', 'mD']] {i: d1[i].sort() for i in d1} d2 = {len(d1[i]): d1[i] for i in d1} print([item for sublist in [d2[i] for i in sorted(d2.keys())] for item in sublist])
This produces the desired result: ['fH', 'aS', 'mS', 'fC', 'hC', 'iC', 'bD', 'eD', 'jD', 'mD']
but it's done in such a way that to understand it, the student will need to understand roughly
three or four things he has probably not been taught yet.