Commit ecc90a6
committed
Rework the search box for the sample problems page.
This is a rework of #2733.
This does not add any scripts that need to be run when webwork is
installed or upgraded. Instead the search data is dynamically
generated. The first time that the sample problems home page is loaded
all PG macros and sample problems are parsed and the search data
extracted. Then the data is saved to the
`DATA/sample-problem-search-data.json` file. This takes less than half a
second on my computer, but that will probably vary some depending on the
server's processing capabilities. The last modified time of each file is
also saved in that search data. On subsequent requests the last
modified time is checked, and a file is only parsed again if it has been
modified since the last time the page was loaded. If a file is deleted
from PG, the data is removed from the file. So even in development the
data will always reflect the current state of the PG repository on the
server. Subsequent requests when no changes to PG occur usually
complete in around 1/25th of a second. A change of a single file
increases that time only slightly.
Note that the search data is accessed by JavaScript via the new
`/sampleproblems/search_data` route.
The layout of the sample problems home page is changed considerably
from #2733. The layout now works on narrow screens and some
accessibility and html validation issues were addressed.
There is also quite a bit of improvement in the search data that is
saved. There is no attempt to single out methods or functions for
macros from the POD headers. Unfortunately, that was never really going
to work. Instead the words from all headers (that are not stop words)
are used. So the methods or functions that are in a POD header will be
in the search data, but other things will also be there. There are some
custom stop words added that are not desirable in the search data, like
"description", "synopsis", "podlink", and "problink".
Also, macros that don't have POD in them are not indexed at all since
there isn't anything to show for these files.1 parent ac6c643 commit ecc90a6
File tree
12 files changed
+386
-482
lines changed- assets
- bin
- htdocs
- js/SampleProblemViewer
- lib/WeBWorK
- ContentGenerator
- Utils
- templates/ContentGenerator
- SampleProblemViewer
12 files changed
+386
-482
lines changedLines changed: 23 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
9 | | - | |
10 | | - | |
11 | 7 | | |
12 | 8 | | |
13 | 9 | | |
| |||
1300 | 1296 | | |
1301 | 1297 | | |
1302 | 1298 | | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 83 | | |
88 | | - | |
| 84 | + | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| |||
0 commit comments