-
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 #26 from acdh-oeaw/feature/crosslink-tei
Feature/crosslink tei
- Loading branch information
Showing
17 changed files
with
1,906 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import logging | ||
from apis_ontology.models import Excerpts | ||
import pandas as pd | ||
from django.apps import apps | ||
from django.core.management.base import BaseCommand | ||
from tqdm.auto import tqdm | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Imports excerpts from data/excerpts.csv | ||
""" | ||
|
||
def handle(self, *args, **kwargs): | ||
def create_record(row): | ||
record, _ = Excerpts.objects.get_or_create(xml_id=row.xml_id) | ||
record.xml_content = row.xml_content | ||
record.source = row.source | ||
record.save() | ||
|
||
print(len(Excerpts.objects.all())) | ||
import_file = "data/excerpts.csv" | ||
df = pd.read_csv(import_file) | ||
for _, row in tqdm(df.iterrows(), total=df.shape[0]): | ||
create_record(row) | ||
|
||
self.stdout.write(self.style.SUCCESS(f"Processed {df.shape[0]} excerpts.")) | ||
print(len(Excerpts.objects.all())) |
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 4.2.13 on 2024-05-19 00:22 | ||
|
||
import apis_core.generic.abc | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apis_ontology", "0008_instancecopiedwrittendownatplace_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Excerpts", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("xml_id", models.CharField(max_length=255, unique=True)), | ||
("xml_content", models.TextField()), | ||
("source", models.CharField(max_length=255, unique=True)), | ||
], | ||
bases=(apis_core.generic.abc.GenericModel, models.Model), | ||
), | ||
] |
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,17 @@ | ||
# Generated by Django 4.2.13 on 2024-05-19 00:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apis_ontology", "0009_excerpts"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="excerpts", | ||
name="source", | ||
field=models.CharField(max_length=255), | ||
), | ||
] |
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,17 @@ | ||
function showPopup(recordId, renderStyle) { | ||
renderStyle = "tei"; | ||
fetch(`/apis/excerpts/${recordId}/${renderStyle}`) | ||
.then(response => response.text()) | ||
.then(data => { | ||
// Display the data in the popup | ||
document.getElementById('popupContent').innerHTML = data; | ||
document.getElementById('popupModal').style.display = 'block'; | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching dynamic content:', error); | ||
}); | ||
} | ||
|
||
function closePopup() { | ||
document.getElementById('popupModal').style.display = 'none'; | ||
} |
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
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,19 @@ | ||
<script src="/static/scripts/show_popup.js"></script> | ||
|
||
<div class="modal" id="popupModal" style="display:none;" tabindex="-1" role="dialog"> | ||
<div class="modal-dialog modal-dialog-centered" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Excerpt</h5> | ||
</div> | ||
<div class="modal-body"> | ||
|
||
<span id="popupContent"></span> | ||
</div> | ||
<div class="modal-footer"> | ||
|
||
<button onclick="closePopup()">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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,19 @@ | ||
from django.http import HttpResponse | ||
from django.views import View | ||
from django.shortcuts import get_object_or_404 | ||
from .models import Excerpts | ||
|
||
|
||
class ExcerptsView(View): | ||
def get(self, request, xml_id, render_style, *args, **kwargs): | ||
print("You are here!") | ||
record = get_object_or_404(Excerpts, xml_id=xml_id) | ||
|
||
# Generate dynamic content based on link_type | ||
if render_style == "tei": | ||
# TODO: render correctly with xslt | ||
content = f"{record.xml_content}" | ||
else: | ||
content = f"{record.xml_content}" | ||
|
||
return HttpResponse(content) |
Oops, something went wrong.