Mercurial > repos > mingchen0919 > tripal_db_explorer
changeset 4:5ca75e914699 draft
tripal database resource summary tool
author | mingchen0919 |
---|---|
date | Sun, 18 Mar 2018 23:24:18 -0400 |
parents | ae644a724667 |
children | 5accedb3133e |
files | get_content_types.Rmd |
diffstat | 1 files changed, 44 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/get_content_types.Rmd Sun Mar 18 18:38:17 2018 -0400 +++ b/get_content_types.Rmd Sun Mar 18 23:24:18 2018 -0400 @@ -1,14 +1,20 @@ --- -title: 'HTML report title' +title: 'Tripal Database explorer' output: html_document: - number_sections: true - toc: true theme: cosmo highlight: tango - code_folding: hide --- +<style> +pre code, pre, code { + white-space: pre !important; + overflow-x: scroll !important; + word-break: keep-all !important; + word-wrap: initial !important; +} +</style> + ```{r setup, include=FALSE, warning=FALSE, message=FALSE} knitr::opts_chunk$set( echo = TRUE, @@ -17,11 +23,42 @@ ``` +# Database resources summary + ```{r echo=FALSE} tripal_content = fromJSON(opt$X_u) -``` - -```{r} DT::datatable(tripal_content$member) ``` + +```{r, results='asis', echo=FALSE} +for (i in 1:nrow(tripal_content$member)) { + content_type_url = tripal_content$member[i, '@id'] + content_type_label = tripal_content$member[i, 'label'] + content_type_json = fromJSON(content_type_url) + content_type_total_items = content_type_json$totalItems + if (content_type_total_items > 0) { + example_1st_item_id = content_type_json$member[1, '@id'] + example_1st_item_item_page = content_type_json$member[1, 'ItemPage'] + example_1st_item_content = toJSON(fromJSON(example_1st_item_id), pretty = TRUE) + } else { + example_1st_item_id = 'Not available' + example_1st_item_item_page = 'Not available' + example_1st_item_content = 'Not available' + } + cat('##', content_type_label, '\n') + cat('\n') + cat('* **Total items:**', content_type_total_items, '\n') + cat('* **Web service URL:**', content_type_json$`@id`, '\n') + cat('* **Example page:**', example_1st_item_item_page, '\n') + + ## display one example item in json format + cat('* **Example item in JSON:**\n\n') + cat('```json\n') + cat(example_1st_item_content) + cat('\n') + cat('```\n\n') +} +``` + +