-
Notifications
You must be signed in to change notification settings - Fork 80
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
hasjob PWA #425
hasjob PWA #425
Conversation
vidya-ram
commented
Mar 7, 2018
•
edited
Loading
edited
- Introduced Webpack to build & bundle hasjob's css & js
- Used Workbox Webpack plugin to generate service worker that takes care of caching & offline support
- Add Manifest.json to enable "Add to homescreen" feature.
- Add the new Hasjob logo
…ts and tablelayoutscripts blocks to sheet.html & tablelayout.html
hasjob/templates/layout.html.jinja2
Outdated
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.register('/service-worker.js') | ||
.then(function(registration) { | ||
console.log('Service Worker registration successful with scope: ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps better to raise an exception with Sentry?
I really wish we didn't include built static files in the repo. Can we move the building part to the server? just include the main static files in repo and then when deploying, run build command. |
hasjob/__init__.py
Outdated
ext_requires=['baseframe-bs3', | ||
('jquery.autosize', 'jquery.sparkline', 'jquery.liblink', 'jquery.wnumb', 'jquery.nouislider'), | ||
baseframe.init_app(app, requires=['baseframe-bs3', | ||
'jquery.autosize', 'jquery.sparkline', 'jquery.liblink', 'jquery.wnumb', 'jquery.nouislider', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We stopped using sparkline
a while ago. Safe to remove now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
hasjob/static/js/styles-app.js
Outdated
@@ -0,0 +1 @@ | |||
import '../sass/app.sass'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this needs compilation, it should be in the assets
folder, not static
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in static
is published to the world and can be directly accessed from a URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -1,6 +1,6 @@ | |||
body | |||
font-family: $font-default | |||
background: #e8e7e6 image-url("canvas.jpg") | |||
background: #e8e7e6 url("~/static/img/canvas.jpg") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move SASS files into assets
as well, which means this path will need to be updated (image files stay in static
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -12,7 +12,7 @@ | |||
</div> | |||
{% endblock %} | |||
|
|||
{% block footerscripts %} | |||
{% block tablelayoutscripts %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be tablayout
, not tablelayout
. Please amend in the source template as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
hasjob/templates/layout.html.jinja2
Outdated
@@ -229,5 +240,20 @@ | |||
|
|||
{% block layoutscripts %} | |||
{%- if header_campaign %}{{ campaign_script() }}{% endif %} | |||
<script src='{{ asset_path('manifest') | safe }}' type="text/javascript"></script> | |||
<script src='{{ asset_path('vendor') | safe }}' type="text/javascript"></script> | |||
<script src='{{ asset_path('app') | safe }}' type="text/javascript"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not safe to use the | safe
filter. If asset_path
is confirming the strings are escaped, let it return Markup
strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
hasjob/templates/stats.html.jinja2
Outdated
@@ -21,7 +21,7 @@ | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% block footerscripts %} | |||
{% block sheetscripts %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These templates should continue to use footerscripts
. Only overwrite sheetscripts
or tablayoutscripts
in layout templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In stats.html.jinja
{% block sheetscripts %}
{% block footerscripts %}
.....
{% endblock %}
{% endblock %}
Would this be fine, @jace ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using just {% block footerscripts %}
should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In sheet.html.jinja2
, I have added
{% block layoutscripts %}
{{ super() }}
{% endblock %}
And used just {% block footerscripts %}
in templates that extend sheet.html.jinja2
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script> | ||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/c3/0.4.14/c3.min.js"></script> | ||
{% block footerscripts %}{% endblock %} | ||
{% endblock %} | ||
{% block tablelayoutscripts %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{% block tablayoutscripts %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
hasjob/views/index.py
Outdated
|
||
@app.route('/workbox-sw.prod.v2.1.2.js', methods=['GET']) | ||
def workbox(): | ||
return app.send_static_file('workbox-sw.prod.v2.1.2.js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is v2.1.2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workbox-webpack-plugin
generates the service worker that import's Workbox's service worker library
https://developers.google.com/web/tools/workbox/get-started/webpack#register
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So v2.1.2 is a static path that won't change? Or it's linked to the webpack version? If latter, we should avoid a dependency on having to change this line every time webpack changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
2. Add new logo. 3. Add offline page to be served by service worker during network error.
hasjob/templates/sheet.html.jinja2
Outdated
@@ -22,6 +22,5 @@ | |||
{% endblock %} | |||
|
|||
{% block layoutscripts %} | |||
{%- if header_campaign %}{{ campaign_script() }}{% endif %} | |||
{% block footerscripts %}{% endblock %} | |||
{{ super() }} | |||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to define a block if it only contains super()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
hasjob/views/index.py
Outdated
@@ -819,3 +819,18 @@ def logoimage(domain, hashid): | |||
@app.route('/search') | |||
def search(): | |||
return redirect(url_for('index', **request.args)) | |||
|
|||
|
|||
@app.route('/offline') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be careful about adding new top-level routes? This merits a discussion. See #145.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to /api/1/template/offline
I have just these two comments, @vidya-ram. |