Documentation tweaks

This commit is contained in:
Tom Dyson 2014-05-28 13:22:32 +01:00
parent 07733c83ec
commit 9e294cb030
3 changed files with 35 additions and 42 deletions

View file

@ -187,33 +187,29 @@ In addition to the model fields provided, ``Page`` has many properties and metho
Properties:
specific
url
full_url
relative_url
has_unpublished_changes
status_string
subpage_types
indexed_fields
* specific
* url
* full_url
* relative_url
* has_unpublished_changes
* status_string
* subpage_types
* indexed_fields
Methods:
route
serve
get_context
get_template
is_navigable
get_other_siblings
get_ancestors
get_descendants
get_siblings
search
get_page_modes
show_as_mode
* route
* serve
* get_context
* get_template
* is_navigable
* get_other_siblings
* get_ancestors
* get_descendants
* get_siblings
* search
* get_page_modes
* show_as_mode
Page Queryset Methods

View file

@ -2,11 +2,7 @@ Building your site
==================
.. note::
Documentation currently incomplete and in draft status
Serafeim Papastefanos has written a comprehensive tutorial on creating a site from scratch in Wagtail; for the time being, this is our recommended resource:
`spapas.github.io/2014/02/13/wagtail-tutorial/ <http://spapas.github.io/2014/02/13/wagtail-tutorial/>`_
This documentation is currently incomplete.
.. toctree::
:maxdepth: 3

View file

@ -1,14 +1,14 @@
Search
======
Wagtail provides a very comprehensive, extensible, and flexible search interface. In addition, it provides ways to promote search results through "Editor's Picks." Wagtail also collects simple statistics on queries made through the search interface.
Wagtail provides a comprehensive and extensible search interface. In addition, it provides ways to promote search results through "Editor's Picks." Wagtail also collects simple statistics on queries made through the search interface.
Default Page Search
-------------------
Wagtail provides a default frontend search interface which indexes the ``title`` field common to all ``Page``-derived models. Lets take a look at all the components of the search interface.
Wagtail provides a default frontend search interface which indexes the ``title`` field common to all ``Page``-derived models. Let's take a look at all the components of the search interface.
The most basic search functionality just needs a search box which submits a request. Since this will be reused throughout the site, lets put it in ``mysite/includes/search_box.html`` and then use ``{% include ... %}`` to weave it into templates:
The most basic search functionality just needs a search box which submits a request. Since this will be reused throughout the site, let's put it in ``mysite/includes/search_box.html`` and then use ``{% include ... %}`` to weave it into templates:
.. code-block:: django
@ -17,15 +17,15 @@ The most basic search functionality just needs a search box which submits a requ
<input type="submit" value="Search">
</form>
The form is submitted to the url of the ``wagtailsearch_search`` view, with the search terms variable ``q``. The view will use its own (very) basic search results template.
The form is submitted to the url of the ``wagtailsearch_search`` view, with the search terms variable ``q``. The view will use its own basic search results template.
Lets use our own template for the results, though. First, in your project's ``settings.py``, define a path to your template:
Let's use our own template for the results, though. First, in your project's ``settings.py``, define a path to your template:
.. code-block:: python
WAGTAILSEARCH_RESULTS_TEMPLATE = 'mysite/search_results.html'
Next, lets look at the template itself:
Next, let's look at the template itself:
.. code-block:: django
@ -82,7 +82,7 @@ Editor's Picks are a way of explicitly linking relevant content to search terms,
``editors_pick.description``
The description entered when choosing the pick, perhaps explaining why the page is relevant to the search terms.
Putting this all together, a block of your search results template displaying Editor's Picks might look like this:
Putting this all together, a block of your search results template displaying editor's Picks might look like this:
.. code-block:: django
@ -106,10 +106,10 @@ Putting this all together, a block of your search results template displaying Ed
{% endif %}
{% endwith %}
Asyncronous Search with JSON and AJAX
-------------------------------------
Asynchronous Search with JSON and AJAX
--------------------------------------
Wagtail's provides JSON search results when queries are made to the ``wagtailsearch_suggest`` view. To take advantage of it, we need a way to make that URL available to a static script. Instead of hard-coding it, lets set a global variable in our ``base.html``:
Wagtail provides JSON search results when queries are made to the ``wagtailsearch_suggest`` view. To take advantage of it, we need a way to make that URL available to a static script. Instead of hard-coding it, let's set a global variable in our ``base.html``:
.. code-block:: django
@ -117,7 +117,7 @@ Wagtail's provides JSON search results when queries are made to the ``wagtailsea
var wagtailJSONSearchURL = "{% url 'wagtailsearch_suggest' %}";
</script>
Lets also add a simple interface for the search with a ``<input>`` element to gather search terms and a ``<div>`` to display the results:
Now add a simple interface for the search with a ``<input>`` element to gather search terms and a ``<div>`` to display the results:
.. code-block:: html
@ -130,7 +130,7 @@ Lets also add a simple interface for the search with a ``<input>`` element to ga
Finally, we'll use JQuery to make the asynchronous requests and handle the interactivity:
.. code-block:: guess
$(function() {
// cache the elements
@ -226,7 +226,8 @@ Prerequisites are the Elasticsearch service itself and, via pip, the `elasticuti
pip install elasticutils pyelasticsearch
NB: The dependency on pyelasticsearch is scheduled to be replaced by a dependency on `elasticsearch-py`_.
.. note::
The dependency on pyelasticsearch is scheduled to be replaced by a dependency on `elasticsearch-py`_.
The backend is configured in settings: