Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert pipelines's internal links inside Git document pages to direct Github links #60

Merged
merged 1 commit into from
Sep 29, 2023
Merged
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: 12 additions & 6 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,20 @@ function return_json($response) {
exit();
}

function get_self_url($strip_query = true) {
// Build URL for this page
function get_url_protocol() {
if (((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'))
|| $_SERVER['HTTP_HOST'] === 'pipelines.tol.sanger.ac.uk'){
$self_url = 'https://';
} else {
$self_url = 'http://';
|| endsWith($_SERVER['HTTP_HOST'], 'tol.sanger.ac.uk') ){
$protocol = 'https://';
}else{
$protocol = 'http://';
}
return $protocol;
}

function get_self_url($strip_query = true) {
// Build URL for this page
$self_url = get_url_protocol();

if ($strip_query) {
$url = strtok($_SERVER['REQUEST_URI'], '?');
} else {
Expand Down
4 changes: 2 additions & 2 deletions includes/pipeline_page/_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
}
# Some other URL pattern that we don't recognise - 404
elseif ($_GET['path'] != $pipeline->name && $_GET['path'] != $pipeline->name . '/' . $release) {
$protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
$protocol = get_url_protocol();
$url_string = trim(str_replace($pipeline->name, '', $_GET['path']), '/');
$url_string = trim(str_replace($release, '', $url_string), '/');
header('HTTP/1.1 404 Not Found');
Expand Down Expand Up @@ -287,7 +287,7 @@

<div class="container-xxl main-content">

<ul class="nav nav-fill nfcore-subnav justify-content-start justify-content-md-around d-print-none">
<ul class="nav nav-fill nfcore-subnav justify-content-start justify-content-md-around d-print-none">
<li class="nav-item dropdown d-block d-lg-none" style="z-index:10000;">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<?php echo $subpage_names[$pagetab]; ?>
Expand Down
13 changes: 9 additions & 4 deletions includes/pipeline_page/docs_md.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@
}

# Configs to make relative URLs work
$href_url_prepend = '/' . $pipeline->name . '/' . $release . '/' . dirname($filename) . '/';
$href_url_prepend = '/' . $release . '/' . dirname($filename) . '/';
$href_url_prepend = preg_replace('/\/\/+/', '/', $href_url_prepend);
$src_url_prepend = 'https://raw.githubusercontent.com/nf-core' . $href_url_prepend;
$href_url_prepend = 'https://github.com/' . $pipeline->full_name . '/blob/' . $href_url_prepend;

$src_url_prepend = '/' . $pipeline->name . '/' . $release . '/' . dirname($filename) . '/';
$src_url_prepend= preg_replace('/\/\/+/', '/', $src_url_prepend);
$src_url_prepend = 'https://raw.githubusercontent.com/sanger-tol' . $src_url_prepend;

$href_url_suffix_cleanup = '\.md';

# Markdown cleanup
$md_content_replace[] = ['/# nf-core\/' . $pipeline->name . ': /', '# '];
$md_content_replace[] = ['/# sanger-tol\/' . $pipeline->name . ': /', '# '];
$md_content_replace[] = [
'/# !\[nf-core\/' . $pipeline->name . '\]\(images\/nf-core-' . $pipeline->name . '_logo.png\)/',
'/# !\[sanger-tol\/' . $pipeline->name . '\]\(images\/sanger-tol-' . $pipeline->name . '_logo.png\)/',
'',
];
$md_content_replace[] = ['/(## :warning:)(.*?)( files\._)/s', ''];
Expand Down
Loading