Skip to content

Commit

Permalink
mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Nov 26, 2024
1 parent 017a625 commit 840f925
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion application/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ article {
font-size: 0.7rem;
border: 2px solid black;
border-radius: 8px;
padding: 3px;
padding: 5px;
line-height: 0.4rem;
}

Expand Down
4 changes: 2 additions & 2 deletions application/assets/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export let setTabindex = () => {
export let load_ads = function () {
getKaiAd({
publisher: "4408b6fa-4e1d-438f-af4d-f3be2fa97208",
app: "flop",
slot: "flop",
app: "feedolin",
slot: "feedolin",
test: 0,
timeout: 10000,
h: 120,
Expand Down
50 changes: 35 additions & 15 deletions application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { mastodon_account_info, reblog } from "./assets/js/mastodon.js";
import localforage from "localforage";
import { detectMobileOS } from "./assets/js/helper.js";
import m from "mithril";
import { v4 as uuidv4 } from "uuid";
import * as sanitizeHtml from "sanitize-html";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
Expand Down Expand Up @@ -79,6 +78,8 @@ let default_settings = {
"proxy_url": "https://corsproxy.io/?",
"cache_time": 1000,
};
//store all articles id to compare
let articlesID = [];

export let settings = {};
let channels = [];
Expand Down Expand Up @@ -324,6 +325,12 @@ let clean = (i) => {
});
};

let raw = (i) => {
return sanitizeHtml(i, {
allowedTags: [],
allowedAttributes: {},
});
};
const fetchOPML = async (url) => {
try {
const uniqueUrl = `${url}?t=${new Date().getTime()}`;
Expand Down Expand Up @@ -430,7 +437,6 @@ const fetchContent = async (feed_download_list) => {
localforage
.setItem("articles", articles)
.then(() => {
console.log("feeds cached");
articles.sort((a, b) => new Date(b.isoDate) - new Date(a.isoDate));

articles.forEach((e) => {
Expand Down Expand Up @@ -736,6 +742,7 @@ let load_mastodon = () => {
articles.push(f);
});
channels.push("Mastodon");
side_toaster("Logged in as " + status.mastodon_logged, 4000);
});
};

Expand All @@ -750,10 +757,9 @@ let start_loading = () => {
.then((f) => {
status.mastodon_logged = f.display_name;
load_mastodon();
setTimeout(() => {}, 5000);
})
.catch((e) => {
alert(e);
});
.catch((e) => {});
}

channel_filter = localStorage.getItem("last_channel_filter");
Expand Down Expand Up @@ -940,6 +946,10 @@ var start = {
(h) => channel_filter === "" || channel_filter === h.channel
);

articles.forEach((e) => {
articlesID.push(e.id);
});

return m(
"div",
{
Expand Down Expand Up @@ -1026,6 +1036,9 @@ var start = {
clean(h.feed_title)
),
m("h3", clean(h.title)),
h.type == "mastodon"
? m("h3", raw(h.content.substring(0, 30)) + "...")
: null,
]
);
})
Expand Down Expand Up @@ -1451,21 +1464,25 @@ try {
}

// Function to play and update audio
let playedAudio = async (url, time) => {
let playedAudio = async (url, time, id) => {
const index = hasPlayedAudio.findIndex((e) => e.url === url);

if (index !== -1) {
// If the URL exists, update the time
hasPlayedAudio[index].time = time;
} else {
// If the URL does not exist, push a new object
hasPlayedAudio.push({ url, time });
hasPlayedAudio.push({ url, time, id });
}

clean_hasPlayedaudio();

// Save the updated hasPlayedAudio array to localforage
localforage.setItem("hasPlayedAudio", hasPlayedAudio).then(() => {
console.log(hasPlayedAudio);
});
localforage.setItem("hasPlayedAudio", hasPlayedAudio).then(() => {});
};

let clean_hasPlayedaudio = () => {
hasPlayedAudio = hasPlayedAudio.filter((e) => articlesID.includes(e.id));
};

let startX = 0; // Initial X position
Expand All @@ -1490,7 +1507,7 @@ const AudioPlayerView = {

hasPlayedAudio.map((e) => {
if (e.url === globalAudioElement.src) {
if (confirm("contiune playing ?") == true) {
if (confirm("continue playing ?") == true) {
globalAudioElement.currentTime = e.time;
}
}
Expand All @@ -1507,8 +1524,12 @@ const AudioPlayerView = {
AudioPlayerView.currentTime = globalAudioElement.currentTime;

//store audio url to contiune to play
playedAudio(globalAudioElement.src, globalAudioElement.currentTime);

playedAudio(
globalAudioElement.src,
globalAudioElement.currentTime,
attrs.id
);
status.player = true;
m.redraw();
};

Expand Down Expand Up @@ -2513,7 +2534,7 @@ document.addEventListener("DOMContentLoaded", function (e) {
m.route.set(
`/AudioPlayerView?url=${encodeURIComponent(
current_article.enclosure["@_url"]
)}`
)}&id=${current_article.id}`
);

if (current_article.type == "video")
Expand Down Expand Up @@ -2743,7 +2764,6 @@ try {
//KaiOS3 handel mastodon oauth
sw_channel.addEventListener("message", (event) => {
let result = event.data.oauth_success;
console.log(result);

if (result) {
var myHeaders = new Headers();
Expand Down
2 changes: 1 addition & 1 deletion application/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.7",
"version": "2.0.8",
"name": "feedolin",
"description": "Feedolin is an RSS / Atom / Mastodon reader and podcast player. It is intended for users who already use an rss reader client and want to read their feeds on a kaios device. the list of subscribed websites / podcasts is managed locally or online in an opml file.",
"launch_path": "/index.html",
Expand Down
2 changes: 1 addition & 1 deletion application/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],

"b2g_features": {
"version": "1.8.112",
"version": "1.8.117",
"id": "feedolin",
"subtitle": "RSS Reader and Mastodon Reader",
"core": true,
Expand Down
2 changes: 1 addition & 1 deletion application/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ self.addEventListener("systemmessage", async (evt) => {
const userAgent = navigator.userAgent || "";

if (userAgent && !userAgent.includes("KAIOS")) {
const CACHE_NAME = "pwa-cache-v0.1169";
const CACHE_NAME = "pwa-cache-v0.1174";
const FILE_LIST_URL = "/file-list.json"; // URL of the JSON file containing the array of files

self.addEventListener("install", (event) => {
Expand Down
4 changes: 2 additions & 2 deletions docs/index.339e55c4.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.63982eba.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.f0337e49.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.7",
"version": "2.0.8",
"name": "feedolin",
"description": "Feedolin is an RSS / Atom / Mastodon reader and podcast player. It is intended for users who already use an rss reader client and want to read their feeds on a kaios device. the list of subscribed websites / podcasts is managed locally or online in an opml file.",
"launch_path": "/index.html",
Expand Down
2 changes: 1 addition & 1 deletion docs/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],

"b2g_features": {
"version": "1.8.112",
"version": "1.8.117",
"id": "feedolin",
"subtitle": "RSS Reader and Mastodon Reader",
"core": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/sw.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 840f925

Please sign in to comment.