-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete app plugin - transfer all functionality to core hooks.
- Loading branch information
Showing
32 changed files
with
369 additions
and
433 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
Testing Kolibri with app plugin enabled | ||
======================================= | ||
Testing Kolibri in app mode | ||
=========================== | ||
|
||
The Kolibri app plugin | ||
---------------------- | ||
App mode | ||
-------- | ||
|
||
The Kolibri app plugin is designed to provide features and behavior with the mobile app user in mind. In order to test or develop Kolibri in this mode, there are commands that can be used to initialize Kolibri as needed. | ||
Kolibri app mode is designed to provide features and behavior with the mobile app user in mind. In order to test or develop Kolibri in this mode, a browser session can be set to app mode. | ||
|
||
By running the command: `yarn app-python-devserver` you will start Kolibri in development mode. You can also run `yarn app-devserver` to run the frontend devserver in parallel. | ||
|
||
When you start the server with these commands, you will see a message with a URL pointing to `http://127.0.0.1:8000/app/api/initialize/<some token>` - visiting this URL will set your browser so that it can interact with Kolibri as it runs with the app plugin. **You will only have to do this once unless you clear your browser storage.** | ||
When you start the server, you will see a message with a URL pointing to `http://127.0.0.1:8000/app/api/initialize/<some token>` - visiting this URL will set your browser so that it can interact with Kolibri in app mode. **You will only have to do this once unless you clear your browser storage.** |
File renamed without changes.
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,72 @@ | ||
import logging | ||
|
||
from magicbus.plugins import SimplePlugin | ||
|
||
from kolibri.core.content.hooks import ShareFileHook | ||
from kolibri.core.device.hooks import CheckIsMeteredHook | ||
from kolibri.core.device.hooks import GetOSUserHook | ||
from kolibri.core.tasks.hooks import StorageHook | ||
from kolibri.plugins import KolibriPluginBase | ||
from kolibri.plugins.hooks import register_hook | ||
from kolibri.utils.server.hooks import KolibriProcessHook | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ExampleAppPlugin(KolibriPluginBase): | ||
pass | ||
|
||
|
||
@register_hook | ||
class ExampleAppGetOSUserHook(GetOSUserHook): | ||
def get_os_user(self, auth_token): | ||
return "os_user", True | ||
|
||
|
||
@register_hook | ||
class ExampleAppCheckIsMeteredHook(CheckIsMeteredHook): | ||
def check_is_metered(self): | ||
return True | ||
|
||
|
||
@register_hook | ||
class ExampleAppShareFileHook(ShareFileHook): | ||
def share_file(self, file_path, message): | ||
logger.debug(f"Sharing file {file_path} with message {message}") | ||
|
||
|
||
@register_hook | ||
class ExampleAppStorageHook(StorageHook): | ||
def schedule(self, job, orm_job): | ||
logger.debug(f"Scheduling job {job} with ORM job {orm_job}") | ||
|
||
def update(self, job, orm_job, state=None, **kwargs): | ||
from kolibri.core.tasks.job import log_status | ||
|
||
log_status(job, orm_job, state=state, **kwargs) | ||
|
||
def clear(self, job, orm_job): | ||
logger.debug(f"Clearing job {job} with ORM job {orm_job}") | ||
|
||
|
||
class AppUrlLoggerPlugin(SimplePlugin): | ||
def SERVING(self, port): | ||
self.port = port | ||
|
||
def RUN(self): | ||
from kolibri.core.device.utils import app_initialize_url | ||
|
||
start_url = "http://127.0.0.1:{port}".format( | ||
port=self.port | ||
) + app_initialize_url(auth_token="1234") | ||
# Use warning to make sure this message stands out in the console | ||
logger.warning( | ||
"Open this URL to activate app mode: {start_url}".format( | ||
start_url=start_url | ||
) | ||
) | ||
|
||
|
||
@register_hook | ||
class DeveloperAppUrlLogger(KolibriProcessHook): | ||
MagicBusPluginClass = AppUrlLoggerPlugin |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.