diff --git a/.travis.yml b/.travis.yml index f8ada83d3..86b4d8c38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: node_js node_js: - - "0.12" - - "0.11" - - "0.10" + - "0.8" before_script: - - npm install -g grunt-ci + - npm install -g grunt-cli script: - npm install && grunt diff --git a/_schemas/NIST800.json b/_data/NIST800.json similarity index 100% rename from _schemas/NIST800.json rename to _data/NIST800.json diff --git a/_schemas/NIST800.yaml b/_data/NIST800.yaml similarity index 100% rename from _schemas/NIST800.yaml rename to _data/NIST800.yaml diff --git a/_schemas/dataset.json b/_schemas/dataset.json new file mode 100644 index 000000000..2f37f07b9 --- /dev/null +++ b/_schemas/dataset.json @@ -0,0 +1,372 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://project-open-data.cio.gov/v1.1/schema/dataset.json#", + "title": "Project Open Data Dataset", + "description": "The metadata format for all federal open data. Validates a single JSON object entry (as opposed to entire Data.json catalog).", + "type": "object", + "required": [ + "bureauCode", + "programCode", + "title", + "description", + "keyword", + "modified", + "publisher", + "contactPoint", + "identifier", + "accessLevel" + ], + "properties": { + "@type": { + "title": "Metadata Context", + "description": "IRI for the JSON-LD data type. This should be dcat:Dataset for each Dataset", + "enum": [ + "dcat:Dataset" + ] + }, + "accessLevel": { + "description": "The degree to which this dataset could be made publicly-available, regardless of whether it has been made available. Choices: public (Data asset is or could be made publicly available to all without restrictions), restricted public (Data asset is available under certain use restrictions), or non-public (Data asset is not available to members of the public)", + "title": "Public Access Level", + "enum": [ + "public", + "restricted public", + "non-public" + ] + }, + "rights": { + "title": "Rights", + "description": "This may include information regarding access or restrictions based on privacy, security, or other policies. This should also provide an explanation for the selected \"accessLevel\" including instructions for how to access a restricted file, if applicable, or explanation for why a \"non-public\" or \"restricted public\" data assetis not \"public,\" if applicable. Text, 255 characters.", + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + { + "type": "null" + } + ] + }, + "accrualPeriodicity": { + "title": "Frequency", + "description": "Frequency with which dataset is published.", + "anyOf": [ + { + "enum": [ + "irregular" + ] + }, + { + "type": "string", + "pattern": "^R\\/P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$" + }, + { + "type": "null" + } + ] + }, + "bureauCode": { + "title": "Bureau Code", + "description": "Federal agencies, combined agency and bureau code from OMB Circular A-11, Appendix C in the format of 015:010.", + "type": "array", + "items": { + "type": "string", + "pattern": "[0-9]{3}:[0-9]{2}" + }, + "minItems": 1, + "uniqueItems": true + }, + "contactPoint": { + "$ref": "vcard.json" + }, + "describedBy": { + "title": "Data Dictionary", + "description": "URL to the data dictionary for the dataset or API. Note that documentation other than a data dictionary can be referenced using Related Documents as shown in the expanded fields.", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "describedByType": { + "title": "Data Dictionary Type", + "description": "The machine-readable file format (IANA Media Type or MIME Type) of the distribution’s describedBy URL", + "anyOf": [ + { + "pattern": "^[-\\w]+/[-\\w]+(\\.[-\\w]+)*([+][-\\w]+)?$", + "type": "string" + }, + { + "type": "null" + } + ] + }, + "conformsTo": { + "title": "Data Standard", + "description": "URI used to identify a standardized specification the dataset conforms to", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "dataQuality": { + "title": "Data Quality", + "description": "Whether the dataset meets the agency’s Information Quality Guidelines (true/false).", + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ] + }, + "description": { + "title": "Description", + "description": "Human-readable description (e.g., an abstract) with sufficient detail to enable a user to quickly understand whether the asset is of interest.", + "type": "string", + "minLength": 1 + }, + "distribution": { + "title": "Distribution", + "description": "A container for the array of Distribution objects", + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "distribution.json", + "minItems": 1, + "uniqueItems": true + } + }, + { + "type": "null" + } + ] + }, + "identifier": { + "title": "Unique Identifier", + "description": "A unique identifier for the dataset or API as maintained within an Agency catalog or database.", + "type": "string", + "minLength": 1 + }, + "issued": { + "title": "Release Date", + "description": "Date of formal issuance.", + "anyOf": [ + { + "type": "string", + "pattern": "^([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$" + }, + { + "type": "null" + } + ] + }, + "keyword": { + "title": "Tags", + "description": "Tags (or keywords) help users discover your dataset; please include terms that would be used by technical and non-technical users.", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 + }, + "landingPage": { + "title": "Homepage URL", + "description": "Alternative landing page used to redirect user to a contextual, Agency-hosted “homepage” for the Dataset or API when selecting this resource from the Data.gov user interface.", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "language": { + "title": "Language", + "description": "The language of the dataset.", + "anyOf": [ + { + "type": "array", + "items": { + "type": "string", + "pattern": "^(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$" + } + }, + { + "type": "null" + } + ] + }, + "license": { + "title": "License", + "description": "The license dataset or API is published with. See Open Licenses for more information.", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "modified": { + "title": "Last Update", + "description": "Most recent date on which the dataset was changed, updated or modified.", + "anyOf": [ + { + "type": "string", + "pattern": "^([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$" + }, + { + "type": "string", + "pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$" + }, + { + "type": "string", + "pattern": "^(R\\d*\\/)?([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\4([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\18[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?(\\/)P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$" + } + ] + }, + "primaryITInvestmentUII": { + "title": "Primary IT Investment UII", + "description": "For linking a dataset with an IT Unique Investment Identifier (UII)", + "anyOf": [ + { + "type": "string", + "pattern": "[0-9]{3}-[0-9]{9}" + }, + { + "type": "null" + } + ] + }, + "programCode": { + "title": "Program Code", + "description": "Federal agencies, list the primary program related to this data asset, from the Federal Program Inventory. Use the format of 015:001", + "type": "array", + "items": { + "type": "string", + "pattern": "[0-9]{3}:[0-9]{3}" + }, + "minItems": 1, + "uniqueItems": true + }, + "publisher": { + "$ref": "organization.json" + }, + "references": { + "title": "Related Documents", + "description": "Related documents such as technical information about a dataset, developer documentation, etc.", + "anyOf": [ + { + "type": "array", + "items": { + "type": "string", + "format": "uri" + }, + "minItems": 1, + "uniqueItems": true + }, + { + "type": "null" + } + ] + }, + "spatial": { + "title": "Spatial", + "description": "The range of spatial applicability of a dataset. Could include a spatial region like a bounding box or a named place.", + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, + "systemOfRecords": { + "title": "System of Records", + "description": "If the systems is designated as a system of records under the Privacy Act of 1974, provide the URL to the System of Records Notice related to this dataset.", + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, + "temporal": { + "title": "Temporal", + "description": "The range of temporal applicability of a dataset (i.e., a start and end date of applicability for the data).", + "anyOf": [ + { + "type": "string", + "pattern": "^([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?(\\/)([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$" + }, + { + "type": "string", + "pattern": "^(R\\d*\\/)?([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\4([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\18[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?(\\/)P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$" + }, + { + "type": "string", + "pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?\\/([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\4([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\18[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$" + }, + { + "type": "null" + } + ] + }, + "isPartOf": { + "title": "Collection", + "description": "The collection of which the dataset is a subset", + "anyOf": [ + { + "type": "string", + "minLength": 1 + } + ] + }, + "theme": { + "title": "Category", + "description": "Main thematic category of the dataset.", + "anyOf": [ + { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1, + "uniqueItems": true + }, + { + "type": "null" + } + ] + }, + "title": { + "title": "Title", + "description": "Human-readable name of the asset. Should be in plain English and include sufficient detail to facilitate search and discovery.", + "type": "string", + "minLength": 1 + } + } +} diff --git a/_schemas/distribution.json b/_schemas/distribution.json new file mode 100644 index 000000000..decc99716 --- /dev/null +++ b/_schemas/distribution.json @@ -0,0 +1,139 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://project-open-data.cio.gov/v1.1/schema/distribution.json#", + "title": "Project Open Data Distribution", + "description": "Validates an entire collection of common core metadata JSON objects. Agencies produce said collections in the form of Data.json files.", + "type": "object", + "dependencies": { + "downloadURL": { + "properties": { + "mediaType": { + "type": "string", + "pattern": "^[-\\w]+/[-\\w]+(\\.[-\\w]+)*([+][-\\w]+)?$" + } + }, + "required": [ + "mediaType" + ] + } + }, + "properties": { + "@type": { + "title": "Metadata Context", + "description": "IRI for the JSON-LD data type. This should be dcat:Distribution for each Distribution", + "enum": [ + "dcat:Distribution" + ] + }, + "downloadURL": { + "title": "Download URL", + "description": "URL providing direct access to a downloadable file of a dataset", + "type": "string", + "format": "uri" + }, + "mediaType": { + "title": "Media Type", + "description": "The machine-readable file format (IANA Media Type or MIME Type) of the distribution’s downloadURL", + "anyOf": [ + { + "pattern": "^[-\\w]+/[-\\w]+(\\.[-\\w]+)*([+][-\\w]+)?$", + "type": "string" + }, + { + "type": "null" + } + ] + }, + "format": { + "title": "Format", + "description": "A human-readable description of the file format of a distribution", + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, + "accessURL": { + "title": "Access URL", + "description": "URL providing indirect access to a dataset", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "description": { + "title": "Description", + "description": "Human-readable description of the distribution", + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, + "title": { + "title": "Title", + "description": "Human-readable name of the distribution", + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, + "conformsTo": { + "title": "Data Standard", + "description": "URL providing indirect access to a dataset", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "describedBy": { + "title": "Data Dictionary", + "description": "URL to the data dictionary for the distribution found at the downloadURL", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "describedByType": { + "title": "Data Dictionary Type", + "description": "The machine-readable file format (IANA Media Type or MIME Type) of the distribution’s describedBy URL", + "anyOf": [ + { + "pattern": "^[-\\w]+/[-\\w]+(\\.[-\\w]+)*([+][-\\w]+)?$", + "type": "string" + }, + { + "type": "null" + } + ] + } + } +} diff --git a/_schemas/organization.json b/_schemas/organization.json new file mode 100644 index 000000000..10ec4aba0 --- /dev/null +++ b/_schemas/organization.json @@ -0,0 +1,30 @@ + +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "https://project-open-data.cio.gov/v1.1/schema/organization.json#", + "title": "Project Open Data Organization", + "description": "A Dataset Publisher Organization as a foaf:Agent object", + "type": "object", + "required": [ + "name" + ], + "properties": { + "@type": { + "title": "Metadata Context", + "description": "IRI for the JSON-LD data type. This should be org:Organization for each publisher", + "enum": [ + "org:Organization" + ] + }, + "name": { + "title": "Publisher Name", + "description": "A full formatted name, eg Firstname Lastname", + "type": "string", + "minLength": 1 + }, + "subOrganizationOf": { + "title": "Parent Organization", + "$ref": "organization.json" + } + } +} diff --git a/_schemas/project.json b/_schemas/project.json new file mode 100644 index 000000000..b18a82009 --- /dev/null +++ b/_schemas/project.json @@ -0,0 +1,547 @@ +{ + "title": "FederalProjectSchema", + "type": "object", + "properties": { + "title": { + "title": "Title", + "description": "Title or Name of the Project", + "type": "string", + "minLength": 10, + "propertyOrder": 1 + }, + "description": { + "title": "Description", + "description": "Abstract or Summary of the Project", + "type": "string", + "minLength": 10, + "propertyOrder": 2 + }, + "status": { + "title": "Status", + "description": "Phase or Stage of a Project", + "type": "string", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ], + "propertyOrder": 3 + }, + "categories": { + "title": "Categories", + "description": "validate agaisnt a list of options", + "type": "string", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ], + "propertyOrder": 4 + }, + "keywords": { + "type": "array", + "format": "table", + "title": "Keywords", + "description": "", + "uniqueItems": true, + "propertyOrder": 5, + "items": { + "type": "object", + "title": "Keywords", + "properties": { + "additional": { + "type": "string", + "title": "Keyword", + "description": "" + } + } + } + }, + "accessLevel": { + "title": "Access Level", + "description": "Access Level", + "type": "string", + "enum": [ + "public", + "restricted", + "non-public" + ], + "propertyOrder": 7 + }, + "publisher": { + "title": "Publisher", + "description": "Organization hosting the Project", + "type": "string", + "minLength": 4, + "propertyOrder": 8 + }, + "publishedURL": { + "title": "Publisher URL", + "description": "Link to the project website or page from the source Publisher", + "type": "string", + "minLength": 4, + "propertyOrder": 9 + }, + "contacts": { + "type": "array", + "format": "tabs", + "title": "Contacts", + "description": "Project Team and Contributors", + "uniqueItems": true, + "propertyOrder": 10, + "items": { + "type": "object", + "title": "Contact", + "headerTemplate": "{{ self.email }}", + "properties": { + "contactType": { + "type": "string", + "title": "Contact Type", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ] + }, + "contactRole": { + "type": "string", + "title": "Role", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ] + }, + "name": { + "type": "string", + "title": "Full Name" + }, + "email": { + "type": "string", + "title": "Email" + }, + "office": { + "type": "string", + "title": "Office" + }, + "description": { + "type": "string", + "title": "Description" + } + } + } + }, + "spatial": { + "type": "array", + "format": "table", + "title": "Spatial", + "uniqueItems": true, + "propertyOrder": 11, + "items": { + "type": "object", + "title": "Spatial", + "properties": { + "name": { + "type": "string", + "title": "Name" + }, + "geojson": { + "type": "string", + "title": "Geojson", + "description": "Copy/Paste or URL see http://geojson.io", + "format": "geojson" + }, + "address": { + "type": "string", + "title": "Address", + "description": "Only use if Geojson is unavailable" + }, + "city": { + "type": "string", + "title": "City", + "description": "Only use if Geojson is unavailable" + }, + "state": { + "type": "string", + "title": "State", + "description": "Only use if Geojson is unavailable" + } + } + } + }, + "temporal": { + "type": "array", + "format": "tabs", + "title": "Temporal", + "description": "Duration of a specific Activity", + "uniqueItems": true, + "propertyOrder": 12, + "items": { + "type": "object", + "title": "Activity", + "headerTemplate": "{{ self.name }},{{ self.milestoneType }}", + "properties": { + "activityType": { + "type": "string", + "title": "Activity Type", + "descripton": "Discrete Process/Step/Requirement/Phase of a project", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ] + }, + "name": { + "type": "string", + "title": "Name" + }, + "description": { + "type": "string", + "title": "Description" + }, + "to": { + "type": "string", + "title": "Date from", + "format": "date", + "default": "YYYY-MM-DD" + }, + "from": { + "type": "string", + "title": "Date to", + "format": "date", + "default": "YYYY-MM-DD" + }, + "estimated": { + "type": "string", + "title": "Estimated Date", + "format": "date", + "default": "YYYY-MM-DD" + }, + "modified": { + "type": "string", + "title": "Date Modified", + "format": "date", + "default": "YYYY-MM-DDT12:00:00.000Z" + }, + "contactId": { + "type": "string", + "title": "Point of Contact", + "description": "Name@email.gov for person @email.gov for org" + }, + "isPublic": { + "type": "boolean", + "title": "Public", + "format": "checkbox", + "default": "true", + "description": "Is the activity publically viewable" + }, + "tasks": { + "type": "array", + "format": "tabs", + "title": "Tasks", + "description": "Tasks within a Milestone", + "uniqueItems": true, + "items": { + "type": "object", + "title": "Tasks", + "headerTemplate": "{{ self.name }}", + "properties": { + "milestoneType": { + "type": "string", + "title": "Task Type", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ] + }, + "name": { + "type": "string", + "title": "Name" + }, + "description": { + "type": "string", + "title": "Description" + }, + "to": { + "type": "string", + "title": "Date from", + "format": "date", + "default": "YYYY-MM-DD" + }, + "from": { + "type": "string", + "title": "Date to", + "format": "date", + "default": "YYYY-MM-DD" + }, + "estimated": { + "type": "string", + "title": "Estimated Date", + "format": "date", + "default": "YYYY-MM-DD" + }, + "modified": { + "type": "string", + "title": "Date Modified", + "format": "date", + "default": "YYYY-MM-DDT12:00:00.000Z" + }, + "contactId": { + "type": "string", + "title": "Point of Contact", + "description": "Name@email.gov for person @email.gov for org" + }, + "pause": { + "type": "boolean", + "title": "Pause", + "format": "checkbox", + "default": "false", + "description": "Is the task out of your control/responsibility" + }, + "isPublic": { + "type": "boolean", + "title": "Public", + "format": "checkbox", + "default": "true", + "description": "Is the task publically viewable" + } + } + } + } + } + } + }, + "media": { + "type": "array", + "format": "table", + "title": "Media", + "description": "Project Websites, Social Media, Feeds, Images", + "uniqueItems": true, + "propertyOrder": 13, + "items": { + "type": "object", + "title": "Media", + "properties": { + "name": { + "type": "string", + "title": "Name" + }, + "url": { + "type": "string", + "title": "URL", + "description": "Link to Site or File" + }, + "mediaType": { + "type": "string", + "title": "Media Type", + "description": "File or Format", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ], + "default": "" + }, + "attribution": { + "type": "string", + "title": "Attribution", + "description": "Attribution Credits Rights" + } + } + } + }, + "resources": { + "type": "array", + "format": "tabs", + "title": "Resources", + "description": "Optional for Resources, Funds, Materials, Services for the Project", + "uniqueItems": true, + "propertyOrder": 14, + "items": { + "type": "object", + "title": "Resources", + "properties": { + "resourceType": { + "type": "string", + "title": "Resource Type", + "description": "List of Resources Categories", + "enum": [ + "options", + "provided", + "through", + "describedBy" + ], + "default": "" + }, + "email": { + "type": "string", + "title": "Email", + "description": "Use name@email.gov for responsible POC or @email.gov for organization" + }, + "portionOf": { + "type": "string", + "title": "Portion of", + "description": "$ or %" + }, + "ofTotal": { + "type": "string", + "title": "of Total", + "description": "$ or %" + }, + "description": { + "type": "string", + "title": "Description" + }, + "isPublic": { + "type": "boolean", + "title": "Public", + "format": "checkbox", + "default": "false", + "description": "Is the milestone publically viewable" + } + } + } + }, + "federalData": { + "type": "array", + "format": "table", + "title": "Federal Data", + "description": "Federal Data created or used by the project on Data.gov", + "uniqueItems": true, + "propertyOrder": 15, + "items": { + "type": "object", + "title": "Federal Data", + "properties": { + "uri": { + "type": "string", + "title": "URI to Data.gov", + "description": "Permenant Link to Dataset on Data.gov" + }, + "created": { + "type": "boolean", + "title": "Created", + "format": "checkbox", + "description": "Was data created from the Project" + } + } + } + }, + "data": { + "type": "array", + "format": "table", + "title": "Data", + "description": "Non-Federal Data created or used by the project", + "uniqueItems": true, + "propertyOrder": 16, + "items": { + "type": "object", + "title": "Data", + "properties": { + "name": { + "type": "string", + "title": "Name" + }, + "url": { + "type": "string", + "title": "URL" + }, + "license": { + "type": "string", + "title": "License", + "enum": [ + "Public Domain CC0", + "Creative Commons Share-alike", + "Other (use Attribution)" + ], + "default": "Public Domain CC0" + }, + "attribution": { + "type": "string", + "title": "Attribution", + "description": "Attribution Credits Rights" + }, + "created": { + "type": "boolean", + "title": "Created", + "format": "checkbox", + "default": "true", + "description": "Was the Data Created or Produced from the Project" + } + } + } + }, + "isPartof": { + "type": "array", + "format": "table", + "title": "Related Projects", + "description": "isPartof implies current project is a smaller/subset to a larger project or effort uses UUID", + "uniqueItems": true, + "propertyOrder": 17, + "items": { + "type": "object", + "title": "Parent Project UUID", + "properties": { + "parentUUID": { + "type": "string", + "title": "Parent UUID", + "description": "isPartof implies current project is a smaller/subset to a larger project or effort use Parent UUID or URI" + } + } + } + }, + "conformsTo": { + "title": "Federal Project Schema", + "description": "Human readable documentation on schema does not yet exist - only provided as an example", + "type": "string", + "propertyOrder": 18, + "default": "https://some.website/projects/1.0/schema" + }, + "describedBy": { + "title": "describedBy Schema", + "description": "Extended from Federal Project Schema but provides values for dropdowns and/or can extended to add additional fields", + "type": "string", + "propertyOrder": 19, + "default": "https://some.website/projects/category/v1.0/schema.json" + }, + "UUID": { + "title": "UUID", + "description": "UUID are Globally Unique ID used to ensure stablity in referencing and identification of Projects", + "type": "string", + "format": "uuid", + "propertyOrder": 20 + }, + "extended": { + "type": "array", + "format": "table", + "title": "Extended", + "description": "Custom Fields must be defined in describedBy Schema", + "uniqueItems": true, + "propertyOrder": 21, + "items": { + "type": "object", + "title": "Extended", + "properties": { + "additional": { + "type": "string", + "title": "Additional", + "description": "example 1" + }, + "fields": { + "type": "string", + "title": "Fields", + "description": "example 2" + } + } + } + } + } +} diff --git a/_schemas/resource.json b/_schemas/resource.json new file mode 100644 index 000000000..e69de29bb diff --git a/_schemas/site/datacollection.json b/_schemas/site/datacollection.json new file mode 100644 index 000000000..e69de29bb diff --git a/_schemas/site/glosary.json b/_schemas/site/glosary.json new file mode 100644 index 000000000..0f5dc331a --- /dev/null +++ b/_schemas/site/glosary.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://jsonschema.net", + "type": "object", + "properties": { + "section": { + "id": "http://jsonschema.net/section", + "type": "string", + "enum": [ + "terms" + ] + }, + "lang": { + "id": "http://jsonschema.net/lang", + "type": "string", + "description": "English (en) or Spanish (es)", + "enum": [ + "en", + "es" + ] + }, + "title": { + "id": "http://jsonschema.net/title", + "type": "string", + "description": "Title for the Glossary Term" + } + }, + "required": [ + "section", + "lang", + "title" + ] +} diff --git a/_schemas/site/impact.json b/_schemas/site/impact.json new file mode 100644 index 000000000..e69de29bb diff --git a/_schemas/site/solution.json b/_schemas/site/solution.json new file mode 100644 index 000000000..e69de29bb diff --git a/_schemas/site/topic.json b/_schemas/site/topic.json new file mode 100644 index 000000000..e69de29bb diff --git a/dist/datasourceeditor.js b/dist/datasourceeditor.js index 46e26ec68..e6a31fcb3 100644 --- a/dist/datasourceeditor.js +++ b/dist/datasourceeditor.js @@ -2,12 +2,11 @@ var schema={}; var catalog={}; var editor; - $(function() { var schemafile; - $.getJSON('catalog.json', afterSchemaLoad) - .fail(function(jqxhr, status, error) { - alert('Couldn\'t access schema file "catalog.json": \n' + error) + $.getJSON('project.json', afterSchemaLoad) + .fail(function(jqxhr, status, error) { + alert('Couldn\'t access schema file "project.json": \n' + error) }); $('.row .btn').on('click', function(e) { e.preventDefault(); @@ -18,27 +17,11 @@ $(function() { }); - -function afterSchemaLoad(json) { +function afterSchemaLoad(json) { // Initialize the editor schema = json; - JSONEditor.defaults.iconlibs.mybootstrap = JSONEditor.AbstractIconLib.extend({ - mapping: { - collapse: 'resize-small', - expand: 'resize-full', - "delete": 'remove', - edit: 'pencil', - add: 'plus', - cancel: 'floppy-remove', - save: 'floppy-saved', - moveup: 'arrow-up', - movedown: 'arrow-down' - }, - icon_prefix: 'glyphicon glyphicon-' - }); - - var alwaysname = { + var alwaysname = { compile: function() { return function (vars) { return vars.self.name; @@ -46,30 +29,29 @@ function afterSchemaLoad(json) { } }; - - editor = new JSONEditor(document.getElementById('editor_holder'),{ + editor = new JSONEditor(document.getElementById('editor'),{ // Enable fetching schemas via ajax ajax: true, keep_oneof_values: false, // See https://github.com/jdorn/json-editor/issues/398 - + // The schema for the editor schema: schema,//{ $ref: "schema2.json" }, //remove_empty_properties: true, //theme: "foundation5", theme: "bootstrap3", template: 'default',//alwaysname, // soooo much faster than the default template engine as long as we only use it for this. - iconlib: "mybootstrap", + iconlib: "mybootstrap", disable_edit_json: true }); editor.on('ready', function() { - $("#nm-jsons").show(); + $("#schemas-jsons").show(); }); - $("#jsonoutput").change(function() { + $("#output").change(function() { var t; try { - t = JSON.parse($("#jsonoutput").val()); + t = JSON.parse($("#output").val()); } catch (e) { alert("There's a syntax problem with your JSON code. \n\n" + e.message); return; @@ -99,20 +81,20 @@ function afterSchemaLoad(json) { var t0 = performance.now(); editor.setValue(t); console.log("Loaded in " + ((performance.now() - t0)/1000).toFixed(1) + " seconds."); - $("#editor_holder").show(); + $("#editor").show(); $("#loading").hide(); $("#savejson").show(); - $("#editor_holder")[0].scrollIntoView(); + $("#editor")[0].scrollIntoView(); }); - - // Hook up the validation indicator to update its + + // Hook up the validation indicator to update its // status whenever the editor changes editor.on('change',function() { // Get an array of errors from the validator var errors = editor.validate(); - + // Not valid if(errors.length) { // probably not an issue, validation errors are shown already. @@ -120,7 +102,7 @@ function afterSchemaLoad(json) { // console.log(JSON.stringify(errors,null,2)); } else { //if (!$("#loading").is(":visible")) - $("#jsonoutput").val(JSON.stringify(editor.getValue(), null, 2)); + $("#output").val(JSON.stringify(editor.getValue(), null, 2)); } }); @@ -131,31 +113,34 @@ function clickedExternalJson(e) { e.preventDefault(); var url; targetname = e.target.textContent.trim(); - // Need to go through Github API or else CORS issues. + // Need to go through Github API or else CORS issues. if ($(e.target).data("url")) { url = $(e.target).data("url"); - } else if (targetname=='test-special') { - url = 'https://gist.githubusercontent.com/stevage/08f89468f51822ade8d7/raw/ced603a2dd6c4dd8664751bc45915a45f493dcbf/gistfile1.json'; - } else if (targetname == 'ganew') { - url ='https://api.github.com/repos/NICTA/nationalmap/contents/wwwroot/init/ganew.json?ref=ga-datasource'; - } else if (targetname == 'aremi') { - url = 'https://api.github.com/repos/NICTA/aremi-natmap/contents/wwwroot/init/aremi.json'; - } else if (targetname == '(blank)') { - //url = 'https://gist.github.com/4092eda0d9b6a54ca839'; + } else if (targetname=='data') { + url = ''; + } else if (targetname == 'project') { + url =''; + } else if (targetname == 'impact') { + url = 'https://api.github.com/repos/JJediny/json-editor/contents/_schemas/site/impact.json'; + } else if (targetname == 'resource') { + url ='https://api.github.com/repos/JJediny/json-editor/contents/_schemas/site/resource.json'; + } else if (targetname == 'solution') { + url = 'https://api.github.com/repos/JJediny/json-editor/contents/_schemas/site/solution.json'; + } else if (targetname == 'topic') { + url = 'https://api.github.com/repos/JJediny/json-editor/contents/_schemas/site/impact.json'; + } else if (targetname == 'datacollection') { loadedFile({catalog:[]}); - //$("#jsonoutput").trigger("change"); return; } else { - url = 'https://api.github.com/repos/NICTA/nationalmap/contents/wwwroot/init/' + targetname + '.json'; + url = 'https://api.github.com/repos/JJediny/json-editor/contents/_schemas/' + targetname + '.json'; } $("#sourceurl").val(url); return; } -$("#nm-jsons li").click(clickedExternalJson); -$("#other-jsons li").click(clickedExternalJson); - +$("#hardcoded-jsons li").click(clickedExternalJson); +$("#schemas-json li").click(clickedExternalJson); //https://api.github.com/gists/08f89468f51822ade8d7 @@ -188,7 +173,7 @@ function loadURL(url) { success: loadedFile, error: function(e) { alert("Error " + e.status + ": " + e.statusText); } }); - $("#editor_holder").hide(); + $("#editor").hide(); $("#loadingmsg").html("

Loading datasource

Large files may take a very long time. Really."); $("#loading").show(); @@ -204,15 +189,15 @@ function loadedFile(t, status, request) { "or manually copy/paste the source file in."); } } - $("#jsonoutput").val(JSON.stringify(t,null,2)); - $("#jsonoutput").trigger("change"); + $("#output").val(JSON.stringify(t,null,2)); + $("#output").trigger("change"); return; - + } -// Use the list of data sources in the National Map Github repo to make a list of clickable targets. +// Use the list of data sources in the Github repo to make a list of clickable targets. function populateSources() { - var appendtarget = "#nm-jsons"; + var appendtarget = "#schemas-json"; function loadDataSourceList(url) { $.ajax({ @@ -228,41 +213,38 @@ function populateSources() { function loadedList(j) { j.forEach(function(e) { if (e.url.match(/\.json/)) { - //https://rawgit.com/NICTA/nationalmap/6756f1a1304722b27ff2553a2eb64bfed9dcf212/datasources/000_settings.json - // html_url: https://github.com/NICTA/nationalmap/blob/master/datasources/000_settings.json - // use rawgit to save Github requests - // thought we could use the sha, but it's not the right sha? - var url = 'https://rawgit.com/NICTA/nationalmap/master' + '/' + e.path; + //Uses Github API to read json files in a directory + var url = 'https://api.github.com/repos/jjediny/json-editor/_schemas' + '/' + e.path; $(appendtarget).append($( "
  • " + + ">" + e.name.replace('.json','') .replace(/^\d\d_/, '') .replace(/^\d\d_/, '') // catch 00_01_names .replace(/_/g, ' ') .replace('000 settings', 'General settings') + "" + - (e.name.match('00_National_Data_Sets') ? ' ' : '') + + (e.name.match('site') ? ' ' : '') + "
  • " )); } }); - $("#nm-jsons li").click(clickedExternalJson); + $("#schemas-json li").click(clickedExternalJson); console.log(j); - if (appendtarget === "#nm-jsons") { - $(appendtarget).append('
  • National Data Sets
  • '); - appendtarget='#nm-jsons-national'; - loadDataSourceList('https://api.github.com/repos/NICTA/nationalmap/contents/datasources/00_National_Data_Sets'); + if (appendtarget === "#schemas-json") { + $(appendtarget).append('
  • Forms
  • '); + appendtarget='#schemas-json'; + loadDataSourceList('https://api.github.com/repos/JJediny/json-editor/contents/_schemas/json'); } }; - $("#nm-jsons").html(""); + $("#schemas-json").html(""); - var source = 'https://api.github.com/repos/NICTA/nationalmap/contents/datasources'; + var source = 'https://api.github.com/repos/JJediny/json-editor/contents/_schemas/json'; // for testing, to reduce wasting Github API calls - if (false) { source = 'https://gist.githubusercontent.com/stevage/d2aef2fddd7e24e305e5/raw/gistfile1.txt'; } + if (false) { source = ''; } loadDataSourceList(source); } @@ -270,18 +252,16 @@ function populateSources() { $("#savejson").click(function(e) { function savedGist(j) { var raw_url = j.files[Object.keys(j.files)[0]].raw_url; - var cleanpreviewurl = 'http://nationalmap.research.nicta.com/#clean&' + encodeURIComponent(raw_url); - var previewurl = 'http://nationalmap.research.nicta.com/#' + encodeURIComponent(raw_url); - $("#loadingmsg").html('

    Saved!

    ' + - '

    Preview your changes in National Map

    ' + - '

    If you\'re happy with your changes, you can: ' + - '