• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rero / sonar / 17425918180

03 Sep 2025 07:11AM UTC coverage: 95.796% (-0.6%) from 96.378%
17425918180

push

github

PascalRepond
translations: extract messages

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>

7816 of 8159 relevant lines covered (95.8%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.64
/sonar/help/views.py
1
# Swiss Open Access Repository
2
# Copyright (C) 2022 RERO
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU Affero General Public License as published by
6
# the Free Software Foundation, version 3 of the License.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
12
#
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15

16
"""help organisation views."""
17

18
import re
1✔
19

20
from flask import Blueprint, current_app, redirect, render_template, request, url_for
1✔
21
from flask_wiki.api import current_wiki
1✔
22
from whoosh import index as whoosh_index
1✔
23

24
blueprint = Blueprint("help", __name__, template_folder="templates", static_folder="static")
1✔
25

26

27
@blueprint.route("/<org_code:view>/help/", methods=["GET"])
1✔
28
def index(view):
1✔
29
    """Help index redirect to home."""
30
    return redirect(url_for("help.page", view=view, url=current_app.config.get("WIKI_HOME")))
×
31

32

33
@blueprint.route("/<org_code:view>/help/<path:url>/", methods=["GET"])
1✔
34
def page(view, url):
1✔
35
    """Help page."""
36
    page = current_wiki.get_or_404(url)
×
37
    return render_template("help/page_wiki.html", view=view, page=page)
×
38

39

40
@blueprint.route("/<org_code:view>/help/search", methods=["GET"])
1✔
41
def search(view):
1✔
42
    """Help search."""
43
    query = request.args.get("q", "")
×
44
    results = []
×
45
    index_dir = whoosh_index.open_dir(current_app.config.get("WIKI_INDEX_DIR"))
×
46
    results = current_wiki.search(query, index_dir, index_dir.searcher())
×
47
    return render_template("help/page_wiki_search.html", results=results, query=query, view=view)
×
48

49

50
@blueprint.app_template_filter()
1✔
51
def process_link(body, view):
1✔
52
    """Process help body to transform link with viewcode.
53

54
    The transformation is only done on the link and not on the image.
55

56
    :param body: the html body to process.
57
    :param view: viewcode to actual view.
58
    :return: processed body.
59
    """
60
    return re.sub(r"\]\((\/help)(?!\/files\/)", rf"](/{view}\1", body)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc