Browse Source

Add admin code, bump 1.8.4 and add custom sections

master
Leonie 2 weeks ago
parent
commit
4ae536cebd
9 changed files with 239 additions and 13 deletions
  1. +193
    -0
      admin.html
  2. +21
    -0
      backend.py
  3. +1
    -1
      config.xml
  4. +0
    -0
      data/ca/custom
  5. +0
    -0
      data/de/custom
  6. +1
    -1
      www/app.html
  7. +20
    -10
      www/app.js
  8. +1
    -1
      www/style.css
  9. +2
    -0
      www/views/mainview.html

+ 193
- 0
admin.html View File

@@ -0,0 +1,193 @@
<script src="https://web.nordcast.app/jquery.js"></script>
<script>
$(document).ready(function() {
$.get("https://api.nordcast.app/api/v1/getfeatured/de", function(data) {
data.forEach(function(el) {
$("textarea#getfeatured_de").val($("textarea#getfeatured_de").val()+el[0]+"#"+el[1]);
});
});
$.get("https://api.nordcast.app/api/v1/getfeatured/ca", function(data) {
data.forEach(function(el) {
$("textarea#getfeatured_en").val($("textarea#getfeatured_en").val()+el[0]+"#"+el[1]);
});
});
$.get("https://api.nordcast.app/api/v1/gethiddendownloads", function(data) {
$("textarea#gethiddendownloads").val(data);
});
$.get("https://api.nordcast.app/api/v1/gethiddendownloads", function(data) {
$("textarea#gethiddendownloads").val(data);
});
$.get("https://api.nordcast.app/api/v1/gethiddenauthors", function(data) {
$("textarea#gethiddenauthors").val(data);
});
$.get("https://api.nordcast.app/api/v1/gethiddensubtitles", function(data) {
$("textarea#gethiddensubtitles").val(data);
});
$.get("https://api.nordcast.app/api/v1/getoriginals/de", function(data) {
$("textarea#getoriginals_de").val(data["podlist"]);
});
$.get("https://api.nordcast.app/api/v1/getoriginals/ca", function(data) {
$("textarea#getoriginals_en").val(data["podlist"]);
});
$.get("https://api.nordcast.app/api/v1/getcustom/de", function(data) {
$("textarea#getcustom_de").val(data);
});
$.get("https://api.nordcast.app/api/v1/getcustom/ca", function(data) {
$("textarea#getcustom_en").val(data);
});
$.get("https://api.nordcast.app/api/v1/getreversed", function(data) {
$("textarea#getreversed").val(data);
});

$("#submit_featured").click(function() {
$("#submit_featured").attr("disabled", "");
$("#submit_featured").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/featured/"+$("#admin_id").val()+"/de", {content: $("#getfeatured_de").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_featured").removeAttr("disabled");
$("#submit_featured").html("Submit");
}
});
$("#submit_featured").attr("disabled", "");
$("#submit_featured").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/featured/"+$("#admin_id").val()+"/ca", {content: $("#getfeatured_en").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_featured").removeAttr("disabled");
$("#submit_featured").html("Submit");
}
});
});

$("#submit_originals").click(function() {
$("#submit_originals").attr("disabled", "");
$("#submit_originals").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/originals/"+$("#admin_id").val()+"/de", {content: $("#getoriginals_de").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_originals").removeAttr("disabled");
$("#submit_originals").html("Submit");
}
});
$("#submit_originals").attr("disabled", "");
$("#submit_originals").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/originals/"+$("#admin_id").val()+"/ca", {content: $("#getoriginals_en").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_originals").removeAttr("disabled");
$("#submit_originals").html("Submit");
}
});
});

$("#submit_custom").click(function() {
$("#submit_custom").attr("disabled", "");
$("#submit_custom").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/originals/"+$("#admin_id").val()+"/de", {content: $("#getcustom_de").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_custom").removeAttr("disabled");
$("#submit_custom").html("Submit");
}
});
$("#submit_custom").attr("disabled", "");
$("#submit_custom").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/originals/"+$("#admin_id").val()+"/ca", {content: $("#getcustom_en").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_custom").removeAttr("disabled");
$("#submit_custom").html("Submit");
}
});
});

