Compare commits
2 commits
54fdba7207
...
802efbe286
Author | SHA1 | Date | |
---|---|---|---|
802efbe286 | |||
c1eb47c64e |
4 changed files with 134 additions and 9 deletions
|
@ -0,0 +1,42 @@
|
||||||
|
Node.prototype.gel = function (id) {
|
||||||
|
return this.getElementById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Node.prototype.gcn = function (classname) {
|
||||||
|
return this.getElementsByClassName(classname);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dgel(id) {
|
||||||
|
return document.getElementById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dgcn(classname) {
|
||||||
|
return document.getElementsByClassName(classname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronous function. Promises the text content of url. Automatically adds/removes from the loading counter.
|
||||||
|
* @param {string} url URL to request. Note that unless cross-domain is specifically permitted, this URL must come from the same domain as this file.
|
||||||
|
*/
|
||||||
|
async function ajax(url) { //must be called from an async function! use 'await', e.g. "var result = await ajax('https://google.com');"
|
||||||
|
return new Promise(resolve => {
|
||||||
|
var pageGetter = new XMLHttpRequest;
|
||||||
|
pageGetter.onreadystatechange = function () {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
resolve(this.responseText);
|
||||||
|
} else if (this.readyState == 4) {
|
||||||
|
resolve('Error: Expecting HTTP 200, got HTTP ' + this.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pageGetter.open('GET', url, true)
|
||||||
|
pageGetter.send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function cont() {
|
||||||
|
url = dgel('instance-input').value;
|
||||||
|
if (url.substr(0,8) != "https://") {
|
||||||
|
url = "https://" + url
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin: 5%;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #282c37;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
h1, h2 {
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 4em;
|
||||||
|
margin:0;
|
||||||
|
font-family:"Open Sans", sans-serif;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 2.5em;
|
||||||
|
font-family:"Open Sans", sans-serif;
|
||||||
|
}
|
||||||
|
#footer {
|
||||||
|
position:absolute;
|
||||||
|
bottom:5%;
|
||||||
|
width:90%;
|
||||||
|
}
|
||||||
|
#logo-main {
|
||||||
|
height:300px;
|
||||||
|
width:300px;
|
||||||
|
}
|
||||||
|
form {
|
||||||
|
background-color: #444b5d;
|
||||||
|
display:inline-block;
|
||||||
|
padding:50px;
|
||||||
|
border-radius:5px;
|
||||||
|
font-size:1.4em;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
margin:20px;
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
font-size:1em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color:#2b90d9;
|
||||||
|
border: 2px #2b90d9 solid;
|
||||||
|
background-color:transparent;
|
||||||
|
border-radius:2px;
|
||||||
|
padding:10px 25px;
|
||||||
|
transition:0.2s all ease-in;
|
||||||
|
}
|
||||||
|
button:hover{
|
||||||
|
background-color:#2b90d9;
|
||||||
|
color:white;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Curious Greg</title>
|
||||||
|
<link rel='stylesheet' type='text/css' href="{{ url_for('static', filename='style.css') }}" />
|
||||||
|
<script type="text/javascript" src="{{ url_for('static', filename='script.js') }}"></script>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Curious Greg</h1>
|
||||||
|
<h2>Connect your Curious Cat and Mastodon accounts for automated crossposting.</h2>
|
||||||
|
<!-- <div id='logo-main'></div> -->
|
||||||
|
<form onsubmit='cont(); return false'>
|
||||||
|
<label for='instance'>Instance URL</label><br />
|
||||||
|
<input name='instance' placeholder='mastodon.social' id='instance-input' /><br />
|
||||||
|
<button class='loading'>Continue</button>
|
||||||
|
</form>
|
||||||
|
<div id='footer'>
|
||||||
|
Note that Curious Greg requires first-party cookies to be enabled. You may safely delete the cookie upon completing the connection process.
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
26
web.py
26
web.py
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import requests, sqlite3, json
|
import requests, sqlite3, json
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
from flask import Flask
|
from flask import Flask, render_template
|
||||||
|
|
||||||
cfg = json.load(open("meta.json"))
|
cfg = json.load(open("meta.json"))
|
||||||
|
|
||||||
|
@ -20,15 +20,23 @@ app.secret_key = cfg['flask_key']
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def main():
|
def main():
|
||||||
return "test"
|
return render_template("landing_page.html")
|
||||||
|
|
||||||
@app.route('/internal/auth_a')
|
@app.route('/internal/auth_a')
|
||||||
def internal_auth_a():
|
def internal_auth_a():
|
||||||
client_id, client_secret = Mastodon.create_app(cfg['name'],
|
# client_id, client_secret = Mastodon.create_app(cfg['name'],
|
||||||
api_base_url=instance_url,
|
# api_base_url=instance_url,
|
||||||
scopes="write:statuses",
|
# scopes="write:statuses",
|
||||||
website="https://git.lynnesbian.space/lynnesbian/curious-greg")
|
# website=cfg['website'])
|
||||||
|
|
||||||
client = Mastodon(client_id = client_id,
|
client_id = "abc"
|
||||||
client_secret = client_secret,
|
client_secret = "123"
|
||||||
api_base_url=instance_url)
|
|
||||||
|
client_info = {
|
||||||
|
"client_id": client_id,
|
||||||
|
"client_secret":client_secret,
|
||||||
|
"scopes":"write:statuses",
|
||||||
|
"website": cfg['website']
|
||||||
|
}
|
||||||
|
|
||||||
|
return(json.dumps(client_info))
|
||||||
|
|
Loading…
Reference in a new issue