Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-jig to only use ajax where required #806

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions OZprivate/ServerScripts/Utilities/partial_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
# the local version, in static/
m = re.match('\s*<div id="OZ_js_modules" data-include="([^>]+)">', line)
if m:
include_path = os.path.join(os.path.dirname(fileinput.filename()), m.group(1))
with open(include_path) as include_file:
for inc_line in include_file:
line += inc_line
for include_path in m.group(1).split(" "):
include_path = os.path.join(os.path.dirname(fileinput.filename()), include_path)
with open(include_path) as include_file:
for inc_line in include_file:
line += inc_line
skip_lines = True
elif line.strip() == '</div>':
skip_lines = False
Expand Down
1 change: 1 addition & 0 deletions views/default/sponsor_leaf.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
response.files.append(URL('static', 'OZSponsor/EOLqueries.js'))
response.files.append(URL('static','css/content_pages.css'))
}}
{{include 'web2py_ajax.html' # I'm not actually sure we need ajax on the leaf page: perhaps this could be removed?}}
{{import img}}
{{if is_testing: response.meta.viewfile, response.meta.date_accessed = response.view, request.now}}{{pass}}
{{extend ('popup.html' if 'popup' in request.vars else 'uikit_layout.html')}}
Expand Down
1 change: 1 addition & 0 deletions views/default/sponsor_node.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{if is_testing: response.meta.viewfile, response.meta.date_accessed = response.view, request.now}}{{pass}}
{{response.files.insert(0,URL('static','js/web2py.js')) #To allow =LOAD(ajax=True) to work}}
{{response.files.append(URL('static', 'css/content_pages.css'))}}
{{include 'web2py_ajax.html' # We need ajax to load scrolling pictures in the sponsor node page}}
{{extend ('popup.html' if 'popup' in request.vars else 'uikit_layout.html')}}

{{block masthead}}
Expand Down
7 changes: 4 additions & 3 deletions views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
<!--[if lt IE 9]>
<script src="{{=URL('static','js/respond-1.4.2.min.js')}}"></script>
<![endif]-->
{{include 'web2py_ajax.html'}} <!-- this includes jquery.js, calendar.js/.css and web2py.js -->

{{include 'web2py_ajax.html' # This makes web2py ajax available in the include below: used e.g. as this is the layout for management pages}}
{{include 'web2py.html'}}
<!-- Treeviewer code for search / embedded view -->
{{if is_testing:}}<script>window.is_testing = true;</script>{{pass}}
<script>var OZstrings={{include 'treeviewer/js_strings.json'}};</script>
{{include '../static/OZTreeModule/dist/OZ_main.html'}} <!--includes OZui-->
{{include '../static/OZTreeModule/dist/OZentry.html'}}
{{include '../static/OZTreeModule/dist/OZui.html'}}
{{include 'treeviewer/server_urls.html' }}

{{block head}}{{end}}
Expand Down
11 changes: 2 additions & 9 deletions views/popup.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<!DOCTYPE html>
<html lang="{{=T.accepted_language or 'en'}}" class="{{='leaf_redirect' if response.view.startswith('default/spl_') else ''}}">
<head>
<script type="text/javascript" src="{{=URL('static','js/jquery.min.js')}}"></script>
<script src="{{=URL('static','uikit-3/js/uikit.min.js')}}"></script>
<link rel="stylesheet" href="{{=URL('static','uikit-3/css/uikit.min.css')}}" />
<link rel="stylesheet" href="{{=URL('static','css/content.css')}}" type="text/css" />
<link rel="stylesheet" href="{{=URL('static','css/popup.css')}}" type="text/css" />
<link rel="shortcut icon" href="{{=URL('static', 'favicon.ico')}}" type="image/x-icon" />
<link rel="apple-touch-icon" href="{{=URL('static','favicon.png')}}">
{{include 'web2py.html'}}
<style>h2 {margin-top: 0}</style>
{{
response.include_meta()
response.include_files()
}}
<script>
{{include 'popup.js'}}
var OZstrings={{include 'treeviewer/js_strings.json'}};
Expand All @@ -36,10 +32,7 @@
<!-- All JavaScript at the bottom, except for Modernizr which enables
HTML5 elements & feature detects -->
<script src="{{=URL('static','js/modernizr-2.8.3.min.js')}}"></script>
<!--[if lt IE 9]>
<script src="{{=URL('static','js/respond-1.4.2.min.js')}}"></script>
<![endif]-->
{{include '../static/OZTreeModule/dist/OZui.html'}} <!--Doesn't need the main stuff in a popup -->
{{include '../static/OZTreeModule/dist/OZui.html' # NB: Not including OZentry.html }}
{{include 'treeviewer/server_urls.html' }}
{{block head}}{{end}}
</head>
Expand Down
8 changes: 4 additions & 4 deletions views/treeviewer/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
}}
<title>OneZoom Tree of Life Explorer, text page for {{=page_info.get('title_name')}}</title>
{{if response.canonical:}}<link rel="canonical" href="{{=response.canonical}}" />{{pass}}
{{include 'web2py_ajax.html' #only really needed for web2py ajax loading in sponsor_node tab (must be above the UIkit lines)}}
{{include 'web2py.html' # must be above the UIkit lines}}
<link rel="stylesheet" href="{{=URL('static','uikit-3/css/uikit.min.css')}}" />
<script src="{{=URL('static','uikit-3/js/uikit.min.js')}}"></script>
<script src="{{=URL('static','uikit-3/js/uikit-icons.min.js')}}"></script>
<link rel="stylesheet" type="text/css" href="{{=URL('static', 'css/tree.css')}}" />
<link rel="stylesheet" type="text/css" href="{{=URL('static', 'css/OZ_shared.css')}}" />
{{if is_testing:}}<script>window.is_testing = true;</script>{{pass}}
<!-- do not change the next line in any way. The exact format is used for partial installs -->
<div id="OZ_js_modules" data-include="../static/OZTreeModule/dist/OZ_main.html">
{{include "../static/OZTreeModule/dist/OZ_main.html"}}
{{include '../static/OZTreeModule/dist/OZui.html'}}
<div id="OZ_js_modules" data-include="../static/OZTreeModule/dist/OZentry.html ../static/OZTreeModule/dist/OZui.html">
{{include '../static/OZTreeModule/dist/OZentry.html'}}
{{include '../static/OZTreeModule/dist/OZui.html'}}
</div>

<!-- treeviewer constants -->
Expand Down
11 changes: 2 additions & 9 deletions views/uikit_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,14 @@
<meta name="google-site-verification" content="">
{{if response.canonical:}}<link rel="canonical" href="{{=response.canonical}}">{{pass}}

<script type="text/javascript" src="{{=URL('static','js/jquery.min.js')}}"></script>
<link rel="stylesheet" href="{{=URL('static','uikit-3/css/uikit.min.css')}}" />
<script src="{{=URL('static','uikit-3/js/uikit.min.js')}}"></script>
<script src="{{=URL('static','uikit-3/js/uikit-icons.min.js')}}"></script>
<link rel="stylesheet" type="text/css" href="{{=URL('static', 'css/content.css')}}" />

{{
response.include_meta()
response.include_files()
}}
<!-- include 'web2py_ajax.html' could be done here, but it performs more than we want so we disect it and keep only the bits we really need -->

{{include 'web2py.html'}}

{{if is_testing:}}<script>window.is_testing = true;</script>{{pass}}
{{include '../static/OZTreeModule/dist/OZ_main.html'}}
{{include '../static/OZTreeModule/dist/OZentry.html'}}
{{include '../static/OZTreeModule/dist/OZui.html'}}
<script>var OZstrings={{include 'treeviewer/js_strings.json'}}</script>
{{include 'treeviewer/server_urls.html' }}
Expand Down
6 changes: 6 additions & 0 deletions views/web2py.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--A OneZoom-specific slimmed down version of the standard w2p includes, to be used if web2py ajax is not required-->
{{
response.files.insert(0,URL('static','js/jquery.min.js'))
response.include_meta()
response.include_files()
}}
8 changes: 2 additions & 6 deletions views/web2py_ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
)}}
//--></script>
{{
response.files.insert(0,URL('static','js/jquery.min.js'))
response.files.insert(1,URL('static','css/calendar.css'))
response.files.insert(2,URL('static','js/calendar.js'))
response.files.insert(3,URL('static','js/web2py.js'))
response.include_meta()
response.include_files()
# Include this file as well as web2py.html if web2py ajax functionality is needed
response.files.insert(1, URL('static','js/web2py.js'))
}}
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ var config = {
plugins: [
new HtmlWebpackPlugin({
scriptLoading: 'blocking',
filename: 'OZ_main.html',
filename: 'OZentry.html',
chunks: ['OZentry'],
// This template contains the script tags refering to the js files generated by
// the webpack compile command
template: OZTreeModule_src('OZ_script_template.html')
Expand Down