Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Feb 12, 2024
2 parents e170111 + 4677189 commit f0e875d
Show file tree
Hide file tree
Showing 22 changed files with 899 additions and 49 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:

strategy:
matrix:
# Having "" here enables the `node-version-file` option
node-version: ["", 18, 20]
# From lowest supported version up to the one pinned in .nvmrc
# The empty string enables the `node-version-file` option which reads from .nvmrc
node-version: [18, ""]

steps:
- name: Checkout main repo
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9
20.11
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [9.5.1] - 2024-02-12

### Changed

- Logos with taglines

### Fixed

- Improve UX for "in order" option [#335](https://github.com/spraakbanken/korp-frontend/issues/335)
- Unnecessary scrollbars in the corpus selector info panel [#333](https://github.com/spraakbanken/korp-frontend/issues/333)
- Bug with undefined `arguments`
- On repetition error (all tokens repeat from 0), restore red outline for input
- Use `<match>` to constraint CQP subqueries (from statistics rows etc)

## [9.5.0] - 2023-01-22

### Added
Expand Down Expand Up @@ -73,7 +87,7 @@
- Most bug fixes was related to the refactoring breaking things
- Lots of bug fixes for the sidebar


[9.5.1]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.5.1
[9.5.0]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.5.0
[9.4.4]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.4.4
[9.4.3]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.4.3
Expand Down
2 changes: 1 addition & 1 deletion app/config/statistics_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let getCqp = function (hitValues, ignoreCase) {
}
tokens.push("[" + andExpr.join(" & ") + "]")
}
return tokens.join(" ")
return `<match> ${tokens.join(" ")} []* </match>`
}

let reduceCqp = function (type, tokens, ignoreCase) {
Expand Down
188 changes: 188 additions & 0 deletions app/img/korp_slogan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
183 changes: 183 additions & 0 deletions app/img/korp_slogan_en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
213 changes: 213 additions & 0 deletions app/img/sprakbanken_text_slogan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
204 changes: 204 additions & 0 deletions app/img/sprakbanken_text_slogan_en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions app/scripts/components/advanced_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ export const advancedSearchComponent = {
on-search="$ctrl.onSearch()"
on-search-save="$ctrl.onSearchSave(name)"
></search-submit>
<input id="inOrderChkAdv" type="checkbox" ng-model="$ctrl.inOrder" ng-disabled="!$ctrl.inOrderEnabled" />
<label for="inOrderChkAdv"> {{'in_order_chk' | loc:$root.lang}}</label>
<input id="inOrderChkAdv" type="checkbox" ng-model="$ctrl.inOrder" />
<label for="inOrderChkAdv">
{{'in_order_chk' | loc:$root.lang}}
<i
class="fa fa-info-circle text-gray-400"
uib-tooltip="{{'order_help' | loc:$root.lang}}"
tooltip-placement="right"
></i>
</label>
</div>`,
bindings: {},
controller: [
Expand All @@ -46,8 +53,6 @@ export const advancedSearchComponent = {
const $ctrl = this

$ctrl.inOrder = $location.search().in_order == null
/** Whether the "in order" option is applicable. */
$ctrl.inOrderEnabled = true

if ($location.search().search && $location.search().search.split("|")) {
var [type, ...expr] = $location.search().search.split("|")
Expand All @@ -61,14 +66,10 @@ export const advancedSearchComponent = {
}

$ctrl.onSearch = () => {
// The "in order" option should be available only if >1 token and no wildcards.
const cqpObjs = CQP.parse($ctrl.cqp)
$ctrl.inOrderEnabled = cqpObjs.length > 1 && !CQP.hasWildcards(cqpObjs)

$location.search("search", null)
$location.search("page", null)
$location.search("within", null)
$location.search("in_order", !$ctrl.inOrder && $ctrl.inOrderEnabled ? false : null)
$location.search("in_order", !$ctrl.inOrder ? false : null)
$timeout(() => $location.search("search", `cqp|${$ctrl.cqp}`), 0)
}

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/corpus_chooser/corpus_chooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const corpusChooserComponent = {
{{ $ctrl.selectedNumberOfSentences | prettyNumber }} {{'corpselector_sentences_long' | loc:$root.lang}}
</p>
</div>
<cc-info-box ng-if="$ctrl.showInfoBox" class="sticky top-0 bg-gray-100" style="width: 480px; overflow: scroll;" object="$ctrl.infoNode"></cc-info>
<cc-info-box ng-if="$ctrl.showInfoBox" class="sticky top-0 bg-gray-100 overflow-auto" style="width: 480px;" object="$ctrl.infoNode"></cc-info>
</div>
</div>
`,
Expand Down
1 change: 1 addition & 0 deletions app/scripts/components/extended/extended_tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const extendedTokensComponent = {
parallell-lang="$ctrl.parallellLang"
toggle-start="$ctrl.toggleStart($index)()"
toggle-end="$ctrl.toggleEnd($index)()"
repeat-error="$ctrl.repeatError"
></extended-token>
<extended-struct-token
ng-if="!token.and_block"
Expand Down
40 changes: 32 additions & 8 deletions app/scripts/components/extended/standard_extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ export const extendedStandardComponent = {
cqp-change="$ctrl.cqpChange(cqp)"
update-repeat-error="$ctrl.updateRepeatError(error)"
></extended-tokens>
<div ng-show="$ctrl.repeatError" style="color: red; margin-bottom: 10px;">
{{'repeat_error' | loc:$root.lang}}
</div>
<div ng-show="$ctrl.orderError" style="color: red; margin-bottom: 10px;">
{{'order_error' | loc:$root.lang}}
</div>
<search-submit
pos="right"
on-search="$ctrl.onSearch()"
on-search-save="$ctrl.onSearchSave(name)"
disabled="$ctrl.repeatError"
disabled="$ctrl.repeatError || $ctrl.orderError"
></search-submit>
<input id="inOrderChkExt" type="checkbox" ng-model="$ctrl.inOrder" ng-disabled="!$ctrl.inOrderEnabled" />
<input id="inOrderChkExt" type="checkbox" ng-model="inOrder" ng-disabled="!$ctrl.inOrderEnabled" />
<label for="inOrderChkExt"> {{'in_order_chk' | loc:$root.lang}}</label>
<span> {{'and' | loc:$root.lang}} </span>
<span>{{'within' | loc:$root.lang}}</span>
Expand All @@ -35,21 +41,23 @@ export const extendedStandardComponent = {
controller: [
"$location",
"$rootScope",
"$scope",
"compareSearches",
"$timeout",
function ($location, $rootScope, compareSearches, $timeout) {
function ($location, $rootScope, $scope, compareSearches, $timeout) {
const ctrl = this

ctrl.lang = $rootScope.lang
ctrl.inOrder = $location.search().in_order == null
$scope.inOrder = $location.search().in_order == null
/** Whether the "in order" option is applicable. */
ctrl.inOrderEnabled = true
ctrl.orderError = false

// TODO this is *too* weird
function triggerSearch() {
$location.search("search", null)
$location.search("page", null)
$location.search("in_order", !ctrl.inOrder && ctrl.inOrderEnabled ? false : null)
$location.search("in_order", !$scope.inOrder && ctrl.inOrderEnabled ? false : null)
$timeout(function () {
$location.search("search", "cqp")
if (!_.keys(settings["default_within"]).includes(ctrl.within)) {
Expand Down Expand Up @@ -87,13 +95,29 @@ export const extendedStandardComponent = {
c.log("Error", e)
}

// The "in order" option should be available only if >1 token and no wildcards.
const cqpObjs = CQP.parse(cqp)
ctrl.inOrderEnabled = cqpObjs.length > 1 && !CQP.hasWildcards(cqpObjs)
ctrl.validateInOrder()

$location.search("cqp", cqp)
}

$scope.$watch("inOrder", () => {
ctrl.validateInOrder()
})

/** Trigger error if the "in order" option is incompatible with the query */
ctrl.validateInOrder = () => {
const cqpObjs = CQP.parse(ctrl.cqp)
if (!CQP.supportsInOrder(cqpObjs)) {
// If query doesn't support free word order, and the "in order" checkbox has been unchecked,
// then disable search, show explanation and let user resolve the conflict
ctrl.orderError = !$scope.inOrder
ctrl.inOrderEnabled = !$scope.inOrder
} else {
ctrl.orderError = false
ctrl.inOrderEnabled = true
}
}

ctrl.cqp = $location.search().cqp

ctrl.repeatError = false
Expand Down
1 change: 1 addition & 0 deletions app/scripts/components/extended/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const extendedTokenComponent = {
showClose: "=",
token: "=",
parallellLang: "<",
repeatError: "<",
remove: "&",
change: "&",
toggleStart: "&",
Expand Down
28 changes: 18 additions & 10 deletions app/scripts/components/header.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** @format */
import korpLogo from "../../img/korp.svg"
import sbxLogo from "../../img/sprakbanken_text.svg"
import korpLogo from "../../img/korp_slogan.svg"
import korpLogoEn from "../../img/korp_slogan_en.svg"
import sbxLogo from "../../img/sprakbanken_text_slogan.svg"
import sbxLogoEn from "../../img/sprakbanken_text_slogan_en.svg"
import guLogo from "../../img/gu_logo_sv_head.svg"

let html = String.raw
Expand Down Expand Up @@ -99,9 +101,10 @@ export const headerComponent = {
<!-- TODO too many divs -->
</div>
<div class="flex justify-between items-end gap-3 h-24 pb-1 mb-5 mt-2 px-3" id="header_left">
<div class="flex justify-between items-end gap-3 my-3 px-3" id="header_left">
<a class="shrink-0 relative ml-4 pl-0.5" ng-click="$ctrl.logoClick()">
<img class="-mb-5" src="${korpLogo}" height="300" width="300" />
<img ng-if="$root.lang == 'swe'" src="${korpLogo}" height="300" width="300" />
<img ng-if="$root.lang != 'swe'" src="${korpLogoEn}" height="300" width="300" />
</a>
<div id="labs_logo">
<svg
Expand All @@ -124,15 +127,20 @@ export const headerComponent = {
</svg>
</div>
<div class="grow lg_hidden"></div>
<div class="grow min-[1150px]_hidden"></div>
<corpus-chooser></corpus-chooser>
<div class="grow hidden lg_block"></div>
<a class="hidden lg_block h-12 shrink" href="https://spraakbanken.gu.se" target="_blank">
<img src="${sbxLogo}" class="h-full" />
<div class="grow hidden min-[1150px]_block"></div>
<a
class="hidden min-[1150px]_flex h-20 shrink flex-col justify-end"
href="https://spraakbanken.gu.se/"
target="_blank"
>
<img ng-if="$root.lang == 'swe'" src="${sbxLogo}" />
<img ng-if="$root.lang != 'swe'" src="${sbxLogoEn}" />
</a>
<a class="hidden xl_block shrink-0 h-32 pt-1 -mb-6" href="https://gu.se" target="_blank">
<a class="hidden xl_block shrink-0 h-32 -mt-2" href="https://gu.se/" target="_blank">
<img src="${guLogo}" class="h-full" />
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/kwic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const kwicComponent = {
ng-class="{odd : $index % 2 != 0, even : $index % 2 == 0}"
ng-click="$ctrl.pageEvent(corpus.page)"
uib-tooltip="{{corpus.rtitle | locObj:lang}}: {{corpus.abs}}"
uib-tooltip-placement='{{$last? "left":"top"}}'
tooltip-placement='{{$last? "left":"top"}}'
append-to-body="false"
></td>
</tr>
Expand Down
12 changes: 8 additions & 4 deletions app/scripts/components/simple_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const simpleSearchComponent = {

ctrl.inOrder = $location.search().in_order == null
/** Whether the "in order" option is applicable. */
ctrl.inOrderEnabled = true
ctrl.inOrderEnabled = false
ctrl.prefix = $location.search().prefix != null
ctrl.mid_comp = $location.search().mid_comp != null
ctrl.suffix = $location.search().suffix != null
Expand Down Expand Up @@ -233,6 +233,7 @@ export const simpleSearchComponent = {
ctrl.lemgram = search.val
}
$rootScope.simpleCQP = CQP.expandOperators(ctrl.getCQP())
ctrl.updateInOrderEnabled()
ctrl.doSearch()
}
})
Expand All @@ -246,9 +247,12 @@ export const simpleSearchComponent = {
ctrl.currentText = null
}

// The "in order" option should be available only if >1 token.
const cqpObjs = CQP.parse(ctrl.getCQP())
ctrl.inOrderEnabled = cqpObjs.length > 1 && !CQP.hasWildcards(cqpObjs)
ctrl.updateInOrderEnabled()
}

ctrl.updateInOrderEnabled = () => {
const cqpObjs = CQP.parse(ctrl.getCQP() || "[]")
ctrl.inOrderEnabled = CQP.supportsInOrder(cqpObjs)
}

ctrl.doSearch = function () {
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/controllers/statistics_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ korpApp.directive("statsResultCtrl", () => ({
})
},
(textStatus, err) => {
const arguments_ = arguments
$timeout(() => {
c.log("fail", arguments)
c.log("fail", arguments_)
c.log(
"stats fail",
s.loading,
Expand Down
19 changes: 11 additions & 8 deletions app/scripts/cqp_parser/cqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,15 @@ window.CQP = {
},

/** Check if a query has any wildcards (`[]`) */
hasWildcards(cqpObjs) {
for (const token of cqpObjs) {
// Stringify individual token
const str = CQP.stringify([token])
if (str.indexOf("[]") === 0) return true
}
return false
},
hasWildcard: (cqpObjs) => cqpObjs.some((token) => CQP.stringify([token]).indexOf("[]") === 0),

/** Check if a query has any tokens with repetition */
hasRepetition: (cqpObjs) => cqpObjs.some((token) => token.repeat),

/** Check if a query has any structure boundaries, e.g. sentence start */
hasStruct: (cqpObjs) => cqpObjs.some((token) => token.struct),

/** Determine whether a query will work with the in_order option */
supportsInOrder: (cqpObjs) =>
cqpObjs.length > 1 && !CQP.hasWildcard(cqpObjs) && !CQP.hasRepetition(cqpObjs) && !CQP.hasStruct(cqpObjs),
}
2 changes: 1 addition & 1 deletion app/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ li.active a span .num-to-find {
}

.input-error {
border:red 2px solid;
outline:red 2px solid;
}

// TODO we should not do this, update boostrap instead?
Expand Down
2 changes: 2 additions & 0 deletions app/translations/locale-eng.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@
"add_filter_value": "Add",

"repeat_error": "Error: Not possible to repeat from 0 for all tokens.",
"order_error": "Error: Disabling \"in order\" requires multiple tokens, no repetition, no boundaries and no wildcards.",
"order_help": "Disabling the \"in order\" option is compatible with queries that have multiple tokens, no repetition, no boundaries and no wildcards.",

"choose_value": "Choose a value",
"login_needed_for_corpora": "Login needed for access to",
Expand Down
2 changes: 2 additions & 0 deletions app/translations/locale-swe.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@
"add_filter_value": "Lägg till",

"repeat_error": "Fel: Det går inte att upprepa från 0 på alla token.",
"order_error": "Fel: Det går bara att välja bort \"i följd\" om sökfrågan har flera tokens samt inga repetitioner, gränser eller tomma token.",
"order_help": "Att välja bort \"i följd\" är kompatibelt med sökfrågor som har flera tokens samt inga repetitioner, gränser eller tomma token.",

"choose_value": "Välj ett värde",
"login_needed_for_corpora": "Inloggning behövs för åtkomst till",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "korp-frontend",
"version": "9.5.0",
"version": "9.5.1",
"dependencies": {
"@fortawesome/fontawesome-free": "6.2.1",
"angular": "1.8.3",
Expand Down

0 comments on commit f0e875d

Please sign in to comment.