From 5bd4bf05ee18bb723d48e3ef46f1cfbb7ceaf975 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:21:56 +0200 Subject: [PATCH] Fix: Annotator fast context special chars issues & statistics page syntax error (#561) * fix statistics page syntax error * update ontoportal instances home section title * fix fast context option in annotator page * remove special chars from annotator's input on submit to avoid errors --- app/controllers/annotator_controller.rb | 10 +++++++++- app/views/statistics/index.html.haml | 6 +++--- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/annotator_controller.rb b/app/controllers/annotator_controller.rb index cfda565c3..d1f286b44 100644 --- a/app/controllers/annotator_controller.rb +++ b/app/controllers/annotator_controller.rb @@ -37,7 +37,7 @@ def annotator_results(uri) if params[:text] && !params[:text].empty? @init_whole_word_only = true api_params = { - text: escape(params[:text]), + text: remove_special_chars(params[:text]), ontologies: params[:ontologies], semantic_types: params[:semantic_types], semantic_groups: params[:semantic_groups], @@ -210,5 +210,13 @@ def json_link(url, optional_params) return base_url + optional_params_str + "&apikey=#{$API_KEY}" end + def remove_special_chars(input) + regex = /^[a-zA-Z0-9\s]*$/ + unless input.match?(regex) + input.gsub!(/[^\w\s]/, '') + end + input + end + end diff --git a/app/views/statistics/index.html.haml b/app/views/statistics/index.html.haml index a83365522..e42fac412 100644 --- a/app/views/statistics/index.html.haml +++ b/app/views/statistics/index.html.haml @@ -5,9 +5,9 @@ = t('statistics.lead', last_years: Date.today.year - Date.parse(@merged_data[:labels].first).year) %div.container %div - = chart_component(title: nil, type: 'line', show_legend: true, - labels: @merged_data[:labels], - datasets: visits_chart_dataset_array({ t('statistics.ontologies'): @merged_data[:visits][2] ,t('statistics.users'): @merged_data[:visits][0], t('statistics.projects'): @merged_data[:visits][1]}, fill: false)) + = chart_component(title: nil, type: 'line', show_legend: true, + labels: @merged_data[:labels], datasets: visits_chart_dataset_array({ t('statistics.ontologies') => @merged_data[:visits][2], + t('statistics.users') => @merged_data[:visits][0], t('statistics.projects') => @merged_data[:visits][1] }, fill: false)) %div.pb-3.pb-md-4 - size = @merged_data[:labels].size - 1 diff --git a/config/locales/en.yml b/config/locales/en.yml index f437410ab..bae0d3589 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -342,7 +342,7 @@ en: paste_text_prompt: Enter a paragraph of text or some keywords... recommender_annotator: Recommender and Annotator support_and_collaborations: Support & Collaborations - ontoportal_instances: Ontoportal Instances + ontoportal_instances: Other OntoPortal Instances see_details: See details info_tooltip_text: "You are seing the average scores for all the public ontologies in AgroPortal. FAIR scores are computed with the O'FAIRe methodology. More details here: https://github.com/agroportal/fairness" average: Average diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7dbd4254c..c1e0782be 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -315,7 +315,7 @@ fr: home: - ontoportal_instances: "Instances d'Ontoportal" + ontoportal_instances: "Autres installations d’OntoPortal" bug: Bug proposition: Proposition question: Question