add per page scripts and styles

This commit is contained in:
Bruno Rybársky 2024-02-01 09:46:52 +01:00
parent 166ac751c8
commit 76a0568ee2
5 changed files with 65 additions and 32 deletions

@ -1,29 +0,0 @@
function login() {
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
// Assuming you use fetch API to send data to the server
fetch('https://home.adlerka.top/account', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'login',
email: email,
password: password
}),
})
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
document.getElementById("statusMessage").innerText = "Login successful!";
// Redirect or perform other actions after successful login
} else {
document.getElementById("statusMessage").innerText = "Login failed. Please check your credentials.";
}
})
.catch((error) => {
console.error('Error:', error);
});
}

@ -0,0 +1,29 @@
function login() {
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
// Assuming you use fetch API to send data to the server
fetch('https://home.adlerka.top/account', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'login',
email: email,
password: password
}),
})
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
document.getElementById("statusMessage").innerText = "Login successful!";
// Redirect or perform other actions after successful login
} else {
document.getElementById("statusMessage").innerText = "Login failed. Please check your credentials.";
}
})
.catch((error) => {
console.error('Error:', error);
});
}

@ -119,12 +119,45 @@ function getPage($page_name = null): array|false|string
$page_title = $page_name; $page_title = $page_name;
} }
$site_name = $routerRequest["subdomain"];
if(!empty($pageMetadata["parameters"]["page_style"])){
$style_location = $pageMetadata["parameters"]["page_style"];
}
else{
$style_location = "assets/styles/$site_name/$page_name.css";
}
if(file_exists($style_location)) {
$style_tag = $style_location;
}
else{
$style_tag = "";
}
if(!empty($pageMetadata["parameters"]["page_script"])){
$script_location = $pageMetadata["parameters"]["page_script"];
}
else{
$script_location = "assets/scripts/$site_name/$page_name.js";
}
if(file_exists($style_location)) {
$script_tag = $script_location;
}
else{
$script_tag = "";
}
$navpages = generateNavigation(); $navpages = generateNavigation();
$nav = str_replace("__NAV_PAGES__", $navpages, $nav); $nav = str_replace("__NAV_PAGES__", $navpages, $nav);
$out = $skeleton; $out = $skeleton;
$out = str_replace("__TEMPLATE__NAV__", $nav, $out); $out = str_replace("__TEMPLATE__NAV__", $nav, $out);
$out = str_replace("__TEMPLATE_PAGE_STYLE_TAG__", $style_tag, $out);
$out = str_replace("__TEMPLATE_PAGE_SCRIPT_TAG__", $script_tag, $out);
$out = str_replace("__TEMPLATE__PAGE__", $page, $out); $out = str_replace("__TEMPLATE__PAGE__", $page, $out);
return str_replace("__TEMPLATE_PAGE_TITLE__", $page_title, $out); return str_replace("__TEMPLATE_PAGE_TITLE__", $page_title, $out);
} }

@ -11,5 +11,3 @@
</form> </form>
<p id="statusMessage"></p> <p id="statusMessage"></p>
</div> </div>
<script src="assets/login-script.js"></script>

@ -6,6 +6,8 @@
<script src="https://kit.fontawesome.com/e9016e1de1.js" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/e9016e1de1.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.0.1/remixicon.min.css" integrity="sha512-dTsohxprpcruDm4sjU92K0/Gf1nTKVVskNHLOGMqxmokBSkfOAyCzYSB6+5Z9UlDafFRpy5xLhvpkOImeFbX6A==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.0.1/remixicon.min.css" integrity="sha512-dTsohxprpcruDm4sjU92K0/Gf1nTKVVskNHLOGMqxmokBSkfOAyCzYSB6+5Z9UlDafFRpy5xLhvpkOImeFbX6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="/assets/style.css"> <link rel="stylesheet" href="/assets/style.css">
__TEMPLATE_PAGE_STYLE_TAG__
__TEMPLATE_PAGE_SCRIPT_TAG__
<script async src="https://umami.brn.systems/script.js" data-website-id="95e93885-5c19-4cab-ba9b-2f746a316a2a"></script> <script async src="https://umami.brn.systems/script.js" data-website-id="95e93885-5c19-4cab-ba9b-2f746a316a2a"></script>
<title>Adlerka __TEMPLATE_PAGE_TITLE__</title> <title>Adlerka __TEMPLATE_PAGE_TITLE__</title>
</head> </head>