Commit 9ca3c29e authored by Duhoux Pierre-Louis's avatar Duhoux Pierre-Louis

Add repositories, start websites deactivation

parent d59875a0
......@@ -284,6 +284,18 @@
"options_gen_notificationtimer_def": {
"message": "Closed by user action",
"description": "Option closed by user action for option select time before notif closes"
},
"options_sup_desc": {
"message": "AMR provides many supported Web Sites. For each web sites, AMR stores the list of existing mangas. To prevent AMR from using too much RAM, you can deactivate web sites you don't use. Only web sites for which you don't have mangas in your reading list can be deactivated. You can filter the websites supporting specific language to help you. Clicking a checkbox in the table below deactivate the corresponding website.",
"description": "Description of the supported websites tab"
},
"options_sup_repos": {
"message": "Mirrors implementation repositories",
"description": "Options page section mirrors repositories"
},
"options_sup_repos_desc": {
"message": "Here you can define the different repositories in which All Mangas Reader will try to load mirrors implementations. AMR loads the first repository from which it can download the file websites.json correctly. If you want to help us and want to develop new implementations for a website or fix bugs in existing one, you can fork the official github mirrors repo and serve the files on your localhost (the procedure is described in the github repo). Set your local server on top of the list and refresh mirrors lists when you update something, don't forget to share your implementations !",
"description": "Options page section mirrors repositories description"
}
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ class MirrorsImpl {
return new Promise(async (resolve, reject) => {
let found = false;
// Try to load script from first repo, next, ...
for (let repo of store.state.options["impl-repositories"]) {
for (let repo of store.state.options["impl_repositories"]) {
let mirror = store.state.mirrors.all.find(mir => mir.mirrorName === mirrorName);
await self.loadImplScript(mirrorName, repo + mirror.jsFile)
.catch(() => { }) // ignore repo and go to next
......
......@@ -64,7 +64,7 @@ class HandleManga {
if (mir === null) return Promise.resolve(null);
let impl;
// Load mirror implementation from repo (try next repo if previous fail)
for (let repo of store.state.options["impl-repositories"]) {
for (let repo of store.state.options["impl_repositories"]) {
impl = await Axios.get(repo + mir.jsFile).catch(() => { }); // ignore error, jump to next repo
if (impl) break;
}
......
......@@ -76,7 +76,9 @@ export default {
module: "mirrors",
key: "all",
mutation: "setMirrors"
});
}).then(() => {
document.dispatchEvent(new CustomEvent("mirrorsLoaded"));
});
},
methods: {
openOptions() {
......
This diff is collapsed.
......@@ -80,8 +80,12 @@ const actions = {
};
// Try all repos --> first to work wins.
for (let repo of rootState.options["impl-repositories"]) {
let ws = await Axios.get(repo + "websites.json", config);
for (let repo of rootState.options["impl_repositories"]) {
utils.debug("loading from repository " + repo);
let ws = await Axios.get(repo + "websites.json", config).catch(e => {
utils.debug("Failed to load websites.json from repo " + repo);
return e;
});
if (ws && ws.data) {
let updts = []
for (let w of ws.data) {
......
import storedb from '../../amr/storedb'
import Vue from 'vue';
/**
* Default options of AMR.
......@@ -31,7 +32,7 @@ const default_options = {
/**
* Options used by background script
*/
"impl-repositories": [ // repositories containing mirrors implementations
"impl_repositories": [ // repositories containing mirrors implementations
"https://community.allmangasreader.com/latest_v2/",
"https://raw.github.com/AllMangasReader-dev/mirrors/master/"
],
......@@ -70,17 +71,17 @@ const default_options = {
{ name: "Read", state: "include", type: "native" },
{ name: "Unread", state: "include", type: "native" },
{ name: "One Shots", state: "include", type: "native" }
],
],
/** Internal timestamps and state booleans */
updated: 0, // last time something has been changed in the list
changesSinceSync: 0, // 1 : something has been changed since last sync
lastChaptersUpdate: 0, // last time chapters lists have been updated
lastMirrorsUpdate: 0, // last time mirrors have been updated
}
const jsonOptions = ["categoriesStates", "impl-repositories"];
const jsonOptions = ["categoriesStates", "impl_repositories"];
const stringOptions = ["colornew", "colorread", "colornotfollow"];
/**
......@@ -144,7 +145,7 @@ const actions = {
localStorage["o.categoriesStates"] = JSON.stringify(state.categoriesStates);
for (let mg of rootState.mangas.all) {
if (mg.cats.includes(name)) {
dispatch("removeCategoryFromManga", {key: mg.key, name: name});
dispatch("removeCategoryFromManga", { key: mg.key, name: name });
}
}
},
......@@ -156,7 +157,43 @@ const actions = {
updateCategory({ commit, dispatch, state }, catObj) {
commit('updateCategory', catObj);
localStorage["o.categoriesStates"] = JSON.stringify(state.categoriesStates);
}
},
/**
* Move a repository up in the list
* @param {*} param0
* @param {*} repourl
*/
moveUpRepository({ commit, state }, repourl) {
commit('moveUpRepository', repourl);
localStorage["o.impl_repositories"] = JSON.stringify(state.impl_repositories);
},
/**
* Move a repository down in the list
* @param {*} param0
* @param {*} repourl
*/
moveDownRepository({ commit, state }, repourl) {
commit('moveDownRepository', repourl);
localStorage["o.impl_repositories"] = JSON.stringify(state.impl_repositories);
},
/**
* Delete a repository from the list
* @param {*} param0
* @param {*} repourl
*/
deleteRepository({ commit, state }, repourl) {
commit('deleteRepository', repourl);
localStorage["o.impl_repositories"] = JSON.stringify(state.impl_repositories);
},
/**
* Adds a repository in the list
* @param {*} param0
* @param {*} repourl
*/
addRepository({ commit, state }, repourl) {
commit('addRepository', repourl);
localStorage["o.impl_repositories"] = JSON.stringify(state.impl_repositories);
},
}
/**
......@@ -210,10 +247,53 @@ const mutations = {
* @param {*} state
* @param {*} param1
*/
updateCategory(state, {name, catstate}) {
updateCategory(state, { name, catstate }) {
let cat = state.categoriesStates.find(cat => cat.name === name);
cat.state = catstate;
}
},
/**
* Move a repository up in the list
* @param {*} state
* @param {*} repourl
*/
moveUpRepository(state, repourl) {
let index = state.impl_repositories.indexOf(repourl);
if (index > 0) {
let tmp = state.impl_repositories[index];
Vue.set(state.impl_repositories, index, state.impl_repositories[index - 1]);
Vue.set(state.impl_repositories, index - 1, tmp);
}
},
/**
* Move a repository down in the list
* @param {*} state
* @param {*} repourl
*/
moveDownRepository(state, repourl) {
let index = state.impl_repositories.indexOf(repourl);
if (index < state.impl_repositories.length - 1) {
let tmp = state.impl_repositories[index];
Vue.set(state.impl_repositories, index, state.impl_repositories[index + 1]);
Vue.set(state.impl_repositories, index + 1, tmp);
}
},
/**
* Delete a repository from the list
* @param {*} state
* @param {*} repourl
*/
deleteRepository(state, repourl) {
let index = state.impl_repositories.indexOf(repourl);
if (index >= 0) state.impl_repositories.splice(index, 1);
},
/**
* Adds a repository in the list
* @param {*} state
* @param {*} repourl
*/
addRepository(state, repourl) {
state.impl_repositories.unshift(repourl);
},
}
export default {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment