Skip to content

Commit

Permalink
[MyDownloads] Setup the new Kolibri module
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Feb 23, 2023
1 parent 5ea140d commit 3861e4e
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 0 deletions.
Empty file.
1 change: 1 addition & 0 deletions kolibri/plugins/my_downloads/api_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
urlpatterns = []
25 changes: 25 additions & 0 deletions kolibri/plugins/my_downloads/assets/src/app.js
Original file line number Diff line number Diff line change
@@ -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();
21 changes: 21 additions & 0 deletions kolibri/plugins/my_downloads/assets/src/modules/pluginModule.js
Original file line number Diff line number Diff line change
@@ -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;
},
},
};
16 changes: 16 additions & 0 deletions kolibri/plugins/my_downloads/assets/src/routes.js
Original file line number Diff line number Diff line change
@@ -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);
// }
// },
},
];
20 changes: 20 additions & 0 deletions kolibri/plugins/my_downloads/assets/src/views/MyDownloads.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>

<div>
<h1>My Downloads</h1>
<p>Downloaded files will appear here.</p>
</div>

</template>


<script>
export default {
name: 'MyDownloads',
};
</script>


<style lang="scss"></style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>

<CoreMenuOption
:label="$tr('profile')"
:link="url"
icon="profile"
/>

</template>


<script>
import { UserKinds, NavComponentSections } from 'kolibri.coreVue.vuex.constants';
import CoreMenuOption from 'kolibri.coreVue.components.CoreMenuOption';
import navComponents from 'kolibri.utils.navComponents';
import urls from 'kolibri.urls';
const component = {
name: 'MyDownloadsSideNavEntry',
components: {
CoreMenuOption,
},
$trs: {
profile: 'Profile',
},
computed: {
url() {
return urls['kolibri:kolibri.plugins.my_downloads:my_downloads']();
},
},
role: UserKinds.LEARNER,
priority: 10,
section: NavComponentSections.ACCOUNT,
};
navComponents.register(component);
export default component;
</script>
14 changes: 14 additions & 0 deletions kolibri/plugins/my_downloads/buildConfig.js
Original file line number Diff line number Diff line change
@@ -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',
},
},
];
30 changes: 30 additions & 0 deletions kolibri/plugins/my_downloads/kolibri_plugin.py
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "kolibri/base.html" %}
{% load webpack_tags %}
{% block content %}
{% webpack_asset 'kolibri.plugins.my_downloads.app' %}
{% endblock %}
5 changes: 5 additions & 0 deletions kolibri/plugins/my_downloads/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.conf.urls import url

from . import views

urlpatterns = [url(r"^$", views.MyDownloadsView.as_view(), name="my_downloads")]
13 changes: 13 additions & 0 deletions kolibri/plugins/my_downloads/views.py
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions kolibri/utils/build_config/default_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3861e4e

Please sign in to comment.