Skip to content

Commit

Permalink
down to 252 lines for #479
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Aug 30, 2022
1 parent 1757a24 commit c62c96d
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 162 deletions.
2 changes: 1 addition & 1 deletion justpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""JustPy is an object-oriented, component based, high-level Python Web Framework that requires no front-end programming"""

from .justpy import *
__version__ = "0.4.0"
__version__ = "0.4.1"
11 changes: 11 additions & 0 deletions justpy/templates/css/highcharts_jp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* needed for exporting menu - used to be part of highcharts.html template */
hr {
display: block;
margin-before: 0.5em;
margin-after: 0.5em;
margin-start: auto;
margin-end: auto;
overflow: hidden;
border-style: inset;
border-width: 1px;
}
26 changes: 13 additions & 13 deletions justpy/templates/favicon.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<script>
// Reload page if reached via back button (history in general)
// @TODO - deprecated see https://stackoverflow.com/questions/58652880/what-is-the-replacement-for-performance-navigation-type-in-angular
if(performance.navigation.type == 2){
<script>
// Reload page if reached via back button (history in general)
// @TODO - deprecated see https://stackoverflow.com/questions/58652880/what-is-the-replacement-for-performance-navigation-type-in-angular
if(performance.navigation.type == 2){
location.reload(true);
}
// ScrollIntoView polyfill https://www.npmjs.com/package/smoothscroll-polyfill
}
// ScrollIntoView polyfill https://www.npmjs.com/package/smoothscroll-polyfill
!function(){"use strict";function o(){var o=window,t=document;if(!("scrollBehavior"in t.documentElement.style&&!0!==o.__forceSmoothScrollPolyfill__)){var l,e=o.HTMLElement||o.Element,r=468,i={scroll:o.scroll||o.scrollTo,scrollBy:o.scrollBy,elementScroll:e.prototype.scroll||n,scrollIntoView:e.prototype.scrollIntoView},s=o.performance&&o.performance.now?o.performance.now.bind(o.performance):Date.now,c=(l=o.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(l)?1:0);o.scroll=o.scrollTo=function(){void 0!==arguments[0]&&(!0!==f(arguments[0])?h.call(o,t.body,void 0!==arguments[0].left?~~arguments[0].left:o.scrollX||o.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:o.scrollY||o.pageYOffset):i.scroll.call(o,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:o.scrollX||o.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:o.scrollY||o.pageYOffset))},o.scrollBy=function(){void 0!==arguments[0]&&(f(arguments[0])?i.scrollBy.call(o,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(o,t.body,~~arguments[0].left+(o.scrollX||o.pageXOffset),~~arguments[0].top+(o.scrollY||o.pageYOffset)))},e.prototype.scroll=e.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==f(arguments[0])){var o=arguments[0].left,t=arguments[0].top;h.call(this,this,void 0===o?this.scrollLeft:~~o,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");i.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},e.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==f(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):i.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},e.prototype.scrollIntoView=function(){if(!0!==f(arguments[0])){var l=function(o){for(;o!==t.body&&!1===(e=p(l=o,"Y")&&a(l,"Y"),r=p(l,"X")&&a(l,"X"),e||r);)o=o.parentNode||o.host;var l,e,r;return o}(this),e=l.getBoundingClientRect(),r=this.getBoundingClientRect();l!==t.body?(h.call(this,l,l.scrollLeft+r.left-e.left,l.scrollTop+r.top-e.top),"fixed"!==o.getComputedStyle(l).position&&o.scrollBy({left:e.left,top:e.top,behavior:"smooth"})):o.scrollBy({left:r.left,top:r.top,behavior:"smooth"})}else i.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function n(o,t){this.scrollLeft=o,this.scrollTop=t}function f(o){if(null===o||"object"!=typeof o||void 0===o.behavior||"auto"===o.behavior||"instant"===o.behavior)return!0;if("object"==typeof o&&"smooth"===o.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+o.behavior+" is not a valid value for enumeration ScrollBehavior.")}function p(o,t){return"Y"===t?o.clientHeight+c<o.scrollHeight:"X"===t?o.clientWidth+c<o.scrollWidth:void 0}function a(t,l){var e=o.getComputedStyle(t,null)["overflow"+l];return"auto"===e||"scroll"===e}function d(t){var l,e,i,c,n=(s()-t.startTime)/r;c=n=n>1?1:n,l=.5*(1-Math.cos(Math.PI*c)),e=t.startX+(t.x-t.startX)*l,i=t.startY+(t.y-t.startY)*l,t.method.call(t.scrollable,e,i),e===t.x&&i===t.y||o.requestAnimationFrame(d.bind(o,t))}function h(l,e,r){var c,f,p,a,h=s();l===t.body?(c=o,f=o.scrollX||o.pageXOffset,p=o.scrollY||o.pageYOffset,a=i.scroll):(c=l,f=l.scrollLeft,p=l.scrollTop,a=n),d({scrollable:c,method:a,startTime:h,startX:f,startY:p,x:e,y:r})}}"object"==typeof exports&&"undefined"!=typeof module?module.exports={polyfill:o}:o()}();
</script>
{% if page_options.title %}
</script>
{%- if page_options.title %}
<title>{{ page_options.title }}</title>
{% else %}
{%- else %}
<title>JustPy</title>
{% endif %}
{% if page_options.favicon %}
{%- endif %}
{%- if page_options.favicon %}
{% if page_options.favicon.startswith('http') %}
<link rel="shortcut icon" href={{ page_options.favicon }}>
{% else %}
<link rel="shortcut icon" href={{ url_for(options.static_name, path=page_options.favicon) }}>
{% endif %}
{% else %}
{%- else %}
<link rel="shortcut icon" href='https://elimintz.github.io/favicon.png'>
{% endif %}
{%- endif %}
30 changes: 8 additions & 22 deletions justpy/templates/highcharts.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<style>
{#needed for exporting menu#}
hr {
display: block;
margin-before: 0.5em;
margin-after: 0.5em;
margin-start: auto;
margin-end: auto;
overflow: hidden;
border-style: inset;
border-width: 1px;
}
</style>
{% if not options.no_internet %}
<link href="/template/css/highcharts_jp.css" rel="stylesheet">
{%- if not options.no_internet %}
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/modules/variable-pie.js"></script>
<script src="https://code.highcharts.com/stock/modules/histogram-bellcurve.js"></script>
Expand Down Expand Up @@ -42,22 +30,20 @@
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<script src="https://code.highcharts.com/modules/xrange.js"></script>

<script src="http://code.highcharts.com/maps/modules/map.js"></script>

{#Must be last#}
<script src="https://code.highcharts.com/stock/modules/boost.js"></script>
{% else %}
{%- else %}
<script src="/templates/local/highcharts.js"></script>
{% endif %}
<script>
{%- endif %}
<script>
Highcharts.setOptions({
lang: {
thousandsSep: ','
}
});
{% if page_options.highcharts_theme %}
{%- if page_options.highcharts_theme %}
{% set theme_file = 'highcharts/' + page_options.highcharts_theme + '.js' %}
{% include theme_file %}
{% endif %}
</script>
{%- endif %}
</script>
10 changes: 4 additions & 6 deletions justpy/templates/main.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% for file_name in options.component_file_list %}
{%- for file_name in options.component_file_list %}
<script src={{ url_for(options.static_name, path=file_name) }}></script>
{%- endfor %}
<script>
<script>
{% if page_options.redirect %}
location.href = '{{ page_options.redirect|safe }}';
{%endif %}
Expand All @@ -11,17 +11,16 @@
{% if page_options.display_url is not none %}
window.history.pushState("", "", '{{ page_options.display_url }}');
{%endif %}

var page_id = {{ page_id | safe }};
var websocket_id = '';
var use_websockets = JSON.parse('{{ use_websockets }}');
var justpyComponents = {{ justpy_dict.replace('</' + 'script>', '</" + "script>') | safe }};
</script>
</script>
{%- for file_name in ["justpy_core","event_handler","html_component","quasar_component",
"chartjp","aggrid","iframejp","deckgl","altairjp","plotlyjp","bokehjp","katexjp","editorjp"] %}
<script src='/templates/js/{{file_name}}.js'></script>
{%- endfor %}
<script>
<script>
{%- for event in page_options.events %}
document.addEventListener('{{ event }}', function (evt) {
console.log(evt);
Expand All @@ -48,7 +47,6 @@
send_to_server(e, 'page_event', false);
});
{%- endfor %}

if (use_websockets) {
console.log(location.protocol + ' Domain: ' + document.domain);
if (location.protocol === 'https:') {
Expand Down
77 changes: 35 additions & 42 deletions justpy/templates/optional_packages.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,44 @@
{% if options.highcharts %}
{% include 'highcharts.html' %}
{% endif %}

{% if options.aggrid %}
{% if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"></script>
{% else %}
<script src="/templates/local/ag-grid-community.js"></script>
{% endif %}
{% endif %}

{% if options.aggrid_enterprise %}
{% if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.js"></script>
{% else %}
<script src="/templates/local/ag-grid-enterprise.js"></script>
{% endif %}
{% endif %}

{% if options.deckgl %}
{%- if options.highcharts %}
{%- include 'highcharts.html' %}
{%- endif %}
{%- if options.aggrid %}
{%- if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"></script>
{%- else %}
<script src="/templates/local/ag-grid-community.js"></script>
{%- endif %}
{%- endif %}
{%- if options.aggrid_enterprise %}
{%- if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.js"></script>
{%- else %}
<script src="/templates/local/ag-grid-enterprise.js"></script>
{%- endif %}
{%- endif %}
{%- if options.deckgl %}
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js"></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.0/mapbox-gl.css' rel='stylesheet'/>
<script src='https://cdn.jsdelivr.net/npm/@deck.gl/jupyter-widget@~8.4.*/dist/index.js'></script>
{% endif %}

{% if options.katex %}
{%- endif %}
{%- if options.katex %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"
integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.js"
integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp"
crossorigin="anonymous"></script>
{% endif %}

{% if options.vega %}
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@4"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
{% endif %}

{% if options.plotly %}
<script src="https://cdn.plot.ly/plotly-2.1.0.min.js"></script>
{% endif %}

{% if options.bokeh %}
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-api-2.3.2.min.js"></script>
{% endif %}
{%- endif %}
{%- if options.vega %}
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@4"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
{%- endif %}
{%- if options.plotly %}
<script src="https://cdn.plot.ly/plotly-2.1.0.min.js"></script>
{%- endif %}
{%- if options.bokeh %}
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-api-2.3.2.min.js"></script>
{%- endif %}
19 changes: 3 additions & 16 deletions justpy/templates/quasar.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<!--This is a justpy application using the quasar.html template-->
<head>
{% include 'favicon.html' %}
{%- include 'favicon.html' -%}
{% if options.tailwind %}
{% if not options.no_internet %}
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^2.0/dist/base.min.css">
Expand All @@ -15,11 +15,8 @@
<link href="/templates/local/tailwind/typography.css" rel="stylesheet">
<link href="/templates/local/tailwind/utilities.css" rel="stylesheet">
{% endif %}
<style>
{% include 'css/form.css' %}
</style>
<link href="/template/css/form.css" rel="stylesheet">
{% endif %}

{% if not options.no_internet %}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons"
rel="stylesheet" type="text/css">
Expand All @@ -42,21 +39,17 @@
<link rel="stylesheet" href="/templates/local/animate.css"/>
<link rel="stylesheet" href="/templates/local/quasar.css"/>
{% endif %}

<style>
{{ page_options.css | safe}}
</style>
{{ page_options.head_html | safe }}
{% include 'optional_packages.html' %}
</head>


<body class="" style="{{ page_options.body_style }}" class="{{ page_options.body_classes }}">
{% if html %}
{{ html | safe }}
{% else %}
{{ page_options.body_html | safe }}

{% if not options.no_internet %}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
Expand All @@ -65,17 +58,13 @@
{% else %}
<script src="https://cdn.jsdelivr.net/npm/quasar@^1.8.5/dist/quasar.umd.min.js"></script>
{% endif %}

{% else %}
<script src="/templates/local/jquery.js"></script>
<script src="/templates/local/vue.js"></script>
<script src="/templates/local/quasar.js"></script>
{% endif %}

<div id="components">

</div>

<script>
console.log('Quasar Version ' + Quasar.version);
{% if page_options.dark %}
Expand All @@ -85,9 +74,7 @@
Quasar.Dark.set("auto");
{% endif %}
</script>

{% include 'main.html' %}

{% endif %}
</body>
</html>
</html>
Loading

0 comments on commit c62c96d

Please sign in to comment.