From bfc5487d402287cb6b3cb2f70390f10033a1eae3 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Fri, 15 Jun 2018 18:29:21 +0930 Subject: [PATCH 01/12] moved config to http-vue-loader --- .../slim/static/js/lib/http-vue-loader.min.js | 470 ++++++++++++++++++ .../slim/static/js/templates/config.vue | 58 +++ themes-default/slim/views/layouts/main.mako | 1 + .../dark/assets/js/lib/http-vue-loader.min.js | 470 ++++++++++++++++++ themes/dark/assets/js/templates/config.vue | 58 +++ themes/dark/templates/layouts/main.mako | 1 + .../assets/js/lib/http-vue-loader.min.js | 470 ++++++++++++++++++ themes/light/assets/js/templates/config.vue | 58 +++ themes/light/templates/layouts/main.mako | 1 + 9 files changed, 1587 insertions(+) create mode 100644 themes-default/slim/static/js/lib/http-vue-loader.min.js create mode 100644 themes-default/slim/static/js/templates/config.vue create mode 100644 themes/dark/assets/js/lib/http-vue-loader.min.js create mode 100644 themes/dark/assets/js/templates/config.vue create mode 100644 themes/light/assets/js/lib/http-vue-loader.min.js create mode 100644 themes/light/assets/js/templates/config.vue diff --git a/themes-default/slim/static/js/lib/http-vue-loader.min.js b/themes-default/slim/static/js/lib/http-vue-loader.min.js new file mode 100644 index 0000000000..6e24a0cdf4 --- /dev/null +++ b/themes-default/slim/static/js/lib/http-vue-loader.min.js @@ -0,0 +1,470 @@ +(function umd(root,factory){ + if(typeof module==='object' && typeof exports === 'object' ) + module.exports=factory() + else if(typeof define==='function' && define.amd) + define([],factory) + else + root.httpVueLoader=factory() +})(this,function factory() { + 'use strict'; + + var scopeIndex = 0; + + StyleContext.prototype = { + + withBase: function(callback) { + + var tmpBaseElt; + if ( this.component.baseURI ) { + + // firefox and chrome need the to be set while inserting or modifying diff --git a/themes-default/slim/views/layouts/main.mako b/themes-default/slim/views/layouts/main.mako index d128c9cf3b..eb563a5032 100644 --- a/themes-default/slim/views/layouts/main.mako +++ b/themes-default/slim/views/layouts/main.mako @@ -114,6 +114,7 @@ ## @NOTE: These will be usable on all pages %> + diff --git a/themes/dark/assets/js/lib/http-vue-loader.min.js b/themes/dark/assets/js/lib/http-vue-loader.min.js new file mode 100644 index 0000000000..6e24a0cdf4 --- /dev/null +++ b/themes/dark/assets/js/lib/http-vue-loader.min.js @@ -0,0 +1,470 @@ +(function umd(root,factory){ + if(typeof module==='object' && typeof exports === 'object' ) + module.exports=factory() + else if(typeof define==='function' && define.amd) + define([],factory) + else + root.httpVueLoader=factory() +})(this,function factory() { + 'use strict'; + + var scopeIndex = 0; + + StyleContext.prototype = { + + withBase: function(callback) { + + var tmpBaseElt; + if ( this.component.baseURI ) { + + // firefox and chrome need the to be set while inserting or modifying diff --git a/themes/dark/templates/layouts/main.mako b/themes/dark/templates/layouts/main.mako index d128c9cf3b..eb563a5032 100644 --- a/themes/dark/templates/layouts/main.mako +++ b/themes/dark/templates/layouts/main.mako @@ -114,6 +114,7 @@ ## @NOTE: These will be usable on all pages %> + diff --git a/themes/light/assets/js/lib/http-vue-loader.min.js b/themes/light/assets/js/lib/http-vue-loader.min.js new file mode 100644 index 0000000000..6e24a0cdf4 --- /dev/null +++ b/themes/light/assets/js/lib/http-vue-loader.min.js @@ -0,0 +1,470 @@ +(function umd(root,factory){ + if(typeof module==='object' && typeof exports === 'object' ) + module.exports=factory() + else if(typeof define==='function' && define.amd) + define([],factory) + else + root.httpVueLoader=factory() +})(this,function factory() { + 'use strict'; + + var scopeIndex = 0; + + StyleContext.prototype = { + + withBase: function(callback) { + + var tmpBaseElt; + if ( this.component.baseURI ) { + + // firefox and chrome need the to be set while inserting or modifying diff --git a/themes/light/templates/layouts/main.mako b/themes/light/templates/layouts/main.mako index d128c9cf3b..eb563a5032 100644 --- a/themes/light/templates/layouts/main.mako +++ b/themes/light/templates/layouts/main.mako @@ -114,6 +114,7 @@ ## @NOTE: These will be usable on all pages %> + From ff118dc6407ea19cf6362681709e1a9c95d71c8d Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Fri, 15 Jun 2018 18:37:56 +0930 Subject: [PATCH 02/12] switch config component to vue SFC --- themes-default/slim/views/config.mako | 111 +------------------------- themes/dark/templates/config.mako | 111 +------------------------- themes/light/templates/config.mako | 111 +------------------------- 3 files changed, 3 insertions(+), 330 deletions(-) diff --git a/themes-default/slim/views/config.mako b/themes-default/slim/views/config.mako index e2bebc0d0f..012ceb1c22 100644 --- a/themes-default/slim/views/config.mako +++ b/themes-default/slim/views/config.mako @@ -1,121 +1,12 @@ <%inherit file="/layouts/main.mako"/> <%block name="scripts"> - -<%block name="css"> - - <%block name="content">

Medusa Configuration

diff --git a/themes/dark/templates/config.mako b/themes/dark/templates/config.mako index e2bebc0d0f..012ceb1c22 100644 --- a/themes/dark/templates/config.mako +++ b/themes/dark/templates/config.mako @@ -1,121 +1,12 @@ <%inherit file="/layouts/main.mako"/> <%block name="scripts"> - -<%block name="css"> - - <%block name="content">

Medusa Configuration

diff --git a/themes/light/templates/config.mako b/themes/light/templates/config.mako index e2bebc0d0f..012ceb1c22 100644 --- a/themes/light/templates/config.mako +++ b/themes/light/templates/config.mako @@ -1,121 +1,12 @@ <%inherit file="/layouts/main.mako"/> <%block name="scripts"> - -<%block name="css"> - - <%block name="content">

Medusa Configuration

From f535c3d89c28e97861ec5cf6cb36f8d725d21fb2 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Sun, 1 Jul 2018 17:17:21 +0930 Subject: [PATCH 03/12] finished conversion --- medusa/server/web/config/handler.py | 2 +- themes-default/slim/static/js/router.js | 47 +++++++++++++++++++ .../slim/static/js/templates/config.vue | 3 -- .../slim/static/js/templates/http/404.vue | 3 ++ themes-default/slim/views/config.mako | 13 ----- themes-default/slim/views/index.mako | 5 ++ themes-default/slim/views/layouts/main.mako | 10 +--- themes/dark/assets/js/router.js | 47 +++++++++++++++++++ themes/dark/assets/js/router.js.map | 1 + themes/dark/assets/js/templates/config.vue | 3 -- themes/dark/assets/js/templates/http/404.vue | 3 ++ themes/dark/templates/config.mako | 12 +---- themes/dark/templates/index.mako | 5 ++ themes/dark/templates/layouts/main.mako | 10 +--- themes/light/assets/js/router.js | 47 +++++++++++++++++++ themes/light/assets/js/router.js.map | 1 + themes/light/assets/js/templates/config.vue | 3 -- themes/light/assets/js/templates/http/404.vue | 3 ++ themes/light/templates/config.mako | 12 +---- themes/light/templates/index.mako | 5 ++ themes/light/templates/layouts/main.mako | 10 +--- 21 files changed, 178 insertions(+), 67 deletions(-) create mode 100644 themes-default/slim/static/js/router.js create mode 100644 themes-default/slim/static/js/templates/http/404.vue delete mode 100644 themes-default/slim/views/config.mako create mode 100644 themes/dark/assets/js/router.js create mode 100644 themes/dark/assets/js/router.js.map create mode 100644 themes/dark/assets/js/templates/http/404.vue create mode 100644 themes/light/assets/js/router.js create mode 100644 themes/light/assets/js/router.js.map create mode 100644 themes/light/assets/js/templates/http/404.vue diff --git a/medusa/server/web/config/handler.py b/medusa/server/web/config/handler.py index e9a96e8857..7b3a45bfc8 100644 --- a/medusa/server/web/config/handler.py +++ b/medusa/server/web/config/handler.py @@ -46,7 +46,7 @@ def index(self): """ Render the Help & Info page """ - t = PageTemplate(rh=self, filename='config.mako') + t = PageTemplate(rh=self, filename='index.mako') try: import pwd diff --git a/themes-default/slim/static/js/router.js b/themes-default/slim/static/js/router.js new file mode 100644 index 0000000000..af4810bc4a --- /dev/null +++ b/themes-default/slim/static/js/router.js @@ -0,0 +1,47 @@ +const VueRouter = window.vueRouter; +const { routes, httpVueLoader } = window; + +if (!window.router) { + const configComponent = httpVueLoader('js/templates/config.vue'); + const notFoundComponent = httpVueLoader('js/templates/http/404.vue'); + + const router = new VueRouter({ + base: document.body.getAttribute('api-root').replace('api/v2/', ''), + mode: 'history', + routes: Object.assign(routes || [], [{ + path: '/config', + name: 'config', + meta: { + title: 'Help & Info', + header: 'Medusa Configuration' + }, + component: configComponent + }, { + path: '/not-found', + name: 'not-found', + meta: { + title: '404', + header: '404 - page not found' + }, + component: notFoundComponent + }, { + path: '*', + redirect: '/not-found' + }]) + }); + + router.beforeEach((to, from, next) => { + const { meta } = to; + const { title } = meta; + + // If there's no title then it's not a .vue route so skip + if (title) { + document.title = `${to.meta.title} | Medusa`; + } + + // Always call next otherwise the will be empty + next(); + }); + + window.router = router; +} diff --git a/themes-default/slim/static/js/templates/config.vue b/themes-default/slim/static/js/templates/config.vue index faf9d1b483..be27cfb6b6 100644 --- a/themes-default/slim/static/js/templates/config.vue +++ b/themes-default/slim/static/js/templates/config.vue @@ -37,9 +37,6 @@ - -<%block name="content"> -

Medusa Configuration

- - diff --git a/themes-default/slim/views/index.mako b/themes-default/slim/views/index.mako index e69de29bb2..672544e1fd 100644 --- a/themes-default/slim/views/index.mako +++ b/themes-default/slim/views/index.mako @@ -0,0 +1,5 @@ +<%inherit file="/layouts/main.mako"/> +<%block name="content"> +

{{$route.meta.header}}

+ + diff --git a/themes-default/slim/views/layouts/main.mako b/themes-default/slim/views/layouts/main.mako index eb563a5032..5fb896aeec 100644 --- a/themes-default/slim/views/layouts/main.mako +++ b/themes-default/slim/views/layouts/main.mako @@ -182,19 +182,13 @@ } <%block name="scripts" /> + - <%block name="content"> -

Medusa Configuration

- +

{{$route.meta.header}}

+ diff --git a/themes/dark/templates/index.mako b/themes/dark/templates/index.mako index e69de29bb2..672544e1fd 100644 --- a/themes/dark/templates/index.mako +++ b/themes/dark/templates/index.mako @@ -0,0 +1,5 @@ +<%inherit file="/layouts/main.mako"/> +<%block name="content"> +

{{$route.meta.header}}

+ + diff --git a/themes/dark/templates/layouts/main.mako b/themes/dark/templates/layouts/main.mako index eb563a5032..5fb896aeec 100644 --- a/themes/dark/templates/layouts/main.mako +++ b/themes/dark/templates/layouts/main.mako @@ -182,19 +182,13 @@ } <%block name="scripts" /> + - <%block name="content"> -

Medusa Configuration

- +

{{$route.meta.header}}

+ diff --git a/themes/light/templates/index.mako b/themes/light/templates/index.mako index e69de29bb2..672544e1fd 100644 --- a/themes/light/templates/index.mako +++ b/themes/light/templates/index.mako @@ -0,0 +1,5 @@ +<%inherit file="/layouts/main.mako"/> +<%block name="content"> +

{{$route.meta.header}}

+ + diff --git a/themes/light/templates/layouts/main.mako b/themes/light/templates/layouts/main.mako index eb563a5032..5fb896aeec 100644 --- a/themes/light/templates/layouts/main.mako +++ b/themes/light/templates/layouts/main.mako @@ -182,19 +182,13 @@ } <%block name="scripts" /> + - + diff --git a/themes/dark/templates/layouts/main.mako b/themes/dark/templates/layouts/main.mako index 5fb896aeec..78d16e0df6 100644 --- a/themes/dark/templates/layouts/main.mako +++ b/themes/dark/templates/layouts/main.mako @@ -114,7 +114,7 @@ ## @NOTE: These will be usable on all pages %> - + diff --git a/themes/light/templates/layouts/main.mako b/themes/light/templates/layouts/main.mako index 5fb896aeec..78d16e0df6 100644 --- a/themes/light/templates/layouts/main.mako +++ b/themes/light/templates/layouts/main.mako @@ -114,7 +114,7 @@ ## @NOTE: These will be usable on all pages %> - + From 460cba6ff564f0f8e2cb3ac862861a7cba6da60d Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Mon, 2 Jul 2018 16:07:46 +0930 Subject: [PATCH 08/12] add missing __future__ import --- medusa/server/web/config/handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/medusa/server/web/config/handler.py b/medusa/server/web/config/handler.py index daefa77862..15d5e38678 100644 --- a/medusa/server/web/config/handler.py +++ b/medusa/server/web/config/handler.py @@ -2,6 +2,8 @@ """Base handler for Config pages.""" +from __future__ import unicode_literals + from medusa.server.web.core import PageTemplate, WebRoot from tornroutes import route From 90e3046aad8100e0eea9ccea2d956eb106ee491f Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Tue, 3 Jul 2018 02:12:55 +0930 Subject: [PATCH 09/12] remove unneeded dispatch and sync themes --- .../slim/static/js/templates/config.vue | 4 -- themes/dark/assets/js/templates/config.vue | 4 -- themes/light/assets/js/templates/config.vue | 44 +++++++++---------- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/themes-default/slim/static/js/templates/config.vue b/themes-default/slim/static/js/templates/config.vue index 7974d46dbb..5fd18cc526 100644 --- a/themes-default/slim/static/js/templates/config.vue +++ b/themes-default/slim/static/js/templates/config.vue @@ -51,10 +51,6 @@ const { store } = window; module.exports = { name: 'config', computed: store.mapState(['config']), - mounted() { - const { $store } = this; - $store.dispatch('getConfig'); - }, methods: { prettyPrintJSON: str => JSON.stringify(str, undefined, 4) } diff --git a/themes/dark/assets/js/templates/config.vue b/themes/dark/assets/js/templates/config.vue index 7974d46dbb..5fd18cc526 100644 --- a/themes/dark/assets/js/templates/config.vue +++ b/themes/dark/assets/js/templates/config.vue @@ -51,10 +51,6 @@ const { store } = window; module.exports = { name: 'config', computed: store.mapState(['config']), - mounted() { - const { $store } = this; - $store.dispatch('getConfig'); - }, methods: { prettyPrintJSON: str => JSON.stringify(str, undefined, 4) } diff --git a/themes/light/assets/js/templates/config.vue b/themes/light/assets/js/templates/config.vue index bf834ff8ba..5fd18cc526 100644 --- a/themes/light/assets/js/templates/config.vue +++ b/themes/light/assets/js/templates/config.vue @@ -5,42 +5,42 @@ Medusa Info: Branch: - {{branch}} + {{config.branch}} Unknown
Commit: - {{commitHash}} + {{config.commitHash}} Unknown
Version: - {{release}} + {{config.release}} Unknown
Database: - {{databaseVersion.major}}.{{databaseVersion.minor}} + {{config.databaseVersion.major}}.{{config.databaseVersion.minor}} Unknown - Python Version:{{pythonVersion}} - SSL Version:{{sslVersion}} - OS:{{os}} - Locale:{{locale}} + Python Version:{{config.pythonVersion}} + SSL Version:{{config.sslVersion}} + OS:{{config.os}} + Locale:{{config.locale}}       - User:{{localUser}} - Program Folder:{{programDir}} - Config File:{{configFile}} - Database File:{{dbPath}} - Cache Folder:{{cacheDir}} - Log Folder:{{logDir}} - Arguments:
{{prettyPrintJSON(appArgs)}}
- Web Root:{{webRoot}} + User:{{config.localUser}} + Program Folder:{{config.programDir}} + Config File:{{config.configFile}} + Database File:{{config.dbPath}} + Cache Folder:{{config.cacheDir}} + Log Folder:{{config.logDir}} + Arguments:
{{prettyPrintJSON(config.appArgs)}}
+ Web Root:{{config.webRoot}}       - Website:{{githubUrl}} - Wiki:{{wikiUrl}} - Source:{{sourceUrl}} - IRC Chat:#pymedusa on irc.freenode.net + Website:{{config.githubUrl}} + Wiki:{{config.wikiUrl}} + Source:{{config.sourceUrl}} + IRC Chat:#pymedusa on irc.freenode.net @@ -51,10 +51,6 @@ const { store } = window; module.exports = { name: 'config', computed: store.mapState(['config']), - mounted() { - const { $store } = this; - $store.dispatch('getConfig'); - }, methods: { prettyPrintJSON: str => JSON.stringify(str, undefined, 4) } From b76c8bd7000fbd4bcadfe402883fb692a4fe72ac Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Tue, 3 Jul 2018 11:35:31 +0930 Subject: [PATCH 10/12] remove old config.mako --- themes/dark/templates/config.mako | 5 ----- themes/light/templates/config.mako | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 themes/dark/templates/config.mako delete mode 100644 themes/light/templates/config.mako diff --git a/themes/dark/templates/config.mako b/themes/dark/templates/config.mako deleted file mode 100644 index 672544e1fd..0000000000 --- a/themes/dark/templates/config.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%inherit file="/layouts/main.mako"/> -<%block name="content"> -

{{$route.meta.header}}

- - diff --git a/themes/light/templates/config.mako b/themes/light/templates/config.mako deleted file mode 100644 index 672544e1fd..0000000000 --- a/themes/light/templates/config.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%inherit file="/layouts/main.mako"/> -<%block name="content"> -

{{$route.meta.header}}

- - From 6963ada11c0609526a6d8229d157ea715e5ac278 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Tue, 3 Jul 2018 11:36:20 +0930 Subject: [PATCH 11/12] move computed config to this.store --- themes-default/slim/static/js/templates/config.vue | 9 ++++++--- themes/dark/assets/js/templates/config.vue | 9 ++++++--- themes/light/assets/js/templates/config.vue | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/themes-default/slim/static/js/templates/config.vue b/themes-default/slim/static/js/templates/config.vue index 5fd18cc526..3831194985 100644 --- a/themes-default/slim/static/js/templates/config.vue +++ b/themes-default/slim/static/js/templates/config.vue @@ -46,11 +46,14 @@