diff --git a/src/components/elements/MissingConfigurationElement.js b/src/components/elements/MissingConfigurationElement.js new file mode 100644 index 0000000..9dad1dc --- /dev/null +++ b/src/components/elements/MissingConfigurationElement.js @@ -0,0 +1,27 @@ +function MissingConfigurationElement() { + return ` +
+
+ Configuration.example.yml
+
+
+
+ Configuration.yml
+
+
- Gravity was unable to fetch your configuration file because it was either missing, corrupt, blocked or unavailable. -
-- Welcome to gravity - ! -
-Let's start configurating gravity to your needs and get you up and running in no time.
- - -
- Head over to your configuration/
directory and copy (or rename) the example configuration file
- and adjust it to your liking.
-
-
- Configuration.example.yml
-
-
-
- Configuration.yml
-
-
- Save/push your changes and refresh this page! - If you did everything correctly, your blog should be up and running. -
- ` -} \ No newline at end of file diff --git a/src/configuration/FetchConfiguration.js b/src/configuration/FetchConfiguration.js index 156ca3b..1fbba70 100644 --- a/src/configuration/FetchConfiguration.js +++ b/src/configuration/FetchConfiguration.js @@ -1,9 +1,7 @@ +let ConfigurationURL = "./configuration/Configuration.yml" + async function FetchConfiguration() { var xhr = new XMLHttpRequest() - let ConfigurationURL = "./configuration/Configuration.yml" - if(window.location.hostname == "gravity.prpl.wtf") { - ConfigurationURL = "./configuration/Configuration.example.yml" - } xhr.open("GET", ConfigurationURL, true) xhr.onreadystatechange = async function () { if (xhr.readyState == 4 && xhr.status == 200) { @@ -13,9 +11,18 @@ async function FetchConfiguration() { return; } if (xhr.readyState == 4 && xhr.status == 404) { - window.Configuration = false - await RenderConfiguration() - return console.error("Configuration.yml could not be found!") + if(ConfigurationURL != "./configuration/Configuration.example.yml") { + ProgressBar(99.99, 5) + App.innerHTML = `${MissingConfigurationElement()}` + setTimeout(() => { + ProgressBar(100) + ConfigurationURL = "./configuration/Configuration.example.yml" + FetchConfiguration() + }, 5000); + } else { + await RenderConfiguration() + return console.error("Configuration.yml could not be found!") + } } } xhr.send() diff --git a/src/imports/ImportElements.js b/src/imports/ImportElements.js index 36f9682..619f81a 100644 --- a/src/imports/ImportElements.js +++ b/src/imports/ImportElements.js @@ -4,6 +4,7 @@ async function ImportElements() { { Identifier: "FooterElement", Path: "FooterElement.js" }, { Identifier: "LinkElement", Path: "LinkElement.js" }, { Identifier: "ConnectionElement", Path: "ConnectionElement.js" }, + { Identifier: "MissingConfigurationElement", Path: "MissingConfigurationElement.js" }, ] for (let i = Elements.length - 1; i >= 0; i--) { diff --git a/src/router/ProgressBar.js b/src/router/ProgressBar.js index 2f2c5b3..52780a7 100644 --- a/src/router/ProgressBar.js +++ b/src/router/ProgressBar.js @@ -1,6 +1,6 @@ var IsAnimating = false -function ProgressBar(length) { +function ProgressBar(length, duration) { if(IsAnimating) return; ProgressBarElement.style.opacity = 1 @@ -19,6 +19,7 @@ function ProgressBar(length) { return; } - ProgressBarElement.style.width = length+"%" + ProgressBarElement.style = `width: ${length}%; --TransitionWidthDuration: ${duration || 0.4}s;` + IsAnimating = false } \ No newline at end of file diff --git a/src/router/Route.js b/src/router/Route.js index 12f979a..97f8d7f 100644 --- a/src/router/Route.js +++ b/src/router/Route.js @@ -1,6 +1,4 @@ function Route(view) { - if(!window.Configuration) {view = "#welcome"} - if(window.Configuration && view == "#welcome") {view = "#"} window.location.hash = view Unload("Section") ProgressBar(25) @@ -30,14 +28,6 @@ function Route(view) { }) } - // #welcome - if(view == "#welcome") { - return Import("./src/components/sections/WelcomeSection.js", "Section", function() { - App.innerHTML = `${WelcomeSection()}` - ProgressBar(100) - }) - } - ProgressBar(100) return App.innerHTML = `An unknown error occured, check your browser console for more information.` }