← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands-website/searching_with_haystack_whoosh into lp:widelands-website

 

Added some comments and proofreading. We should definitely do some cross-browse testing on he alpha site.

Diff comments:

> 
> === modified file 'templates/navigation.html'
> --- templates/navigation.html	2017-09-23 08:52:36 +0000
> +++ templates/navigation.html	2017-10-05 21:59:22 +0000
> @@ -59,12 +59,15 @@
>  <div class="searchBox posRight">
>  	<form method="post" action="/search/">
>  		<div class="searchBoxInner">
> -			<input id="id_nav_search" type="text" name="search" class="searchField placeholder" placeholder="Search..." maxlength="200" />
> -			<input id="id_nav_incl_wiki" type="hidden" name="incl_wiki" value="1" />
> -			<input id="id_nav_incl_news" type="hidden" name="incl_news" value="1" />
> -			<input id="id_nav_incl_maps" type="hidden" name="incl_maps" value="1" />
> -			<input id="id_nav_incl_help" type="hidden" name="incl_help" value="1" />
> -			<input id="id_nav_incl_forum" type="hidden" name="incl_forum" value="1" />
> +			<select name="section" class="selection" title="Search in">
> +				<option>Forum</option>
> +				<option>Wiki</option>
> +				<option>Encyclopedia</option>
> +				<option>News</option>
> +				<option>Maps</option>
> +				<option>All</option>
> +			</select>
> +			<input id="id_nav_search" type="text" name="q" class="searchField" placeholder="Search Forum" size="15" maxlength="200" />

Is searching the forum only the default? If not, this should just say "Search".

>  			{% csrf_token %}
>  		</div>
>  	</form>
> 
> === added file 'templates/search/search.html'
> --- templates/search/search.html	1970-01-01 00:00:00 +0000
> +++ templates/search/search.html	2017-10-05 21:59:22 +0000
> @@ -0,0 +1,165 @@
> +{% extends 'base.html' %}
> +{% load custom_date %}
> +
> +{% block extra_head %}
> +<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/search.css" />
> +<script src="{{ MEDIA_URL }}js/jquery-ui.min.js"></script>
> +
> +{{block.super}}
> +{% endblock %}
> +
> +{% block content %}
> +
> +    <h2>Search</h2>
> +
> +    <div class="blogEntry">
> +        <div class="closeable" title="Click to expand">Help</div>
> +        <ul class="search-help-hints">
> +            <li>The search is case insensitive.</li>
> +            <li>Search terms get stemmed: E.g. 'Mining' finds also 'mine', 'mines' and 'miner'.</li>

finds also -> will also find

> +            <li>Providing more than one word, the words get ANDed: E.g. all words must be in a forum topics name.</li>

Should we avoid the technical lingo here?

If you search for more than one word, only entries that contain all of the given words will be returned.

> +            <li>Words surrounded with parentheses will find exact matches:

with -> by

> +            E.g. "main page" finds all wiki articles whith this name or the content contains 'main page'</li>

finds -> will find
whith -> with

Sounds like a wiki article called "main page foo bar" will not be found - id this correct?

> +            <li>Words preceding with a minus means excluding: E.g. searching for 'tribe -barbarian'

means excluding -> will be excluded

> +            finds all forum posts containing 'tribe' but excludes all forum posts containing 'barbarian'.</li>

finds ... excludes -> will find ... exclude

> +            <li>The Startdate is not considered when searching the Encyclopedia, the Wiki and Maps.

The start date won't be considered when searching the encyclopedia or the wiki, and the default is set to return results for the span of one year.

> +            Default is searching the last year from today.</li>
> +        </ul>
> +    <form method="get" action=".">
> +      {{ form.non_field_errors }}
> +      <hr>
> +      <div class="search-options">
> +        <div>
> +          <strong>Search for: </strong>{{ form.q }}
> +        </div>
> +        <div>
> +          <strong>Startdate: </strong>{{ form.start_date }}
> +            {% if form.start_date.errors %}
> +                <span class="errormessage"> Enter a date in form of YYYY-MM-DD </span>

in form -> in the form

