Skip to content

Commit 2fdcdda

Browse files
authored
Merge pull request #10 from opencitations/fixing-html-meta-description-ramose
Fixing html tag (description)
2 parents 025cda0 + c5ca152 commit 2fdcdda

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

docker_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.4sync
1+
1.5.2sync

html-template/api.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<head>
66
<meta charset="UTF-8" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<meta name="description" content="Access open citation data and bibliographic metadata via REST API. Query Index and Meta endpoints using DOI, ORCID, PMID, OMID, ISBN, ISSN. Free access." />
89
<title>OpenCitations - API</title>
910
<!-- Bootstrap CSS -->
1011
<link href="/static/bootstrap-533/css/bootstrap.min.css" rel="stylesheet" />

src/api/index_v1.hf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#type api
33
#base https://api.opencitations.net/index
44
#title The unifying REST API for all the OpenCitations Indexes
5+
#html_meta_description Old Version of OpenCitations INDEX API
56
#description This document describe the REST API for accessing the data stored in all the [OpenCitations Indexes](https://w3id.org/oc/index) hosted by [OpenCitations](http://opencitations.net). This API implements operations to retrieve the citation data for all the references to other works appearing in a particular bibliographic entity, or the citation data for all the references appearing in other works to a particular bibliographic entity, given the DOI of a bibliographic entity, or to retrieve citation data about a particular citation identified by means of its [Open Citation Identifier (OCI)](https://opencitations.wordpress.com/2018/03/12/citations-as-first-class-data-entities-open-citation-identifiers/).
67

78
All the present operations return either a JSON document (default) or a CSV document according to the mimetype specified in the `Accept` header of the request. If you would like to suggest an additional operation to be included in this API, please use the [issue tracker](https://github.com/opencitations/api/issues) of the OpenCitations APIs available on GitHub.

src/api/index_v2.hf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#type api
33
#base https://api.opencitations.net/index
44
#title The REST API for OpenCitations Index
5+
#html_meta_description OpenCitations Index REST API: retrieve citation data, bibliographic references, citation counts using DOI, PMID, OMID identifiers. Free access.
56
#description This document describe the REST API for accessing the data stored in the [OpenCitations Index](https://w3id.org/oc/index) hosted by [OpenCitations](http://opencitations.net). This API implements operations to retrieve the citation data for all the references to other works appearing in a particular bibliographic entity, or the citation data for all the references appearing in other works to a particular bibliographic entity, given the identifier of a bibliographic entity, or to retrieve citation data about a particular citation identified by means of its [Open Citation Identifier (OCI)](https://opencitations.wordpress.com/2018/03/12/citations-as-first-class-data-entities-open-citation-identifiers/).
67

78
All the present operations return either a JSON document (default) or a CSV document according to the mimetype specified in the `Accept` header of the request. If you would like to suggest an additional operation to be included in this API, please use the [issue tracker](https://github.com/opencitations/api/issues) of the OpenCitations APIs available on GitHub.

src/api/meta_v1.hf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#type api
33
#base https://api.opencitations.net/meta
44
#title The REST API for OpenCitations Meta
5+
#html_meta_description OpenCitations Meta REST API: retrieve bibliographic metadata, authors, editors, venues using DOI, ORCID, PMID, OMID, ISBN, ISSN identifiers. Free access.
56
#description This is the REST API for OpenCitations Meta, the OpenCitations dataset containing bibliographic metadata associated with the documents involved in the citations stored in the OpenCitations Indexes. All the present operations return either a JSON document (default) or a CSV document according to the mimetype specified in the `Accept` header of the request. If you would like to suggest an additional operation to be included in this API, please use the [issue tracker](https://github.com/opencitations/api/issues) of the OpenCitations APIs available on GitHub.
67

78
If you are going to use the REST APIs within an application/code, we encourage you to get the [OpenCitations Access Token](https://opencitations.net/accesstoken) and specify it in the "authorization" header of your REST API call. Here is a usage example in Python:

src/ramose.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ def __title(self, conf):
143143
"""This method returns the title string defined in the API specification."""
144144
return conf["conf_json"][0]["title"]
145145

146+
def __htmlmetadescription(self, conf):
147+
"""This method returns the HTML meta-description string defined in the API specification."""
148+
return conf["conf_json"][0]["html_meta_description"]
149+
146150
def __sidebar(self, conf):
147151
"""This method builds the sidebar of the API documentation"""
148152
result = ""
@@ -724,7 +728,7 @@ def get_documentation(self, css_path=None, base_url=None):
724728
"""This method generates the HTML documentation of an API described in configuration file."""
725729
if base_url is None:
726730
first_key = next(iter(self.conf_doc))
727-
conf = self.conf_doc[first_key]
731+
conf = self.conf_doc[first_key]
728732
else:
729733
conf = self.conf_doc['/'+base_url]
730734

@@ -734,6 +738,7 @@ def get_documentation(self, css_path=None, base_url=None):
734738
<title>%s</title>
735739
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
736740
<meta name="viewport" content="width=device-width" />
741+
<meta name="description" content="%s"/>
737742
<style>%s</style>
738743
%s
739744
</head>
@@ -743,7 +748,16 @@ def get_documentation(self, css_path=None, base_url=None):
743748
<section id="operations">%s</section>
744749
<footer>%s</footer>
745750
</body>
746-
</html>""" % (self.__title(conf), self.__css(), self.__css_path(css_path), self.__sidebar(conf), self.__header(conf), self.__operations(conf), self.__footer())
751+
</html>""" % (
752+
self.__title(conf),
753+
self.__htmlmetadescription(conf),
754+
self.__css(),
755+
self.__css_path(css_path),
756+
self.__sidebar(conf),
757+
self.__header(conf),
758+
self.__operations(conf),
759+
self.__footer()
760+
)
747761

748762
def get_index(self, css_path=None):
749763
"""This method generates the index of all the HTML documentations that can be

0 commit comments

Comments
 (0)