Browse Source

Good night patch

tags/1.0.0
Leonie 3 months ago
parent
commit
6a592c9aea
8 changed files with 115 additions and 30 deletions
  1. 1
    1
      app/www/app.html
  2. 54
    24
      app/www/app.js
  3. 1
    1
      app/www/config.js
  4. 20
    1
      app/www/style.css
  5. 35
    1
      backend.py
  6. 1
    1
      data/featured
  7. 1
    1
      views/mainview.html
  8. 2
    0
      views/searchview.html

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

@@ -12,7 +12,7 @@
<script src="getfeed.js"></script>
<script src="https://unpkg.com/[email protected]/dist/ionicons.js"></script>
<script src="config.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?12.0.4"></script>
<script src="cordova.js"></script>
<script src="app.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

+ 54
- 24
app/www/app.js View File

@@ -60,12 +60,12 @@ $(document).ready(function() {
$("#podcard").attr("style", "background-image: linear-gradient(rgb("+color+"),#fff);");
}
});
$("#text__cast").html(callback.feed.title);
$("#text__cast").html(twemoji.parse(callback.feed.title.split(" | ")[0].split(" - ")[0].split(" – ")[0]));
$("#text__subtitle").html(callback.feed.subtitle);
$("#text__author").html(callback.feed.author);
$("#text__description").html(callback.feed.content.replaceAll("\n", "<br />"));
$("#text__author").html(callback.feed.author.split(" | ")[0].split(" - ")[0].split(" – ")[0]);
$("#text__description").html(callback.feed.summary.replaceAll("\n", "<br />"));
callback.entries.forEach(function(item) {
$("#podtable tbody").append("<tr><td><ion-icon name=\"play-circle\"></ion-icon></td><td>"+item.title+"</td></tr>");
$("#podtable tbody").append("<tr><td><ion-icon name=\"play-circle\"></ion-icon></td><td>"+twemoji.parse(item.title)+"</td></tr>");
});
$("#button__follow").click(function() {
$.get(backend+"/api/v1/getlist/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid"), function(data) {
@@ -117,6 +117,20 @@ $(document).ready(function() {
});
}, 500);
$("#view__main").css("padding-top", "60px");
} else if(findGetParameter("search")) {
$("#view__main").css("padding-top", "60px");
$("#view__main").hide();
$("#view__settings").hide();
$("#nav").hide();
$("#text__query").html(findGetParameter("search"));
$.get(backend+"/api/v1/getview/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/search", function(data) {
$("#view__main").html(data);
$.getJSON(backend+"/api/v1/search/"+localStorage.getItem("lang")+"/"+findGetParameter("search"), function(data) {
data["results"].forEach(function(item) {
$("#searchtable tbody").append("<tr><td><a href=\"app.html?cast="+item.feedUrl+"\"><img src=\""+item.artworkUrl100+"\" class=\"card__small\"></a></td><td><a href=\"app.html?cast="+item.feedUrl+"\" style=\"color:#333;\">"+twemoji.parse(item.collectionName)+"</a></td></tr>");
});
});
});
} else {
if (findGetParameter("nosplash") === "ok") {
$("#logo__intro").hide();
@@ -173,6 +187,13 @@ $(document).ready(function() {

$.get(backend+"/api/v1/getname/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid"), function(data) {
$(".placeholder__username").html(data["ksname"]);
$.get(backend+"/api/v1/getemoji/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid"), function(data) {
var ksemoji = data["ksemoji"];
ksemoji.forEach(function(emoji) {
$(".placeholder__username").html($(".placeholder__username").html().replaceAll(":" + emoji["shortcode"] + ":", "<img src=\"" + emoji["url"] + "\" height=\"16\">"));
});
});
$(".placeholder__username").html(twemoji.parse($(".placeholder__username").html()));
}).error(function() {
$("#text__username").hide();
});
@@ -183,7 +204,7 @@ $(document).ready(function() {
if (searchtoggle === false) {
$("#wrapper__search").show();
searchtoggle = true;
$("#view__main").css("padding-top", "150px");
$("#view__main").css("padding-top", "165px");
} else {
$("#wrapper__search").hide();
searchtoggle = false;
@@ -205,25 +226,34 @@ $(document).ready(function() {
$(".fa__nav2").show();
$("#view__settings").hide();
});
$("#qq").keyup(function() {
$.getJSON(backend+"/api/v1/search/"+localStorage.getItem("lang")+"/"+$("#qq").val(), function(data) {
var results = [];
data["results"].forEach(function(el) {
results.push(el["collectionName"]);
});
$("#qq").autocomplete({
source: results,
select: function() {
setTimeout(function() {
data["results"].forEach(function(el) {
if (el["collectionName"] == $("#qq").val()) {
location.href = "app.html?cast="+el["feedUrl"];
}
});
}, 50);
}
$("#qq").keydown(function() {
function qq() {
$.getJSON(backend+"/api/v1/search/"+localStorage.getItem("lang")+"/"+$("#qq").val(), function(data) {
var results = [];
data["results"].forEach(function(el) {
results.push(el["collectionName"]);
});
$("#qq").autocomplete({
source: results,
select: function() {
setTimeout(function() {
data["results"].forEach(function(el) {
if (el["collectionName"] == $("#qq").val()) {
location.href = "app.html?cast="+el["feedUrl"];
}
});
}, 50);
}
});
});
});
}
$("#qq").keydown(qq());
});
$("#qq").keypress(function (e) {
if (e.which === 13) {
location.href = "app.html?search="+$("#qq").val();
return false;
}
});
$("#logo__intro").hide();
$("#view__main").show();
@@ -255,5 +285,5 @@ function onDeviceReady() {
}, 1000);
}
});
}, 500);
}, 1200);
}

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

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

