Skip to content

Commit 73cd0d9

Browse files
v0.14.1 (see NEWS)
1 parent a832ec2 commit 73cd0d9

File tree

10 files changed

+229
-82
lines changed

10 files changed

+229
-82
lines changed

NEWS

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
| |_| | |_| | _ <| |___| __/ | |\ | |___ \ V V / ___) |
55
\___/ \___/|_| \_\_____|_| |_| \_|_____| \_/\_/ |____/
66

7+
v0.14.1 Sat Jan 21 11:11:56 CET 2023
8+
--------------------------------------------------------
9+
- Minor improvements and changes:
10+
- Update FAQ with example searches
11+
12+
- Bug fixes:
13+
- When logged in, the landing page contained the input mask twice
14+
- Exact searches like "wisdom t*" would not be highlighted in MM
15+
search
16+
- Sharing of search link would fail when quotation marks were used
17+
718
v0.14.0 Wed Dec 28 17:39:17 CET 2022
819
--------------------------------------------------------
920
- Main features:

backend/app/org/multics/baueran/frep/backend/controllers/Get.scala

+48-23
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package org.multics.baueran.frep.backend.controllers
33
import javax.inject._
44
import io.circe.syntax._
55
import play.api.mvc._
6-
import org.multics.baueran.frep.backend.dao.{CazeDao, EmailHistoryDao, FileDao, MemberDao, PasswordChangeRequestDao, RepertoryDao, MMDao}
6+
import org.multics.baueran.frep.backend.dao.{CazeDao, EmailHistoryDao, FileDao, MMDao, MemberDao, PasswordChangeRequestDao, RepertoryDao}
77
import org.multics.baueran.frep.shared._
88
import org.multics.baueran.frep.backend.db.db.DBContext
99
import Defs._
10+
import play.api.libs.json.JsResult.Exception
1011

12+
import java.net.URLEncoder
13+
import java.nio.charset.StandardCharsets
1114
import java.text.SimpleDateFormat
1215

