Commit 6c6bba7f authored by Duhoux Pierre-Louis's avatar Duhoux Pierre-Louis

Create separation of pages, init lab and test load from different repos

parent 9ca3c29e
......@@ -5,8 +5,8 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"popup/*": [
"popup/components/*"
"pages/*": [
"pages/components/*"
]
}
}
......
......@@ -6,7 +6,7 @@ const fs = require('fs');
const BUNDLE_DIR = path.join(__dirname, '../dist');
const bundles = [
'background/background.js',
'popup/popup.js'
'pages/popup/popup.js'
];
const evalRegexForProduction = /;([a-z])=function\(\){return this}\(\);try{\1=\1\|\|Function\("return this"\)\(\)\|\|\(0,eval\)\("this"\)}catch\(t\){"object"==typeof window&&\(\1=window\)}/g;
......
......@@ -95,14 +95,6 @@
"message": "Facilities",
"description": "This is the title of the options page section facilities"
},
"options_web_newbar_opt": {
"message": "Navigation in one top bar",
"description": "Option Navigation in one top bar"
},
"options_web_newbar_desc": {
"message": "Display navigation features in one always visible bar. (If you uncheck it, two navigation panels are included in each page, one on top of the scans and one at the bottom)",
"description": "Option Navigation in one top bar description"
},
"options_web_addauto_opt": {
"message": "Automatically add manga to updates list",
"description": "Option automatically add manga to list"
......
......@@ -39,8 +39,8 @@ const matchUrlWildCards = function(str, rule) {
*/
export function currentPageMatch(url) {
for (let mir of store.state.mirrors.all) {
if (mir.activated) {
let wss = (typeof mir.webSites === 'object') ? mir.webSites : JSON.parse(wsloc[i].webSites);
if (mir.activated && mir.webSites) {
let wss = (mir.webSites.length) ? mir.webSites : JSON.parse(mir.webSites);
for (let u of wss) {
if (matchUrlWildCards(url, u)) {
return mir;
......
......@@ -16,27 +16,11 @@ class Navigation {
async createNavBar() {
// Get the chapter select from page
let select = mirrorImpl.get().getMangaSelectFromPage(document, window.location.href);
let isSel = true;
if (select === null) {
// If non existing, build one
let selectIns = $("<select></select>");
selectIns.data("mangaCurUrl", pageData.currentChapterURL);
// Change currentMangaURL so no conflict in http over https
mirrorImpl.get().getListChaps(util.removeProtocol(pageData.currentMangaURL), pageData.name, selectIns, this.callbackListChaps.bind(this));
isSel = false;
}
if (isSel) {
let whereNav;
if (options.newbar == 1) {
let barstate = await browser.runtime.sendMessage({ action: "barState" });
whereNav = this.createBar(barstate.barVis);
} else {
whereNav = mirrorImpl.get().whereDoIWriteNavigation(document, window.location.href);
}
this.writeNavigation(whereNav, select);
}
// Build the select
let selectIns = $("<select></select>");
selectIns.data("mangaCurUrl", pageData.currentChapterURL);
// Change currentMangaURL so no conflict in http over https
mirrorImpl.get().getListChaps(util.removeProtocol(pageData.currentMangaURL), pageData.name, selectIns, this.callbackListChaps.bind(this));
}
/**
......@@ -58,14 +42,9 @@ class Navigation {
}
let whereNav;
if (options.newbar == 1) {
let barstate = await browser.runtime.sendMessage({ action: "barState" });
whereNav = this.createBar(barstate.barVis);
this.writeNavigation(whereNav, select);
} else {
whereNav = mirrorImpl.get().whereDoIWriteNavigation(document, window.location.href);
this.writeNavigation(whereNav, select);
}
let barstate = await browser.runtime.sendMessage({ action: "barState" });
whereNav = this.createBar(barstate.barVis);
this.writeNavigation(whereNav, select);
}
/**
......@@ -230,15 +209,20 @@ class Navigation {
window.location.href = $("option:selected", $(this)).val();
});
let prevUrl = mirrorImpl.get().previousChapterUrl(selectIns, document, window.location.href);
let prevUrl;
if (selectIns.children("option:selected").next().length > 0) {
prevUrl = selectIns.children("option:selected").next().val();
}
if (prevUrl !== null) {
let aprev = $("<a id='pChapBtn" + index + "' class='buttonAMR' href='" + prevUrl + "' onclick='window.location.href = this.href; window.location.reload();'>Previous</a>");
aprev.appendTo($w);
}
selectIns.appendTo($w);
let nextUrl = mirrorImpl.get().nextChapterUrl(selectIns, document, window.location.href);
let nextUrl;
if (selectIns.children("option:selected").prev().length > 0) {
nextUrl = selectIns.children("option:selected").prev().val();
}
if (nextUrl !== null) {
let anext = $("<a id='nChapBtn" + index + "' class='buttonAMR' href='" + nextUrl + "' onclick='window.location.href = this.href; window.location.reload();'>Next</a>");
anext.appendTo($w);
......@@ -401,9 +385,6 @@ class Navigation {
}
$w.addClass("amrbarlayout");
let whereNavToTrail = mirrorImpl.get().whereDoIWriteNavigation(document, window.location.href);
navigation.addTrailingLastChap($(whereNavToTrail).last());
});
}
......
......@@ -443,7 +443,7 @@ class Reading {
return ((nba < nbb) ? -1 : ((nba == nbb) ? 0 : 1));
}).each(function (index) {
//console.log("setting image position...");
if (reading.isLandscape(this) || mirrorImpl.get().isImageInOneCol(this, document, window.location.href)) {
if (reading.isLandscape(this)) {
posImg[index] = 2;
if (reading.isLandscape(this) && isFirstDouble) {
if (index !== 0 && posImg[index - 1] != 1) {
......
......@@ -11,7 +11,7 @@
},
"browser_action": {
"default_title": "All Mangas Reader",
"default_popup": "popup/popup.html"
"default_popup": "pages/popup/popup.html"
},
"background": {
"persistent": true,
......@@ -41,7 +41,7 @@
"contextMenus",
"notifications"
],
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com https://community.allmangasreader.com/ https://raw.github.com/ ; object-src 'self'",
"content_security_policy": "script-src 'self' http://localhost:8080/ https://ssl.google-analytics.com https://community.allmangasreader.com/ https://raw.github.com/ ; object-src 'self'",
"web_accessible_resources" : [
"icons/icon_32.png",
"icons/down.png",
......
......@@ -61,10 +61,6 @@
<!-- Facilities -->
<div class="headline">{{ i18n("options_web_facilities") }}</div>
<!-- Display one always visible bar-->
<div class="subtitle">{{i18n('options_web_newbar_desc')}}</div>
<v-checkbox v-model="newbar" @change="setOption('newbar')"
:label="i18n('options_web_newbar_opt')"></v-checkbox>
<!-- Automatically add manga to updates list -->
<div class="subtitle">{{i18n('options_web_addauto_desc')}}</div>
<v-checkbox v-model="addauto" @change="setOption('addauto')"
......@@ -545,7 +541,6 @@ const converters = {
"imgorder",
"prefetch",
"markwhendownload",
"newbar",
"addauto",
"lrkeys",
"autobm",
......@@ -624,7 +619,6 @@ export default {
{ text: "Website name / number of mangas read", value: "name" },
{ text: "Language", value: "lang" }
],
supportedWebsites: [],
newRepo: "",
newRepositoryDialog: false
};
......@@ -638,15 +632,10 @@ export default {
});
return res;
},
created() {
document.addEventListener(
"mirrorsLoaded",
function() {
// set mirrors in table once loaded
console.log("loaded");
this.supportedWebsites = this.$store.state.mirrors.all;
}.bind(this)
);
computed: {
supportedWebsites() {
return this.$store.state.mirrors.all
}
},
watch: {
/**
......@@ -714,7 +703,9 @@ export default {
},
addRepository() {
if (this.newRepo !== "") {
this.$store.dispatch("addRepository", this.newRepo);
let r = this.newRepo;
if (r.slice(-1) !== "/") r += "/"
this.$store.dispatch("addRepository", r);
}
this.newRepositoryDialog = false;
}
......
<template>
<v-app :dark="$store.state.options.dark === 1">
<v-toolbar app>
<img src="/icons/icon_32.png" alt="All Mangas Reader">
<v-toolbar-title v-text="title"></v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon @click.stop="options = true">
<v-icon>mdi-settings</v-icon>
</v-btn>
</v-toolbar>
<v-content>
</v-content>
<v-dialog
v-model="options"
fullscreen
transition="dialog-bottom-transition"
:overlay="false"
scrollable
>
<v-card tile>
<v-toolbar card dark color="primary">
<v-btn icon @click.native="options = false" dark>
<v-icon>close</v-icon>
</v-btn>
<v-toolbar-title>Settings</v-toolbar-title>
</v-toolbar>
<Options />
</v-card>
</v-dialog>
</v-app>
</template>
<script>
import Options from "../components/Options";
export default {
data() {
return {
title: "All Mangas Reader Lab",
options: false
};
},
name: "App",
components: { Options },
created() {
// initialize state for store in popup from background
this.$store.dispatch("getStateFromReference", {
module: "mirrors",
key: "all",
mutation: "setMirrors"
});
}
};
</script>
<style>
.dialog .card__title,
.dialog .card__text {
padding: 4px 16px;
}
.dialog .card__title {
padding-top: 10px;
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>All Mangas Reader Lab</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons" rel="stylesheet">
<link href="https://cdn.materialdesignicons.com/2.1.19/css/materialdesignicons.min.css" rel="stylesheet">
<link rel="stylesheet" href="lab.css">
</head>
<body>
<div id="app">
</div>
<script src="lab.js"></script>
</body>
</html>
import 'vuetify/dist/vuetify.min.css';
import './lab.css';
import 'regenerator-runtime/runtime';
import browser from "webextension-polyfill";
import Vue from 'vue';
import Vuetify from 'vuetify';
import App from './App.vue';
import store from '../../store';
import theme from '../theme';
(async function() {
// Load options in store before everything
await store.dispatch("getStateFromReference", {
module: "options",
mutation: "extendOptions"
});
// Load vue
Vue.config.productionTip = false
Vue.use(Vuetify, {theme: theme})
new Vue({
el: '#app',
store,
render: h => h(App)
});
})();
\ No newline at end of file
......@@ -55,8 +55,8 @@
</template>
<script>
import MangaList from "./components/MangaList";
import Options from "./components/Options";
import MangaList from "../components/MangaList";
import Options from "../components/Options";
import PopupResizer from './resizePopup';
export default {
......@@ -76,9 +76,7 @@ export default {
module: "mirrors",
key: "all",
mutation: "setMirrors"
}).then(() => {
document.dispatchEvent(new CustomEvent("mirrorsLoaded"));
});
});
},
methods: {
openOptions() {
......
......@@ -6,8 +6,8 @@ import browser from "webextension-polyfill";
import Vue from 'vue';
import Vuetify from 'vuetify';
import App from './App.vue';
import store from './../store';
import theme from './theme';
import store from '../../store';
import theme from '../theme';
(async function() {
// Load options in store before everything
......@@ -21,7 +21,7 @@ import theme from './theme';
&& window.location.href.indexOf("mode=tab") < 0) {
browser.runtime.sendMessage({
action: "opentab",
url: "/popup/popup.html?mode=tab"
url: "/pages/popup/popup.html?mode=tab"
});
}
......
......@@ -3,6 +3,7 @@ import Axios from 'axios'
import * as utils from '../../amr/utils'
import iconHelper from '../../amr/icon-helper';
import mirrorsImpl from '../../amr/mirrors-impl';
import amrUpdater from '../../amr/amr-updater';
/**
* initial state of the mirrors module
......@@ -83,7 +84,8 @@ const actions = {
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);
console.error("Failed to load websites.json from repo " + repo);
console.error(e);
return e;
});
if (ws && ws.data) {
......@@ -97,6 +99,7 @@ const actions = {
// do not wait that all implementations are in db... few seconds. as the stores have been updated instantly, we do not need to wait for it to be in db
Promise.all(updts);
websites = ws.data;
break;
}
}
if (!websites.length) {
......@@ -109,7 +112,7 @@ const actions = {
mirrorsImpl.resetImplementations();
//update badges and icon state
iconHelper.resetIcon();
amrUpdater.refreshBadgeAndIcon();
return websites;
}
......@@ -129,7 +132,8 @@ const mutations = {
* @param {*} mirrors
*/
setMirrors(state, mirrors) {
state.all = mirrors
state.all = []
state.all.push(...mirrors)
}
}
......
......@@ -12,7 +12,6 @@ const default_options = {
* Options used in content scripts (included in mangas pages)
*/
displayChapters: 1, // display scans as a book
newbar: 1, // display one navigation bar on top
/**
* mode = 1 --> images are displayed on top of one another
* mode = 2 --> images are displayed two by two occidental reading mode
......
......@@ -9,7 +9,8 @@ const config = {
'background/background': './background/background.js',
'content/testcontent': './content/testcontent.js',
'content/back': './content/back.js',
'popup/popup': './popup/popup.js'
'pages/popup/popup': './pages/popup/popup.js',
'pages/lab/lab': './pages/lab/lab.js'
},
output: {
path: __dirname + '/dist',
......@@ -63,7 +64,8 @@ const config = {
}),
new CopyWebpackPlugin([
{from: 'icons', to: 'icons', ignore: ['icon.xcf']},
{from: 'popup/popup.html', to: 'popup/popup.html'},
{from: 'pages/popup/popup.html', to: 'pages/popup/popup.html'},
{from: 'pages/lab/lab.html', to: 'pages/lab/lab.html'},
{from: 'manifest.json', to: 'manifest.json'},
{from: 'content/*.css', to: '.'},
{from: '_locales/**/*', to: '.'},
......
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