Skip to content

Commit

Permalink
add: contribution doc and fix use_latest template tag (#293)
Browse files Browse the repository at this point in the history
* add: contribution doc and fix use_latest template tag fix

* chore: add doc_string for use_latest filter

---------

Co-authored-by: Harsh Shah <[email protected]>
  • Loading branch information
deepakdinesh1123 and shahharsh176 authored Aug 1, 2024
1 parent 96760b3 commit 2b81c9a
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 1 deletion.
145 changes: 145 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Contribution Guide for Zango

## Table of Contents

1. [How to Contribute](#how-to-contribute)
- [Reporting Issues](#reporting-issues)
- [Contributing to Zango](#contributing-to-zango)
2. [Contributing to Zango backend](#contributing-to-zango-backend)
3. [Contributing to Zango frontend](#contributing-to-zango-frontend)
4. [Contributing to documentation](#contributing-to-documentation)
5. [Community](#community)

## How to Contribute

### Reporting Issues

If you find a bug or have a feature request, please create an issue in our [issue tracker](https://github.com/Healthlane-Technologies/Zango/issues). When reporting an issue, please include as much detail as possible, including steps to reproduce the problem, your environment, and any relevant log output.

## Contributing to Zango

This section describes the general practices for contributing to zango, you can check the next sections which describe how to contribute to [frontend](#contributing-to-zango-frontend), [backend](#contributing-to-zango-backend) and [documentation](#contributing-to-documentation)

### Getting Started

1. **Fork the Repository**: Fork the [Zango repository](https://github.com/Healthlane-Technologies/Zango) to your GitHub account.
2. **Clone the Repository**: Clone your forked repository to your local machine.
3. Set Up Environment: Follow the setup instructions in Setup.md to configure your development environment.

### Development Workflow

1. Create a Branch: Create a new branch for your feature or bugfix

```bash
git checkout -b feature/your-feature-name
```

2. Implement Changes: Make your changes, ensuring to follow the coding standards and best practices.
3. Commit Changes: Commit your changes with a meaningful commit message.

```bash
git add .
git commit -m "Add feature <feature_name>"
```

### Submitting Changes

1. Push to GitHub: Push your changes to your forked repository.

```bash
git push origin feature/your-feature-name
```

2. Create a Pull Request: Open a pull request from your branch to the main branch of the original repository. Provide a clear description of your changes and link any related issues.

### Code Review

1. Respond to Feedback: Be prepared to make changes based on feedback from code reviewers.
2. Update PR: Push any updates to your branch to reflect the feedback received.

## Contributing to Zango backend

### Steps to contribute to Zango backend

1. Clone the zango repository
2. Create a new virtual environment
3. From the `zango/backend` directory run the following command

```bash
pip install -e .
```

4. Perform the steps to setup a new project as described in the docs [here](https://www.zango.dev/docs/core/getting-started/installing-zelthy/manual#zango-the-zango-cli)
5. Start your project
6. Lanuch a new app
7. Make changes to Zango and view the changes through your project.

**Running Migrations:** You can run all the Zango migrations using the command `python manage.py migrate_schemas`, this is for the zango
core migrations only, you can create and run app specific migrations as described [here](https://www.zango.dev/docs/core/ddms/migrating-ddms)
**Static Files:** To add static files that you have added to Zango, you can use the command `python manage.py collectstatic`

## Contributing to Zango frontend

1. Go to the frontend directory of the repository and install the dependencies

```bash
cd frontend
yarn install
```

2. Start the application with mock service worker

```bash
yarn mock
```

3. Generating and Using frontend build in Zango
To test your frontend app with the Zango framework, follow these steps:

Run the build command:

```bash
yarn build
```

This command generates the build and places it inside the `backend/src/zango/assets/app_panel/js` directory of Zango.

The generated build will include the latest timestamp in its filename (`build.<timestamp>.min.js`). By default, the most recent build will be served. If you need to use a different build, you can update the filename in the ``backend/src/zango/apps/shared/tenancy/templates/app_panel.html`` file.


4. Collecting Static Build for Your Project

Before testing the build, collect the static files for your project. Ensure your project is already created and your environment is activated.

Change directory to your project:

```bash
cd <project_name>
```

Collect the static build:

```bash
python manage.py collectstatic
```

## Contributing to Documentation

We use docusaurus for maintaining Zango's documentation

1. Go to the docs directory of the repository and install the dependencies

```bash
cd zango/docs
yarn install
```

2. Start the application

```bash
yarn start
```

## Community

If you face any issues or need any help you can use our [discord](https://discord.com/invite/WHvVjU23e7) to connect with other contributors.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,28 @@ def humanize_timedelta(timedelta_obj):

@register.filter()
def use_latest(build_path):
"""
Returns the latest version of a static file based on a given file path pattern.
Args:
build_path (str): the original file path pattern
Returns:
str: The path to the latest version of the file, or the original path if no match is found.
Example:
Usage in a Django template to reference the latest static file:
<script src="{% static 'app_panel/js/build.*.min.js'|use_latest %}"></script>
Make sure to load the zango filters with {% load zango_filters %}.
"""
buildir = os.path.dirname(build_path)
filep = os.path.basename(build_path)
for dir in settings.STATICFILES_DIRS:
for dirpath, dirnames, filenames in os.walk(dir):
filenames = sorted(filenames, reverse=True)
for filename in filenames:
if re.match(filep, filename):
return os.path.join(buildir, filename)
return build_path
return build_path

0 comments on commit 2b81c9a

Please sign in to comment.