-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1801 from laws-africa/search-index-toc
Search legislation TOC
- Loading branch information
Showing
9 changed files
with
295 additions
and
69 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
29 changes: 29 additions & 0 deletions
29
peachjam/js/components/FindDocuments/SearchResultProvision.vue
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,29 @@ | ||
<template> | ||
<div class="mb-1"> | ||
<div v-if="parents.length"> | ||
<a :href="`${expressionFrbrUri}#${parents[0].id}`">{{ parents[0].title }}</a> | ||
<div class="ms-3"> | ||
<SearchResultProvision | ||
:item="item" | ||
:parents="parents.slice(1)" | ||
:expression-frbr-uri="expressionFrbrUri" | ||
/> | ||
</div> | ||
</div> | ||
<div v-else> | ||
<a :href="`${expressionFrbrUri}#${item.id}`">{{ item.title }}</a> | ||
<div class="ms-3" v-if="item.highlight['provisions.body']" v-html="item.highlight['provisions.body'].join(' ... ')" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'SearchResultProvision', | ||
props: { | ||
item: { type: Object, default: () => {} }, | ||
expressionFrbrUri: { type: String, default: '' }, | ||
parents: { type: Array, default: () => [] } | ||
} | ||
}; | ||
</script> |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,8 @@ | ||
import lxml.html | ||
|
||
html_parser = lxml.html.HTMLParser(encoding="utf-8") | ||
|
||
|
||
def parse_html_str(html): | ||
"""Encode HTML into utf-8 bytes and parse.""" | ||
return lxml.html.fromstring(html.encode("utf-8"), parser=html_parser) |
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
31 changes: 31 additions & 0 deletions
31
peachjam_search/migrations/0001_es_mapping_add_provisions.py
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,31 @@ | ||
# Generated by Django 3.2.25 on 2024-04-26 17:17 | ||
|
||
import os | ||
|
||
from django.db import migrations | ||
|
||
|
||
def forwards(apps, schema_editor): | ||
from django.conf import settings | ||
from django_elasticsearch_dsl.registries import registry | ||
|
||
if settings.ELASTICSEARCH_DSL_AUTOSYNC and os.environ.get("ELASTICSEARCH_HOST"): | ||
for ix in registry.get_indices(): | ||
if not ix._mapping: | ||
continue | ||
print(f"Adding provisions mapping for {ix._name}") | ||
ix.connection.indices.put_mapping( | ||
index=ix._name, | ||
body={ | ||
"properties": {"provisions": ix._mapping["provisions"].to_dict()} | ||
}, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("peachjam", "0125_judgment_auto_assign_title"), | ||
] | ||
|
||
operations = [migrations.RunPython(forwards, migrations.RunPython.noop)] |
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
Oops, something went wrong.