Skip to content

Commit

Permalink
always show code snippets. closes #113
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed Sep 19, 2024
1 parent 79cfcfb commit dc1ade8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
32 changes: 21 additions & 11 deletions src/components/CodeSnippet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,40 @@ export default {
`api = gemmapy.GemmaPy()\n` +
`data = api.get_all_pages(api.get_datasets,`);
queryGemmapy.push(`)\n`)
} else {
queryGemmapy.push(`import gemmapy\n` +
`api = gemmapy.GemmaPy()\n` +
`data = api.get_all_pages(api.get_datasets)`
)
}
tabs[0].content = queryGemmapy.join("");
// Gemma.R snippet
let queryGemmaR = [];
if (query !== undefined) {
queryGemmaR.push(`BiocManager::install("gemma.R")\n` +
`library(gemma.R)\n`+
`library(dplyr)\n` +
`data <- get_datasets(`);
if (query !== undefined){
queryGemmaR.push(`query = ${this.escapeRString(query)}`);
}
if (filter !== undefined && filter.length > 0) {
if (queryGemmaR.length > 0) {
if (queryGemmaR.length > 1){
queryGemmaR.push(`, `);
}
queryGemmaR.push(`filter = ${this.escapeRString(filter)}`);
}
if (queryGemmaR.length > 0) {
if (sort !== undefined) {
queryGemmaR.push(`, sort = ${this.escapeRString(sort)}`);
if (sort !== undefined){
if (queryGemmaR.length > 1){
queryGemmaR.push(`, `);
}
queryGemmaR.unshift(`BiocManager::install("gemma.R")\n` +
`library(gemma.R)\n` +
`library(dplyr)\n` +
`data <- get_datasets(`);
queryGemmaR.push(`) %>% \n` +
`\tgemma.R:::get_all_pages()`);
queryGemmaR.push(`sort = ${this.escapeRString(sort)}`)
}
queryGemmaR.push(`) %>% \n` +
`\tgemma.R:::get_all_pages()`);
tabs[1].content = queryGemmaR.join("");
// curl snippet
Expand All @@ -181,6 +190,7 @@ export default {
const parsedBaseUrl = new URL(this.compressedUrl);
tabs[3].content = `GET ${parsedBaseUrl.pathname}${parsedBaseUrl.search} HTTP/1.1\nHost: ${parsedBaseUrl.hostname}\nAccept: application/json`;
return tabs;
}
},
Expand Down
3 changes: 1 addition & 2 deletions src/views/Browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@
Collapse all datasets
</v-btn>
<v-spacer/>
<v-menu v-if="browsingOptions.filter.length > 0 || searchSettings.query !== undefined && searchSettings.query !== ''"
ref="codeSnippetMenu">
<v-menu ref="codeSnippetMenu">
<template v-slot:activator="{ on, attrs }">
<v-btn plain v-on="on" v-bind="attrs">
<span style="text-transform: none;">Dataset download code</span>
Expand Down

0 comments on commit dc1ade8

Please sign in to comment.