Skip to content

Commit

Permalink
Merge pull request pyfa-org#2440 from pyfa-org/merge-gh-pages
Browse files Browse the repository at this point in the history
Merge gh pages
  • Loading branch information
blitzmann committed May 8, 2022
2 parents 893f9f8 + e43e7ba commit d9df495
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions gh_pages/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-midnight
104 changes: 104 additions & 0 deletions gh_pages/callback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>pyfa Authentication Proxy</title>
<style type="text/css">


body { width: 700px; margin: 150px auto; }
h1 { font-size: 40px; }
h2 { font-size: 32px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
#article { display: block; text-align: left; width: 650px; margin: 0 auto; }
.hidden { display:none; }
.success { color: #28a745; }
.error { color: #dc3545; }
textarea { width: 100%; height: 100px; }
hr { border-width: 1px 0 0 0; border-style: solid; border-color: #333; }
button { cursor: pointer; background-color: white; border: 1px solid #333; color: #333; padding: 8px 11px; text-align: center; text-decoration: none; display: inline-block; }
@media (prefers-color-scheme: dark) {
body { background-color: #333; color: white; }
textarea { width: 100%; height: 100px; background-color: #aaa;}
button { background-color: #333; border: 1px solid white; color: white; }
hr { border-color: white; }
}
</style>
</head>

<body>
<!-- Layout from Short Circuit's CREST login. Shout out! https://github.com/farshield/shortcircuit -->
<h1>pyfa</h1>
<div id="mode0" class="hidden">
<p id="mode0-msg">Processing request...</p>
<button id="showBtn" onClick="showCode()">Show Code</button>
</div>
<div id="mode1" class="hidden">
<p id="mode1-p">Please copy and paste the token below into pyfa.</p>
<textarea id="authCodeText" readonly></textarea>
</div>

</div>
<script>
debugger;
function showCode() {
var element = document.getElementById(`mode1`);
element.classList.remove("hidden");
element = document.getElementById(`showBtn`);
element.classList.add("hidden");
}

function httpPostAsync(url, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == XMLHttpRequest.DONE)
callback(xmlHttp);
}
xmlHttp.open("GET", url, true); // true for asynchronous
xmlHttp.send(null);
}

const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());
let stateInfo;
try {
stateInfo = JSON.parse(atob(params.state))
} catch (err) {
// something has happened and we cannot continue.
// todo: show a simple message and exit.
throw err;
}

// we always want to show the text box for manual.
var element = document.getElementById(`mode${stateInfo.mode}`);
element.classList.remove("hidden");

if (stateInfo.mode === 0) {
let p = document.getElementById(`mode1-p`);
p.prepend(document.createElement("hr"))
}
debugger;
document.getElementById(`authCodeText`).value = btoa(JSON.stringify(params))

if (stateInfo.mode == 0) { // auto / server mode
httpPostAsync(stateInfo.redirect + window.location.search, (req)=>{
debugger;
const msgDiv = document.getElementById(`mode0-msg`);
if (req.status === 200) {
msgDiv.innerHTML ="<span class='success'>Success!</span> You may close this window and return to the application.";
return;
} else if (req.status === 0){
msgDiv.innerHTML = "<span class='error'>Error!</span> Server response not received.<p><small>The local pyfa server may have timed out, or may not have started correctly.</small></p>";
} else if (req.status === 400){
msgDiv.innerHTML = `<span class='error'>Error!</span> <p><small>${req.responseText}</small></p>`
} else {
msgDiv.innerHTML = `<span class='error'>Error!</span> <p><small>There was an unknown error. Please report this to the pyfa issues page.</p><p><textarea readdonly>${req.responseText}</textarea></small></p>`
}
showCode()
// todo: bad request error when it's not an error itself, but rather
})
// todo: post message to local EVE server
}
</script>
</body>
</html>
37 changes: 37 additions & 0 deletions gh_pages/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Welcome to GitHub Pages

You can use the [editor on GitHub](https://github.com/pyfa-org/Pyfa/edit/gh-pages/index.md) to maintain and preview the content for your website in Markdown files.

Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.

### Markdown

Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for

```markdown
Syntax highlighted code block

# Header 1
## Header 2
### Header 3

- Bulleted
- List

1. Numbered
2. List

**Bold** and _Italic_ and `Code` text

[Link](url) and ![Image](src)
```

For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/).

### Jekyll Themes

Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/pyfa-org/Pyfa/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file.

### Support or Contact

Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out.

0 comments on commit d9df495

Please sign in to comment.