Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New structure for Django module
  • Loading branch information
kthoden committed Sep 21, 2019
1 parent 0e15fc0 commit 8763a7b
Show file tree
Hide file tree
Showing 20 changed files with 195 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
/opds/migrations/
/dist/
/django_opds.egg-info/
1 change: 1 addition & 0 deletions LICENSE
@@ -0,0 +1 @@
Coffeeware
5 changes: 5 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,5 @@
include LICENSE
include README.rst
recursive-include opds/static *
recursive-include opds/templates *
recursive-include docs *
29 changes: 28 additions & 1 deletion README.md → README.rst
@@ -1,5 +1,32 @@
# OPDS for EOA
=====
OPDS module for Django
=====

The OPDS is a Django app and provides and endpoint for OPDS applications

Quick start
-----------

1. Add "opds" to your INSTALLED_APPS setting like this::

INSTALLED_APPS = [
...
'opds',
]

2. Run `python manage.py migrate` to create the opds models.



====
OPDS for EOA
====

Examples downloaded from <http://www.feedbooks.com/opensearch.xml>, <http://www.feedbooks.com/store/selection.atom> and <http://www.feedbooks.com/catalog.atom>. A title feed was at http://www.feedbooks.com/item/2846030.atom

`textbooks.atom` was manually coded following above examples. It is currently active at http://www.edition-open-access.de/textbooks.atom and can be harvested by programs like [Readium2](https://github.com/readium/readium-desktop/releases).

As an Django app
----------------
- views will direct the browser to the app
- files need to be created
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added opds/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions opds/admin.py
@@ -0,0 +1,8 @@
# -*- coding: utf-8; mode: python -*-

from django.contrib import admin
from .models import Catalogue


# Register your models here:
admin.site.register(Catalogue)
6 changes: 6 additions & 0 deletions opds/apps.py
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class OPDSConfig(AppConfig):
name = 'opds'
verbose_name = 'OPDS module'
15 changes: 15 additions & 0 deletions opds/models.py
@@ -0,0 +1,15 @@
from django.db import models
from cms.models import CMSPlugin, Model

class Catalogue(Model):
name = models.CharField(
max_length=200,
unique=True
)
description = models.CharField(
max_length=1000
)

# functions:
def __str__(self):
return self.name
63 changes: 63 additions & 0 deletions opds/templates/eoaseries/index.html
@@ -0,0 +1,63 @@
{% extends "base.html" %}
{% load menu_tags %}

{% block title %}{{ request.site.name }}{% endblock %}

{% block breadcrumb %}
{% show_breadcrumb %}
{% endblock %}

