Project

General

Profile

Design Notes » History » Version 12

Luke Murphey, 11/07/2018 06:51 PM

1 1 Luke Murphey
h1. Design Notes
2 1 Luke Murphey
3 1 Luke Murphey
h2. AJAX content loading caching system
4 1 Luke Murphey
5 1 Luke Murphey
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:
6 1 Luke Murphey
7 1 Luke Murphey
# Caching the current page on the server
8 1 Luke Murphey
# Pre-loading the next page so that it is pre-cached
9 1 Luke Murphey
10 9 Luke Murphey
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.
11 1 Luke Murphey
12 9 Luke Murphey
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.
13 1 Luke Murphey
14 1 Luke Murphey
h2. ajaxify: what does it do?
15 1 Luke Murphey
16 1 Luke Murphey
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.
17 2 Luke Murphey
18 2 Luke Murphey
h2. How the type-ahead system in the search works
19 2 Luke Murphey
20 2 Luke Murphey
# The search-query uses the Bootstrap type-ahead component to invoke a call to get_works_search_typeahead_hints()
21 2 Luke Murphey
# get_works_search_typeahead_hints() obtains the type-ahead hints for Bootstrap
22 2 Luke Murphey
# On submitting the search query, jump_to_searched_text() will be used to jump directly to the matching work
23 3 Luke Murphey
24 3 Luke Murphey
h2. How are related works identified in the importer?
25 3 Luke Murphey
26 3 Luke Murphey
The RelatedWork model function autodiscover() attempts to find related works and link them. It considers them comparable when:
27 3 Luke Murphey
#  The number of authors are the same and the authors names are the same and in the same order
28 3 Luke Murphey
#  The number of editors are the same and the editors names are the same and in the same order
29 3 Luke Murphey
# The divisions are the same (same number of them and the descriptors are the same and in the same order)
30 4 Luke Murphey
31 5 Luke Murphey
h2. How search indexes get re-populated
32 4 Luke Murphey
33 5 Luke Murphey
There is a built-in command to re-index works. For example:
34 4 Luke Murphey
35 4 Luke Murphey
<pre>
36 4 Luke Murphey
python manage.py make_search_indexes -w lxx
37 4 Luke Murphey
</pre>
38 4 Luke Murphey
39 4 Luke Murphey
If you want to clear the existing index for a work before indexing it, then include the -f option:
40 4 Luke Murphey
41 4 Luke Murphey
<pre>
42 4 Luke Murphey
python manage.py make_search_indexes -f -w lxx
43 4 Luke Murphey
</pre>
44 4 Luke Murphey
45 4 Luke Murphey
You can clear the index entirely with:
46 4 Luke Murphey
47 4 Luke Murphey
<pre>
48 4 Luke Murphey
python manage.py make_search_indexes -c
49 4 Luke Murphey
</pre>
50 4 Luke Murphey
51 4 Luke Murphey
You can re-create the index entirely with:
52 4 Luke Murphey
53 4 Luke Murphey
<pre>
54 4 Luke Murphey
python manage.py make_search_indexes
55 4 Luke Murphey
</pre>
56 6 Luke Murphey
57 6 Luke Murphey
h2. How to populate related works
58 6 Luke Murphey
59 6 Luke Murphey
The following will be compared to see if two works are equivalent:
60 6 Luke Murphey
61 6 Luke Murphey
# TItles
62 6 Luke Murphey
# Count of authors
63 6 Luke Murphey
# Author names
64 6 Luke Murphey
# Count of editors (optionally)
65 6 Luke Murphey
# Editor names (optionally)
66 1 Luke Murphey
# Divisions (optionally)
67 6 Luke Murphey
68 9 Luke Murphey
This can be done in code with the following:
69 6 Luke Murphey
<pre>
70 1 Luke Murphey
from reader.models import RelatedWork
71 1 Luke Murphey
RelatedWork.autodiscover()
72 9 Luke Murphey
</pre>
73 9 Luke Murphey
74 9 Luke Murphey
You can also use the autodiscover_related_works command to link related works. Generally, I suggest starting with the test parameter to see what would be linked:
75 9 Luke Murphey
76 9 Luke Murphey
<pre>
77 9 Luke Murphey
python manage.py autodiscover_related_works -w the-histories-greek --test
78 9 Luke Murphey
</pre>
79 9 Luke Murphey
80 9 Luke Murphey
If you want the linkage to be created, then run the command without the test parameter:
81 9 Luke Murphey
82 9 Luke Murphey
<pre>
83 9 Luke Murphey
python manage.py autodiscover_related_works -w the-histories-greek
84 6 Luke Murphey
</pre>
85 10 Luke Murphey
86 10 Luke Murphey
h2. How can I import Perseus works?
87 10 Luke Murphey
88 10 Luke Murphey
You can batch import Perseus works by running the batch_import_perseus command against a directory of Perseus works:
89 10 Luke Murphey
90 10 Luke Murphey
<pre>
91 10 Luke Murphey
python manage.py batch_import_perseus -d var/import_queue/
92 10 Luke Murphey
</pre>
93 10 Luke Murphey
94 10 Luke Murphey
The command above will import the work according to the import policy (thus using the recommended settings).
95 10 Luke Murphey
96 10 Luke Murphey
h2. What is the purpose of the Perseus import policy?
97 10 Luke Murphey
98 10 Luke Murphey
The import policy indicates if a work will be imported and what settings will be used. Here is how the importer uses the policy:
99 10 Luke Murphey
100 10 Luke Murphey
# Gets import policy. Stop is there is no matching import policy.
101 10 Luke Murphey
# The PerseusTextImporter is called with the import policy
102 10 Luke Murphey
# The is imported unless the file doesn't already exist or is directed to force update
103 10 Luke Murphey
104 10 Luke Murphey
Similar works are linked using the autodiscover() function in the RelatedWork class. This needs to be called manually since the import process doesn't do this automatically.
105 11 Luke Murphey
106 11 Luke Murphey
h2. How does the AJAH system work?
107 11 Luke Murphey
108 11 Luke Murphey
The intention of this system is to quickly load a loading page and then get the main content a bit later.
109 11 Luke Murphey
110 11 Luke Murphey
* *ajaxify*: renders a page which in turns will get the content asynchronously
111 11 Luke Murphey
* *ajah_redirect.html*: a template that loads the HTML holder page and calls TextCritical.load_ajah() to get the main content.
112 12 Luke Murphey
* *TextCritical.load_ajah()*: The main content will be retrieved with the argument necessary to only get the main content, not the surrounding page.