aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/migrations.py12
-rw-r--r--mediagoblin/db/models.py1
-rw-r--r--mediagoblin/routing.py4
-rw-r--r--mediagoblin/templates/mediagoblin/metadata_contexts/v170
-rw-r--r--mediagoblin/views.py6
-rw-r--r--setup.py1
6 files changed, 93 insertions, 1 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 426080a2..a7400bf0 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -31,6 +31,7 @@ from mediagoblin.db.migration_tools import (
RegisterMigration, inspect_table, replace_table_hack)
from mediagoblin.db.models import (MediaEntry, Collection, MediaComment, User,
Privilege)
+from mediagoblin.db.extratypes import JSONEncoded, MutationDict
MIGRATIONS = {}
@@ -720,3 +721,14 @@ def drop_MediaEntry_collected(db):
media_collected.drop()
db.commit()
+
+@RegisterMigration(20, MIGRATIONS)
+def add_work_metadata_column(db):
+ metadata = MetaData(bind=db.bind)
+
+ media_file = inspect_table(metadata, 'core__mediafiles')
+
+ col = Column('work_metadata', MutationDict.as_mutable(JSONEncoded))
+ col.create(media_file)
+
+ db.commit()
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index b750375d..ac69d040 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -420,6 +420,7 @@ class MediaFile(Base):
name_id = Column(SmallInteger, ForeignKey(FileKeynames.id), nullable=False)
file_path = Column(PathTupleWithSlashes)
file_metadata = Column(MutationDict.as_mutable(JSONEncoded))
+ work_metadata = Column(MutationDict.as_mutable(JSONEncoded))
__table_args__ = (
PrimaryKeyConstraint('media_entry', 'name_id'),
diff --git a/mediagoblin/routing.py b/mediagoblin/routing.py
index 1393f01c..a6b2a543 100644
--- a/mediagoblin/routing.py
+++ b/mediagoblin/routing.py
@@ -28,7 +28,9 @@ _log = logging.getLogger(__name__)
def get_url_map():
add_route('index', '/', 'mediagoblin.views:root_view')
add_route('terms_of_service','/terms_of_service',
- 'mediagoblin.views:terms_of_service')
+ 'mediagoblin.views:terms_of_service'),
+ add_route('metadata_context','/metadata_context/v<int:version_number>/',
+ 'mediagoblin.views:metadata_context_view'),
mount('/auth', auth_routes)
mount('/mod', moderation_routes)
diff --git a/mediagoblin/templates/mediagoblin/metadata_contexts/v1 b/mediagoblin/templates/mediagoblin/metadata_contexts/v1
new file mode 100644
index 00000000..1325d920
--- /dev/null
+++ b/mediagoblin/templates/mediagoblin/metadata_contexts/v1
@@ -0,0 +1,70 @@
+{
+ "@context": {
+ "dc": "http://purl.org/dc/elements/1.1/",
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
+ "contributor":{
+ "@id":"dc:title",
+ "@type":"xsd:string"
+ },
+ "coverage":{
+ "@id":"dc:coverage",
+ "@type":"xsd:string"
+ },
+ "created":{
+ "@id":"dc:created",
+ "@type":"xsd:date"
+ },
+ "creator":{
+ "@id":"dc:created",
+ "@type":"xsd:date"
+ },
+ "date":{
+ "@id":"dc:date",
+ "@type":"xsd:date"
+ },
+ "description":{
+ "@id":"dc:description",
+ "@type":"xsd:string"
+ },
+ "format":{
+ "@id":"dc:format",
+ "@type":"xsd:string"
+ },
+ "identifier":{
+ "@id":"dc:identifier",
+ "@type":"xsd:string"
+ },
+ "language":{
+ "@id":"dc:language",
+ "@type":"xsd:string"
+ },
+ "publisher":{
+ "@id":"dc:publisher",
+ "@type":"xsd:string"
+ },
+ "relation":{
+ "@id":"dc:relation",
+ "@type":"xsd:string"
+ },
+ "rights":{
+ "@id":"dc:rights",
+ "@type":"xsd:anyURI"
+ },
+ "source":{
+ "@id":"dc:source",
+ "@type":"xsd:string"
+ },
+ "subject":{
+ "@id":"dc:subject",
+ "@type":"xsd:string"
+ },
+ "title": {
+ "@id":"dc:title",
+ "@type":"xsd:string"
+ },
+ "type":{
+ "@id":"dc:type",
+ "@type":"xsd:string"
+ }
+ }
+}
diff --git a/mediagoblin/views.py b/mediagoblin/views.py
index 009e48e4..1ed71473 100644
--- a/mediagoblin/views.py
+++ b/mediagoblin/views.py
@@ -62,3 +62,9 @@ def terms_of_service(request):
return render_to_response(request,
'mediagoblin/terms_of_service.html', {})
+
+def metadata_context_view(request):
+ version = request.matchdict['version_number']
+ return render_to_response(request,
+ 'mediagoblin/metadata_contexts/v{version}'.format(
+ version=version), {})
diff --git a/setup.py b/setup.py
index d3f91686..93873d73 100644
--- a/setup.py
+++ b/setup.py
@@ -66,6 +66,7 @@ try:
'six>=1.4.1',
'oauthlib==0.5.0',
'unidecode',
+ 'jsonschema',
## Annoying. Please remove once we can! We only indirectly
## use pbr, and currently it breaks things, presumably till