posm-gcpi integration, django template inclusion, minor refactoring

pull/384/head
Piero Toffanin 2018-03-01 16:29:23 -05:00
rodzic f97d4c1813
commit 4fea36fc7e
21 zmienionych plików z 72 dodań i 39 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
from .plugin_base import PluginBase from .plugin_base import PluginBase
from .menu import Menu from .menu import Menu
from .mountpoint import MountPoint from .mount_point import MountPoint
from .functions import * from .functions import *

Wyświetl plik

@ -6,8 +6,8 @@ class MountPoint:
:param url: path to mount this view to, relative to plugins directory :param url: path to mount this view to, relative to plugins directory
:param view: Django view :param view: Django view
:param args: extra args to pass to url() :param args: extra args to pass to url() call
:param kwargs: extra kwargs to pass to url() :param kwargs: extra kwargs to pass to url() call
""" """
super().__init__() super().__init__()

Wyświetl plik

@ -18,20 +18,34 @@ class PluginBase(ABC):
return os.path.join(os.path.dirname(sys.modules[self.get_module_name()].__file__), *paths) return os.path.join(os.path.dirname(sys.modules[self.get_module_name()].__file__), *paths)
def get_name(self): def get_name(self):
"""
:return: Name of current module (reflects the directory in which this plugin is stored)
"""
return self.name return self.name
def get_module_name(self): def get_module_name(self):
return self.__class__.__module__ return self.__class__.__module__
def get_include_js_urls(self): def get_include_js_urls(self):
return [self.url(js_file) for js_file in self.include_js_files()] return [self.public_url(js_file) for js_file in self.include_js_files()]
def get_include_css_urls(self): def get_include_css_urls(self):
return [self.url(css_file) for css_file in self.include_css_files()] return [self.public_url(css_file) for css_file in self.include_css_files()]
def url(self, path): def public_url(self, path):
"""
:param path: unix-style path
:return: Path that can be accessed via a URL (from the browser), relative to plugins/<yourplugin>/public
"""
return "/plugins/{}/{}".format(self.get_name(), path) return "/plugins/{}/{}".format(self.get_name(), path)
def template_path(self, path):
"""
:param path: unix-style path
:return: path used to reference Django templates for a plugin
"""
return "plugins/{}/templates/{}".format(self.get_name(), path)
def has_public_path(self): def has_public_path(self):
return os.path.isdir(self.get_path("public")) return os.path.isdir(self.get_path("public"))

Wyświetl plik

@ -0,0 +1,5 @@
{% extends "app/logged_in_base.html" %}
{% block content %}
Hello World! Override me.
{% endblock %}

Wyświetl plik

@ -259,4 +259,9 @@ footer{
&:first-child{ &:first-child{
border-top-width: 1px; border-top-width: 1px;
} }
}
.full-height{
height: calc(100vh - 110px);
padding-bottom: 12px;
} }

Wyświetl plik