{% block content %}
<main class="main">
<div class="container">
<div class="main-content">
<div class="accordion"><a class="accordion__showall" href="#">Show All</a>
{% for serie in allseries %}
<div class="accordion__item"><a class="accordion__title" id="{{ serie }}">
<h2>{{ serie|capfirst }}</h2></a>
<div class="accordion__content">
<section>
{% if serie == 'sources' %}
<p>Each volume of the Sources series typically presents a primary source—relevant for the history and development of knowledge—in facsimile, transcription, or translation. The original sources are complemented by an introduction and by commentaries reflecting original scholarly work. The sources reproduced in this series may be rare books, manuscripts, documents or data that are not readily accessible in libraries and archives.</p>
{% elif serie == 'studies' %}
<p>Each volume of the <em>Studies</em> series is dedicated to a key subject in the history and development of knowledge, bringing together perspectives from different fields and combining source-based empirical research with theoretically guided approaches. The studies are typically working group volumes presenting integrative approaches to problems ranging from the globalization of knowledge to the nature of spatial thinking.</p>
{% elif serie == 'proceedings' %}
<p>Each volume of the Proceedings series presents the results of a scientific meeting on current issues and supports, at the same time, further cooperation on these issues by offering an electronic platform with further resources and the possibility for comments and interactions.</p>
{% elif serie == 'textbooks' %}
<p>Each volume of the Textbooks series presents concise and synthetic information on a wide range of current research topics, both introductory and advanced. They use the new publication channel to offer students affordable access to highlevel scientific and scholarly overviews. The textbooks are prepared and updated by experts in the relevant fields and supplemented by additional online materials.</p>
{% endif %}
</section>
{% if Listofpublications %}
{% for Publication in Listofpublications %}
{% if Publication.Serie == serie %}
<div class="project-teaser">
<div class="project-teaser__image"><img src="/media/{{ Publication.Coversmallright }}" data-object-fit="cover"/></div>
<div class="project-teaser-info">
<div class="project-teaser-info__category">{{ Publication.get_Serie_display }} {{ Publication.Number }}</div>
<h2 class="project-teaser-info__title">{{ Publication.Title|safe }}</h2>
<div class="project-teaser-info__description">{{ Publication.Descriptionshort }}</div>
<div class="project-teaser-info-authors">
{% if Publication.Publicationauthor1 %} <a class="project-teaser-info__author-link" href="/author/{{ Publication.Publicationauthor1number }}.html">{{ Publication.Publicationauthor1 }}</a>{% if Publication.Publicationauthor2 %}, <a class="project-teaser-info__author-link" href="/author/{{ Publication.Publicationauthor2number }}.html">{{ Publication.Publicationauthor2 }}</a>{% if Publication.Publicationauthor3 %}, <a class="project-teaser-info__author-link" href="/author/{{ Publication.Publicationauthor3number }}.html">{{ Publication.Publicationauthor3 }}</a>{% if Publication.Publicationauthor4 %}, <a class="project-teaser-info__author-link" href="/author/{{ Publication.Publicationauthor4number }}.html">{{ Publication.Publicationauthor4 }}</a>{% if Publication.Publicationauthor5 %}, <a class="project-teaser-info__author-link" href="/author/{{ Publication.Publicationauthor5number }}.html">{{ Publication.Publicationauthor5 }}</a>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if Publication.Publicationauthorsuffix %}
{{ Publication.Publicationauthorsuffix }}
{% endif %}</div>
<div class="project-teaser-info__buttons"><a class="link" href="/{{ Publication.Serie }}/{{ Publication.Number }}/index.html"><span class="link__label">More</span></a>
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</main>
{% endblock %}
3 changes: 3 additions & 0 deletions opds/tests.py
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions opds/urls.py
@@ -0,0 +1,9 @@
#-*- coding: utf-8 -*-
from django.conf.urls import url

from . import views

app_name = "opds"
urlpatterns = [
url(r'', views.index),
]
18 changes: 18 additions & 0 deletions opds/views.py
@@ -0,0 +1,18 @@
#-*- coding: utf-8 -*-
from django.urls import reverse
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.views import generic
from eoapublications.models import *

from .models import Catalogue

def index(request):
allseries = set(Publication.objects.values_list("Serie", flat=True))
Listofpublications = Publication.objects.filter(Published=True).order_by('-Number').order_by('Serie')
Content = {
'Listofpublications' : Listofpublications,
'allseries' : sorted(allseries),
'Series' : Series
}
return render(request, 'eoaseries/index.html', Content)
36 changes: 36 additions & 0 deletions setup.py
@@ -0,0 +1,36 @@
# -*- coding: utf-8; mode: python -*-

import os
from setuptools import find_packages, setup

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
README = readme.read()

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

setup(
name='opds',
version='1.0',
packages=find_packages(),
include_package_data=True,
license='Coffeeware', # example license
description='A Django app to provide an OPDS endpoint for book browsing.',
long_description=README,
url='http://www.edition-open-access.de/',
author='Klaus Thoden',
author_email='kthoden@mpiwg-berlin.mpg.de',
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Intended Audience :: Developers',
'License :: OSI Approved :: Coffeeware',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)

0 comments on commit 8763a7b

Please sign in to comment.