-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MyDownloads] Setup the new Kolibri module
- Loading branch information
1 parent
5ea140d
commit 3861e4e
Showing
13 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
urlpatterns = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
kolibri/plugins/my_downloads/assets/src/modules/pluginModule.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
kolibri/plugins/my_downloads/assets/src/views/MyDownloads.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
41 changes: 41 additions & 0 deletions
41
kolibri/plugins/my_downloads/assets/src/views/MyDownloadsSideNavEntry.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
5 changes: 5 additions & 0 deletions
5
kolibri/plugins/my_downloads/templates/my_downloads/my_downloads.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters