From f23f60e540643a3d883085224d5ef2194b8355fc Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Sat, 16 Mar 2019 23:47:13 +0100 Subject: [PATCH] ++ Open Web Analytics https://test.freeplanet.app/owa --- .env.development | 2 +- quasar.conf.js | 15 +++---- src-pwa/custom-service-worker.js | 4 ++ src/boot/guard.ts | 7 +-- src/boot/myconfig.ts | 2 +- src/boot/track-disattivato-riutilizzare.ts | 8 ++++ src/boot/vue-idb.ts | 13 ------ src/globalroutines/index.ts | 6 +-- src/index.template.html | 9 ++-- src/root/home/home.scss | 19 ++++++++ src/root/home/home.ts | 2 + src/root/home/home.vue | 4 +- src/statics/i18n.js | 2 +- src/statics/js/track.js | 43 +++++++++++++++++++ src/track/index.ts | 50 ++++++++++++++++++++++ src/typings/libs/errorHandler.d.ts | 1 - src/typings/libs/track.d.ts | 8 ++++ 17 files changed, 154 insertions(+), 41 deletions(-) create mode 100644 src/boot/track-disattivato-riutilizzare.ts create mode 100644 src/statics/js/track.js create mode 100644 src/track/index.ts create mode 100644 src/typings/libs/track.d.ts diff --git a/.env.development b/.env.development index 2327087..f2a9600 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="0.0.54" +APP_VERSION="0.0.55" APP_NAME="FreePlanet" SERVICE_WORKER_FILE="service-worker.js" APP_ID="1" diff --git a/quasar.conf.js b/quasar.conf.js index 48a4714..f79b710 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -54,20 +54,15 @@ const extendHTMLToWebpack = (config) => { module.exports = function (ctx) { return { - // Quasar looks for *.js files by default - sourceFiles: { - router: 'src/router/index.ts', - store: 'src/store/index.ts' + htmlVariables: { + appName: 'FreePlanet', + appDescription: 'The first Real Social, Free, Fair and Equitable' }, // Quasar looks for *.js files by default sourceFiles: { router: 'src/router/index.ts', store: 'src/store/index.ts' }, - sourceFiles: { - router: 'src/router/index.ts', - store: 'src/store/index.ts' - }, // app plugins (/src/plugins) boot: ['vue-i18n', 'axios', 'vee-validate', 'myconfig', 'local-storage', 'error-handler', 'globalroutines', 'vue-idb', 'dragula', 'guard'], css: [ @@ -103,7 +98,7 @@ module.exports = function (ctx) { .alias .set('~', __dirname) .set('@', helpers.root('src')) - // .set('env', helpers.root('config/helpers/env.js')) + // .set('env', helpers.root('config/helpers/env.js')) config.module .rule('template-engine') .test(/\.pug$/) @@ -215,7 +210,7 @@ module.exports = function (ctx) { // swSrc: 'src/sw.js', }, manifest: { - name: 'Free Planet', + name: 'FreePlanet', version: '0.0.14', short_name: 'freeplanet', description: 'Social project in order to connecting people each others (working in progress...)', diff --git a/src-pwa/custom-service-worker.js b/src-pwa/custom-service-worker.js index b7fd3b4..b1c5a73 100644 --- a/src-pwa/custom-service-worker.js +++ b/src-pwa/custom-service-worker.js @@ -289,6 +289,10 @@ if (workbox) { workbox.strategies.networkOnly() ); + workbox.routing.registerRoute( + new RegExp('/owa/'), + workbox.strategies.networkOnly() + ); } diff --git a/src/boot/guard.ts b/src/boot/guard.ts index 45dde93..9e9e721 100644 --- a/src/boot/guard.ts +++ b/src/boot/guard.ts @@ -1,9 +1,6 @@ // import something here -// leave the export, even if you don't use it export default ({ app, router, store, Vue }) => { - // something to do - // ****************************************** // *** Per non permettere di accedere alle pagine in cui รจ necessario essere Loggati ! *** // ****************************************** @@ -15,7 +12,7 @@ export default ({ app, router, store, Vue }) => { const subsequentMiddleware = middleware[index] // If no subsequent Middleware exists, // the default `next()` callback is returned. - if (!subsequentMiddleware) return context.next + if (!subsequentMiddleware) { return context.next } return (...parameters) => { // Run the default Vue Router `next()` callback first. @@ -24,7 +21,7 @@ export default ({ app, router, store, Vue }) => { // `nextMiddleware()` callback. const nextMiddleware = nextFactory(context, middleware, index + 1) subsequentMiddleware({ ...context, next: nextMiddleware }) - }; + } } router.beforeEach((to, from, next) => { diff --git a/src/boot/myconfig.ts b/src/boot/myconfig.ts index 64d6adc..75ac404 100644 --- a/src/boot/myconfig.ts +++ b/src/boot/myconfig.ts @@ -3,7 +3,7 @@ import myconfig from '../myconfig' // leave the export, even if you don't use it export default ({ Vue }) => { - //Vue.use(myconfig); + // Vue.use(myconfig); // something to do Vue.prototype.$myconfig = myconfig } diff --git a/src/boot/track-disattivato-riutilizzare.ts b/src/boot/track-disattivato-riutilizzare.ts new file mode 100644 index 0000000..c1a9cc6 --- /dev/null +++ b/src/boot/track-disattivato-riutilizzare.ts @@ -0,0 +1,8 @@ +// import something here +import track from '../track' + +// leave the export, even if you don't use it +export default ({ app, router, store, Vue }) => { + // something to do + Vue.prototype.$track = track +} diff --git a/src/boot/vue-idb.ts b/src/boot/vue-idb.ts index 3b1f502..afa362b 100644 --- a/src/boot/vue-idb.ts +++ b/src/boot/vue-idb.ts @@ -5,16 +5,3 @@ export default ({ Vue }) => { Vue.use(VueIdb) } - - -/* - - -export default new VueIdb({ - version: 1, - database: 'test', - schemas: [ - { categories: '++_id, sub_categ_id, descr_it' } - ] -}) -*/ diff --git a/src/globalroutines/index.ts b/src/globalroutines/index.ts index 1ae91ce..782d89e 100644 --- a/src/globalroutines/index.ts +++ b/src/globalroutines/index.ts @@ -1,12 +1,12 @@ import indexdb from './indexdb' -import { GlobalStore } from "../store/Modules"; +import { GlobalStore } from '../store/Modules' export default async (context, cmd, table, data = null, id = '') => { const descr = data !== null ? data.descr : '' // console.log('globalroutines', cmd, table, descr, id) return await indexdb(context, cmd, table, data, id) .then(ris => { - setTimeout(function () { + setTimeout(() => { GlobalStore.state.connData.uploading_indexeddb = 0 GlobalStore.state.connData.downloading_indexeddb = 0 }, 1000) @@ -14,7 +14,7 @@ export default async (context, cmd, table, data = null, id = '') => { } ).catch(err => { - setTimeout(function () { + setTimeout(() => { GlobalStore.state.connData.uploading_indexeddb = (GlobalStore.state.connData.uploading_indexeddb === 1) ? -1 : GlobalStore.state.connData.uploading_indexeddb GlobalStore.state.connData.downloading_indexeddb = (GlobalStore.state.connData.downloading_indexeddb === 1) ? -1 : GlobalStore.state.connData.downloading_indexeddb }, 1000) diff --git a/src/index.template.html b/src/index.template.html index ba11dae..2dcfdeb 100644 --- a/src/index.template.html +++ b/src/index.template.html @@ -1,10 +1,10 @@ - <%= htmlWebpackPlugin.options.productName %> + <%= htmlWebpackPlugin.options.appName %> - + - + - + + diff --git a/src/root/home/home.scss b/src/root/home/home.scss index 9c4804b..89c1f9f 100644 --- a/src/root/home/home.scss +++ b/src/root/home/home.scss @@ -303,7 +303,17 @@ body.mobile .landing:before { padding: 10px; } +.carousel_img_3 { + //background-image: url(../../statics/images/cibo_sano.jpg); + background-size: cover !important; + background-position: 50% center !important; + background-repeat: no-repeat !important; +} + + @media (max-width: 718px) { + // PER VERSIONE MOBILE + .landing__hero { text-align: center } @@ -360,6 +370,14 @@ body.mobile .landing:before { .text-subtitle3 { font-size: 0.75rem; } + + .carousel_img_3 { + //background-image: url(../../statics/images/cibo_sano.jpg); + background-size: 620px 620px !important; + background-position: 50% top !important; + background-repeat: no-repeat !important; + } + } .custom-caption { @@ -368,3 +386,4 @@ body.mobile .landing:before { color: white; background-color: rgba(0, 0, 0, .3); } + diff --git a/src/root/home/home.ts b/src/root/home/home.ts index 981ec5d..998000f 100644 --- a/src/root/home/home.ts +++ b/src/root/home/home.ts @@ -35,6 +35,7 @@ export default class Home extends Vue { public $q public polling public slide = 'first' + public animare: number = 0 constructor() { super() @@ -64,6 +65,7 @@ export default class Home extends Vue { clearInterval(this.polling) } public created() { + this.animare = process.env.DEV ? 0 : 8000 GlobalStore.actions.prova() } diff --git a/src/root/home/home.vue b/src/root/home/home.vue index 2dbd9b6..a09d4c3 100644 --- a/src/root/home/home.vue +++ b/src/root/home/home.vue @@ -5,7 +5,7 @@
Famous City
--> - +
diff --git a/src/statics/i18n.js b/src/statics/i18n.js index 5e0e938..03c7433 100644 --- a/src/statics/i18n.js +++ b/src/statics/i18n.js @@ -481,7 +481,7 @@ const messages = { underconstruction: 'App in construction...', myDescriz: '', sottoTitoloApp: 'The first Real Social', - sottoTitoloApp2: 'Free, Fair and solidarity', + sottoTitoloApp2: 'Free, Fair and Equitable', sottoTitoloApp3: 'Where the conscience and community help live', sottoTitoloApp4: 'Free and without advertising', }, diff --git a/src/statics/js/track.js b/src/statics/js/track.js new file mode 100644 index 0000000..0e7838c --- /dev/null +++ b/src/statics/js/track.js @@ -0,0 +1,43 @@ +function geturl() { + const miaurl = document.location.href + + if (miaurl.includes('test.')) { + return 'https://test.freeplanet.app/' + } else { + if (miaurl.includes('localhost')) { + return 'http://localhost:8080/' + } else { + return 'https://freeplanet.app/' + } + } +} + +function getidtrack() { + const miaurl = document.location.href + + if (miaurl.includes('test.') || miaurl.includes('localhost')) { + return '4c40a07bc88a9c50c9b70dc9c5cd8e2e' + } else { + return '9853abef079fc8330ab188a9cbf07a0c' + } +} + + +var owa_baseUrl = geturl() + 'owa/'; +if (owa_cmds) + var owa_cmds = []; +else + var owa_cmds = owa_cmds || []; +owa_cmds.push(['setSiteId', getidtrack()]); +owa_cmds.push(['trackPageView']); +owa_cmds.push(['trackClicks']); + +(function () { + var _owa = document.createElement('script'); + _owa.type = 'text/javascript'; + _owa.async = true; + owa_baseUrl = ('https:' == document.location.protocol ? window.owa_baseSecUrl || owa_baseUrl.replace(/http:/, 'https:') : owa_baseUrl); + _owa.src = owa_baseUrl + 'modules/base/js/owa.tracker-combined-min.js'; + var _owa_s = document.getElementsByTagName('script')[0]; + _owa_s.parentNode.insertBefore(_owa, _owa_s); +}()); diff --git a/src/track/index.ts b/src/track/index.ts new file mode 100644 index 0000000..a8bede0 --- /dev/null +++ b/src/track/index.ts @@ -0,0 +1,50 @@ +// Start Open Web Analytics Tracker +export default ({ app, router, store, Vue }) => { + console.log('Track 1') + function geturl() { + const miaurl = document.location.href + + if (miaurl.includes('test.')) { + return 'https://test.freeplanet.app/' + } else { + if (miaurl.includes('localhost')) { + return 'http://localhost:8080/' + } else { + return 'https://freeplanet.app/' + } + } + } + + let owa_cmds + + if (owa_cmds) { + owa_cmds = owa_cmds || [] + } + else { + owa_cmds = [] + } + + let idsite = '' + if (process.env.PROD) { + idsite = '9853abef079fc8330ab188a9cbf07a0c' + } else { + // TEST + idsite = '4c40a07bc88a9c50c9b70dc9c5cd8e2e' + } + + owa_cmds.push(['setSiteId', idsite]) + owa_cmds.push(['trackPageView']) + owa_cmds.push(['trackClicks']) + + const owa_baseUrl = geturl() + 'owa/' + console.log('******* setTrack', 'owa_baseUrl:', owa_baseUrl) + const _owa = document.createElement('script') + _owa.type = 'text/javascript' + _owa.async = true + + // owa_baseUrl = ('https:' === document.location.protocol ? window.owa_baseSecUrl || owa_baseUrl.replace(/http:/, 'https:') : owa_baseUrl) + + _owa.src = owa_baseUrl + 'modules/base/js/owa.tracker-combined-min.js' + const _owa_s = document.getElementsByTagName('script')[0] + _owa_s.parentNode.insertBefore(_owa, _owa_s) +} diff --git a/src/typings/libs/errorHandler.d.ts b/src/typings/libs/errorHandler.d.ts index 5c6cd10..b63a644 100644 --- a/src/typings/libs/errorHandler.d.ts +++ b/src/typings/libs/errorHandler.d.ts @@ -5,4 +5,3 @@ declare module 'vue/types/vue' { $errorHandler: errorHandler } } - diff --git a/src/typings/libs/track.d.ts b/src/typings/libs/track.d.ts new file mode 100644 index 0000000..5c3449e --- /dev/null +++ b/src/typings/libs/track.d.ts @@ -0,0 +1,8 @@ +import { track } from '../../track' + +declare module 'vue/types/vue' { + interface Vue { + $track: track + } +} +