-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
424 additions
and
262 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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'iiif_to_jekyll', '0.9.4', git: 'https://github.com/ecds/iiif-to-jekyll.git' | ||
gem 'iiif_to_jekyll', '0.9.5', git: 'https://github.com/ecds/iiif-to-jekyll.git' |
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 |
---|---|---|
@@ -1,46 +1,62 @@ | ||
GIT | ||
remote: https://github.com/ecds/iiif-to-jekyll.git | ||
revision: 6f734546fe58c8d24ab07d24d29eee43a564a701 | ||
revision: de5365cd30e5b70756328f2d584e0400c70eaf47 | ||
specs: | ||
iiif_to_jekyll (0.9.4) | ||
iiif_to_jekyll (0.9.5) | ||
iiif-presentation (~> 0.2.0) | ||
openssl | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
activesupport (6.1.0) | ||
activesupport (6.1.4.1) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
zeitwerk (~> 2.3) | ||
concurrent-ruby (1.1.7) | ||
faraday (1.3.0) | ||
concurrent-ruby (1.1.9) | ||
faraday (1.8.0) | ||
faraday-em_http (~> 1.0) | ||
faraday-em_synchrony (~> 1.0) | ||
faraday-excon (~> 1.1) | ||
faraday-httpclient (~> 1.0.1) | ||
faraday-net_http (~> 1.0) | ||
faraday-net_http_persistent (~> 1.1) | ||
faraday-patron (~> 1.0) | ||
faraday-rack (~> 1.0) | ||
multipart-post (>= 1.2, < 3) | ||
ruby2_keywords | ||
faraday-net_http (1.0.0) | ||
i18n (1.8.7) | ||
ruby2_keywords (>= 0.0.4) | ||
faraday-em_http (1.0.0) | ||
faraday-em_synchrony (1.0.0) | ||
faraday-excon (1.1.0) | ||
faraday-httpclient (1.0.1) | ||
faraday-net_http (1.0.1) | ||
faraday-net_http_persistent (1.2.0) | ||
faraday-patron (1.0.0) | ||
faraday-rack (1.0.0) | ||
i18n (1.8.11) | ||
concurrent-ruby (~> 1.0) | ||
iiif-presentation (0.2.0) | ||
activesupport (>= 3.2.18) | ||
faraday (>= 0.9) | ||
json | ||
json (2.5.1) | ||
minitest (5.14.2) | ||
ipaddr (1.2.3) | ||
json (2.6.1) | ||
minitest (5.14.4) | ||
multipart-post (2.1.1) | ||
openssl (2.2.0) | ||
ruby2_keywords (0.0.2) | ||
openssl (2.2.1) | ||
ipaddr | ||
ruby2_keywords (0.0.5) | ||
tzinfo (2.0.4) | ||
concurrent-ruby (~> 1.0) | ||
zeitwerk (2.4.2) | ||
zeitwerk (2.5.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
iiif_to_jekyll (= 0.9.4)! | ||
iiif_to_jekyll (= 0.9.5)! | ||
|
||
BUNDLED WITH | ||
2.1.4 |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "2.2.1" | ||
__version__ = "2.2.2" | ||
__version_info__ = tuple( | ||
[ | ||
int(num) if num.isdigit() else num | ||
|
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,16 @@ | ||
""" | ||
Celery config for ingest tasks. | ||
""" | ||
import os | ||
from celery import Celery | ||
from django.conf import settings | ||
# import config.settings.local as settings | ||
|
||
# set the default Django settings module for the 'celery' program. | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local') | ||
app = Celery('apps.export', result_extended=True) | ||
|
||
# Using a string here means the worker will not have to | ||
# pickle the object when using Windows. | ||
app.config_from_object('django.conf:settings') | ||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) |
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,68 @@ | ||
"""Django Forms for export.""" | ||
import logging | ||
from django import forms | ||
from django.contrib.admin import site as admin_site, widgets | ||
|
||
from apps.iiif.kollections.models import Collection | ||
from apps.iiif.manifests.models import Manifest | ||
from apps.iiif.canvases.models import Canvas | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
# add is_checkbox method to all form fields, to enable template logic. | ||
# thanks to: | ||
# http://stackoverflow.com/questions/3927018/django-how-to-check-if-field-widget-is-checkbox-in-the-template | ||
setattr( | ||
forms.Field, | ||
'is_checkbox', | ||
lambda self: isinstance(self.widget, forms.CheckboxInput) | ||
) | ||
|
||
class JekyllExportForm(forms.Form): | ||
"""Form to provide export options.""" | ||
#: export mode | ||
mode = forms.ChoiceField( | ||
label='Export mode', | ||
choices=[ | ||
('download', 'Download Jekyll site export'), | ||
('github', 'Publish Jekyll site on GitHub'), | ||
], | ||
initial='none', | ||
widget=forms.RadioSelect(attrs={'class': 'uk-radio'}), | ||
help_text='Choose how to export your annotated volume.' | ||
) | ||
#: help text for export mode choices | ||
mode_help = [ | ||
'Download a zip file with all Jekyll site contents', | ||
'''Create or update a GitHub repository with the generated Jekyll | ||
site content and publish it using Github Pages''' | ||
] | ||
|
||
#: github repository name to be created | ||
github_repo = forms.SlugField( | ||
label='GitHub repository name', required=False, | ||
widget=forms.TextInput(attrs={'class': 'rdx-input uk-input'}), | ||
help_text='Name of the repository to be created or updated, which will also ' + | ||
'determine the GitHub pages URL.') | ||
|
||
#: options that are relevant to jekyll export but not to TEI | ||
jekyll_options = [ | ||
# 'page_one', | ||
# 'deep_zoom', | ||
# 'image_hosting' | ||
] | ||
|
||
# flag to allow suppressing annotation choice display when | ||
# user does not belong to any annotation groups | ||
hide_annotation_choice = False | ||
|
||
def __init__(self, user, *args, **kwargs): | ||
self.user = user | ||
|
||
# initialize normally | ||
super(JekyllExportForm, self).__init__(*args, **kwargs) | ||
# If the person has not authorized GitHub access, remove the GitHub | ||
# options and select download by default. | ||
if 'github' not in user.socialaccount_list: | ||
self.fields['mode'].choices = self.fields['mode'].choices[:1] | ||
self.fields['mode'].widget.attrs = {'class': 'uk-radio', 'checked': True} |
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,24 @@ | ||
''' | ||
''' | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from allauth.socialaccount.models import SocialAccount | ||
from apps.export.forms import JekyllExportForm | ||
|
||
class ManifestTests(TestCase): | ||
fixtures = ['users.json'] | ||
|
||
def setUp(self): | ||
self.user = get_user_model().objects.get(pk=111) | ||
|
||
def test_form_mode_choices_no_github(self): | ||
form = JekyllExportForm(user=self.user) | ||
assert len(form.fields['mode'].choices) == 1 | ||
assert form.fields['mode'].choices[0] != 'github' | ||
|
||
def test_form_mode_choices_with_github(self): | ||
sa = SocialAccount(provider='github', user=self.user) | ||
sa.save() | ||
form = JekyllExportForm(user=self.user) | ||
assert len(form.fields['mode'].choices) == 2 | ||
assert form.fields['mode'].choices[1][0] == 'github' |
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,9 @@ | ||
"""URL patterns for manifests.""" | ||
from django.urls import path | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('iiif/<version>/<pid>/plain', views.PlainExport.as_view(), name="PlainExport"), | ||
path('iiif/<version>/<pid>/export', views.ManifestExport.as_view(), name="ManifestExport"), | ||
path('iiif/<version>/<pid>/jekyllexport', views.JekyllExport.as_view(), name="JekyllExport"), | ||
] |
Oops, something went wrong.