From 0b1dfeb010273c9dc2d9db24543c72ea17e9ac55 Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Thu, 28 Sep 2023 14:49:57 +0200 Subject: [PATCH] removed code for the old archive explorer website --- .github/workflows/buildWebsite.yml | 48 ------- website_generator/.Rbuildignore | 2 - website_generator/.gitignore | 68 --------- website_generator/DESCRIPTION | 22 --- website_generator/README.md | 10 -- .../create_landing_page_figure.R | 131 ------------------ website_generator/generate_source.R | 79 ----------- website_generator/package_page_template.Rmd | 111 --------------- website_generator/website_generator.Rproj | 17 --- website_generator/website_source/_site.yml | 19 --- website_generator/website_source/styles.css | 3 - 11 files changed, 510 deletions(-) delete mode 100644 .github/workflows/buildWebsite.yml delete mode 100644 website_generator/.Rbuildignore delete mode 100644 website_generator/.gitignore delete mode 100644 website_generator/DESCRIPTION delete mode 100644 website_generator/README.md delete mode 100644 website_generator/create_landing_page_figure.R delete mode 100644 website_generator/generate_source.R delete mode 100644 website_generator/package_page_template.Rmd delete mode 100644 website_generator/website_generator.Rproj delete mode 100644 website_generator/website_source/_site.yml delete mode 100644 website_generator/website_source/styles.css diff --git a/.github/workflows/buildWebsite.yml b/.github/workflows/buildWebsite.yml deleted file mode 100644 index 49bc6682..00000000 --- a/.github/workflows/buildWebsite.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: build website - -# Trigger the workflow when the validation action finished -on: - workflow_run: - workflows: ["trident validate"] - types: - - completed - branches: - - "master" - -jobs: - buildWebsite: - # only run if the validation was successful and if this was an event on the master branch - if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/master' }} - name: build repo website - runs-on: ubuntu-latest - - steps: - - - name: Clone repo - uses: actions/checkout@v3 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - with: - # Use the public version of RStudio package manager to serve binaries for Linux and Windows - use-public-rspm: true - - - name: Install Pandoc - uses: r-lib/actions/setup-pandoc@v2 - - - name: Install R depedencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - cache-version: 1 - working-directory: website_generator - - - name: Build website - run: | - cd website_generator - Rscript generate_source.R - - - name: Deploy website - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: website_generator/website_source/_site diff --git a/website_generator/.Rbuildignore b/website_generator/.Rbuildignore deleted file mode 100644 index 91114bf2..00000000 --- a/website_generator/.Rbuildignore +++ /dev/null @@ -1,2 +0,0 @@ -^.*\.Rproj$ -^\.Rproj\.user$ diff --git a/website_generator/.gitignore b/website_generator/.gitignore deleted file mode 100644 index cb68dd51..00000000 --- a/website_generator/.gitignore +++ /dev/null @@ -1,68 +0,0 @@ -/website_source/* -!/website_source/_site.yml -!/website_source/styles.css - -# History files -.Rhistory -.Rapp.history - -# Session Data files -.RData - -# User-specific files -.Ruserdata - -# Example code in package build process -*-Ex.R - -# Output files from R CMD build -/*.tar.gz - -# Output files from R CMD check -/*.Rcheck/ - -# RStudio files -.Rproj.user/ - -# produced vignettes -vignettes/*.html -vignettes/*.pdf - -# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 -.httr-oauth - -# knitr and R markdown default cache directories -*_cache/ -/cache/ - -# Temporary files created by R markdown -*.utf8.md -*.knit.md - -# R Environment Variables -.Renviron - -# data -data/ - -# plots -plots/ - -# tables -tables/ - -# schemata -schemata/*.png - -# singularity images -*.sif -stempdir/ - -# github access token -.github_pat - -# rendered stuff -*.pdf -*.html -*.log - diff --git a/website_generator/DESCRIPTION b/website_generator/DESCRIPTION deleted file mode 100644 index 04386406..00000000 --- a/website_generator/DESCRIPTION +++ /dev/null @@ -1,22 +0,0 @@ -Package: placeholder -Title: This is a placeholder. -Version: 0.0.1 -Depends: R (>= 4.1.0) -Imports: - cowplot, - dplyr, - DT, - ggplot2, - knitr, - leaflet, - magrittr, - purrr, - remotes, - rmarkdown, - rnaturalearth, - sf, - yaml, - janno -Remotes: - github::poseidon-framework/janno, - github::ropensci/rnaturalearth \ No newline at end of file diff --git a/website_generator/README.md b/website_generator/README.md deleted file mode 100644 index e56e637a..00000000 --- a/website_generator/README.md +++ /dev/null @@ -1,10 +0,0 @@ -This directory holds the code for the https://poseidon-framework.GitHub.io/published_data website. It works as follows: - -- If the [validation GitHub action](https://GitHub.com/poseidon-framework/published_data/blob/master/.GitHub/workflows/validation.yml) passes, then the [buildWebsite action](https://GitHub.com/poseidon-framework/published_data/blob/master/.GitHub/workflows/buildWebsite.yml) runs. -- This action installs R, pandoc and all dependencies necessary to render the website. The dependencies are listed in the minimal [DESCRIPTION file](DESCRIPTION) in this directory. -- The action also runs the [generate_source.R](generate_source.R) script. This script reads the .janno files and builds the building blocks of the website in the [website_source/](website_source) directory. -- As the website is an [Rmarkdown website](https://bookdown.org/yihui/rmarkdown/rmarkdown-site.html) we need .Rmd files for each package page. These are created from a template ([package_page_template.Rmd](package_page_template.Rmd)), where the name of each package can be filled in by generate_source.R. The index.Rmd file is built right in the script. Some other elements of the website are static and already in website_source/. All dynamic elements are ignored by Git. -- generate_source.R finally runs `rmarkdown::render_site` to transform the generated .Rmd files to .html files (and thus the website) in website_source/_site/. -- The buildWebsite GitHub action takes the content of _site/ and deploys it to the gh-pages branch, from where it is served as the website we know and love. - -For development/testing I suggest to open the RStudio project in this directory, make the desired changes in generate_source.R and package_page_template.Rmd and then run generate_source.R to render the website locally. Before pushing this to GitHub, remember to add new dependencies to the DESCRIPTION file. diff --git a/website_generator/create_landing_page_figure.R b/website_generator/create_landing_page_figure.R deleted file mode 100644 index 90662ea4..00000000 --- a/website_generator/create_landing_page_figure.R +++ /dev/null @@ -1,131 +0,0 @@ -# This script assumes that the total_janno object is in the global environment - -library(ggplot2) -library(magrittr) - -#### prepare input data #### - -poseidon_ancient <- total_janno %>% - dplyr::filter( - Date_Type %in% c("C14", "contextual") & - !is.na(Date_BC_AD_Median) & - !is.na(Latitude) & !is.na(Longitude) - ) #%>% - # janno::process_age() %>% - # dplyr::filter( - # !is.na(Date_BC_AD_Median_Derived) - # ) - -#### prepare spatial data objects #### - -world <- rnaturalearth::ne_countries(scale = "small", returnclass = "sf") -world_6933 <- sf::st_transform(world, 6933) %>% - sf::st_make_valid() %>% - sf::st_union() -extent_world_6933 <- world_6933 %>% - sf::st_bbox() %>% - sf::st_as_sfc() %>% - sf::st_segmentize(dfMaxLength = 10000) -world_grid_6933 <- sf::st_make_grid( - world_6933, - n = c(36,18), - what = 'polygons', - flat_topped = TRUE -) %>% sf::st_as_sf() %>% - dplyr::mutate( - area_id = seq_along(x) - ) %>% sf::st_segmentize(dfMaxLength = 10000) - -poseidon_sf_6933 <- poseidon_ancient %>% - sf::st_as_sf(coords = c('Longitude', 'Latitude'), crs = 4326) %>% - sf::st_transform(6933) - -#### perform counting in spatial bins #### - -inter_world <- function(x) { - x %>% sf::st_intersects(world_grid_6933, .) %>% lengths() -} - -world_with_count <- world_grid_6933 %>% - dplyr::mutate( - count = poseidon_sf_6933 %>% inter_world(), - ) %>% - dplyr::filter(count != 0) - - -#### create world plot #### - -p_map <- ggplot() + - geom_sf(data = extent_world_6933, fill = "#c2eeff", color = NA, alpha = 0.5) + - geom_sf(data = world_6933, fill = "white", color = NA) + - geom_sf( - data = world_with_count, - mapping = aes(fill = count), color = NA, size = 0.1 - ) + - geom_sf(data = world_6933, fill = NA, color = "black", cex = 0.2) + - geom_sf_text( - data = world_with_count, - mapping = aes(label = count), color = "white", size = 3.4 - ) + - coord_sf(expand = F, crs = "+proj=natearth") + - scale_fill_gradientn( - colours = c("darkgrey", "red"), - guide = "colorbar" - ) + - theme_minimal() + - theme( - legend.position = "bottom", - legend.background = element_blank(), - panel.grid.major = element_line(colour = "grey", size = 0.3), - axis.title = element_blank(), - plot.title = element_text(face = "bold", size = 14) - ) + - guides( - fill = guide_colorbar( - title = "Poseidon individuals count", - barwidth = 20, barheight = 1.5 - ) - ) + - ggtitle( - paste("Spatial and temporal distribution of ancient human individuals in the merged Poseidon dataset"), - paste0(Sys.Date(), ", this only counts ancient samples with dating and coordinates, World in Natural Earth projection") - ) - -#### - -p_hist <- poseidon_ancient %>% - dplyr::mutate( - age_cut = cut( - Date_BC_AD_Median, - breaks = c( - min(poseidon_ancient$Date_BC_AD_Median), - seq(-10000, 2000, 500) - ), - labels = c("< -10000", paste0("> ", seq(-10000, 1500, 500))), - include.lowest = T - ) - ) %>% - ggplot() + - geom_histogram( - aes(x = age_cut), - fill = "red", - color = "white", - stat = "count" - ) + - coord_flip() + - theme_minimal() + - theme( - axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1) - ) + - xlab("age [years calBC/AD]") - -p <- cowplot::plot_grid(p_map, p_hist, ncol = 2, rel_widths = c(0.82, 0.2)) - -ggsave( - "website_source/landing_page_figure.png", - plot = p, - device = "png", - scale = 2, - height = 3.6, - width = 7 -) diff --git a/website_generator/generate_source.R b/website_generator/generate_source.R deleted file mode 100644 index 5eeb8e00..00000000 --- a/website_generator/generate_source.R +++ /dev/null @@ -1,79 +0,0 @@ -library(magrittr) - -repo_path <- ".." - -#### janno input #### - -# read all janno files -total_janno <- janno::read_janno(repo_path, validate = F) - -# compile a useful overview table for all packages -janno_table <- total_janno %>% - dplyr::group_by(source_file) %>% - dplyr::summarise( - `# Inds` = dplyr::n(), - Package = dirname(unique(source_file)), - `# ancient` = (Date_Type %in% c("C14", "contextual")) %>% sum(na.rm = TRUE), - `# modern` = (Date_Type == "modern") %>% sum(na.rm = TRUE), - `Github` = paste0( - "[Github](https://github.com/poseidon-framework/published_data/tree/master/", - Package, ")" - ), - `Download` = paste0( - "[Download](http://c107-224.cloud.gwdg.de:3000/zip_file/", Package, ")" - ), - `View` = paste0("[View](", Package, ".html)") - ) %>% - dplyr::select(-source_file) - -pac_names <- janno_table$Package#[1:5] - -#### read bib data #### - -# find all .bib files -# bib_file_paths <- list.files("../.", pattern = ".bib", full.names = TRUE, recursive = TRUE) -# purrr::map(bib_file_paths, bibtex::read.bib) # this fails! - -#### prepare package-wise .Rmd files #### - -generate_Rmd <- function(x) { - out_path <- file.path("website_source", paste0(x, ".Rmd")) - template <- readLines("package_page_template.Rmd") - template_mod <- gsub("####package_name####", x, template) - writeLines(template_mod, con = out_path) -} -purrr::walk(pac_names, generate_Rmd) - -#### copy the .bib file for each package #### - -copy_bib <- function(x) { - pac_path <- file.path(repo_path, x) - bib_file <- list.files(pac_path, pattern = ".bib", full.names = TRUE) - if (length(bib_file) == 1) { - out_path <- file.path("website_source", paste0(x, ".bib")) - file.copy(bib_file, out_path) - } -} -purrr::walk(pac_names, copy_bib) - -#### render landing page figure #### - -source("create_landing_page_figure.R") - -#### create index.Rmd file #### - -write(c( - "---", - "title: Poseidon published data", - "---", - "", - '![](landing_page_figure.png "World map with all ancient, dated and located samples in the Poseidon repository")', - "", - knitr::kable(janno_table, format = "pipe") %>% as.character() - ), - file = file.path("website_source", "index.Rmd") -) - -#### render website from .Rmd files - -rmarkdown::render_site(input = "website_source") diff --git a/website_generator/package_page_template.Rmd b/website_generator/package_page_template.Rmd deleted file mode 100644 index 25c3f66b..00000000 --- a/website_generator/package_page_template.Rmd +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: ####package_name#### -editor_options: - chunk_output_type: console -bibliography: ####package_name####.bib -link-citations: false ---- - -```{r setup, include=FALSE} -knitr::opts_chunk$set( - echo = FALSE, - message = FALSE, - warning = FALSE -) -``` - -```{r dependencies} -library(magrittr) - -package_name <- "####package_name####" -package_path <- file.path("../..", package_name) -#package_path <- file.path("..", package_name) -# warning( -# "Package path: ", package_path, "\n", -# "Working dir: ", getwd() -# ) -``` - -```{r janno} -janno_file <- list.files(package_path, pattern = ".janno", full.names = TRUE) -janno <- janno::read_janno(janno_file, validate = F) -literature <- paste0("@", janno$Publication %>% unlist %>% unique, collapse = ", ") -``` - -```{r ymlfile} -poseidon_yml_file <- list.files(package_path, pattern = "POSEIDON.yml", full.names = TRUE) -poseidon_yml <- yaml::read_yaml(poseidon_yml_file) -``` - -*** - -**Package version:** `r poseidon_yml$packageVersion` (`r poseidon_yml$lastModified`), -**Poseidon version:** `r poseidon_yml$poseidonVersion` - -```{r changelog, results='asis'} -if (!is.null(poseidon_yml$changelogFile)) { - changelog_file <- file.path(package_path, poseidon_yml$changelogFile) - changelog <- readLines(changelog_file) - cat("**Changelog:**\n\n") - cat(paste("-", changelog), sep = "\n") -} -``` - -```{r} -contributors <- paste(purrr::map_chr( - poseidon_yml$contributor, function(x) { - paste0(x$name, " (", x$email, ")") - }), collapse = ", ") -``` - -**Contributors:** `r contributors` - -*** - -**Description:** `r poseidon_yml$description` - -**Literature:** `r literature` - -
- -*** - -```{r readme, results='asis'} -if (!is.null(poseidon_yml$readmeFile)) { - readme_file <- file.path(package_path, poseidon_yml$readmeFile) - readme <- readLines(readme_file) - cat("**README:**\n\n") - cat(readme, sep = "\n\n") - cat("\n\n***") -} -``` - -```{r map} -if (all(c("Longitude", "Latitude", "Poseidon_ID") %in% colnames(janno))) { - leaflet::leaflet( - janno, - width = "100%" - ) %>% - leaflet::addTiles( - urlTemplate = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" - ) %>% - leaflet::addMarkers( - lng = ~Longitude, - lat = ~Latitude, - popup = ~Poseidon_ID, - clusterOptions = leaflet::markerClusterOptions() - ) -} -``` - -```{r table} -DT::datatable( - janno[-1], - class = "compact", - filter = 'top', - options = list( - pageLength = 20, - scrollX = TRUE - ) -) -``` \ No newline at end of file diff --git a/website_generator/website_generator.Rproj b/website_generator/website_generator.Rproj deleted file mode 100644 index 21a4da08..00000000 --- a/website_generator/website_generator.Rproj +++ /dev/null @@ -1,17 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/website_generator/website_source/_site.yml b/website_generator/website_source/_site.yml deleted file mode 100644 index 69b0bfc6..00000000 --- a/website_generator/website_source/_site.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: "poseidon-published-data" -navbar: - title: "Poseidon published data repository" - left: - - text: "Package list" - icon: fa-list - href: index.html - - text: "Package repository" - icon: fa-github - href: https://github.com/poseidon-framework/published_data - - text: "Poseidon website" - icon: fa-globe - href: https://poseidon-framework.github.io -output: - html_document: - theme: spacelab - highlight: textmate - css: styles.css - diff --git a/website_generator/website_source/styles.css b/website_generator/website_source/styles.css deleted file mode 100644 index cdf802a3..00000000 --- a/website_generator/website_source/styles.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background-color: white; -}