$("#submit_hiddendownloads").click(function() {
$("#submit_hiddendownloads").attr("disabled", "");
$("#submit_hiddendownloads").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/hiddendownloads/"+$("#admin_id").val(), {content: $("#gethiddendownloads").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_hiddendownloads").removeAttr("disabled");
$("#submit_hiddendownloads").html("Submit");
}
});
});

$("#submit_hiddenauthors").click(function() {
$("#submit_hiddenauthors").attr("disabled", "");
$("#submit_hiddenauthors").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/hiddenauthors/"+$("#admin_id").val(), {content: $("#gethiddenauthors").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_hiddenauthors").removeAttr("disabled");
$("#submit_hiddenauthors").html("Submit");
}
});
});

$("#submit_hiddensubtitles").click(function() {
$("#submit_hiddensubtitles").attr("disabled", "");
$("#submit_hiddensubtitles").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/hiddensubtitles/"+$("#admin_id").val(), {content: $("#gethiddensubtitles").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_hiddensubtitles").removeAttr("disabled");
$("#submit_hiddensubtitles").html("Submit");
}
});
});

$("#submit_reversed").click(function() {
$("#submit_reversed").attr("disabled", "");
$("#submit_reversed").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/reversed/"+$("#admin_id").val(), {content: $("#getreversed").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_reversed").removeAttr("disabled");
$("#submit_reversed").html("Submit");
}
});
});

$("#submit_banner").click(function() {
$("#submit_banner").attr("disabled", "");
$("#submit_banner").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$("#error").attr("style", "display:none;color:red;");
try {
var fd = new FormData();
var file = $("#banner")[0].files[0];
fd.append('banner', file);
$.ajax({
url: "https://api.nordcast.app/api/v1/admin/banner/"+$("#admin_id").val(),
type: 'post',
data: fd,
contentType: false,
processData: false,
success: function(data){
if (data["action"] === "success") {
$("#submit_banner").removeAttr("disabled");
$("#submit_banner").html("Submit");
$("#banner").val("");
} else {
$("#submit_banner").removeAttr("disabled");
$("#submit_banner").html("Submit");
$("#banner").val("");
$("#error").attr("style", "color:red;");
}
},
}).error(function() {
$("#submit_banner").removeAttr("disabled");
$("#submit_banner").html("Submit");
$("#banner").val("");
$("#error").attr("style", "color:red;");
});
} catch (e) {
$("#submit_banner").removeAttr("disabled");
$("#submit_banner").html("Submit");
$("#banner").val("");
$("#error").attr("style", "color:red;");
}
});

var userLang = navigator.language || navigator.userLanguage;
if (userLang.includes("de")) {
$(".text-intro").html("Die Podcast-App von koyu.space");
$("#privacypolicy").html("Datenschutz");
$("#sourcecode").html("Quellcode");
$(".gplay").attr("src", "https://play.google.com/intl/en_us/badges/images/generic/de_badge_web_generic.png");
$(".appstore").attr("src", "https://www.apple.com/de/itunes/link/images/link_badge_appstore_large.png");
$("#post-15 > div > div > small").html("(Bald verfügbar)");
}
});
</script>

+ 21
- 0
backend.py View File

@@ -563,4 +563,25 @@ def getlastplayed(username, uuid, instance, feed):
if uuid in suid:
return json.dumps({"login": "ok", "uuid": uuid, "lastplayed": lastplayed})

@post("/api/v1/admin/custom/<adminkey>/<lang>")
def setcustom(adminkey, lang):
response.headers['Access-Control-Allow-Origin'] = '*'
response.content_type = "application/json"
content = request.forms.get("content") # pylint: disable=no-member
if adminkey == ADMINKEY:
f = open("data/"+lang+"/custom", "w")
f.write(content)
f.close()
return json.dumps({"login": "ok", "action": "success"})
else:
return "{\"action\": \"error\"}"

@get("/api/v1/getcustom/<lang>")
def getcustom(lang):
f = open("data/"+lang+"/custom", "r")
x = f.read()
f.close()
response.headers['Access-Control-Allow-Origin'] = '*'
return x

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

