Design Notes » History » Version 6
Version 5 (Luke Murphey, 03/10/2016 06:56 AM) → Version 6/13 (Luke Murphey, 03/27/2016 03:06 AM)
h1. Design Notes
h2. AJAX content loading caching system
The content for the reading pages is cached in order to reduce the loading time of the chapters. This is necessary because rendering is expensive. This works by:
# Caching the current page on the server
# Pre-loading the next page so that it is pre-cached
The way that this works is that the template for the page will only return the non-content part of the page if the request is not an AJAX request. This will not be cached.
On the other hand. if the request is for an AJAX request, then only the content part of the page will be returned. This will be cached.
h2. ajaxify: what does it do?
The ajaxify decorator changes the page that will be returned such that it is a shell that will request the actual page. This is useful in order to show content to a user quickly with a progress-bar instead of showing a white screen while the content is prepared.
h2. How the type-ahead system in the search works
# The search-query uses the Bootstrap type-ahead component to invoke a call to get_works_search_typeahead_hints()
# get_works_search_typeahead_hints() obtains the type-ahead hints for Bootstrap
# On submitting the search query, jump_to_searched_text() will be used to jump directly to the matching work
h2. How are related works identified in the importer?
The RelatedWork model function autodiscover() attempts to find related works and link them. It considers them comparable when:
# The number of authors are the same and the authors names are the same and in the same order
# The number of editors are the same and the editors names are the same and in the same order
# The divisions are the same (same number of them and the descriptors are the same and in the same order)
h2. How search indexes get re-populated
There is a built-in command to re-index works. For example:
<pre>
python manage.py make_search_indexes -w lxx
</pre>
If you want to clear the existing index for a work before indexing it, then include the -f option:
<pre>
python manage.py make_search_indexes -f -w lxx
</pre>
You can clear the index entirely with:
<pre>
python manage.py make_search_indexes -c
</pre>
You can re-create the index entirely with:
<pre>
python manage.py make_search_indexes
</pre>
h2. How to populate related works
The following will be compared to see if two works are equivalent:
# TItles
# Count of authors
# Author names
# Count of editors (optionally)
# Editor names (optionally)
# Divisions (optionally)
<pre>
from reader.models import RelatedWork
RelatedWork.autodiscover()
</pre>
h2. AJAX content loading caching system
The content for the reading pages is cached in order to reduce the loading time of the chapters. This is necessary because rendering is expensive. This works by:
# Caching the current page on the server
# Pre-loading the next page so that it is pre-cached
The way that this works is that the template for the page will only return the non-content part of the page if the request is not an AJAX request. This will not be cached.
On the other hand. if the request is for an AJAX request, then only the content part of the page will be returned. This will be cached.
h2. ajaxify: what does it do?
The ajaxify decorator changes the page that will be returned such that it is a shell that will request the actual page. This is useful in order to show content to a user quickly with a progress-bar instead of showing a white screen while the content is prepared.
h2. How the type-ahead system in the search works
# The search-query uses the Bootstrap type-ahead component to invoke a call to get_works_search_typeahead_hints()
# get_works_search_typeahead_hints() obtains the type-ahead hints for Bootstrap
# On submitting the search query, jump_to_searched_text() will be used to jump directly to the matching work
h2. How are related works identified in the importer?
The RelatedWork model function autodiscover() attempts to find related works and link them. It considers them comparable when:
# The number of authors are the same and the authors names are the same and in the same order
# The number of editors are the same and the editors names are the same and in the same order
# The divisions are the same (same number of them and the descriptors are the same and in the same order)
h2. How search indexes get re-populated
There is a built-in command to re-index works. For example:
<pre>
python manage.py make_search_indexes -w lxx
</pre>
If you want to clear the existing index for a work before indexing it, then include the -f option:
<pre>
python manage.py make_search_indexes -f -w lxx
</pre>
You can clear the index entirely with:
<pre>
python manage.py make_search_indexes -c
</pre>
You can re-create the index entirely with:
<pre>
python manage.py make_search_indexes
</pre>
h2. How to populate related works
The following will be compared to see if two works are equivalent:
# TItles
# Count of authors
# Author names
# Count of editors (optionally)
# Editor names (optionally)
# Divisions (optionally)
<pre>
from reader.models import RelatedWork
RelatedWork.autodiscover()
</pre>