> +            {% endif %}
> +            (Leave empty for full search)
> +        </div>
> +      </div>
> +      <div  class="search-options">
> +        <div>
> +          <strong>Search in: </strong>
> +          <span class="button">
> +            {{ form.incl_forum.label_tag }} {{ form.incl_forum }}
> +          </span>
> +          <span class="button">
> +            {{ form.incl_maps.label_tag }} {{ form.incl_maps }}
> +          </span>
> +          <span class="button">
> +            {{ form.incl_wiki.label_tag }} {{ form.incl_wiki }}
> +          </span>
> +          <span class="button">
> +            {{ form.incl_help.label_tag }} {{ form.incl_help }}
> +          </span>
> +          <span class="button">
> +            {{ form.incl_news.label_tag }} {{ form.incl_news }}
> +          </span>
> +        </div>
> +        <div class="flex-right">
> +          <input type="submit" value="Search">
> +        </div>
> +      </div>
> +      <hr>
> +      {% if query %}
> +        {% if result %}
> +            {% if result.topics or result.posts %}
> +              <h2>Forum:</h2>
> +              {% if result.topics %}
> +                <h3>Topics:</h3>
> +                <ul class="search">
> +                  {% for topic in result.topics %}
> +                    <li>
> +                      {% include "search/includes/topics.html" %}
> +                    </li>
> +                  {% endfor %}
> +              </ul>
> +              {% endif %}
> +              {% if result.posts %}
> +                <h3>Posts:</h3>
> +                <ul class="search">
> +                  {% for post in result.posts %}
> +                      <li class="highlight">
> +                        {% include "search/includes/posts.html" %}
> +                      </li>
> +                  {% endfor %}
> +                </ul>
> +              {% endif %}
> +            {% endif%}
> +            {% if result.wiki %}
> +              <h2>Wiki:</h2>
> +                  <ul class="search">
> +                      {% for article in result.wiki %}
> +                        <li class="highlight"> 
> +                          {% include "search/includes/wiki_articles.html" %}
> +                        </li>
> +                      {% endfor %}
> +                  </ul>
> +            {% endif %}
> +            {% if result.news %}
> +              <h2>News:</h2>
> +                  <ul class="search">
> +                      {% for news in result.news %}
> +                        <li class="highlight"> 
> +                          {% include "search/includes/news.html" %}
> +                        </li>
> +                      {% endfor %}
> +                  </ul>
> +            {% endif %}
> +            {% if result.maps %}
> +              <h2>Maps:</h2>
> +                  <ul class="search">
> +                      {% for map in result.maps %}
> +                        <li> 
> +                          {% include "search/includes/maps.html" %}
> +                        </li>
> +                      {% endfor %}
> +                  </ul>
> +            {% endif %}
> +            {% if result.workers or result.buildings or result.wares %}
> +                <h2>Encylopedia:</h2>
> +                {% if result.workers %}
> +                    <h3>Workers: </h3>
> +                    <ul class="search">
> +                        {% for worker in result.workers %}
> +                          <li class="highlight">
> +                            {% include "search/includes/workers.html" %}
> +                          </li>
> +                        {% endfor %}
> +                    </ul>
> +                {% endif %}
> +                {% if result.wares %}
> +                    <h3>Wares:</h3>
> +                    <ul class="search">
> +                        {% for ware in result.wares %}
> +                          <li class="highlight">
> +                            {% include "search/includes/wares.html" %}
> +                          </li>
> +                        {% endfor %}
> +                    </ul>
> +                {% endif %}
> +                {% if result.buildings %}
> +                    <h3>Buildings:</h3>
> +                    <ul class="search">
> +                        {% for building in result.buildings %}
> +                          <li class="highlight">
> +                            {% include "search/includes/buildings.html" %}
> +                          </li>
> +                        {% endfor %}
> +                    </ul>
> +                {% endif %}
> +              {% endif %} {# Encyclopedia #}
> +        {% else %}
> +          <p><span class="errormessage">Nothing found... </span>
> +          consider to adjust the start date when searching the Forum or News.

to adjust -> adjusting

> +          </p>
> +        {% endif %} {# result #}
> +      {% else %}
> +        <p class="errormessage">Please enter a term to search for.</p>
> +      {% endif %} {# query #}
> +    </form>
> +    </div>
> +{% endblock %}
> 
> === added file 'wlmaps/search_indexes.py'
> --- wlmaps/search_indexes.py	1970-01-01 00:00:00 +0000
> +++ wlmaps/search_indexes.py	2017-10-05 21:59:22 +0000
> @@ -0,0 +1,31 @@
> +from haystack import indexes
> +from haystack.fields import DateField
> +from wlmaps.models import Map
> +from datetime import date
> +
> +
> +class MapIndex(indexes.SearchIndex, indexes.Indexable):
> +
> +    """Create a search index. Changes made here need to be reindexed.
> +    Defined fields are stored in the index, so when displaying the result the
> +    data is read from the index and do not hit the database.
> +
> +    Except the 'text' field all defined fields will be in the index.
> +
> +    'text' indicates the template where the concatenated data
> +           is gathered and the search runs over.
> +
> +    'date' is the field which is used for sorting
> +
> +    """
> +
> +    text = indexes.CharField(document=True, use_template=True)
> +    author = indexes.CharField(model_attr='author')
> +    date = DateField(default=date.today())
> +    pub_date = indexes.DateTimeField(model_attr='pub_date')

Should we also search the map hints?

> +
> +    def get_model(self):
> +        return Map
> +    
> +    def get_updated_field(self):
> +        return "pub_date"


-- 
https://code.launchpad.net/~widelands-dev/widelands-website/searching_with_haystack_whoosh/+merge/331605
Your team Widelands Developers is subscribed to branch lp:widelands-website.


References