@ -1,10 +1,6 @@
@import '../vendor/potree/js/potree.css'; @import '../vendor/potree/js/potree.css';
@import '../vendor/potree/js/jquery-ui.css'; @import '../vendor/potree/js/jquery-ui.css';
[data-modelview]{
height: calc(100vh - 100px);
padding-bottom: 12px;
}
.model-view{ .model-view{
position: relative; position: relative;
height: 100%; height: 100%;

Wyświetl plik

@ -7,7 +7,7 @@
<h3><i class="fa fa-cube"></i> {{title}}</h3> <h3><i class="fa fa-cube"></i> {{title}}</h3>
<div data-modelview <div data-modelview class="full-height"
{% for key, value in params %} {% for key, value in params %}
data-{{key}}="{{value}}" data-{{key}}="{{value}}"
{% endfor %} {% endfor %}

Wyświetl plik

@ -6,7 +6,7 @@
<h3><i class="fa fa-cube"></i> {{title}}</h3> <h3><i class="fa fa-cube"></i> {{title}}</h3>
<div data-modelview <div data-modelview class="full-height"
{% for key, value in params %} {% for key, value in params %}
data-{{key}}="{{value}}" data-{{key}}="{{value}}"
{% endfor %} {% endfor %}

Wyświetl plik

@ -4,7 +4,7 @@
{% load render_bundle from webpack_loader %} {% load render_bundle from webpack_loader %}
{% render_bundle 'ModelView' attrs='async' %} {% render_bundle 'ModelView' attrs='async' %}
<div data-modelview <div data-modelview class="full-height"
{% for key, value in params %} {% for key, value in params %}
data-{{key}}="{{value}}" data-{{key}}="{{value}}"
{% endfor %} {% endfor %}

Wyświetl plik

@ -3,17 +3,12 @@ from django.shortcuts import render
class Plugin(PluginBase): class Plugin(PluginBase):
def register(self):
pass
def main_menu(self): def main_menu(self):
return [Menu("GCP Editor", self.url("index.html"), "fa fa-map-marker fa-fw")] return [Menu("GCP Interface", self.public_url(""), "fa fa-map-marker fa-fw")]
def mount_points(self): def mount_points(self):
return [ return [
MountPoint("/test", test) MountPoint('$', lambda request: render(request, self.template_path("app.html"), {'title': 'GCP Editor'}))
] ]
def test(request):
return render(request, 'app/dashboard.html', {'title': 'PLUGIN!!'})

Wyświetl plik

@ -1,8 +1,8 @@
{ {
"main.css": "static/css/main.0b2dd337.css", "main.css": "static/css/main.d9d37f4b.css",
"main.css.map": "static/css/main.0b2dd337.css.map", "main.css.map": "static/css/main.d9d37f4b.css.map",
"main.js": "static/js/main.df429876.js", "main.js": "static/js/main.ce50390f.js",
"main.js.map": "static/js/main.df429876.js.map", "main.js.map": "static/js/main.ce50390f.js.map",
"static/media/add.png": "static/media/add.5a2714f3.png", "static/media/add.png": "static/media/add.5a2714f3.png",
"static/media/add@2x.png": "static/media/add@2x.b53b9f2d.png", "static/media/add@2x.png": "static/media/add@2x.b53b9f2d.png",
"static/media/add_point.png": "static/media/add_point.e65f1d0c.png", "static/media/add_point.png": "static/media/add_point.e65f1d0c.png",

Wyświetl plik

@ -1 +1,17 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="shortcut icon" href="/favicon.ico"><title>GCPi</title><link href="/static/css/main.0b2dd337.css" rel="stylesheet"></head><body><div id="root"></div><script type="text/javascript" src="/static/js/main.df429876.js"></script></body></html> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon" href="/plugins/posm-gcpi/favicon.ico">
<title>GCPi</title>
<link href="/plugins/posm-gcpi/static/css/main.d9d37f4b.css" rel="stylesheet">
<style type="text/css">
.header .logo{ zoom: 0.5; }
</style>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="/plugins/posm-gcpi/static/js/main.ce50390f.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"static/css/main.0b2dd337.css","sourceRoot":""} {"version":3,"sources":[],"names":[],"mappings":"","file":"static/css/main.d9d37f4b.css","sourceRoot":""}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -0,0 +1,5 @@
{% extends "app/plugins/templates/base.html" %}
{% block content %}
<iframe src="index.html" style="border: none; display: block; min-height: 420px; width: 100%;" class="full-height"></iframe>
{% endblock %}

Wyświetl plik

@ -1,9 +1,5 @@
from app.plugins import PluginBase from app.plugins import PluginBase
class Plugin(PluginBase): class Plugin(PluginBase):
def register(self):
print("I'm registering!!!")
def include_js_files(self): def include_js_files(self):
return ['hello.js'] return ['hello.js']

Wyświetl plik

@ -100,6 +100,7 @@ TEMPLATES = [
'DIRS': [ 'DIRS': [
os.path.join(BASE_DIR, 'app', 'templates'), os.path.join(BASE_DIR, 'app', 'templates'),
os.path.join(BASE_DIR, 'app', 'templates', 'app'), os.path.join(BASE_DIR, 'app', 'templates', 'app'),
BASE_DIR
], ],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {