Skip to content

Commit 69cbd18

Browse files
committed
Rework the search box for the sample problems page.
This is a rework of openwebwork#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 openwebwork#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 435a549 commit 69cbd18

File tree

12 files changed

+386
-482
lines changed

12 files changed

+386
-482
lines changed

bin/dev_scripts/stop-words-en.txt renamed to assets/stop-words-en.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# This file contains stop words from https://github.com/Alir3z4/stop-words
2-
# These words will be ignored in the processing of macros and sample problems used by the script
3-
# bin/dev_scripts/build-search-db.pl
1+
# Stop words from https://github.com/Alir3z4/stop-words.
42

53
'll
64
'tis
75
'twas
86
've
9-
10
10-
39
117
a
128
a's
139
able
@@ -1300,3 +1296,25 @@ za
13001296
zero
13011297
zm
13021298
zr
1299+
1300+
# Additional specific stop words specific to POD and sample problem documentation.
1301+
constructor
1302+
description
1303+
error
1304+
errors
1305+
macro
1306+
macros
1307+
pod
1308+
podlink
1309+
problink
1310+
synopsis
1311+
usage
1312+
funciton
1313+
functions
1314+
method
1315+
methods
1316+
option
1317+
options
1318+
todo
1319+
fixme
1320+
_

bin/build-search-json.pl

Lines changed: 0 additions & 262 deletions
This file was deleted.

bin/download-OPL-metadata-release.pl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# This script downloads the latest OPL metadata release, and restores the database dump file in that release.
44

5-
use feature say;
65
use strict;
76
use warnings;
7+
use feature 'say';
88

99
use File::Fetch;
1010
use File::Copy;
@@ -80,12 +80,8 @@ BEGIN
8080
die "The directory $libraryDirectory does not exist or is not writable."
8181
if (!-d $libraryDirectory || !-w $libraryDirectory);
8282

83-
warn $ENV{OPL_GIT_REPOSITORY};
84-
85-
my $git_repo = $ENV{OPL_GIT_REPOSITORY} // 'origin';
86-
8783
# Checkout the release tag in the library clone if it hasn't already been done.
88-
`$ce->{externalPrograms}{git} -C $libraryDirectory fetch --tags $git_repo`;
84+
`$ce->{externalPrograms}{git} -C $libraryDirectory fetch --tags origin`;
8985
`$ce->{externalPrograms}{git} -C $libraryDirectory show-ref refs/heads/$releaseTag -q`;
9086
if ($?) {
9187
say "Switching OPL clone in $libraryDirectory to new branch of release tag $releaseTag.";

0 commit comments

Comments
 (0)