+ 20
- 1
app/www/style.css View File

@@ -67,6 +67,7 @@ h1, h2, h3, h4, h5, h6 {
border-radius: 6px;
background: #fff;
box-shadow: 0px 0px 3px -1px rgba(0,0,0,0.75);
border: 1px solid #ccc;
margin: 5px;
width: 80px;
height: 80px;
@@ -77,6 +78,7 @@ h1, h2, h3, h4, h5, h6 {
border-radius: 6px;
background: #fff;
box-shadow: 0px 0px 3px -1px rgba(0,0,0,0.75);
border: 1px solid #f3f3f3;
margin: 5px;
width: 64px;
height: 64px;
@@ -195,8 +197,25 @@ table {
th, td {
text-align: left;
padding: 8px;
text-align: center;
vertical-align: middle;
}

tr:nth-child(even) {
#podtable tr:nth-child(even) {
background-color: #f2f2f2
}

#text__cast {
margin-top: 6px !important;
}

.emoji {
height: 16px;
margin-right: 8px;
vertical-align: middle;
}

h1 .emoji {
height: 36pt;
margin-right: 8px;
}

+ 35
- 1
backend.py View File

@@ -126,9 +126,37 @@ def getname(username, uuid):
)
userdict = mastodon.account_verify_credentials()
if suid == uuid:
ksname = userdict.username
ksname = userdict.display_name
return json.dumps({"login": "ok", "uuid": uuid, "action": "success", "ksname": ksname})

@get("/api/v1/getpic/<username>/<uuid>")
def getpic(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'
)
userdict = mastodon.account_verify_credentials()
if suid == uuid:
kspic = userdict.avatar
return json.dumps({"login": "ok", "uuid": uuid, "action": "success", "kspic": kspic})

@get("/api/v1/getemoji/<username>/<uuid>")
def getemoji(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'
)
userdict = mastodon.account_verify_credentials()
if suid == uuid:
ksemoji = mastodon.custom_emojis()
return json.dumps({"login": "ok", "uuid": uuid, "action": "success", "ksemoji": ksemoji})

@get("/api/v1/search/<lang>/<query>")
def search(lang,query):
response.headers['Access-Control-Allow-Origin'] = '*'
@@ -138,6 +166,12 @@ def search(lang,query):
data = requests.get(url)
return data

@get("/api/v1/search/<lang>/")
def searche(lang):
response.headers['Access-Control-Allow-Origin'] = '*'
response.content_type = "application/json"
return ""

@get("/api/v1/getoriginals")
def getoriginals():
f = open("data/originals", "r")

+ 1
- 1
data/featured View File

@@ -1,2 +1,2 @@
2#https://moinkiel.libsyn.com/rss
3#http://ainfachverkaufen.libsyn.com/rss
3#https://feeds.simplecast.com/_003SKgF

+ 1
- 1
views/mainview.html View File

@@ -1,4 +1,4 @@
<p id="text__username"><span id="text__hello">Hello</span>, <span class="placeholder__username"></span>!</p>
<small id="text__username"><span id="text__hello">Hello</span>, <span class="placeholder__username"></span></small>
<h1 id="text__featured">Featured</h1>
<div id="section__featured">
</div>

+ 2
- 0
views/searchview.html View File

@@ -0,0 +1,2 @@
<br /><h1 id="text__query" style="text-align: center;margin-top: -5px;"></h1>
<br><div id="searchtable"><div style="overflow-x:auto;"><table><tbody></tbody></table></div></div>

Loading…
Cancel
Save