diff --git a/kolibri/plugins/my_downloads/__init__.py b/kolibri/plugins/my_downloads/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/kolibri/plugins/my_downloads/api_urls.py b/kolibri/plugins/my_downloads/api_urls.py new file mode 100644 index 00000000000..637600f58aa --- /dev/null +++ b/kolibri/plugins/my_downloads/api_urls.py @@ -0,0 +1 @@ +urlpatterns = [] diff --git a/kolibri/plugins/my_downloads/assets/src/app.js b/kolibri/plugins/my_downloads/assets/src/app.js new file mode 100644 index 00000000000..fb1fdecd0e6 --- /dev/null +++ b/kolibri/plugins/my_downloads/assets/src/app.js @@ -0,0 +1,25 @@ +import router from 'kolibri.coreVue.router'; +import PageRoot from 'kolibri.coreVue.components.PageRoot'; +import routes from './routes'; +import pluginModule from './modules/pluginModule'; +import KolibriApp from 'kolibri_app'; + +class MyDownloadsModule extends KolibriApp { + get routes() { + return routes; + } + get RootVue() { + return PageRoot; + } + get pluginModule() { + return pluginModule; + } + ready() { + router.afterEach((toRoute, fromRoute) => { + this.store.dispatch('resetModuleState', { toRoute, fromRoute }); + }); + super.ready(); + } +} + +export default new MyDownloadsModule(); diff --git a/kolibri/plugins/my_downloads/assets/src/modules/pluginModule.js b/kolibri/plugins/my_downloads/assets/src/modules/pluginModule.js new file mode 100644 index 00000000000..35d1db353a4 --- /dev/null +++ b/kolibri/plugins/my_downloads/assets/src/modules/pluginModule.js @@ -0,0 +1,21 @@ +export default { + state() { + return { + test: '', + }; + }, + actions: { + reset(store) { + store.commit('CORE_SET_PAGE_LOADING', false); + store.commit('CORE_SET_ERROR', null); + }, + resetModuleState(store) { + store.commit('profile/RESET_STATE'); + }, + }, + mutations: { + SET_Test(state, test) { + state.test = test; + }, + }, +}; diff --git a/kolibri/plugins/my_downloads/assets/src/routes.js b/kolibri/plugins/my_downloads/assets/src/routes.js new file mode 100644 index 00000000000..f36dfccacc6 --- /dev/null +++ b/kolibri/plugins/my_downloads/assets/src/routes.js @@ -0,0 +1,16 @@ +import MyDownloadsPage from './views/MyDownloads'; + +export default [ + { + path: '/', + name: 'MY_DOWNLOADS', + component: MyDownloadsPage, + // beforeEnter(to, from, next) { + // if (!store.getters.isUserLoggedIn) { + // redirectBrowser(); + // } else { + // preload(next); + // } + // }, + }, +]; diff --git a/kolibri/plugins/my_downloads/assets/src/views/MyDownloads.vue b/kolibri/plugins/my_downloads/assets/src/views/MyDownloads.vue new file mode 100644 index 00000000000..66335f3aa9c --- /dev/null +++ b/kolibri/plugins/my_downloads/assets/src/views/MyDownloads.vue @@ -0,0 +1,20 @@ + + + + My Downloads + Downloaded files will appear here. + + + + + + + + + diff --git a/kolibri/plugins/my_downloads/assets/src/views/MyDownloadsSideNavEntry.vue b/kolibri/plugins/my_downloads/assets/src/views/MyDownloadsSideNavEntry.vue new file mode 100644 index 00000000000..d3bb9e5ea59 --- /dev/null +++ b/kolibri/plugins/my_downloads/assets/src/views/MyDownloadsSideNavEntry.vue @@ -0,0 +1,41 @@ + + + + + + + + diff --git a/kolibri/plugins/my_downloads/buildConfig.js b/kolibri/plugins/my_downloads/buildConfig.js new file mode 100644 index 00000000000..a8f741a300c --- /dev/null +++ b/kolibri/plugins/my_downloads/buildConfig.js @@ -0,0 +1,14 @@ +module.exports = [ + { + bundle_id: 'app', + webpack_config: { + entry: './assets/src/app.js', + }, + }, + { + bundle_id: 'my_downloads_side_nav', + webpack_config: { + entry: './assets/src/views/MyDownloadsSideNavEntry.vue', + }, + }, +]; diff --git a/kolibri/plugins/my_downloads/kolibri_plugin.py b/kolibri/plugins/my_downloads/kolibri_plugin.py new file mode 100644 index 00000000000..ca0f9cac092 --- /dev/null +++ b/kolibri/plugins/my_downloads/kolibri_plugin.py @@ -0,0 +1,30 @@ +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +from kolibri.core.hooks import NavigationHook +from kolibri.core.webpack import hooks as webpack_hooks +from kolibri.plugins import KolibriPluginBase +from kolibri.plugins.hooks import register_hook +from kolibri.utils import translation +from kolibri.utils.translation import ugettext as _ + + +class MyDownloads(KolibriPluginBase): + translated_view_urls = "urls" + untranslated_view_urls = "api_urls" + can_manage_while_running = True + + def name(self, lang): + with translation.override(lang): + return _("My downloads") + + +@register_hook +class MyDownloadsAsset(webpack_hooks.WebpackBundleHook): + bundle_id = "app" + + +@register_hook +class MyDownloadsNavAction(NavigationHook): + bundle_id = "my_downloads_side_nav" diff --git a/kolibri/plugins/my_downloads/templates/my_downloads/my_downloads.html b/kolibri/plugins/my_downloads/templates/my_downloads/my_downloads.html new file mode 100644 index 00000000000..b210985254d --- /dev/null +++ b/kolibri/plugins/my_downloads/templates/my_downloads/my_downloads.html @@ -0,0 +1,5 @@ +{% extends "kolibri/base.html" %} +{% load webpack_tags %} +{% block content %} + {% webpack_asset 'kolibri.plugins.my_downloads.app' %} +{% endblock %} diff --git a/kolibri/plugins/my_downloads/urls.py b/kolibri/plugins/my_downloads/urls.py new file mode 100644 index 00000000000..989147a9c23 --- /dev/null +++ b/kolibri/plugins/my_downloads/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [url(r"^$", views.MyDownloadsView.as_view(), name="my_downloads")] diff --git a/kolibri/plugins/my_downloads/views.py b/kolibri/plugins/my_downloads/views.py new file mode 100644 index 00000000000..5e221052663 --- /dev/null +++ b/kolibri/plugins/my_downloads/views.py @@ -0,0 +1,13 @@ +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +from django.utils.decorators import method_decorator +from django.views.generic.base import TemplateView + +from kolibri.core.decorators import cache_no_user_data + + +@method_decorator(cache_no_user_data, name="dispatch") +class MyDownloadsView(TemplateView): + template_name = "my_downloads/my_downloads.html" diff --git a/kolibri/utils/build_config/default_plugins.py b/kolibri/utils/build_config/default_plugins.py index c2892a53e50..a513d70aeba 100644 --- a/kolibri/utils/build_config/default_plugins.py +++ b/kolibri/utils/build_config/default_plugins.py @@ -7,6 +7,7 @@ "kolibri.plugins.facility", "kolibri.plugins.learn", "kolibri.plugins.media_player", + "kolibri.plugins.my_downloads", "kolibri.plugins.pdf_viewer", "kolibri.plugins.perseus_viewer", "kolibri.plugins.setup_wizard",
Downloaded files will appear here.