Browse Source

Bugfixes and more privacy options

tags/1.0.0
Leonie 5 months ago
parent
commit
fb56dd9c9d
9 changed files with 173 additions and 111 deletions
  1. +2
    -1
      .gitignore
  2. +1
    -15
      app/www/app.html
  3. +97
    -89
      app/www/app.js
  4. +2
    -1
      app/www/config.js
  5. +2
    -2
      app/www/index.html
  6. +10
    -2
      app/www/welcome.js
  7. +0
    -0
      authtokens/.keep
  8. +44
    -1
      backend.py
  9. +15
    -0
      mainview.html

+ 2
- 1
.gitignore View File

@@ -1 +1,2 @@
clientcred.secret
clientcred.secret
authtokens/*.secret

+ 1
- 15
app/www/app.html View File

@@ -29,21 +29,7 @@
</div>
</div>
<div id="view__main">
<h1 id="text__featured">Featured</h1>
<div id="section__featured">
</div>
<br /><h2 id="text__originals">Nordcast Originals</h3>
<div id="section__originals">
<p><img src="fake_data/4.jpg" class="card__smaller" /><img src="fake_data/5.jpg" class="card__smaller" /><img src="fake_data/6.jpg" class="card__smaller" /><img src="fake_data/7.jpg" class="card__smaller" /><img src="fake_data/8.jpg" class="card__smaller" /><img src="fake_data/4.jpg" class="card__smaller" /><img src="fake_data/5.jpg" class="card__smaller" /><img src="fake_data/6.jpg" class="card__smaller" /><img src="fake_data/7.jpg" class="card__smaller" /><img src="fake_data/8.jpg" class="card__smaller" /></p>
</div>
<br /><h3 id="text__trending">New and hot</h3>
<div id="section__trending">
<p><img src="fake_data/4.jpg" class="card__small" /><img src="fake_data/5.jpg" class="card__small" /><img src="fake_data/6.jpg" class="card__small" /><img src="fake_data/7.jpg" class="card__small" /><img src="fake_data/8.jpg" class="card__small" /><img src="fake_data/4.jpg" class="card__small" /><img src="fake_data/5.jpg" class="card__small" /><img src="fake_data/6.jpg" class="card__small" /><img src="fake_data/7.jpg" class="card__small" /><img src="fake_data/8.jpg" class="card__small" /></p>
</div>
<br /><h3 id="text__list">Your list</h3>
<div id="section__list">
</div>
</div>
<div id="view__settings">
<h1>Settings</h1><br />

+ 97
- 89
app/www/app.js View File

@@ -1,4 +1,3 @@
document.addEventListener("deviceready", onDeviceReady, false);
$(document).ready(function() {
$("#view__main").css("padding-top", "90px");
var searchtoggle = false;
@@ -12,103 +11,112 @@ $(document).ready(function() {
$("#view__main").show();
$("#nav").show();
}, 2000);
window.setInterval(function() {
$.get(backend+"/api/v1/login2/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid"), function(data) {
if (data["login"] !== "ok" && data["uuid"] !== localStorage.getItem("uuid")) {
localStorage.clear();
window.setTimeout(function() {
location.href = "index.html";
}, 200);
}
}).error(function() {
localStorage.clear();
$.get(backend+"/api/v1/getmainview/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid"), function(data) {
$("#view__main").html(data);
});
window.setTimeout(function() {
if (debug === false) {
window.setInterval(function() {
console.log("Connection to koyu.space");
$.get(backend+"/api/v1/login2/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid"), function(data) {
if (data["login"] !== "ok" && data["uuid"] !== localStorage.getItem("uuid")) {
localStorage.clear();
window.setTimeout(function() {
location.href = "index.html";
}, 200);
}
}).error(function() {
localStorage.clear();
window.setTimeout(function() {
location.href = "index.html";
}, 200);
});
}, 1000);
}
$("#logout").click(function() {
localStorage.clear()
window.setTimeout(function() {
location.href = "index.html";
}, 200);
});
}, 1000);
$("#logout").click(function() {
localStorage.clear()
window.setTimeout(function() {
location.href = "index.html";
}, 200);
});
if (localStorage.getItem("podlist") === null) {
$("#section__list").html("<p style=\"text-align:center;\">Es befinden sich keine Podcasts in deiner Liste.</p>")
} else {
$("#section__list").html($("#section__list").html()+"<p>");
localStorage.getItem("podlist").split(",").forEach(function(feed) {
$.get(backend+"/api/v1/getpodcast?q="+feed, function(callback) {
$("#section__list").html($("#section__list").html()+"<img src=\""+callback.feed.image.href+"\" class=\"card__small\" />")
if (localStorage.getItem("podlist") === null) {
$("#section__list").html("<p style=\"text-align:center;\">Es befinden sich keine Podcasts in deiner Liste.</p>")
} else {
$("#section__list").html($("#section__list").html()+"<p>");
localStorage.getItem("podlist").split(",").forEach(function(feed) {
$.get(backend+"/api/v1/getpodcast?q="+feed, function(callback) {
$("#section__list").html($("#section__list").html()+"<img src=\""+callback.feed.image.href+"\" class=\"card__small\" />")
});
});
});
$("#section__list").html($("#section__list").html()+"</p>");
}
$("#section__featured").html();
$("#section__featured").html($("#section__featured").html()+"<div><img src=\""+backend+"/api/v1/getbanner/1\" class=\"card__big\" /></div>");
$("#section__featured").html($("#section__featured").html()+"<div><img src=\""+backend+"/api/v1/getbanner/2\" class=\"card__big\" /></div>");
$("#section__featured").html($("#section__featured").html()+"<div><img src=\""+backend+"/api/v1/getbanner/3\" class=\"card__big\" /></div>");

$(".card__big").primaryColor({
callback: function(color) {
$(this).css('box-shadow', '0px 0px 13px 2px rgba('+color+',0.75)');
$("#section__list").html($("#section__list").html()+"</p>");
}
});
$(".fa__nav2").click(function() {
if (searchtoggle === false) {
$("#wrapper__search").show();
searchtoggle = true;
$("#view__main").css("padding-top", "150px");
} else {
$("#section__featured").html();
$("#section__featured").html($("#section__featured").html()+"<div><img src=\""+backend+"/api/v1/getbanner/1\" class=\"card__big\" /></div>");
$("#section__featured").html($("#section__featured").html()+"<div><img src=\""+backend+"/api/v1/getbanner/2\" class=\"card__big\" /></div>");
$("#section__featured").html($("#section__featured").html()+"<div><img src=\""+backend+"/api/v1/getbanner/3\" class=\"card__big\" /></div>");

$(".card__big").primaryColor({
callback: function(color) {
$(this).css('box-shadow', '0px 0px 13px 2px rgba('+color+',0.75)');
}
});
$(".fa__nav2").click(function() {
if (searchtoggle === false) {
$("#wrapper__search").show();
searchtoggle = true;
$("#view__main").css("padding-top", "150px");
} else {
$("#wrapper__search").hide();
searchtoggle = false;
$("#view__main").css("padding-top", "90px");
}
});
$(".fa__nav").click(function() {
$("#view__main").hide();
$(".fa__nav").hide();
$(".fa__nav2").hide();
$("#wrapper__search").hide();
searchtoggle = false;
$("#view__main").css("padding-top", "90px");
}
});
$(".fa__nav").click(function() {
$("#view__main").hide();
$(".fa__nav").hide();
$(".fa__nav2").hide();
$("#wrapper__search").hide();
$("#view__main").css("padding-top", "90px");
searchtoggle = false;
$("#view__settings").show();
});
$("#logo__nav").click(function() {
$("#view__main").show();
$(".fa__nav").show();
$(".fa__nav2").show();
$("#view__settings").hide();
});
$("#qq").keyup(function() {
$.getJSON("https://searchapi.koyu.space/" + $("#qq").val(), function(data) {
$("#qq").autocomplete({
source: data[1],
select: function() {
setTimeout(function() {
$("#submit").click();
}, 50);
}
searchtoggle = false;
$("#view__settings").show();
});
$("#logo__nav").click(function() {
$("#view__main").show();
$(".fa__nav").show();
$(".fa__nav2").show();
$("#view__settings").hide();
});
$("#qq").keyup(function() {
$.getJSON("https://searchapi.koyu.space/" + $("#qq").val(), function(data) {
$("#qq").autocomplete({
source: data[1],
select: function() {
setTimeout(function() {
$("#submit").click();
}, 50);
}
});
});
});
});
});

//Cordova-specific code
function onDeviceReady() {
if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString("#fff");
}
navigator.globalization.getPreferredLanguage(function (language) {
//German
if (language.value.includes("de")) {
$("#text__featured").html("Angesagt");
$("#text__trending").html("Neu und beliebt");
$("#text__list").html("Deine Liste");
$("#logout").html("Abmelden");
$("#view__settings h1").html("Einstellungen");
$("#qq").attr("placeholder", "Suchbegriff");
document.addEventListener("deviceready", onDeviceReady, false);
//Cordova-specific code
function onDeviceReady() {
if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString("#fff");
}
navigator.globalization.getPreferredLanguage(function (language) {
//German
if (language.value.includes("de")) {
$("#text__featured").html("Angesagt");
$("#text__trending").html("Neu und beliebt");
$("#text__list").html("Deine Liste");
$("#logout").html("Abmelden");
$("#view__settings h1").html("Einstellungen");
$("#qq").attr("placeholder", "Suchbegriff");
}
});
}
});
}
}, 800);
});

+ 2
- 1
app/www/config.js View File

@@ -1 +1,2 @@
var backend = "http://192.168.178.95:9000";
var backend = "http://192.168.178.95:9000";
var debug = true;

+ 2
- 2
app/www/index.html View File

@@ -22,10 +22,10 @@
<div id="view__welcome">
<h1>Willkommen bei Nordcast</h1>
<p>Bitte melde dich mit deinem koyu.space-Account an. Solltest du noch keinen Account haben, kannst du dir <a href="#" onclick="window.open('https://koyu.space/auth/sign_up', '_system'); return false;">hier</a> einen machen.</p>
<p><input type="text" id="username" placeholder="E-Mailadresse"></p>
<p><input type="email" id="username" placeholder="E-Mailadresse"></p>
<p><input type="password" id="password" placeholder="Passwort"></p>
<p><button class="btn btn-primary" id="kslogin" style="width: 80%;">Anmelden</button></p>
<div id="welcome__error"></div>
<div id="welcome__error"><p><b style="color:red;">Your username and/or password is wrong.</b></p></div>
</div>
</body>
</html>

+ 10
- 2
app/www/welcome.js View File

@@ -1,5 +1,6 @@
document.addEventListener("deviceready", onDeviceReady, false);
$(document).ready(function() {
$("#welcome__error").hide();
$("#view__welcome").hide();
$("#nav").hide();
window.setTimeout(function() {
@@ -11,6 +12,7 @@ $(document).ready(function() {
location.href = "app.html";
}
$("#kslogin").click(function() {
$("#welcome__error").hide();
$("#kslogin").attr("disabled", "");
var oldHTML = $("#kslogin").html();
$("#kslogin").html("<i class=\"fas fa-sync-alt fa-spin\"></i> "+$("#kslogin").html());
@@ -25,12 +27,12 @@ $(document).ready(function() {
} else {
$("#kslogin").removeAttr("disabled");
$("#kslogin").html(oldHTML);
$("#welcome__error").html("<p><b style=\"color:red;\">Der Benutzername und/oder das Passwort ist falsch.</b></p>");
$("#welcome__error").show();
}
}).error(function() {
$("#kslogin").removeAttr("disabled");
$("#kslogin").html(oldHTML);
$("#welcome__error").html("<p><b style=\"color:red;\">Der Benutzername und/oder das Passwort ist falsch.</b></p>");
$("#welcome__error").show();
});
}, 1000)
});
@@ -41,4 +43,10 @@ function onDeviceReady() {
if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString("#fff");
}
navigator.globalization.getPreferredLanguage(function (language) {
//German
if (language.value.includes("de")) {
$("#welcome__error").html("<p><b style=\"color:red;\">Der Benutzername und/oder das Passwort ist falsch.</b></p>");
}
});
}

+ 0
- 0
authtokens/.keep View File


+ 44
- 1
backend.py View File

@@ -37,7 +37,8 @@ def login():
)
mastodon.log_in(
username,
password
password,
to_file = 'authtokens/'+username+'.secret'
)
if not os.path.exists("usercred.secret"):
suid = str(uuid.uuid1())
@@ -51,9 +52,51 @@ def login2(username, uuid):
response.headers['Access-Control-Allow-Origin'] = '*'
response.content_type = "application/json"
suid = str(r.get("nordcast/uuids/" + username)).replace("b'", "").replace("'", "")
mastodon = Mastodon(
access_token = 'authtokens/'+username+'.secret',
api_base_url = 'https://koyu.space'
)
mastodon.account_verify_credentials().source.note
if suid == uuid:
return json.dumps({"login": "ok", "uuid": uuid})
else:
return "{\"login\": \"error\"}"

@get("/api/v1/setlist/<username>/<uuid>/<podlist>")
def setlist(username, uuid, podlist):
response.headers['Access-Control-Allow-Origin'] = '*'
response.content_type = "application/json"
suid = str(r.get("nordcast/uuids/" + username)).replace("b'", "").replace("'", "")
if suid == "uuid":
r.set("nordcast/podlist/" + username, podlist)
return json.dumps({"login": "ok", "uuid": uuid, "action": "success"})
else:
return "{\"login\": \"error\"}"

@get("/api/v1/getlist/<username>/<uuid>")
def getlist(username, uuid):
response.headers['Access-Control-Allow-Origin'] = '*'
response.content_type = "application/json"
suid = str(r.get("nordcast/uuids/" + username)).replace("b'", "").replace("'", "")
podlist = str(r.get("nordcast/uuids/" + username)).replace("b'", "").replace("'", "")
if suid == "uuid":
r.set("nordcast/podlist/" + username, podlist)
return json.dumps({"login": "ok", "uuid": uuid, "action": "success", "podlist": podlist})
else:
return "{\"login\": \"error\"}"

@get("/api/v1/getmainview/<username>/<uuid>")
def getmainview(username, uuid):
response.headers['Access-Control-Allow-Origin'] = '*'
suid = str(r.get("nordcast/uuids/" + username)).replace("b'", "").replace("'", "")
if suid == uuid:
response.content_type = "text/html"
f = open("mainview.html", "r")
s = f.read()
f.close()
return s
else:
response.content_type = "application/json"
return "{\"login\": \"error\"}"

run(server="tornado",port=9000,host="0.0.0.0")

+ 15
- 0
mainview.html View File

@@ -0,0 +1,15 @@
<h1 id="text__featured">Featured</h1>
<div id="section__featured">
</div>
<br /><h2 id="text__originals">Nordcast Originals</h3>
<div id="section__originals">
<p><img src="fake_data/4.jpg" class="card__smaller" /><img src="fake_data/5.jpg" class="card__smaller" /><img src="fake_data/6.jpg" class="card__smaller" /><img src="fake_data/7.jpg" class="card__smaller" /><img src="fake_data/8.jpg" class="card__smaller" /><img src="fake_data/4.jpg" class="card__smaller" /><img src="fake_data/5.jpg" class="card__smaller" /><img src="fake_data/6.jpg" class="card__smaller" /><img src="fake_data/7.jpg" class="card__smaller" /><img src="fake_data/8.jpg" class="card__smaller" /></p>
</div>
<br /><h3 id="text__trending">New and hot</h3>
<div id="section__trending">
<p><img src="fake_data/4.jpg" class="card__small" /><img src="fake_data/5.jpg" class="card__small" /><img src="fake_data/6.jpg" class="card__small" /><img src="fake_data/7.jpg" class="card__small" /><img src="fake_data/8.jpg" class="card__small" /><img src="fake_data/4.jpg" class="card__small" /><img src="fake_data/5.jpg" class="card__small" /><img src="fake_data/6.jpg" class="card__small" /><img src="fake_data/7.jpg" class="card__small" /><img src="fake_data/8.jpg" class="card__small" /></p>
</div>
<br /><h3 id="text__list">Your list</h3>
<div id="section__list">
</div>

Loading…
Cancel
Save