+ 1
- 1
config.xml View File

@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.Sommerlichter.nordcast" version="1.8.3" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<widget id="com.Sommerlichter.nordcast" version="1.8.4" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Nordcast</name>
<description>
A new podcast app

+ 0
- 0
data/ca/custom View File


+ 0
- 0
data/de/custom View File


+ 1
- 1
www/app.html View File

@@ -89,7 +89,7 @@
<p><span id="text__darkmode">Enable dark mode</span> <img src="darth.png" id="starwars" class="emoji"> <input id="cdark__mode" type="checkbox"></p>
<br />
<h2 id="text__about">About</h2>
<p>Nordcast <span id="version">1.8.3</span></p>
<p>Nordcast <span id="version">1.8.4</span></p>
<p><a href="#" onclick="window.open('https://nordcast.app', '_system'); return false;" id="text__website">Website</a> | <a href="#" onclick="window.open('https://git.koyu.space/koyu/nordcast', '_system'); return false;" id="text__sourcecode">Source code</a></p>
<p>&copy; koyu.space 2020</p>
</div>

+ 20
- 10
www/app.js View File

@@ -66,17 +66,19 @@ function removejscssfile(filename, filetype){

function drr2() {
$(document).ready(function() {
if (device.platform === "android") {
$.get("https://updates.koyu.space/nordcast/latest", function(data) {
if ($("#version").html() !== data.split("\n")[0]) {
if (localStorage.getItem("lang") !== "de") {
alert("New version " + data.split("\n")[0] + " available. Please update as soon as possible.");
} else {
alert("Neue Version " + data.split("\n")[0] + " verfügbar. Bitte so schnell wie möglich aktualisieren.");
window.setTimeout(function() {
if (device.platform === "android" || device.platform === "browser") {
$.get("https://updates.koyu.space/nordcast/latest", function(data) {
if ($("#version").html() !== data.split("\n")[0]) {
if (localStorage.getItem("lang") !== "de") {
alert("New version " + data.split("\n")[0] + " available. Please update as soon as possible.");
} else {
alert("Neue Version " + data.split("\n")[0] + " verfügbar. Bitte so schnell wie möglich aktualisieren.");
}
}
}
});
}
});
}
}, 3000);
window.setInterval(function() {
if (localStorage.getItem("uuid") === "dummy") {
$(".dlbutton").hide();
@@ -103,8 +105,10 @@ function drr2() {
}
if (findGetParameter("view") === "main") {
$("#view__yourlist").hide();
$("#section__custom").show();
} else {
$(".bigscreen").hide();
$("#section__custom").hide();
}
if (findGetParameter("view") !== "settings" && localStorage.getItem("uuid") !== "dummy" && localStorage.getItem("offline") === "false") {
$(".fa__nav2").show();
@@ -813,6 +817,12 @@ function drr2() {
if (localStorage.getItem("offline") === "true") {
location.href = "app.html#view=yourlist";
}
$.get(backend+"/api/v1/getcustomsection/"+localStorage.getItem("lang"), function(data) {
$("#text__custom").html(data.split("\n")[0]);
var custom = data.split("\n");
custom.shift();
$("#text__custom").html(custom);
});
} else {
$("#section__featured").hide();
$("#section__originals").hide();

+ 1
- 1
www/style.css View File

@@ -717,7 +717,7 @@ h1 .emoji {
}

.item p {
width: 90vw;
width: 80vw;
}

/* Hack for ionicicons v2 (no animation code) */

+ 2
- 0
www/views/mainview.html View File

@@ -15,6 +15,8 @@
<div id="section__originals"></div>
<h2 id="text__newforyou">New for you</h2>
<div id="section__newforyou"></div>
<h2 id="text__custom"></h2>
<div id="section__custom"></div>
<div id="view__yourlist" style="display: none;">
<h3 class="text__list">Your list</h3><i style="float:right;font-size:24pt;" class="icon ion-md-refresh" onclick="kicker=true;"></i><br><br><br>
<div id="section__list"></div><br>

Loading…
Cancel
Save