Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,24 @@ MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=test-key
AWS_SECRET_ACCESS_KEY=test-secret
AWS_DEFAULT_REGION=us-east-1
AWS_URL=https://s3.uni-jena.de
AWS_ENDPOINT=https://s3.uni-jena.de
AWS_BUCKET=test-bucket
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_DOWNLOADS_URL=https://coconut.s3.uni-jena.de/prod/downloads

COCONUT_PUBLIC_URL=https://coconut.naturalproducts.net
CM_PUBLIC_API=https://api.cheminf.studio/latest/
API_URL=https://api.cheminf.studio/latest/
EUROPEPMC_WS_API=https://www.ebi.ac.uk/europepmc/webservices/rest/search
CROSSREF_WS_API=https://api.crossref.org/works/
DATACITE_WS_API=https://api.datacite.org/dois/
PUBCHEM_API_BASE=https://pubchem.ncbi.nlm.nih.gov/rest/pug
NP_CLASSIFIER_URL=https://npclassifier.gnps2.org/classify
NFDI_OIDC_BASE_URL=https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect
GLOBALNAMES_API_URL=https://finder.globalnames.org/api/v1/find
OLS4_API_BASE=https://www.ebi.ac.uk/ols4/api
UI_AVATARS_URL=https://ui-avatars.com/api

PUSHER_APP_ID=
PUSHER_APP_KEY=
Expand Down
23 changes: 21 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,27 @@ MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_URL=https://s3.uni-jena.de
AWS_ENDPOINT=https://s3.uni-jena.de
AWS_BUCKET=coconut
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_DOWNLOADS_URL=https://coconut.s3.uni-jena.de/prod/downloads

COCONUT_PUBLIC_URL=https://coconut.naturalproducts.net

CM_PUBLIC_API=https://api.cheminf.studio/latest/
API_URL=https://api.cheminf.studio/latest/

EUROPEPMC_WS_API=https://www.ebi.ac.uk/europepmc/webservices/rest/search
CROSSREF_WS_API=https://api.crossref.org/works/
DATACITE_WS_API=https://api.datacite.org/dois/

PUBCHEM_API_BASE=https://pubchem.ncbi.nlm.nih.gov/rest/pug
NP_CLASSIFIER_URL=https://npclassifier.gnps2.org/classify
NFDI_OIDC_BASE_URL=https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect
GLOBALNAMES_API_URL=https://finder.globalnames.org/api/v1/find
OLS4_API_BASE=https://www.ebi.ac.uk/ols4/api
UI_AVATARS_URL=https://ui-avatars.com/api

PUSHER_APP_ID=
PUSHER_APP_KEY=
Expand Down
6 changes: 3 additions & 3 deletions SocialiteProviders/src/NFDIAAI/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ class Provider extends AbstractProvider
*/
protected function getAuthUrl($state)
{
return $this->buildAuthUrlFromBase('https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/auth', $state);
return $this->buildAuthUrlFromBase(config('services.regapp.oidc_base_url').'/auth', $state);
}

/**
* {@inheritdoc}
*/
protected function getTokenUrl()
{
return 'https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/token';
return config('services.regapp.oidc_base_url').'/token';
}

/**
* {@inheritdoc}
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get('https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/userinfo', [
$response = $this->getHttpClient()->get(config('services.regapp.oidc_base_url').'/userinfo', [
RequestOptions::HEADERS => [
'Authorization' => 'Bearer '.$token,
],
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Classify.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function handle()
$canonical_smiles = $mol->canonical_smiles;

// Build endpoints.
$apiUrl = 'https://npclassifier.gnps2.org/classify?smiles=';
$apiUrl = config('services.npclassifier.url').'?smiles=';
$endpoint = $apiUrl.urlencode($canonical_smiles);

// Log the start of processing for this molecule.
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/MapOrganismNamesToOGG.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()
{
parent::__construct();
$this->client = new Client([
'base_uri' => 'https://www.ebi.ac.uk/ols4/api/v2/',
'base_uri' => config('services.ols.base_url').'/v2/',
]);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ protected function getGNFMatches($name, $organism)
];

$client = new Client;
$url = 'https://finder.globalnames.org/api/v1/find';
$url = config('services.globalnames.url');

$response = $client->post($url, [
'json' => $data,
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Dashboard/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static function infolist(Schema $schema): Schema
->label('Collection Image')
->visibility('public')
->size(200)
->state(fn ($record) => $record->image ? 'https://s3.uni-jena.de/coconut/'.$record->image : null),
->state(fn ($record) => $record->image ? public_storage_url($record->image) : null),
]),
Section::make('Distribution')
->schema([
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Dashboard/Resources/OrganismResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected static function getGNFMatches($name, $organism)
];

$client = new Client;
$url = 'https://finder.globalnames.org/api/v1/find';
$url = config('services.globalnames.url');

$response = $client->post($url, [
'json' => $data,
Expand Down Expand Up @@ -228,7 +228,7 @@ protected static function updateOrganismModel($name, $iri, $organism = null, $ra
protected static function getOLSIRI($name, $rank)
{
$client = new Client([
'base_uri' => 'https://www.ebi.ac.uk/ols4/api/',
'base_uri' => config('services.ols.base_url').'/',
]);

try {
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Dashboard/Widgets/TopContributors.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getTopContributors(): array
$contributorData[] = [
'user' => $user,
'contribution_count' => $contributor->contribution_count,
'avatar_url' => $user->profile_photo_url ?? 'https://ui-avatars.com/api/?name='.urlencode($user->name).'&color=7F9CF5&background=EBF4FF',
'avatar_url' => $user->profile_photo_url ?? config('services.avatars.url').'?name='.urlencode($user->name).'&color=7F9CF5&background=EBF4FF',
];
}
}
Expand Down
24 changes: 24 additions & 0 deletions app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ function csp_nonce(): string
return app('csp-nonce');
}

/**
* Public base URL for objects on the configured S3/Ceph disk.
*/
function public_storage_url(?string $path = null): string
{
$base = rtrim((string) config('filesystems.disks.s3.url'), '/');

if ($path === null || $path === '') {
return $base;
}

return $base.'/'.ltrim($path, '/');
}

