-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[proofing] Add partial work for search+replace
## Tests 1. built container with make docker-start 2. checked Texts, Dictionaries, and Proofing pages. 3. tested `proofing > project > edit > search` page 4. tested `proofing > project > edit > search and replace` page ## To do 1. Test actual `search and replace`. I could not find a pre-existing text in db to test this feature. 2. add support in translation files
- Loading branch information
1 parent
52d970a
commit 10cf5fd
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% extends 'proofing/base.html' %} | ||
{% from "macros/forms.html" import field %} | ||
{% import "macros/proofing.html" as m %} | ||
|
||
{% block title %}Search and Replace {{ project.title }} | Ambuda{% endblock %} | ||
|
||
{% block content %} | ||
|
||
{{ m.project_header_nested('Search and Replace', project) }} | ||
{{ m.project_nav(project=project, active='edit') }} | ||
|
||
<div class="prose"> | ||
<p>Use this simple search and replace form to make edits across this project.</p> | ||
</div> | ||
|
||
<form method="GET" class="bg-slate-100 p-4 my-4"> | ||
{{ field(form.query) }} | ||
{{ field(form.replace) }} | ||
<input class="btn btn-submit" type="submit" value="Project-wide Search & Replace"> | ||
</form> | ||
|
||
{% if query %} | ||
<div class="prose"> | ||
|
||
{% macro sp(s, p, n) %}{% if n == 1 %}{{ s }}{% else %}{{ p }}{% endif %}{% endmacro %} | ||
|
||
{% set nr = results|length %} | ||
<p>Found {{ nr }} {{ sp("page", "pages", nr) }} that {{ sp("contains", "contain", nr) }} <kbd>{{ query }}</kbd>.</p> | ||
|
||
<ul> | ||
{% for page in results %} | ||
{% set page_url = url_for("proofing.page.edit", project_slug=project.slug, page_slug=page.slug) %} | ||
<li> | ||
<a href="{{ page_url }}">{{ project.title }}/{{ page.slug }}</a> | ||
<div class="p-2 border-l my-2"> | ||
{% for match in page.matches %} | ||
<pre class="p-0.5">{{ match.query }}</pre> | ||
<pre class="p-0.5">{{ match.update }}</pre> | ||
{%- endfor %} | ||
</div> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters