From: Banana Date: Wed, 11 Nov 2026 22:49:53 +0000 (+0100) Subject: fixed search. X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=9aeb8bb5e1e0dcc8a5add61d7f6b95ba9c491950;p=scientia.git fixed search. added a simple title Signed-off-by: Banana --- diff --git a/CHANGELOG b/CHANGELOG index d2c4611..3f4c27e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ + Config change. Important breaking changes. See upgrade-from-1.1.md for more details. + Updated: README.md + Updated: upgrade-from-1.0.md file for better reading + + Fixed: Search. Works now everywhere. + + Added: Simple page title to see where it is at. 1.1 Atlas - 2024-06-29 + Config change: i18n. See upgrade-from-1.0.md for more details. diff --git a/README.md b/README.md index 5e02755..176a8ad 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Searchable with mysql fulltext search. Protected by BASIC AUTH, single user only Install it and access it with a browser. After login you can browse and search every note. They are sorted by date and grouped by year. Selecting a year -does limit the view to this year only. After selecting an entry you are able to filter by day and month by using the `breadcrumb`. +does limit the view to this year only. After selecting an entry you are able to filter by day and month by using the `Breadcrumb`. Adding, with the action `New`, does create it with the current date and creates a uniq url. diff --git a/webroot/config/config.php.default b/webroot/config/config.php.default index 9ffa908..f0d849f 100644 --- a/webroot/config/config.php.default +++ b/webroot/config/config.php.default @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2023 - 2024 Johannes Keßler + * Copyright 2023 - 2026 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -21,9 +21,9 @@ */ # set to true if you need debug messages in error log file -const DEBUG = true; +const DEBUG = false; # set to ture if you need query log messages in error log file. -const QUERY_DEBUG = true; +const QUERY_DEBUG = false; # timezone settings const TIMEZONE = 'Europe/Berlin'; diff --git a/webroot/lib/entry.class.php b/webroot/lib/entry.class.php index 3cb6297..1f1b8e4 100644 --- a/webroot/lib/entry.class.php +++ b/webroot/lib/entry.class.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2023 - 2024 Johannes Keßler + * Copyright 2023 - 2026 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -202,13 +202,20 @@ class Entry { $ret = array(); $queryStr = "SELECT e.ident, e.date, SUBSTRING(e.body,1,100) AS body - FROM `".DB_PREFIX."_entry` AS e"; - if(!empty($intervalStart) && !empty($intervalEnd)) { - $queryStr .= " WHERE e.date >= '".$intervalStart."' AND e.date <= '".$intervalEnd."'"; + FROM `".DB_PREFIX."_entry` AS e "; + $queryWhere = array(); + if(!empty($intervalStart) || !empty($intervalEnd) || !empty($searchTerm)) { + if(!empty($intervalStart) && !empty($intervalEnd)) { + $queryWhere[] = "(e.date BETWEEN '".$intervalStart."' AND '".$intervalEnd."')"; + } + if(!empty($searchTerm)) { + $queryWhere[] = "MATCH(e.words) AGAINST('".$this->_DB->real_escape_string($searchTerm)."' IN NATURAL LANGUAGE MODE)"; + } } - if(!empty($searchTerm)) { - $queryStr .= " AND MATCH(e.words) AGAINST('".$this->_DB->real_escape_string($searchTerm)."' IN BOOLEAN MODE)"; + if(!empty($queryWhere)) { + $queryStr .= "WHERE ".implode(" AND ",$queryWhere); } + $queryStr .= " ORDER BY `created` DESC"; $queryStr .= " LIMIT $limit"; diff --git a/webroot/view/_head.php b/webroot/view/_head.php index de04365..4134d4a 100644 --- a/webroot/view/_head.php +++ b/webroot/view/_head.php @@ -7,5 +7,6 @@ max-width: 90%; } + <?php echo $TemplateData['title'] ?? ''; ?> scientia diff --git a/webroot/view/entry/entry.php b/webroot/view/entry/entry.php index 7a50ebb..427f9f4 100644 --- a/webroot/view/entry/entry.php +++ b/webroot/view/entry/entry.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2023 - 2024 Johannes Keßler + * Copyright 2023 - 2026 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -27,6 +27,7 @@ $TemplateData['data'] = array(); if(!empty($_id)) { $TemplateData['data'] = $Entry->load($_year,$_month,$_day,$_id); $TemplateData['data']['breadcrumb'] = array($_year,$_month,$_day); + $TemplateData['title'] = implode(" | ",array($_year,$_month,$_day)); } if(isset($_POST['submitForm']) && isset($_POST['fdata'])) { diff --git a/webroot/view/list/list.html b/webroot/view/list/list.html index b04147b..9617a6e 100644 --- a/webroot/view/list/list.html +++ b/webroot/view/list/list.html @@ -27,5 +27,6 @@ +

t('text.home'); ?>

t('text.noentries'); ?>

diff --git a/webroot/view/list/list.php b/webroot/view/list/list.php index b8aa002..bd657fd 100644 --- a/webroot/view/list/list.php +++ b/webroot/view/list/list.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2023 - 2024 Johannes Keßler + * Copyright 2023 - 2026 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -39,6 +39,7 @@ $_groupByFormat = $_year; $breadcrumb = array('Y'); $_intervalStart = ''; $_intervalEnd = ''; +$_hasTitle = false; if(!empty($_requestDateProvided)) { if($_requestDateProvided === 'Y-m-d') { $queryLimit = ""; @@ -60,6 +61,7 @@ if(!empty($_requestDateProvided)) { $_intervalStart = $_groupByFormat.'-01-01'; $_intervalEnd = $_groupByFormat.'-12-31'; } + $_hasTitle = true; } else { $_requestDateProvided = 'Y'; } @@ -74,4 +76,5 @@ foreach($entries as $k=>$entry) { $TemplateData['entries'][$_d->format($_requestDateProvided)]['breadcrumb'] = $_breadcrumb; $TemplateData['entries'][$_d->format($_requestDateProvided)]['e'][$entry['ident']] = $entry; $TemplateData['entries'][$_d->format($_requestDateProvided)]['e'][$entry['ident']]['link'] = str_replace('-','/',$entry['date']).'/'.$entry['ident']; + if($_hasTitle) $TemplateData['title'] = implode(" | ", $_breadcrumb); }