Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ export const i18n = createI18n({
"errors.theme.invalid": "The theme is invalid.",
"errors.unknown":
"An unknown error has occurred. Please close and reopen the extension. If it still doesn’t work, please contact the support.",
"errors.url.presence": "Enter a URL.",
"errors.url.url": "The URL of the current page is not supported by Flus.",
"feeds.count_detected":
"No feeds detected on this page. | 1 feed detected on this page. | {count} feeds detected on this page.",
"feeds.follow": "Follow",
"feeds.loading": "Loading the feeds…",
"feeds.open_in_flus": "Open in Flus",
"feeds.search_tip":
"Tip: search for mentions of the word “RSS” on the page. If there are any, copy and paste the corresponding URL below.",
"feeds.test": "Test",
"feeds.title": "List of Web feeds",
"feeds.unfollow": "Unfollow",
"feeds.url_potential_feed": "URL of a potential feed",
"forms.error": "Error:",
"link.count_collections": "No collections | 1 collection | {count} collections",
"link.invalid_protocol":
Expand Down Expand Up @@ -105,14 +110,19 @@ export const i18n = createI18n({
"errors.theme.invalid": "Le thème est invalide.",
"errors.unknown":
"Une erreur inconnue est survenue. Veuillez fermer et réouvrir l’extension. Si cela ne suffit pas, veuillez contacter le support.",
"errors.url.presence": "Saisissez une URL.",
"errors.url.url": "L’URL de la page actuelle n’est pas supportée par Flus.",
"feeds.count_detected":
"Aucun flux détecté sur cette page. | 1 flux détecté sur cette page. | {count} flux détectés sur cette page.",
"feeds.follow": "Suivre",
"feeds.loading": "Chargement des flux…",
"feeds.open_in_flus": "Ouvrir dans Flus",
"feeds.search_tip":
"Astuce : recherchez des mentions du mot « RSS » dans la page. S’il en existe, copiez-collez l’URL correspondante ci-dessous.",
"feeds.test": "Tester",
"feeds.title": "Liste des flux Web",
"feeds.unfollow": "Ne plus suivre",
"feeds.url_potential_feed": "URL d’un flux potentiel",
"forms.error": "Erreur :",
"link.count_collections": "Aucune collection | 1 collection | {count} collections",
"link.invalid_protocol":
Expand Down
88 changes: 67 additions & 21 deletions src/screens/FeedsScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<template>
<Screen :title="title" header>
<div v-if="ready && alert.type === ''" class="flow">
<div v-if="ready && alert.type === ''" class="flow flow--large">
<p class="text--center">
{{ t("feeds.count_detected", feeds.length) }}
</p>
Expand Down Expand Up @@ -44,6 +44,46 @@
</div>
</li>
</ul>

<div v-else class="flow">
<p>
{{ t("feeds.search_tip") }}
</p>

<form
@submit.prevent="testUrl"
class="flow flow--small"
:disabled="form.inProgress()"
>
<div class="flow flow--smaller">
<label for="url">
{{ t('feeds.url_potential_feed') }}
</label>

<p v-if="form.isInvalid('url')" id="url-error" class="form-group__error" role="alert">
{{ t('forms.error') }}
{{ form.error('url') }}
</p>

<input
v-model="urlToTest"
type="url"
id="url"
placeholder="https://…"
required
:aria-invalid="form.isInvalid('url')"
:aria-errormessage="form.isInvalid('url') ? 'url-error' : null"
:disabled="form.inProgress()"
/>
</div>

<div class="text--center">
<button class="button--primary button--big" :disabled="form.inProgress()">
{{ t('feeds.test') }}
</button>
</div>
</form>
</div>
</div>

<div v-else-if="ready && alert.type == 'info'">
Expand Down Expand Up @@ -81,6 +121,7 @@ import browser from "webextension-polyfill";
import { store } from "../store.js";
import api from "../api.js";
import http from "../http.js";
import form from "../form.js";
import Feed from "../models/feed.js";

const { t, locale } = useI18n();
Expand All @@ -96,6 +137,8 @@ const alert = ref({

const feeds = ref([]);

const urlToTest = ref("");

function feedUrl(feed) {
return `${store.auth.server}/collections/${feed.id}`;
}
Expand All @@ -111,20 +154,7 @@ async function getCurrentTab() {
});
}

async function refreshForCurrentTab() {
const url = (await getCurrentTab()).url;

if (!url.startsWith("http://") && !url.startsWith("https://")) {
alert.value = {
type: "info",
message: t("link.invalid_protocol"),
};

ready.value = true;

return;
}

function refreshForUrl(url) {
api.search(url)
.then((data) => {
// This array is used to deduplicate feeds with the same name.
Expand All @@ -144,12 +174,7 @@ async function refreshForCurrentTab() {
})
.catch((error) => {
if (error instanceof http.HttpError) {
alert.value = {
type: "error",
message: error.errors.url.map((error) => {
return t(`errors.url.${error.code}`);
}),
};
form.setAndFormatErrors(error.errors, t);
} else {
alert.value = {
type: "error",
Expand All @@ -161,6 +186,23 @@ async function refreshForCurrentTab() {
});
}

async function refreshForCurrentTab() {
const url = (await getCurrentTab()).url;

if (!url.startsWith("http://") && !url.startsWith("https://")) {
alert.value = {
type: "info",
message: t("link.invalid_protocol"),
};

ready.value = true;

return;
}

refreshForUrl(url);
}

async function follow(feed) {
api.follow(feed)
.then(() => {
Expand All @@ -187,5 +229,9 @@ async function unfollow(feed) {
});
}

function testUrl() {
refreshForUrl(urlToTest.value);
}

onMounted(refreshForCurrentTab);
</script>