Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into complex_queries
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Oct 24, 2023
2 parents 4819490 + f96d66c commit ec8dbb1
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.10.1.dev0
current_version = 3.11.1.dev0
commit = True
tag = True
sign_tags = True
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0
- name: Prettify code
uses: creyD/[email protected]
with:
dry: true
# This part is also where you can pass other options, for example:
prettier_options: --write **/*.js --check
# only_changed: True
#- name: Prettify code
# uses: creyD/[email protected]
# with:
# dry: true
# # This part is also where you can pass other options, for example:
# prettier_options: --write **/*.js --check
# # only_changed: True
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
3.11.0 (October 2023)
---------------------

- Use search engine for all front-page auto-complete [#40](https://github.com/IDR/idr-gallery/pull/40)

3.10.1 (July 2023)
------------------

- Remove twitter feed [#36](https://github.com/IDR/idr-gallery/pull/36)

3.10.0 (May 2023)
-----------------

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Release process
- run ``bumpversion release`` to remove the dev suffix and create a signed tag
- run ``bumpversion --no-tag patch`` to bump the version to the next dev suffix
- push the newly created tag and ``master`` to ``origin``. e.g. ``git push origin master v3.3.3``
- the Travis CI build for the tag includes a PyPI deployment step, so no need to deploy on PyPi manually
- the GitHub action build for the tag includes a PyPI deployment step, so no need to deploy on PyPI manually

License
-------
Expand All @@ -172,4 +172,4 @@ License
Copyright
---------

2016-2022, The Open Microscopy Environment
2016-2023, The Open Microscopy Environment
43 changes: 22 additions & 21 deletions idr_gallery/static/idr_gallery/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,23 @@ function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}

function autoCompleteDisplayResults(queryVal, data) {
function autoCompleteDisplayResults(queryVal, data, filterImageKeys) {
// For showing the searchengine results in a panel
// filterImageKey is used if we want mapr-like behaviour showing results from a single Key
let queryRegex = new RegExp(escapeRegExp(queryVal), "ig"); // ignore-case, global

// Search-engine results...
let results = [...data.data];

// Also show 'instant' filtering of studies
// Also show 'instant' filtering of studies (if we're not filtering images)
// If there are no search-engine Image results, we highlight first Study
const highlightStudy = results.length === 0;
let studiesHtml = getMatchingStudiesHtml(queryVal, highlightStudy);
let studiesHtml = ""
if (!filterImageKeys) {
studiesHtml = getMatchingStudiesHtml(queryVal, highlightStudy);
} else {
results = results.filter(res => filterImageKeys.includes(res.Key));
}

results.sort(autocompleteSort(queryVal));
let imagesHtml = results
Expand Down Expand Up @@ -163,6 +169,8 @@ $("#maprQuery")
source: function (request, response) {
// if configId is not from mapr, we filter on mapValues...
let configId = document.getElementById("maprConfig").value;
// we only need mapr allKeys if we're filtering searchengine results by mapr keys
let allKeys = document.querySelector('#maprConfig option:checked').dataset.allkeys;
// Don't handle empty queries
if (request.term.trim().length == 0) {
response();
Expand All @@ -187,22 +195,10 @@ $("#maprQuery")
configId = configId.replace("mapr_", "");
let case_sensitive = false;

let requestData = {
case_sensitive: case_sensitive,
};
let url;
if (configId === "any") {
// Use searchengine...
url = `${SEARCH_ENGINE_URL}resources/image/searchvalues/`;
requestData = { value: request.term };
} else {
// Use mapr to find auto-complete matches TODO: to be removed
url = `${BASE_URL}mapr/api/autocomplete/${configId}/`;
requestData.value = case_sensitive
? request.term
: request.term.toLowerCase();
requestData.query = true; // use a 'like' HQL query
}
// We use searchengine for ALL backend queries...
let url = `${SEARCH_ENGINE_URL}resources/image/searchvalues/`;
let requestData = { value: request.term };

showSpinner();
$.ajax({
dataType: "json",
Expand All @@ -214,8 +210,13 @@ $("#maprQuery")
let queryVal = $("#maprQuery").val().trim();
let results = [];
// check that input hasn't changed during the call
if (configId === "any" && request.term.trim() == queryVal) {
autoCompleteDisplayResults(queryVal, data);
if (request.term.trim() == queryVal) {
let filterImageKeys;
if (allKeys) {
// if we've chosen a Mapr-key to filter results...
filterImageKeys = allKeys.split(",");
}
autoCompleteDisplayResults(queryVal, data, filterImageKeys);
} else {
results = data;
}
Expand Down
3 changes: 2 additions & 1 deletion idr_gallery/static/idr_gallery/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ async function init() {

let options = FILTER_MAPR_KEYS.map((key) => {
let config = mapr_settings[key];
let allKeys = config.all.join(",");
if (config) {
return `<option value="mapr_${key}">${config.label}</option>`;
return `<option value="mapr_${key}" data-allkeys="${allKeys}">${config.label}</option>`;
} else {
return "";
}
Expand Down
12 changes: 7 additions & 5 deletions idr_gallery/templates/idr_gallery/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
<link href="{% static 'idr_gallery/css/idr.css' %}?_={{VERSION}}" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<!-- Babel polfill (Symbol, Promise) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-2.2.4.js"
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" crossorigin="anonymous"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" crossorigin="anonymous">

<script src="{% static 'idr_gallery/3rdparty/foundation/foundation.min.js' %}"></script>
<script src="{{ base_url }}about/js/version.js"></script>
<script src="{{ base_url }}about/js/version.js" crossorigin="anonymous"></script>


<script src="{% static 'idr_gallery/model.js' %}?_={{VERSION}}"></script>
Expand Down
25 changes: 3 additions & 22 deletions idr_gallery/templates/idr_gallery/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
const SEARCH_ENGINE_URL = `${BASE_URL}searchengine/api/v1/`;
</script>

<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script src="https://unpkg.com/@popperjs/core@2" crossorigin="anonymous"></script>
<script src="https://unpkg.com/tippy.js@6" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://unpkg.com/tippy.js@6/dist/backdrop.css" />
<link rel="stylesheet" href="https://unpkg.com/tippy.js@6/themes/light-border.css" />

Expand Down Expand Up @@ -198,18 +198,6 @@
background: transparent;
}

/* .twitter-timeline is just while loading twitter */
.tabs-title.is-active a,
.tabs-title a,
.panel>a.twitter-timeline {
color: #292F33;
font-weight: 300;
font-family: Helvetica, Roboto, "Segoe UI", Calibri, sans-serif;
font-size: 21px;
line-height: 24px;
padding: 5px 25px 9px 25px;
margin-bottom: -1px;
}

.tabs-content {
border: none;
Expand Down Expand Up @@ -525,14 +513,7 @@ <h3>{{video.title}}</h3>
</div>
</div>

<div class="small-12 medium-12 large-4 columns">
<div class="panel" style="padding: 10px">
<a class="twitter-timeline" data-height="610" href="https://twitter.com/IDRnews?ref_src=twsrc%5Etfw">
Tweets by IDRnews
</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</div>

</div>

</div>
Expand Down
23 changes: 12 additions & 11 deletions idr_gallery/urls.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from django.conf.urls import url
from django.urls import re_path
from .gallery_settings import SUPER_CATEGORIES

from . import views

urlpatterns = [
# index 'home page' of the idr_gallery app
url(r'^$', views.index, name='idr_gallery_index'),
re_path(r'^$', views.index, name='idr_gallery_index'),

# All settings as JSON
url(r'^gallery_settings/$', views.gallery_settings),
re_path(r'^gallery_settings/$', views.gallery_settings),

# Search page shows Projects / Screens filtered by Map Annotation
url(r'^search/$', views.index, {'super_category': None},
name="idr_gallery_search"),
re_path(r'^search/$', views.index, {'super_category': None},
name="idr_gallery_search"),

# Supports e.g. ?project=1&project=2&screen=3
url(r'^gallery-api/thumbnails/$', views.api_thumbnails,
name='idr_gallery_api_thumbnails'),
re_path(r'^gallery-api/thumbnails/$', views.api_thumbnails,
name='idr_gallery_api_thumbnails'),
]

for c in SUPER_CATEGORIES:
urlpatterns.append(url(r'^%s/$' % c, views.index, {'super_category': c},
name="gallery_super_category"))
urlpatterns.append(url(r'^%s/search/$' % c, views.index,
{'super_category': c}))
urlpatterns.append(re_path(r'^%s/$' % c, views.index,
{'super_category': c},
name="gallery_super_category"))
urlpatterns.append(re_path(r'^%s/search/$' % c, views.index,
{'super_category': c}))
2 changes: 1 addition & 1 deletion idr_gallery/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# This can be loaded via the app.
# It will be updated by bumpversion
VERSION = '3.10.1.dev0'
VERSION = '3.11.1.dev0'

0 comments on commit ec8dbb1

Please sign in to comment.