Skip to content

Commit

Permalink
Merge pull request #32 from diging/develop
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
jdamerow authored Dec 16, 2024
2 parents 9e12d13 + 3c167a2 commit c3be2ca
Show file tree
Hide file tree
Showing 11,864 changed files with 4,219 additions and 1,361,379 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file removed .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .docker-env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POSTGRES_DB=postgres
POSTGRES_NAME=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
2 changes: 2 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DB_PORT=5432
WEB_PORT=8000
17 changes: 17 additions & 0 deletions .env_app-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export SECRET_KEY=
#you can use EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend to get emails in the terminal just to test it in a dev enviornment so you wouldnt have to set any other EMAIL variables
export EMAIL_BACKEND=
export EMAIL_HOST=
export EMAIL_HOST_USER=
export EMAIL_HOST_PASSWORD=
export EMAIL_PORT=
export EMAIL_USE_TLS=
export CONCEPTPOWER_USERID=
export CONCEPTPOWER_PASSWORD=
export CONCEPTPOWER_ENDPOINT=
export CONCEPTPOWER_NAMESPACE=
# Ensure the BASE_URL does not include APP_ROOT
export BASE_URL="http://localhost:8000/"
# Make sure APP_ROOT variable ends with a /
# this is the prefix that vogon will be deployed under (e.g. "vogon-2" for deployment at my-server.org/vogon-2)
export APP_ROOT=
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them [here](https://diging.atlassian.net/wiki/spaces/DIGING/pages/2256076801/Code+Review+Guidelines).

Please confirm the following by adding an x for each item (turn `[ ]` into `[x]`).

- [ ] I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
- [ ] I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
- [ ] I do not have any sysout statements in my code or commented out code that isn’t needed anymore
- [ ] I am not reformatting any files in the wrong format or without cause.
- [ ] I am not changing file encoding or line endings to something else than UTF-8, LF
- [ ] My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
- [ ] I have added Javadoc/documentation where appropriate
- [ ] I have added test cases where appropriate
- [ ] I have explained any part of my code/implementation decisions that is not be self-explanatory

## Please provide a brief description of your ticket
<!-- you can copy the ticket if it hasn't changed -->

... Put ticket description here and add link to ticket ...

## Are there any other pull requests that this one depends on?
<!-- list pull request here (with links) -->

## Anything else the reviewer needs to know?

... describe here ...
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,8 @@ data/files/*
data/db/*

#Mac Files
**/.DS_Store
**/.DS_Store
.DS_Store

#Staticfiles
staticfiles/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ ENV PYTHONUNBUFFERED=1
WORKDIR /vogon

COPY startup.sh /vogon/startup.sh
RUN ["chmod" "+x" "/vogon/startup.sh"]
RUN ["chmod", "+x", "/vogon/startup.sh"]

ENTRYPOINT ["/vogon/startup.sh"]
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# vogon-resuscitate
Resuscitated Vogon that works without Vue.js

#Setup
- Run (`Docker compose Build`)
- Then run (`Docker compose up`)
Note: You may need to run these commands using sudo
# Setup
To run Vogon, copy and rename the following files:
- `.env_app-example` to `.env_app` and define the variables in the file.

If you are using the production docker-compose set up (`docker-compose-prod.yml`) you will have to do the same for `.env-example` and `.docker-env-example`, in which `.env` needs to contain the variables that are in required in the docker-compose file, while `.docker-env` should contain all environment variables needed inside the Docker containers.

# Startup
Run `docker compose up` inside the directory that holds the `docker-compose.yml` file.
Binary file removed annotations/.DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions annotations/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.contrib import admin
from annotations.forms import *
from annotations.models import *
from annotations import quadriga
from annotations.tasks import submit_relationsets_to_quadriga

from itertools import groupby
Expand Down Expand Up @@ -143,4 +142,4 @@ class Meta:
admin.site.register(RelationSet, RelationSetAdmin)
admin.site.register(RelationTemplate)
admin.site.register(RelationTemplatePart)
admin.site.register(DateAppellation)
admin.site.register(DateAppellation)
74 changes: 35 additions & 39 deletions annotations/annotators.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def my_view(request, text_id):
from django.http import Http404
from annotations.tasks import tokenize
from annotations.utils import basepath
from annotations.models import TextCollection, VogonUserDefaultProject
from annotations.models import TextCollection, VogonUserDefaultProject, Text
from urllib.parse import urlparse
import chardet

Expand All @@ -68,12 +68,8 @@ class Annotator(object):
template = ''
content_types = []

def __init__(self, request, text):
project_id = request.GET.get('project_id')
if project_id:
project = TextCollection.objects.get(pk=project_id)
else:
project = request.user.get_default_project()
def __init__(self, request, text, project_id):
project = TextCollection.objects.get(pk=project_id)

self.project = project;
self.context = {
Expand All @@ -100,16 +96,21 @@ def get_content(self, resource):

def get_resource(self):
"""
Retrieve the resource represented by our :class:`.Text` instance.
Retrieve the resource represented by our :class:`.Text` instance,
focusing on the tokenized content for annotation.
"""
if self.resource is not None:
if self.resource:
return self.resource
if not self.text.repository:
return
manager = self.text.repository.manager(self.context['user'])
self.resource = manager.content(id=int(self.text.repository_source_id))

if not self.text:
return None

# Retrieve the tokenized content of the text directly
self.resource = getattr(self.text, 'tokenizedContent', None)
return self.resource



def render(self, context={}):
"""
Render this annotator's template to a response.
Expand Down Expand Up @@ -152,22 +153,24 @@ def render_display(self, context={}):
return render(self.context.get('request'), self.display_template, context)

def get_context(self):
resource = self.get_resource()
"""
Override to provide context for a specific word to annotate.
"""
resource = self.get_resource() # Get the tokenized content, which is a string
request = self.context.get('request')
content = self.get_content(resource)
detect = chardet.detect(content)
return {

context = {
'text': self.text,
'textid': self.text.id,
'title': 'Annotate Text',
'content': content.decode(detect['encoding']).encode('utf-8'), # We are using chardet to guess the encoding becuase giles is returning everyting with a utf-8 header even if it is not utf-8
'baselocation' : basepath(request),
'content': resource, # The entire tokenized content
'userid': request.user.id,
'title': self.text.title,
'repository_id': self.text.repository.id,
'project': self.project
'project': self.project,
}

return context


class PlainTextAnnotator(Annotator):
"""
Expand All @@ -178,25 +181,18 @@ class PlainTextAnnotator(Annotator):
content_types = ('text/plain',)

def get_content(self, resource):
target = resource.get('location')
request = self.context['request']
manager = self.text.repository.manager(request.user)
endpoint = manager.configuration['endpoint']
if urlparse(target).netloc == urlparse(endpoint).netloc:
return manager.get_raw(target)
response = requests.get(target)
if response.status_code == requests.codes.OK:
return response.content
return
"""
Since resource is just the tokenized content string, return it as is.
"""
return resource # Return the tokenized content string directly

def get_context(self):
"""
Override to provide context for a specific word to annotate.
"""
context = super(PlainTextAnnotator, self).get_context()
context.update({
'next': self.resource.get('next'),
'next_content': self.resource.get('next_content'),
'previous': self.resource.get('previous'),
'previous_content': self.resource.get('previous_content'),
})

# Since self.resource is a string (tokenized content)
return context


Expand Down Expand Up @@ -245,7 +241,7 @@ class WebAnnotator(Annotator):
)


def annotator_factory(request, text):
def annotator_factory(request, text, project_id):
"""
Find and instantiate an annotator for a :class:`.Text` instance.
Expand All @@ -261,7 +257,7 @@ def annotator_factory(request, text):
"""
for annotator in ANNOTATORS:
if text.content_type in annotator.content_types:
return annotator(request, text)
return annotator(request, text, project_id)
return


Expand Down
Loading

0 comments on commit c3be2ca

Please sign in to comment.