mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
Rename default branch to ‘main’.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 646c04eff2)
This commit is contained in:
@@ -20,7 +20,7 @@ are in your Git checkout under `static`, and are served unminified.
|
||||
|
||||
## Static files are [served directly][served-directly] by Nginx
|
||||
|
||||
[served-directly]: https://github.com/zulip/zulip/blob/master/puppet/zulip/files/nginx/zulip-include-frontend/app
|
||||
[served-directly]: https://github.com/zulip/zulip/blob/main/puppet/zulip/files/nginx/zulip-include-frontend/app
|
||||
|
||||
Static files include JavaScript, css, static assets (like emoji, avatars),
|
||||
and user uploads (if stored locally and not on S3).
|
||||
@@ -50,7 +50,7 @@ application.
|
||||
|
||||
[Here is the relevant nginx routing configuration.][nginx-config-link]
|
||||
|
||||
[nginx-config-link]: https://github.com/zulip/zulip/blob/master/puppet/zulip/files/nginx/zulip-include-frontend/app
|
||||
[nginx-config-link]: https://github.com/zulip/zulip/blob/main/puppet/zulip/files/nginx/zulip-include-frontend/app
|
||||
|
||||
## Django routes the request to a view in urls.py files
|
||||
|
||||
@@ -70,7 +70,7 @@ on how the REST API handles our user creation example.
|
||||
## Views serving HTML are internationalized by server path
|
||||
|
||||
If we look in
|
||||
[zproject/urls.py](https://github.com/zulip/zulip/blob/master/zproject/urls.py),
|
||||
[zproject/urls.py](https://github.com/zulip/zulip/blob/main/zproject/urls.py),
|
||||
we can see something called `i18n_urls`. These urls show up in the
|
||||
address bar of the browser, and serve HTML.
|
||||
|
||||
@@ -135,7 +135,7 @@ This request:
|
||||
yields a response with this HTTP header:
|
||||
`Allow: PUT, GET`
|
||||
|
||||
We can see this reflected in [zproject/urls.py](https://github.com/zulip/zulip/blob/master/zproject/urls.py):
|
||||
We can see this reflected in [zproject/urls.py](https://github.com/zulip/zulip/blob/main/zproject/urls.py):
|
||||
|
||||
```python
|
||||
rest_path('users',
|
||||
@@ -151,7 +151,7 @@ The endpoints from the legacy JSON API are written without REST in
|
||||
mind. They are used extensively by the web client, and use POST.
|
||||
|
||||
You can see them in
|
||||
[zproject/legacy_urls.py](https://github.com/zulip/zulip/blob/master/zproject/legacy_urls.py).
|
||||
[zproject/legacy_urls.py](https://github.com/zulip/zulip/blob/main/zproject/legacy_urls.py).
|
||||
|
||||
### Incoming webhook integrations may not be RESTful
|
||||
|
||||
@@ -163,7 +163,7 @@ only POST.
|
||||
|
||||
For requests that correspond to a REST url pattern, Zulip configures
|
||||
its url patterns (see
|
||||
[zerver/lib/rest.py](https://github.com/zulip/zulip/blob/master/zerver/lib/rest.py))
|
||||
[zerver/lib/rest.py](https://github.com/zulip/zulip/blob/main/zerver/lib/rest.py))
|
||||
so that the action called is `rest_dispatch`. This method will
|
||||
authenticate the user, either through a session token from a cookie,
|
||||
or from an `email:api-key` string given via HTTP basic auth for API
|
||||
|
||||
@@ -98,7 +98,7 @@ def home(request: HttpRequest) -> HttpResponse:
|
||||
### Writing a template
|
||||
|
||||
Templates for the main website are found in
|
||||
[templates/zerver/app](https://github.com/zulip/zulip/tree/master/templates/zerver/app).
|
||||
[templates/zerver/app](https://github.com/zulip/zulip/tree/main/templates/zerver/app).
|
||||
|
||||
|
||||
## Writing API REST endpoints
|
||||
@@ -109,7 +109,7 @@ view code is in the implementations of API REST endpoints.
|
||||
|
||||
The REST API does authentication of the user through `rest_dispatch`,
|
||||
which is documented in detail at
|
||||
[zerver/lib/rest.py](https://github.com/zulip/zulip/blob/master/zerver/lib/rest.py).
|
||||
[zerver/lib/rest.py](https://github.com/zulip/zulip/blob/main/zerver/lib/rest.py).
|
||||
This method will authenticate the user either through a session token
|
||||
from a cookie on the browser, or from a base64 encoded `email:api-key`
|
||||
string given via HTTP basic auth for API clients.
|
||||
@@ -174,7 +174,7 @@ the inner decorator.
|
||||
|
||||
The implementation of `has_request_variables` is documented in detail
|
||||
in
|
||||
[zerver/lib/request.py](https://github.com/zulip/zulip/blob/master/zerver/lib/request.py))
|
||||
[zerver/lib/request.py](https://github.com/zulip/zulip/blob/main/zerver/lib/request.py))
|
||||
|
||||
REQ also helps us with request variable validation. For example:
|
||||
|
||||
@@ -200,7 +200,7 @@ REQ also helps us with request variable validation. For example:
|
||||
validator on the value of a string.
|
||||
|
||||
See
|
||||
[zerver/lib/validator.py](https://github.com/zulip/zulip/blob/master/zerver/lib/validator.py)
|
||||
[zerver/lib/validator.py](https://github.com/zulip/zulip/blob/main/zerver/lib/validator.py)
|
||||
for more validators and their documentation.
|
||||
|
||||
### Deciding which HTTP verb to use
|
||||
@@ -214,7 +214,7 @@ be read with GET, without the expense of the full GET. OPTIONS is also
|
||||
read-only, and used by clients to determine which HTTP verbs are
|
||||
available for a given path. This isn't something you need to write, as
|
||||
it happens automatically in the implementation of `rest_dispatch`--see
|
||||
[zerver/lib/rest.py](https://github.com/zulip/zulip/blob/master/zerver/lib/rest.py)
|
||||
[zerver/lib/rest.py](https://github.com/zulip/zulip/blob/main/zerver/lib/rest.py)
|
||||
for more.
|
||||
|
||||
If you're creating new data, try to figure out if the thing you are
|
||||
@@ -259,7 +259,7 @@ database) and lead to a 500 error. If an actions function is
|
||||
responsible for validation as well, it should have a name starting
|
||||
with `check_`.
|
||||
|
||||
For example, in [zerver/views/realm.py](https://github.com/zulip/zulip/blob/master/zerver/views/realm.py):
|
||||
For example, in [zerver/views/realm.py](https://github.com/zulip/zulip/blob/main/zerver/views/realm.py):
|
||||
|
||||
```py
|
||||
@require_realm_admin
|
||||
@@ -284,7 +284,7 @@ Zulip realm).
|
||||
|
||||
You should always use `channel.<method>` to make an `HTTP <method>` call
|
||||
to the Zulip JSON API. As an example, in
|
||||
[static/js/admin.js](https://github.com/zulip/zulip/blob/master/static/js/admin.js)
|
||||
[static/js/admin.js](https://github.com/zulip/zulip/blob/main/static/js/admin.js)
|
||||
|
||||
```js
|
||||
var url = "/json/realm";
|
||||
|
||||
Reference in New Issue
Block a user