/**
* Public base URL for COCONUT release downloads on object storage.
*/
function public_downloads_url(string $path): string
{
$base = rtrim((string) config('filesystems.disks.s3.downloads_url'), '/');

return $base.'/'.ltrim($path, '/');
}

/**
* Get all curator users.
* This centralizes curator fetching logic that may change in the future.
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/ClassifyMoleculeAuto.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function handle(): void
$canonical_smiles = $this->molecule->canonical_smiles;

// Build endpoint
$apiUrl = 'https://npclassifier.gnps2.org/classify?smiles=';
$apiUrl = config('services.npclassifier.url').'?smiles=';
$endpoint = $apiUrl.urlencode($canonical_smiles);

// Fetch classification data from API
Expand Down
6 changes: 3 additions & 3 deletions app/Jobs/ImportPubChem.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private function throttledGet(string $url)

public function fetchIUPACNameFromPubChem()
{
$smilesURL = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/TXT?smiles='
$smilesURL = config('services.pubchem.base_url').'/compound/smiles/cids/TXT?smiles='
.urlencode($this->molecule->canonical_smiles);
$cidResponse = $this->throttledGet($smilesURL);

Expand All @@ -71,7 +71,7 @@ public function fetchIUPACNameFromPubChem()

if ($cid && trim($cid) != '0') {
$cid = trim(preg_replace('/\s+/', ' ', $cid));
$cidPropsURL = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'.$cid.'/json';
$cidPropsURL = config('services.pubchem.base_url').'/compound/cid/'.$cid.'/json';
$dataResponse = $this->throttledGet($cidPropsURL);

if (! $dataResponse->successful()) {
Expand Down Expand Up @@ -112,7 +112,7 @@ public function fetchSynonymsCASFromPubChem($cid)
{
if ($cid && trim($cid) != '0') {
$cid = trim(preg_replace('/\s+/', ' ', $cid));
$synonymsURL = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'.$cid.'/synonyms/txt';
$synonymsURL = config('services.pubchem.base_url').'/compound/cid/'.$cid.'/synonyms/txt';

$maxRetries = 3;
$backoffSeconds = 2;
Expand Down
6 changes: 3 additions & 3 deletions app/Jobs/ImportPubChemAuto.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function throttledGet(string $url)

public function fetchIUPACNameFromPubChem()
{
$smilesURL = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/TXT?smiles='.urlencode($this->molecule->canonical_smiles);
$smilesURL = config('services.pubchem.base_url').'/compound/smiles/cids/TXT?smiles='.urlencode($this->molecule->canonical_smiles);
$cidResponse = $this->throttledGet($smilesURL);

if (! $cidResponse->successful()) {
Expand All @@ -180,7 +180,7 @@ public function fetchIUPACNameFromPubChem()
$cid = $cidResponse->body();
if ($cid && trim($cid) != '0') {
$cid = trim(preg_replace('/\s+/', ' ', $cid));
$cidPropsURL = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'.$cid.'/json';
$cidPropsURL = config('services.pubchem.base_url').'/compound/cid/'.$cid.'/json';
$dataResponse = $this->throttledGet($cidPropsURL);

if (! $dataResponse->successful()) {
Expand Down Expand Up @@ -229,7 +229,7 @@ public function fetchSynonymsCASFromPubChem($cid)
{
if ($cid && trim($cid) != '0') {
$cid = trim(preg_replace('/\s+/', ' ', $cid));
$synonymsURL = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'.$cid.'/synonyms/txt';
$synonymsURL = config('services.pubchem.base_url').'/compound/cid/'.$cid.'/synonyms/txt';

$maxRetries = 3;
$backoffSeconds = 2;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/HasDOI.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function generateDOI($doiService)
if (! is_null($doi_host)) {
$identifier = $this->getIdentifier($this, 'identifier');
if ($this->doi == null) {
$url = 'https://coconut.naturalproducts.net/collections/'.$identifier;
$url = url('/collections/'.$identifier);
$attributes = $this->getMetadata();
$attributes['url'] = $url;
$doiResponse = $doiService->createDOI($identifier, $attributes);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Molecule.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function getSchema($type = 'bioschemas')
->email('info.coconut@uni-jena.de');

$coconut = Schema::Organization();
$coconut->url('https://coconut.naturalproducts.net/')
$coconut->url(url('/'))
->name('COCONUT - COlleCtion of Open Natural prodUcTs')
->contactPoint($contactPoint);

Expand Down
2 changes: 1 addition & 1 deletion app/Services/DOI/DataCite.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getDOI($doi)
public function createDOI($identifier, $metadata = [])
{
$doi = $this->prefix.'/'.Config::get('app.name').'.'.$identifier;
$url = 'https://coconut.naturalproducts.net/collections/'.$identifier;
$url = url('/collections/'.$identifier);
$suffix = Config::get('app.name').'.'.$identifier;
$attributes = [
'doi' => $this->prefix.'/'.Config::get('app.name').'.'.$identifier,
Expand Down
Loading
Loading