# "https://ckan.org/", # "CKAN", # comment="The Comprehensive Knowledge Archive Network (CKAN) is a web-based open-source management system for " # "the storage and distribution of open data. This profile it it's native data model", # mediatypes=["application/json"], # default_mediatype="application/json", # languages=["en"], # default_language="en", # ) profile_dcat = Profile( "https://www.w3.org/TR/vocab-dcat/", label="DCAT", comment= "Dataset Catalogue Vocabulary (DCAT) is a W3C-authored RDF vocabulary designed to " "facilitate interoperability between data catalogs " "published on the Web.", mediatypes=["text/html"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_sdo = Profile( "https://schema.org", label="schema.org", comment= "Schema.org is a collaborative, community activity with a mission to create, maintain, and promote schemas " "for structured data on the Internet, on web pages, in email messages, and beyond.", mediatypes=["text/html"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now
from pyldapi.profile import Profile from pyldapi.renderer import Renderer profile_skos = Profile( "https://www.w3.org/TR/skos-reference/", label="SKOS", comment= "Simple Knowledge Organization System (SKOS)is a W3C-authored, common data model for sharing " "and linking knowledge organization systems " "via the Web.", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_dcat = Profile( "https://www.w3.org/TR/vocab-dcat/", label="DCAT", comment= "Dataset Catalogue Vocabulary (DCAT) is a W3C-authored RDF vocabulary designed to " "facilitate interoperability between data catalogs " "published on the Web.", mediatypes=["text/html"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_void = Profile( "https://www.w3.org/TR/vocab-dcat/",
from pyldapi.profile import Profile from pyldapi.renderer import Renderer profile_skos = Profile( "https://www.w3.org/TR/skos-reference/", label="SKOS", comment= "Simple Knowledge Organization System (SKOS)is a W3C-authored, common data model for sharing " "and linking knowledge organization systems " "via the Web.", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_dcat = Profile( "https://www.w3.org/TR/vocab-dcat/", label="DCAT", comment= "Dataset Catalogue Vocabulary (DCAT) is a W3C-authored RDF vocabulary designed to " "facilitate interoperability between data catalogs " "published on the Web.", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_ckan = Profile( "https://ckan.org/",
from pyldapi.profile import Profile from pyldapi.renderer import Renderer profile_openapi = Profile( "http://www.opengis.net/spec/ogcapi-features-1/1.0/req/oas30", label="OpenAPI 3.0", comment="The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which " "allows both humans and computers to discover and understand the capabilities of the service without " "access to source code, documentation, or through network traffic inspection.", mediatypes=["text/html", "application/geo+json", "application/json"], default_mediatype="application/geo+json", languages=["en"], # default 'en' only for now default_language="en", ) profile_dcat = Profile( "https://www.w3.org/TR/vocab-dcat/", label="DCAT", comment="Dataset Catalogue Vocabulary (DCAT) is a W3C-authored RDF vocabulary designed to " "facilitate interoperability between data catalogs " "published on the Web.", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_geosparql = Profile( "http://www.opengis.net/ont/geosparql", label="GeoSPARQL",
def __init__(self, request, instance_uri, label, comment, parent_container_uri, parent_container_label, members, members_total_count, *args, profiles=None, default_profile_token=None, super_register=None, page_size_max=1000): """ Constructor :param request: The Flask request object triggering this class object's creation. :type request: :class:`.flask.request` :param instance_uri: The URI requested. :type instance_uri: str :param label: The label of the Register. :type label: str :param comment: A description of the Register. :type comment: str :param members: The items within this register as a list of URI strings or tuples with string elements like (URI, label). They can also be tuples like (URI, URI, label) if you want to manually specify an item's class. :type members: list :param contained_item_classes: The list of URI strings of each distinct class of item contained in this Register. :type contained_item_classes: list :param members_total_count: The total number of items in this Register (not of a page but the register as a whole). :type members_total_count: int :param profiles: A dictionary of named :class:`.View` objects available for this Register, apart from 'reg' which is auto-created. :type profiles: dict :param default_profile_token: The ID of the default :class:`.View` (key of a profile in the list of Views). :type default_profile_token: str :param super_register: A super-Register URI for this register. Can be within this API or external. :type super_register: str :param members_template: The Jinja2 template to use for rendering the HTML profile of the register. If None, then it will default to try and use a template called :code:`mem.html`. :type members_template: str or None :param per_page: Number of items to show per page if not specified in request. If None, then it will default to RegisterRenderer.DEFAULT_ITEMS_PER_PAGE. :type per_page: int or None """ self.instance_uri = instance_uri if profiles is None: profiles = {} for k, v in profiles.items(): if k == 'mem': raise ProfilesMediatypesException( 'You must not manually add a profile with token \'mem\' as this is auto-created' ) profiles.update({ 'mem': Profile( 'https://w3id.org/profile/mem', 'Members Profile', 'A very basic RDF data model-only profile that lists the sub-items (members) of collections (rdf:Bag)', ['text/html'] + RDF_MEDIATYPES, 'text/html') }) if default_profile_token is None: default_profile_token = 'mem' super(ContainerRenderer, self).__init__(request, instance_uri, profiles, default_profile_token) if self.vf_error is None: self.label = label self.comment = comment self.parent_container_uri = parent_container_uri self.parent_container_label = parent_container_label if members is not None: self.members = members else: self.members = [] self.members_total_count = members_total_count if request.query_params.get("per_page"): self.per_page = int(request.query_params.get("per_page")) else: self.per_page = ContainerRenderer.DEFAULT_ITEMS_PER_PAGE if request.query_params.get("page"): self.page = int(request.query_params.get("page")) else: self.page = 1 self.super_register = super_register self.page_size_max = page_size_max self.paging_error = self._paging()
from pyldapi.profile import Profile from pyldapi.renderer import Renderer from config import DGGSP profile_dcat = Profile( "https://www.w3.org/TR/vocab-dcat/", label="DCAT", comment= "Dataset Catalogue Vocabulary (DCAT) is a W3C-authored RDF vocabulary designed to " "facilitate interoperability between data catalogs " "published on the Web.", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_dggs = Profile( str(DGGSP), label="DGGS Profile", comment="A Semantic Web profile of the DGGS Abstract Specification", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", )
from pyldapi.profile import Profile from pyldapi.renderer import Renderer profile_skos = Profile( "https://www.w3.org/TR/skos-reference/", label="SKOS", comment= "Simple Knowledge Organization System (SKOS)is a W3C-authored, common data model for sharing " "and linking knowledge organization systems " "via the Web.", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_vocpub = Profile( "https://w3id.org/profile/vocpub", label="VocPub", comment= "A profile of SKOS for the publication of Vocabularies. This profile mandates the use of one Concept " "Scheme per vocabulary", mediatypes=["text/html", "application/json"] + Renderer.RDF_MEDIA_TYPES, default_mediatype="text/html", languages=["en"], # default 'en' only for now default_language="en", ) profile_dcat = Profile( "https://www.w3.org/TR/vocab-dcat/", label="DCAT",
def __init__(self, request, instance_uri, profiles, default_profile_token, ): """ Constructor :param request: Flask request object that triggered this class object's creation. :type request: :class:`flask.request` :param instance_uri: The URI that triggered this API endpoint (can be via redirects but the main URI is needed). :type instance_uri: str :param profiles: A dictionary of profiles available for this resource. :type profiles: dict (of :class:`.View` class objects) :param default_profile_token: The ID of the default profile (key of a profile in the dictionary of :class: `.Profile` objects) :type default_profile_token: str (a key in profiles) :param alternates_template: The Jinja2 template to use for rendering the HTML *alternates view*. If None, then it will default to try and use a template called :code:`alternates.html`. :type alternates_template: str .. seealso:: See the :class:`.View` class on how to create a dictionary of profiles. """ self.vf_error = None self.request = request self.instance_uri = instance_uri # ensure alternates token isn't hogged by user for k, v in profiles.items(): if k == 'alternates': self.vf_error = 'You must not manually add a profile with token \'alternates\' as this is auto-created.' self.profiles = profiles # auto-add in an Alternates profile self.profiles['alt'] = Profile( 'http://www.w3.org/ns/dx/conneg/altr', # the ConnegP URI for Alt Rep Data Model 'Alternate Representations', 'The representation of the resource that lists all other representations (profiles and Media Types)', ['text/html', 'application/json'] + RDF_MEDIATYPES, 'text/html', languages=['en'], # default 'en' only for now ) self.profile = None # ensure that the default profile is actually a given profile if default_profile_token == "alternates": self.vf_error = 'You cannot specify \'alternates\' as the default profile.' # ensure the default profile is in the list of profiles if default_profile_token not in self.profiles.keys(): self.vf_error = 'The profile token you specified ({}) for the default profile ' \ 'is not in the list of profiles you supplied ({})'\ .format(default_profile_token, ', '.join(self.profiles.keys())) self.default_profile_token = default_profile_token # get profile & mediatype for this request, flag any errors but do not except out self.profile = self._get_profile() self.mediatype = self._get_mediatype() self.language = self._get_language() # make headers only if there's no error if self.vf_error is None: self.headers = dict() self.headers['Link'] = '<' + self.profiles[self.profile].uri + '>; rel="profile"' self.headers['Content-Type'] = self.mediatype self.headers['Content-Language'] = self.language self.headers['Link'] += ', ' + self._make_header_link_tokens() self.headers['Link'] += ', ' + self._make_header_link_list_profiles() # Issue 18 - https://github.com/RDFLib/pyLDAPI/issues/18 # Enable CORS for browser client consumption self.headers['Access-Control-Allow-Origin'] = '*'