1316
/**
@@ -71,12 +74,24 @@ class Get @Inject()(cc: ControllerComponents, dbContext: DBContext) extends Abst
7174
Redirect(sys.env.get("OOREP_URL_LOGOUT").getOrElse(""))
7275
}
7376

74-
def show(repertory: String, symptom: String, page: Int, remedyString: String, minWeight: Int) = Action { request: Request[AnyContent] =>
75-
Ok(views.html.index_lookup(request, repertory, symptom, page - 1, remedyString, minWeight, s"OOREP - ${symptom} (${repertory})"))
77+
def show(repertory: String, symptom: String, page: Int, remedyString: String, minWeight: Int) = Action { implicit request: Request[AnyContent] =>
78+
try {
79+
Ok(views.html.index_lookup(request, repertory, URLEncoder.encode(symptom, StandardCharsets.UTF_8.toString()), page - 1, remedyString, minWeight, s"OOREP - ${symptom} (${repertory})"))
80+
} catch {
81+
case e: Exception =>
82+
Logger.debug(s"GET: show() failed; most likely URLEncoder.encode(): ${e.toString}")
83+
InternalServerError(views.html.defaultpages.badRequest("GET", request.uri, "Something went wrong. Go to main page, https://www.oorep.com/, and try again, or submit a bug report!"))
84+
}
7685
}
7786

78-
def showMM(materiaMedica: String, symptom: String, page: Int, hideSections: Boolean, remedyString: String) = Action { request: Request[AnyContent] =>
79-
Ok(views.html.index_lookup_mm(request, materiaMedica, symptom, page - 1, hideSections, remedyString, s"OOREP - ${symptom} (${materiaMedica})"))
87+
def showMM(materiaMedica: String, symptom: String, page: Int, hideSections: Boolean, remedyString: String) = Action { implicit request: Request[AnyContent] =>
88+
try {
89+
Ok(views.html.index_lookup_mm(request, materiaMedica, URLEncoder.encode(symptom, StandardCharsets.UTF_8.toString()), page - 1, hideSections, remedyString, s"OOREP - ${symptom} (${materiaMedica})"))
90+
} catch {
91+
case e: Exception =>
92+
Logger.debug(s"GET: showMM() failed; most likely URLEncoder.encode(): ${e.toString}")
93+
InternalServerError(views.html.defaultpages.badRequest("GET", request.uri, "Something went wrong. Go to main page, https://www.oorep.com/, and try again, or submit a bug report!"))
94+
}
8095
}
8196

8297
def serve_static_html(page: String) = Action { implicit request: Request[AnyContent] =>
@@ -266,28 +281,38 @@ class Get @Inject()(cc: ControllerComponents, dbContext: DBContext) extends Abst
266281
}
267282

268283
def apiLookupRep(repertoryAbbrev: String, symptom: String, page: Int, remedyString: String, minWeight: Int, getRemedies: Int) = Action { request: Request[AnyContent] =>
269-
val searchTerms = new SearchTerms(symptom.trim)
270-
val cleanedUpAbbrev = repertoryAbbrev.replaceAll("[^0-9A-Za-z\\-]", "")
271-
272-
repertoryDao.queryRepertory(cleanedUpAbbrev, searchTerms, page, remedyString.trim, minWeight, getRemedies != 0) match {
273-
case Some((ResultsCaseRubrics(totalNumberOfRepertoryRubrics, totalNumberOfResults, totalNumberOfPages, page, results), remedyStats)) if (totalNumberOfPages > 0) =>
274-
Ok((ResultsCaseRubrics(totalNumberOfRepertoryRubrics, totalNumberOfResults, totalNumberOfPages, page, results), remedyStats).asJson.toString())
275-
case _ =>
276-
Logger.info(s"Get: apiLookupRep(abbrev: ${repertoryAbbrev}, symptom: ${symptom}, page: ${page}, remedy: ${remedyString}, weight: ${minWeight}): no results found")
277-
NoContent
284+
// We don't allow '*' in the middle of a search term. '*' can only be at beginning or end of a word, whether exact search term or not.
285+
if (symptom.trim.matches(".*\\w+\\*\\w+.*") || symptom.trim.contains(" * ")) {
286+
NoContent
287+
} else {
288+
val searchTerms = new SearchTerms(symptom.trim)
289+
val cleanedUpAbbrev = repertoryAbbrev.replaceAll("[^0-9A-Za-z\\-]", "")
290+
291+
repertoryDao.queryRepertory(cleanedUpAbbrev, searchTerms, page, remedyString.trim, minWeight, getRemedies != 0) match {
292+
case Some((ResultsCaseRubrics(totalNumberOfRepertoryRubrics, totalNumberOfResults, totalNumberOfPages, page, results), remedyStats)) if (totalNumberOfPages > 0) =>
293+
Ok((ResultsCaseRubrics(totalNumberOfRepertoryRubrics, totalNumberOfResults, totalNumberOfPages, page, results), remedyStats).asJson.toString())
294+
case _ =>
295+
Logger.info(s"Get: apiLookupRep(abbrev: ${repertoryAbbrev}, symptom: ${symptom}, page: ${page}, remedy: ${remedyString}, weight: ${minWeight}): no results found")
296+
NoContent
297+
}
278298
}
279299
}
280300

281301
def apiLookupMM(mmAbbrev: String, symptom: String, page: Int, remedyString: String) = Action { request: Request[AnyContent] =>
282-
val searchTerms = new SearchTerms(symptom.trim)
283-
val cleanedUpAbbrev = mmAbbrev.replaceAll("[^0-9A-Za-z\\-]", "")
284-
285-
mmDao.getSectionHits(cleanedUpAbbrev, searchTerms, page, Some(remedyString)) match {
286-
case Some(sectionHits) if (sectionHits.results.length > 0 || sectionHits.numberOfMatchingSectionsPerChapter.length > 0) =>
287-
Ok(sectionHits.asJson.toString())
288-
case _ =>
289-
Logger.info(s"Get: apiLookupMM(abbrev: ${mmAbbrev}, symptom: ${symptom}, page: ${page}, remedy: ${remedyString}): no results found")
290-
NoContent
302+
// We don't allow '*' in the middle of a search term. '*' can only be at beginning or end of a word, whether exact search term or not.
303+
if (symptom.trim.matches(".*\\w+\\*\\w+.*") || symptom.trim.contains(" * ")) {
304+
NoContent
305+
} else {
306+
val searchTerms = new SearchTerms(symptom.trim)
307+
val cleanedUpAbbrev = mmAbbrev.replaceAll("[^0-9A-Za-z\\-]", "")
308+
309+
mmDao.getSectionHits(cleanedUpAbbrev, searchTerms, page, Some(remedyString)) match {
310+
case Some(sectionHits) if (sectionHits.results.length > 0 || sectionHits.numberOfMatchingSectionsPerChapter.length > 0) =>
311+
Ok(sectionHits.asJson.toString())
312+
case _ =>
313+
Logger.info(s"Get: apiLookupMM(abbrev: ${mmAbbrev}, symptom: ${symptom}, page: ${page}, remedy: ${remedyString}): no results found")
314+
NoContent
315+
}
291316
}
292317
}
293318

backend/app/views/index_lookup.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h1 style="font-size:20pt;">
7272

7373
<script>
7474
$(document).ready(function(){
75-
RepertoryView.doLookup("@repertory", "@symptom", @page, "@remedyString", @minWeight);
75+
RepertoryView.doLookup("@repertory", decodeURIComponent("@symptom").replace( /\+/g, ' ' ), @page, "@remedyString", @minWeight);
7676
});
7777
</script>
7878

backend/app/views/index_lookup_mm.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h1 style="font-size:20pt;">
7272

7373
<script>
7474
$(document).ready(function(){
75-
MateriaMedicaView.doLookup("@materiaMedica", "@symptom", @page, @hideSections, "@remedyString");
75+
MateriaMedicaView.doLookup("@materiaMedica", decodeURIComponent("@symptom").replace( /\+/g, ' ' ), @page, @hideSections, "@remedyString");
7676
});
7777
</script>
7878

backend/app/views/partial/faq.scala.html

+154-51
Original file line numberDiff line numberDiff line change
@@ -226,62 +226,165 @@ <h5 class="freetext">&bull; Which third-party libraries and fonts are used on th
226226
</p>
227227

228228
</div>
229-
230-
<div class="col">
231-
232-
<h3 class="freetext">Other</h3>
233-
234-
<h5 class="freetext">&bull; Why am I not getting good search results from OOREP?</h5>
235229

236-
<p style="text-align:justify;">
237-
There are possibly three major reasons, why you may be dissatisifed with
238-
the search results of this site:
239-
</p>
240-
241-
<p style="text-align:justify;">
242-
1. the search returned too many results and you have trouble finding
243-
the one that is specific to your need. If that's the case, you can try
244-
restricting your search by adding additional search terms to narrow
245-
the scope. Alternatively, you can <b>exclude</b> certain search terms
246-
to make your search more specific. So, for example, rather than looking
247-
for <i>pain</i>, you could look for <tt>pain, -abdomen, -head</tt>, thereby excluding
248-
all results containing <i>head</i> or <i>abdomen</i>.
249-
</p>
250-
251-
<div class="alert alert-primary container" style="width: 85%;">
252-
<i class="oi oi-info"></i>
253-
<strong class="mx-2">Info!</strong>
254-
Exclude certain symptoms using <i>minus</i>, like <tt>pain, -abdomen, -head</tt>.
255-
</div>
230+
<div class="col">
256231

257-
<p style="text-align:justify;">
258-
2. the search doesn't return enough results for a
259-
single look-up. In this case, try using
260-
so-called <b>wildcards</b>. So, instead of looking for
261-
<tt>throat, dry</tt> (2 results in publicum), you could try looking
262-
for <tt>throat*, dry*</tt> (47 results in publicum). This also
263-
matches <i>dryness</i>, for example.
264-
</p>
232+
<h3 class="freetext">Search</h3>
233+
234+
<h5 class="freetext">&bull; Why am I not getting good search results from OOREP?</h5>
235+
236+
<p style="text-align:justify;">
237+
There are possibly three major reasons, why you may be dissatisifed with
238+
the search results of this site:
239+
</p>
240+
241+
<p style="text-align:justify;">
242+
1. the search returned too many results and you have trouble finding
243+
the one that is specific to your need. If that's the case, you can try
244+
restricting your search by adding additional search terms to narrow
245+
the scope. Alternatively, you can <b>exclude</b> certain search terms
246+
to make your search more specific. So, for example, rather than looking
247+
for <i>pain</i>, you could look for <tt>pain, -abdomen, -head</tt>, thereby excluding
248+
all results containing <i>head</i> or <i>abdomen</i>.
249+
</p>
250+
251+
<div class="alert alert-primary container" style="width: 85%;">
252+
<i class="oi oi-info"></i>
253+
<strong class="mx-2">Info!</strong>
254+
Exclude certain symptoms using <i>minus</i>, like <tt>pain, -abdomen, -head</tt>.
255+
</div>
256+
257+
<p style="text-align:justify;">
258+
2. the search doesn't return enough results for a
259+
single look-up. In this case, try using
260+
so-called <b>wildcards</b>. So, instead of looking for
261+
<tt>throat, dry</tt> (2 results in publicum), you could try looking
262+
for <tt>throat*, dry*</tt> (47 results in publicum). This also
263+
matches <i>dryness</i>, for example.
264+
</p>
265+
266+
<div class="alert alert-primary container" style="width: 85%;">
267+
<i class="oi oi-info"></i>
268+
<strong class="mx-2">Info!</strong>
269+
Use the <i>star-symbol</i> as placeholder: <tt>pain*</tt> will also match <i>painful, pain, painless, pains</i>, etc.
270+
</div>
271+
272+
<p style="text-align:justify;">
273+
3. Especially in materia medica search, you may find that results are not
274+
specific enough. For example, if you look for <i>swollen gums</i> as a symptom
275+
then <tt>gums, swollen</tt> gets all sections that contain symptoms about the gums
276+
and swellings, but not necessarily swollen gums. You can use <b>exact search</b>
277+
with explicit <b>quotation marks</b> for that as follows:
278+
</p>
279+
280+
<div class="alert alert-primary container" style="width: 85%;">
281+
<i class="oi oi-info"></i>
282+
<strong class="mx-2">Info!</strong>
283+
Search for <tt>"gums swollen"</tt> instead of <tt>gums swollen</tt> (or even better: <tt>"gums sw*"</tt>).
284+
</div>
285+
286+
<h5 class="freetext">&bull; Show me some EXAMPLE searches!</h5>
287+
288+
<p style="text-align:justify;">
289+
Combine <b>wildcards</b> and <b>exclusion</b> to find all sections that contain anything about swollen gums or swellings, but no sections that merely mention sweets, or sweet taste, etc.:
290+
</p>
291+
292+
<div class="alert alert-success container" style="width: 85%;">
293+
<i class="oi oi-check"></i>
294+
<strong class="mx-2">Valid:</strong>
295+
<tt>gum*, sw*, -sweet*</tt>
296+
</div>
297+
298+
<p style="text-align:justify;">
299+
The <b>exact search</b> (that is, the use of quotation marks) is particularly useful for searching in a materia medica, but can be used in repertory search as well, of course.
300+
</p>
301+
302+
<p style="text-align:justify;">
303+
Combine <b>exact search</b> and <b>wildcard</b> to find all sections that contain <i>wisdom teeth</i> or <i>wisdom tooth</i> (but not, <i>wisdom of Hahnemann's method</i>, for example):
304+
</p>
305+
306+
<div class="alert alert-success container" style="width: 85%;">
307+
<i class="oi oi-check"></i>
308+
<strong class="mx-2">Valid:</strong>
309+
<tt>"wisdom t*"</tt>
310+
</div>
311+
312+
<div class="alert alert-danger container" style="width: 85%;">
313+
<i class="oi oi-flash"></i>
314+
<strong class="mx-2">Invalid:</strong>
315+
<tt>"wisd*m teeth"</tt> (Why? A '<tt>*</tt>' can only be at beginning or end of a word.)
316+
</div>
317+
318+
<p style="text-align:justify;">
319+
Combine <b>exact search</b> and <b>wildcards</b> to find all sections that contain <i>spine pain</i>, <i>spine pains</i>, <i>spinal pain</i>, or <i>spinal pains</i>, etc.:
320+
</p>
321+
322+
<div class="alert alert-success container" style="width: 85%;">
323+
<i class="oi oi-check"></i>
324+
<strong class="mx-2">Valid:</strong>
325+
<tt>"spin* pain*"</tt> (Note the use of two '<tt>*</tt>' in one exact search!)
326+
</div>
327+
328+
<p style="text-align:justify;">
329+
Combine <b>exact search</b> with a <b>plain search</b> to find all sections that contain <i>spine pain</i>, <i>spine pains</i>, <i>spinal pain</i>, or <i>spinal pains</i>, etc. as well as <i>headache</i>:
330+
</p>
331+
332+
<div class="alert alert-success container" style="width: 85%;">
333+
<i class="oi oi-check"></i>
334+
<strong class="mx-2">Valid:</strong>
335+
<tt>"spin* pain*", headache</tt>
336+
</div>
337+
338+
<p style="text-align:justify;">
339+
Combine two or more <b>exact searches</b> to find all sections that contain anything to do with heart palpitations and the exact words <i>pain in</i>:
340+
</p>
341+
342+
<div class="alert alert-success container" style="width: 85%;">
343+
<i class="oi oi-check"></i>
344+
<strong class="mx-2">Valid:</strong>
345+
<tt>"heart palp*", "pain in"</tt>
346+
</div>
347+
348+
<p style="text-align:justify;">
349+
Combine <b>exact search</b> with <b>exclusion</b> to find all sections that contain anything to do with heart palpitations but not the exact words <i>pain in</i>:
350+
</p>
351+
352+
<div class="alert alert-success container" style="width: 85%;">
353+
<i class="oi oi-check"></i>
354+
<strong class="mx-2">Valid:</strong>
355+
<tt>"heart palp*", -"pain in"</tt>
356+
</div>
357+
358+
<div class="alert alert-danger container" style="width: 85%;">
359+
<i class="oi oi-flash"></i>
360+
<strong class="mx-2">Invalid:</strong>
361+
<tt>-"heart palp*", -"pain in"</tt> (Why? You need at least one <i>positive</i> search term.)
362+
</div>
363+
364+
<h5 class="freetext">&bull; When do I need the commas?</h5>
365+
366+
<p style="text-align:justify;">
367+
Search does not care, if you separate search terms with a comma (',') or not.
368+
A comma really only makes a difference within an <b>exact search</b>; that is, within an enclosed term "...".
369+
</p>
370+
371+
<div class="alert alert-success container" style="width: 85%;">
372+
<i class="oi oi-check"></i>
373+
<strong class="mx-2">Equal:</strong>
374+
<tt>pain*, head, left</tt> &nbsp; &nbsp; <b>=</b> &nbsp; &nbsp; <tt>pain* head left</tt>
375+
</div>
376+
377+
<div class="alert alert-danger container" style="width: 85%;">
378+
<i class="oi oi-flash"></i>
379+
<strong class="mx-2">Not equal:</strong>
380+
<tt>"back, pain"</tt> &nbsp; &nbsp; <b>&#8800;</b> &nbsp; &nbsp; <tt>"back pain"</tt>
381+
</div>
265382

266-
<div class="alert alert-primary container" style="width: 85%;">
267-
<i class="oi oi-info"></i>
268-
<strong class="mx-2">Info!</strong>
269-
Use the <i>star-symbol</i> as placeholder: <tt>pain*</tt> will also match <i>painful, pain, painless, pains</i>, etc.
270-
</div>
383+
</div>
271384

272-
<p style="text-align:justify;">
273-
3. Especially in materia medica search, you may find that results are not
274-
specific enough. For example, if you look for <i>swollen gums</i> as a symptom
275-
then <tt>gums, swollen</tt> gets all sections that contain symptoms about the gums
276-
and swellings, but not necessarily swollen gums. You can use <b>exact search</b>
277-
with explicit <b>quotation marks</b> for that as follows:
278-
</p>
385+
<div class="col">
279386

280-
<div class="alert alert-primary container" style="width: 85%;">
281-
<i class="oi oi-info"></i>
282-
<strong class="mx-2">Info!</strong>
283-
Search for <tt><red>"</red>gums swollen"</tt> instead of <tt>gums swollen</tt> (or even better: <tt>"gums sw*"</tt>).
284-
</div>
387+
<h3 class="freetext">Other</h3>
285388

286389
<h5 class="freetext">&bull; How does registration/login work?</h5>
287390

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ lazy val commonSettings = Seq(
109109
scalaVersion := myScalaVersion,
110110
organization := "org.multics.baueran.frep",
111111
maintainer := "[email protected]",
112-
version := "0.14.0"
112+
version := "0.14.1"
113113
)
114114

115115
// TODO: This doesn't work, and I can't be bothered to get it to work.

docker/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=0.14.0
1+
VERSION=0.14.1

sec_frontend/src/main/scala/org/multics/baueran/frep/frontend/secure/base/Main.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.multics.baueran.frep.frontend.secure.base
22

33
import scala.scalajs.js.annotation.JSExportTopLevel
44
import org.multics.baueran.frep.shared._
5-
import frontend.{CaseModals, LoadingSpinner, MainView, RepertoryView, apiPrefix, serverUrl}
5+
import frontend.{CaseModals, LoadingSpinner, MainView, apiPrefix, serverUrl}
66
import sec_frontend.{AddToFileModal, EditFileModal, FileModalCallbacks, NewFileModal, OpenFileModal, RepertoryModal, MMModal}
77
import fr.hmil.roshttp.HttpRequest
88
import fr.hmil.roshttp.response.SimpleHttpResponse
@@ -147,9 +147,10 @@ object Main extends MainUtil {
147147
else if (dom.window.location.toString.contains("/change_password?")) {
148148
;
149149
}
150-
// Static content must not also show the repertorisation view
151150
else {
152-
dom.document.getElementById("content").appendChild(MainView().render)
151+
// Static content must not also show the repertorisation view
152+
// dom.document.getElementById("content").appendChild(MainView().render)
153+
;
153154
}
154155
}
155156

0 commit comments

Comments
 (0)