Skip to content
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
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity, expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at team@appwrite.io. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
101 changes: 101 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Contributing

We would ❤️ for you to contribute to Appwrite and help make it better! We want contributing to Appwrite to be fun, enjoyable, and educational for anyone and everyone. All contributions are welcome, including issues, new docs as well as updates and tweaks, blog posts, workshops, and more.

## How to Start?

If you are worried or don’t know where to start, check out our next section explaining what kind of help we could use and where can you get involved. You can reach out with questions to [Eldad Fux (@eldadfux)](https://twitter.com/eldadfux) or anyone from the [Appwrite team on Discord](https://discord.gg/GSeTUeA). You can also submit an issue, and a maintainer can guide you!

## Code of Conduct

Help us keep Appwrite open and inclusive. Please read and follow our [Code of Conduct](/CODE_OF_CONDUCT.md).

## Submit a Pull Request 🚀

Branch naming convention is as following

`TYPE-ISSUE_ID-DESCRIPTION`

example:

```
doc-548-submit-a-pull-request-section-to-contribution-guide
```

When `TYPE` can be:

- **feat** - is a new feature
- **doc** - documentation only changes
- **cicd** - changes related to CI/CD system
- **fix** - a bug fix
- **refactor** - code change that neither fixes a bug nor adds a feature

**All PRs must include a commit message with the changes description!**

For the initial start, fork the project and use git clone command to download the repository to your computer. A standard procedure for working on an issue would be to:

1. `git pull`, before creating a new branch, pull the changes from upstream. Your master needs to be up to date.

```
$ git pull
```

2. Create new branch from `master` like: `doc-548-submit-a-pull-request-section-to-contribution-guide`<br/>

```
$ git checkout -b [name_of_your_new_branch]
```

3. Work - commit - repeat ( be sure to be in your branch )

4. Push changes to GitHub

```
$ git push origin [name_of_your_new_branch]
```

5. Submit your changes for review
If you go to your repository on GitHub, you'll see a `Compare & pull request` button. Click on that button.
6. Start a Pull Request
Now submit the pull request and click on `Create pull request`.
7. Get a code review approval/reject
8. After approval, merge your PR
9. GitHub will automatically delete the branch after the merge is done. (they can still be restored).

## Introducing New Features

We would 💖 you to contribute to Appwrite, but we would also like to make sure Appwrite is as great as possible and loyal to its vision and mission statement 🙏.

For us to find the right balance, please open an issue explaining your ideas before introducing a new pull request.

This will allow the Appwrite community to have sufficient discussion about the new feature value and how it fits in the product roadmap and vision.

This is also important for the Appwrite lead developers to be able to give technical input and different emphasis regarding the feature design and architecture. Some bigger features might need to go through our [RFC process](https://github.com/appwrite/rfc).

## Other Ways to Help

Pull requests are great, but there are many other areas where you can help Appwrite.

### Blogging & Speaking

Blogging, speaking about, or creating tutorials about one of Appwrite’s many features is great way to contribute and help our project grow.

### Presenting at Meetups

Presenting at meetups and conferences about your Appwrite projects. Your unique challenges and successes in building things with Appwrite can provide great speaking material. We’d love to review your talk abstract/CFP, so get in touch with us if you’d like some help!

### Sending Feedbacks & Reporting Bugs

Sending feedback is a great way for us to understand your use case better. If you had any issues, bugs, or want to share about your experience, feel free to do so on our GitHub issues page or at our [Discord channel](https://discord.gg/GSeTUeA).

### Submitting New Ideas

If you think dynamic-links could use a new feature, please open an issue on our GitHub repository, stating as much information as you can think about your new idea and it's implications. We would also use this issue to gather more information, get more feedback from the community, and have a proper discussion about the new feature.

### Improving Documentation

Submitting documentation updates, enhancements, designs, or bug fixes. Spelling or grammar fixes will be very much appreciated.

### Helping Someone

Searching for Appwrite, GitHub or StackOverflow and helping someone else who needs help. You can also help by teaching others how to contribute to Appwrites's repositories!
131 changes: 120 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Dynamic Link Function
# Dynamic Link Handler

This function is a handler for HTTP requests which redirects the user to a specific target URL based on their user-agent (which typically indicates their operating system and browser type). The redirection configuration is passed in through the `CONFIG` environment variable as a JSON string. The `CONFIG` variable is expected to contain an array of objects, where each object should have a `path` and `targets`.
![Join Discord](https://img.shields.io/discord/564160730845151244)

Here are some example `CONFIG` environment variable settings and the corresponding use cases:
## **Pre-release Notice**

1. **Mobile vs. Desktop Redirection**
This function dependent on Appwrite 1.4. Please note, as of the writing of this document, this version of Appwrite is not publicly available.

## Overview

Dynamic links are links that redirect users to different locations based on their device, operating system, or other factors. For example, a link to a mobile app can redirect users to the Google Play Store or Apple App Store depending on their device. Dynamic links can also be used to redirect users to Deep Links - a specific page within a Mobile app, such as a user profile page.

## Configuration

The service can be configured through the `CONFIG` environment variable in a JSON string format. Each object in the `CONFIG` array is expected to have a `path` and `targets`.

To illustrate, here are example settings for the `CONFIG` environment variable with respective use cases:

### 1. Mobile vs. Desktop Redirection

```json
[
Expand All @@ -18,10 +30,9 @@ Here are some example `CONFIG` environment variable settings and the correspondi
}
]
```
In this example, requests to the `/test` path will redirect mobile users to `https://m.example.com/test`, while desktop users are redirected to `https://www.example.com/test`. Users with unrecognized or non-classified user-agents will be directed to the default URL `https://www.example.com/test`.

In this case, when a request comes to the `/test` path, users with a user-agent string indicating a mobile device will be redirected to `https://m.example.com/test`, while users on desktop devices will be directed to `https://www.example.com/test`. If the user-agent is not recognized or does not fall into these categories, the user will be directed to the default URL `https://www.example.com/test`.

2. **OS Specific Redirection**
### 2. Operating System-Specific Redirection

```json
[
Expand All @@ -35,10 +46,9 @@ In this case, when a request comes to the `/test` path, users with a user-agent
}
]
```
In this scenario, requests to the `/app` path will redirect Android users to the Google Play store and iOS users to the Apple App Store, while all other users are directed to the general application page.

In this case, when a request comes to the `/app` path, users on Android devices will be redirected to the app's page on Google Play, while iOS users will be directed to the app's page on the Apple App Store. Other users will be redirected to a general application page.

3. **Deep Link Redirection with Fallback**
### 3. Deep Link Redirection with Fallback Option

```json
[
Expand All @@ -61,5 +71,104 @@ In this case, when a request comes to the `/app` path, users on Android devices
}
]
```
In this case, requests to the `/deeplink` path will redirect Android and iOS users to a specific part of an app, if installed. If the app is not installed (the deep link fails), they will be directed to their respective app stores. All other users will be redirected to a webpage containing similar information.

## Setting Up Deep Links

### Android

For Android, add the following to your `AndroidManifest.xml`:

```xml
<activity
android:name="com.example.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
<data
android:host="YOUR_HOST"
android:scheme="YOUR_SCHEME" />
</intent-filter>
</activity>
```

Also, add the following to your `MainActivity.java`:

```java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Get the intent that started this activity
Intent intent = getIntent();
Uri data = intent.getData();

// Verify that the intent has the correct action and data
if (Intent.ACTION_VIEW.equals(intent.getAction()) && data != null) {
String path = data.getPath();
String query = data.getQuery();
String screenName = query.substring(query.indexOf("=") + 1);
String url = "https://twitter.com/" + screenName;

// Redirect to the correct screen
Intent redirect = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(redirect);
}
}
```

More information on deep linking for Android can be found [on the Android Developers website](https://developer.android.com/training/app-links/deep-linking).

### iOS

For iOS, add the following to your `Info.plist` file:

```xml
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_SCHEME</string>
</array>
<key>CFBundleURLName</key>
<string>YOUR_HOST</string>
</dict>
</array>
```

Also, in your `AppDelegate.swift` file, add the following to handle deep links:

```swift
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true) else {
return false
}

let path = components.path,
let query = components.query,
let screenName = query.substring(from: query.index(query.startIndex, offsetBy: query.index(of: "=")! + 1))
let url = "https://twitter.com/\(screenName)"

// Redirect to the correct screen
if let url = URL(string: url) {
let svc = SFSafariViewController(url: url)
self.window?.rootViewController?.present(svc, animated: true, completion: nil)
}
return true
}
```

For further details on deep linking in iOS, refer to [Apple's official documentation](https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content).

## License

Here, when a request comes to the `/deeplink` path, Android and iOS users will be redirected to a deep link which opens a specific part of an app if they have it installed. If the app is not installed (the deep link fails), the fallback URL will open, leading them to the app's page on their respective app store. Other users will be redirected to a webpage with similar information.
This project is licensed under The MIT License (MIT). For more information, visit [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php).