Commit Graph

46 Commits

Author SHA1 Message Date
MariaGkoulta b10f156250 settings: Add automatic theme detection feature.
With this implementation of the feature of the automatic theme
detection, we make the following changes in the backend, frontend and
documentation.

This replaces the previous night_mode boolean with an enum, with the
default value being to use the prefers-color-scheme feature of the
operating system to determine which theme to use.

Fixes: #14451.

Co-authored-by: @kPerikou <44238834+kPerikou@users.noreply.github.com>
2020-06-21 01:09:01 -07:00
Anders Kaseorg d33abba687 base: Fix jinja2.exceptions.UndefinedError on Python ≥ 3.7.
Python 3.7 changed dict.update to avoid swallowing exceptions when
checking for the keys attribute (https://bugs.python.org/issue31572).
This broke {}.update(jinja2.Undefined()).

Fix it with an explicit default.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 05:35:51 -07:00
Anders Kaseorg 99242138a7 static: Serve webpack bundles from the root domain.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 00:48:02 -07:00
Anders Kaseorg fda70a5458 templates: Use just one webpack entry point per page.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-10-28 15:53:15 -07:00
Anders Kaseorg f245fcf408 webpack: Enable code splitting and deduplication.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-10-28 15:53:15 -07:00
Anders Kaseorg fbc2de157e templates: Move page_params to a <div> at the bottom of <body>.
In a gigantic realm where we send several MB of `page_params`, it’s
slightly better to have the rest of the `<body>` available to the
browser earlier, so it can show the “Loading…” spinner and start
fetching subresources.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-09-19 12:38:10 -07:00
Anders Kaseorg 7494f1600c templates: Move page_params from an inline script to the <body> dataset.
This sidesteps tricky escaping issues, and will make it easier to
build a strict Content-Security-Policy.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-09-17 16:06:33 -07:00
Anders Kaseorg f1ecd3c18b templates: Defer all script execution.
This allows parsing and resource loading to continue in parallel with
script fetching.  It also means we don’t need to concern ourselves
with explicitly waiting for the DOM to become ready.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-09-17 16:06:33 -07:00
Anders Kaseorg 9b38bcc2a6 templates: Abstract render_bundle behind a Jinja2 macro.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-09-17 16:06:33 -07:00
Anders Kaseorg 76f25bca59 templates: Reenable mobile zooming on non-app pages.
Commit db45d220a8 (#3996) disabled
mobile zooming on all pages, with the reasoning that focusing an input
may automatically zoom the page and break content.  I’m not sure
whether that was a good reason, but at most it only applies to the app
page.  Reenable zooming on all other pages like the portico and
documentation to improve their accessibility.

(Note: the other common reason to disable zooming, which was that
mobile browsers once added a 300ms tap delay to recognize double-tap
zoom gestures, has been obsolete since 2014:
https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away)

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-05-17 11:30:30 -07:00
Anders Kaseorg 643bd18b9f lint: Fix code that evaded our lint checks for string % non-tuple.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-04-23 15:21:37 -07:00
Tim Abbott 399aa43c75 night mode: Fix initial state of night mode. 2019-03-08 15:45:11 -08:00
Anders Kaseorg f75c0e29f4 HTML validation: Remove obsolete attributes from <script>, <style>.
<script charset=…>, <script type=…>, and <style type=…> are “obsolete
but conforming” in HTML5.  They make the validator.nu output noisier
and real problems a little harder to find.

(type was required in HTML 4, which is not relevant to us.)

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-07-13 10:27:23 +05:30
Armaan Ahluwalia 54d3d8e8b3 webpack: Transition app.js to be compiled by webpack.
This commit moves all files previously under the 'app' bundle in
the Django pipeline to being compiled by webpack under the 'app'
entry point. In the process, it moves assets under the app entry
to a file called app.js that consumes all relevant css and js files.

This commit also edits the webpack config to be able to expose certain
variables for third party libraries that are currently required by
some modules. This is bad coding form and should be refactored to
requiring whatever dependencies a module may have; we're just
deferring that to the future to simplify the series of transitions we
need to do here. The variable exposure is done using expose-loader in
webpack.

The app/index.html template is edited to override the newly introduced
'commonjs' block in the base template. This is done as a temporary
measure so as not to disrupt other pages on the app during the transition.

It also fixes the value of the 'this' context that was being inferred
as window by third party libraries. This is done using imports-loader
in the webpack config.  This is also messy and probably isn't how we
want things to work long term.
2018-07-05 11:03:08 +02:00
Steve Howell 8abaca1457 minor: Turn HTML comment into template comment.
We don't need to send comments about our portico
setup over the wire.
2018-05-30 18:12:34 -07:00
Armaan Ahluwalia 1c016e990d css/webpack: Transition common.css to webpack.
This commit transitions common.css from the Django pipeline
to being compiled by webpack under the common bundle.
2018-05-03 19:15:23 -07:00
Vishnu Ks 8705ac1091 portico: Add noindex tags for non root realms.
There may be further work required for the /integrations pages.
2018-05-01 15:28:30 -07:00
Aditya Bansal 8e38b8462b csp_nonce: Add nonce to webpack rendered js.
We use the attrs property provided by render_bundle function of
django-webpack-loader to add `nonce="<csp_nonce_val_here>" to
js scripts being rendered by webpack.
2018-04-24 06:13:21 +05:30
Akash Nimare 1a124ad865 portico: Add open graph and twitter meta tags to all pages.
This PR adds few basic meta tags which are required for a better SEO.

Fixes: #8255.
2018-04-19 22:10:27 -07:00
Tim Abbott e6833b6427 cleanup: Remove the legacy Dropbox file upload integration.
This has been hard-disabled for years, we have no plans to re-enable
it, and it has some hacky code in it.
2018-04-11 11:39:48 -07:00
Brock Whittaker ec43a6e718 portico: Add "porticocustomhead" block to base.html.
This adds a custom header to the base.html strictly for portico assets
that should not be overridden.
2017-10-25 14:47:54 -07:00
Harshit Bansal 0b03fd97a2 webpack: Don't include katex bundle in base.html.
Since we use katex only in the main webapp, we don't need it in things
like landing page etc, so it is better to move it to index.html.
2017-06-22 19:06:32 -04:00
Harshit Bansal c0e4f24a25 webpack: Migrate `common.js` bundle to webpack. 2017-06-22 19:06:32 -04:00
Mehanig 8c0e500d6b webpack: Migrate api and katex js files to Webpack bundler.
This also injects the dev webpack sockets to katex, since that's part
of the main web app bundle.
2017-06-09 12:33:52 -07:00
Yago González c1fea74a65 markdown: Load KaTeX in the app. 2017-04-03 17:01:50 -07:00
Raghav Jajodia c17e574211 Remove product_name setting and return to harcoding 'Zulip'.
This removes some confusion in grep for frontend strings with Zulip in
them and also cleans up the code in some places.

Fixes #1602.
2017-03-09 21:48:15 -08:00
Brock Whittaker db45d220a8 Disable mobile zooming of the Zulip webpage.
This disables the zooming ability of the mobile webpage which is good
as focusing on input will automatically zoom the page and sometimes
break content.
2017-03-08 21:08:04 -08:00
Tim Abbott 90bc76cf87 base.html: Remove commented-out HTML5 shim code.
From reading the history, I think this was actually never uncommented
in any version of Zulip; and regardless we no longer support IE8.
2017-03-04 20:42:25 -08:00
adnrs96 bf2bccb6f8 Clean base.html to use 4 space indents. 2017-02-28 13:49:35 -08:00
Brock Whittaker 6f988b482a Move viewport meta-tag to base template.
The portico template inherits base but not index, but index inherits
base. Therefore the viewport meta-tag should be moved to base so that
the entire site can have the meta tag.
2016-08-25 20:26:06 -07:00
Tim Abbott 543311848d templates: Replace not_voyager check with dropboxAppKey check.
Also remove useless/confusing value of DROPBOX_APP_KEY in
DEFAULT_SETTINGS (it's overridden by the get_secret call anyway).
2016-07-19 15:28:41 -07:00
Umair Khan 043ae8ad65 Upgrade to Django-Pipeline==1.6.8. 2016-07-09 07:09:55 -07:00
Umair Khan 82b5d9304b [third] Integrate i18next with Handlebars 2016-05-19 22:58:25 -07:00
Umair Khan 5359e6b0d4 Convert Zulip to use Jinja2 templates.
This results in a substantial performance improvement for all of
Zulip's backend templates.

Changes in templates:
- Change `block.super` to `super()`.
- Remove `load` tag because Jinja2 doesn't support it.
- Use `minified_js()|safe` instead of `{% minified_js %}`.
- Use `compressed_css()|safe` instead of `{% compressed_css %}`.
- `forloop.first` -> `loop.first`.
- Use `{{ csrf_input }}` instead of `{% csrf_token %}`.
- Use `{# ... #}` instead of `{% comment %}`.
- Use `url()` instead of `{% url %}`.
- Use `_()` instead of `{% trans %}` because in Jinja `trans` is a block tag.
- Use `{% trans %}` instead of `{% blocktrans %}`.
- Use `{% raw %}` instead of `{% verbatim %}`.

Changes in tools:
- Check for `trans` block in `check-templates` instead of `blocktrans`

Changes in backend:
- Create custom `render_to_response` function which takes `request` objects
  instead of `RequestContext` object. There are two reasons to do this:
    1. `RequestContext` is not compatible with Jinja2
    2. `RequestContext` in `render_to_response` is deprecated.
- Add Jinja2 related support files in zproject/jinja2 directory. It
  includes a custom backend and a template renderer, compressors for js
  and css and Jinja2 environment handler.
- Enable `slugify` and `pluralize` filters in Jinja2 environment.

Fixes #620.
2016-05-09 09:55:18 -07:00
Umair Khan f20b907f96 base.html: Add check for undefined user_profile.
The previous code that neglected this check worked with the Django
templating engine but will not work with Jinja2.
2016-05-09 09:48:37 -07:00
David Roe 3f7cb34b00 enterprise => voyager
(imported from commit 04be792bb480d5e5db1c91d296d1000cf1682571)
2015-08-21 10:33:35 -07:00
Zev Benjamin 2c760ae735 Remove mixpanel
(imported from commit 9b6cc58ee9be483db8bf2d2eaaaecabc14f821e4)
2015-02-06 13:59:30 -08:00
Waseem Daher 307d367346 Initial support for white-labeling Zulip as "Dropbox Chat" or otherwise.
Known issues:
* No support for whitelabeling in the email
* No whitelabeling for any externally-visible branding

(imported from commit 9eab7b0744e56a87007b8621a8bb18bbb1080256)
2014-07-29 21:46:33 -07:00
Tim Abbott e64472cd32 Rename enterprise template variable to not_enterprise.
The problem here is that some error-related templates render without
the context managers that we specify, and so we want the handling of
"the context was not set" to default to the enterprise case (because
the enterprise version will work basically fine on !enterprise, but
the opposite is not true because the enterprise distribution doesn't
even have the templates for certain !enterprise pages that may be
linked to).

(imported from commit 7547311d87e048d33221587f44b82fe0ba320ca1)
2013-11-13 20:10:33 -05:00
Tim Abbott 5293cdebe8 Rename LOCAL_SERVER to ENTERPRISE.
(imported from commit 7edf353eefe6c9e7aac74b7bbc37b923cac1b913)
2013-11-12 15:57:01 -05:00
Leo Franchi 8e05f76511 Only enable analytics and dropbox on non-LOCAL_SERVER
(imported from commit 1ba877550b3afde51bec6f344762ea998800c5b6)
2013-10-29 17:33:36 -04:00
Jessica McKellar a9c7f3a387 [manual] Use the name instead of the domain for the user-visible realm identifier.
Do not push this commit to prod until the historical realm names have
been populated.

(imported from commit a58191d181d2fb2b8b5e9793ea57707b36812cfc)
2013-10-17 13:47:51 -04:00
Steve Howell 3ca1ef9a0a Use custom titles for the activity report.
(imported from commit ed991108715d043d5d21d8e9f7573eaedb21fec1)
2013-10-11 16:29:26 -04:00
Scott Feeney bf0909a94d Lazy load Dropbox widget, and only when enabled
This brings several improvements:

* The Dropbox script won't slow loading our app.
* If it fails to load, no traceback; Dropbox link just won't appear.
* For users with Dropbox disabled (most at this point), no loading at all.

(imported from commit e71ae5790fc85a185e622bdafb350109527b4eee)
2013-08-26 13:13:00 -04:00
Waseem Daher dfb60ee966 File uploads using Dropbox.
(imported from commit c552133fc7025eca526fbfef24fd544260d7111b)
2013-08-12 17:22:23 -04:00
Tim Abbott e111a2f9a5 [manual] Rename Django app from zephyr to zerver.
This needs to be deployed to both staging and prod at the same
off-peak time (and the schema migration run).

At the time it is deployed, we need to make a few changes directly in
the database:

(1) UPDATE django_content_type set app_label='zerver' where app_label='zephyr';
(2) UPDATE south_migrationhistory set app_name='zerver' where app_name='zephyr';

(imported from commit eb3fd719571740189514ef0b884738cb30df1320)
2013-08-06 07:39:36 -04:00