Skip to content

Commit

Permalink
make docs url dynamic based on (night/testing) version
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
  • Loading branch information
d00p committed May 12, 2024
1 parent 73182a6 commit cda0b31
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion customer_domains.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}

$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/domains/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/domains/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down
4 changes: 2 additions & 2 deletions customer_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}

$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/emails/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/emails/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down Expand Up @@ -139,7 +139,7 @@
];
}
$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/emails/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/emails/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down
6 changes: 3 additions & 3 deletions customer_extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
];

$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/extras/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/extras/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down Expand Up @@ -200,7 +200,7 @@
];

$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/extras/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/extras/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down Expand Up @@ -349,7 +349,7 @@

$actions_links = [
[
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/extras/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/extras/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down
2 changes: 1 addition & 1 deletion customer_ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
];
}
$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/ftp-accounts/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/ftp-accounts/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down
2 changes: 1 addition & 1 deletion customer_mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
}

$actions_links[] = [
'href' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/databases/',
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/databases/',
'target' => '_blank',
'icon' => 'fa-solid fa-circle-info',
'class' => 'btn-outline-secondary'
Expand Down
20 changes: 19 additions & 1 deletion lib/Froxlor/Froxlor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class Froxlor
// Distribution branding-tag (used for Debian etc.)
const BRANDING = '';

const DOCS_URL = 'https://docs.froxlor.org/v2.2/';
const DOCS_URL = 'https://docs.froxlor.org';

/**
* return path to where froxlor is installed, e.g.
Expand All @@ -52,6 +52,14 @@ public static function getInstallDir(): string
return dirname(__DIR__, 2) . '/';
}

public static function getDocsUrl(): string
{
if (preg_match('/(.+)-(dev|beta|rc)\d+$/', self::VERSION)) {
return self::DOCS_URL . '/dev/';
}
return self::DOCS_URL . '/v' . self::getShortVersion() . '/';
}

/**
* return basic version
*
Expand All @@ -62,6 +70,16 @@ public static function getVersion(): string
return self::VERSION;
}

/**
* return short basic version
*
* @return string
*/
public static function getShortVersion(): string
{
return explode(".", self::VERSION)[0] . '.' . explode(".", self::VERSION)[1];
}

/**
* return version + branding and database-version
*
Expand Down
8 changes: 4 additions & 4 deletions lib/navigation/00.froxlor.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@
'show_element' => (!Settings::IsInList('panel.customer_hide_options', 'misc.documentation')),
'elements' => [
[
'url' => \Froxlor\Froxlor::DOCS_URL . 'user-guide/',
'url' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/',
'label' => lng('admin.userguide'),
'new_window' => true,
'is_external' => true,
],
[
'url' => \Froxlor\Froxlor::DOCS_URL . 'api-guide/',
'url' => \Froxlor\Froxlor::getDocsUrl() . 'api-guide/',
'label' => lng('admin.apiguide'),
'new_window' => true,
'show_element' => Settings::Get('api.enabled') == 1 && CurrentUser::getField('api_allowed') == 1,
Expand Down Expand Up @@ -348,13 +348,13 @@
'icon' => 'fa-solid fa-circle-info',
'elements' => [
[
'url' => \Froxlor\Froxlor::DOCS_URL . 'admin-guide/',
'url' => \Froxlor\Froxlor::getDocsUrl() . 'admin-guide/',
'label' => lng('admin.adminguide'),
'new_window' => true,
'is_external' => true,
],
[
'url' => \Froxlor\Froxlor::DOCS_URL . 'api-guide/',
'url' => \Froxlor\Froxlor::getDocsUrl() . 'api-guide/',
'label' => lng('admin.apiguide'),
'new_window' => true,
'show_element' => Settings::Get('api.enabled') == 1,
Expand Down

0 comments on commit cda0b31

Please sign in to comment.