Skip to content
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

Created the first two part of Diataxis based documentation for Contrib Tracker #672

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
73 changes: 73 additions & 0 deletions docs/how-to-guides/add-custom-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Adding and Customizing a Contribution Source

The Contribution Tracker supports tracking contributions from various data sources through custom plugins. This guide explains how to add a new contribution source, including creating and configuring the plugin and managing any necessary database adjustments.

## Steps to Add and Customize a Contribution Source

1. **Understand the Contribution Plugin System**
- Contribution sources are implemented as plugins of type `ContributionSource` in the [Contribution Plugin Manager](../../web/modules/custom/ct_manager).
- Each plugin retrieves and processes contributions for its source during cron runs.

2. **Configure the New Data Source**
- Identify the API or database schema for the source you wish to integrate.
- Ensure you have access credentials, such as tokens or API keys, for secure integration.

3. **Create the Custom Plugin**
- **File Location**: Place the plugin in the `src/Plugin/ContributionSource` directory of your custom module.
- **Plugin Annotation**: Use the `@ContributionSource` annotation to define the plugin, like this:

```php
/**
* @ContributionSource(
* id = "custom_source",
* description = @Translation("Retrieve contributions from Custom Source.")
* )
*/
```

- **Implement the Interface**: Ensure the plugin implements the `ContributionSourceInterface` and its required methods:
- `process()`: Fetch and process contributions.
- `getUserIssues()` and `getUserCodeContributions()`: Handle data retrieval for user contributions.

4. **Adjust the Database if Necessary**
- Review the existing schema to determine if additional fields or tables are needed for the new data source.
- Use Drupal’s schema API to add custom tables or fields.

5. **Test the Plugin**
- Use test data or sandbox API credentials to validate the plugin.
- Ensure contributions are retrieved and processed correctly without errors.

6. **Integrate with the Contribution Tracker**
- Enable the plugin in the Contribution Tracker configuration.
- Run cron to test how contributions from the new source are tracked.

### Example: Creating a Plugin for Custom API Source

- **File Path**: `custom_module/src/Plugin/ContributionSource/CustomSource.php`
- **Sample Code**:

```php
namespace Drupal\custom_module\Plugin\ContributionSource;

use Drupal\ct_manager\ContributionSourceInterface;

/**
* @ContributionSource(
* id = "custom_source",
* description = @Translation("Retrieve contributions from a custom API.")
* )
*/
class CustomSource implements ContributionSourceInterface {
public function process() {
// Custom logic to fetch and process contributions.
}

public function getUserIssues() {
// Fetch user issues from the API.
}

public function getUserCodeContributions() {
// Fetch user code contributions from the API.
}
}
```
10 changes: 10 additions & 0 deletions docs/how-to-guides/generate-reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Generating Contribution Reports

1. **Access Reports**
Navigate to `/contribution-count` for Contribution Count reports.

2. **Customize Reports**
- Filter by contribution type, technology, contributor name, etc.

3. **Export Data**
- Export reports in CSV or other formats for external analysis.
32 changes: 32 additions & 0 deletions docs/how-to-guides/how-to-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# How to work on this project

Before committing your changes, make sure you are working on the latest codebase by fetching or pulling to make sure you have all the work.

```bash
git checkout main
git pull origin main
```

To initiate a build:

1. Create a branch specific to the feature.

```bash
git checkout -b <branch-name>
```

2. Make the required changes and commit

```bash
git commit -m "commit-message"
```

3. Push the changes

```bash
git push origin <branch-name>
```

For a better understanding of the entire process and standards, please refer to Axelerant's [Git workflow.](https://engg-handbook.axelerant.com/docs/how-we-work/git/git-workflow/)

N.B. If provided with a user account, you can use the management console of Platform.sh to manage your environment and deployments.
21 changes: 21 additions & 0 deletions docs/how-to-guides/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# How-to Guides

This section provides practical, task-oriented guides for working with the Contribution Tracker system.

- [How to Work on This Project](how-to-work.md)
- Steps for working with the latest code, committing changes, and managing branches

- [Adding a New Contribution Source](add-custom-source.md)
- Steps to Add and Customize a Contribution Source

- [Generating Contribution Reports](generate-reports.md)
- How to create, customize, and export reports.

- [Setting Up Social Login Integration](setting-up-social-login.md)
- Overview of supported social login options.
- Configuring and testing GitHub and Drupal.org social logins.

- [Resetting Social Login and Authentication Settings](reset-social-login.md)
- Troubleshooting and reconfiguring social login providers.

For foundational guides, visit the [Tutorials section](../tutorials/index.md).
18 changes: 18 additions & 0 deletions docs/how-to-guides/reset-social-login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Resetting Social Login and Authentication Settings

## Troubleshooting Common Issues

1. **Expired Tokens**:
- Renew OAuth credentials via the provider's dashboard.

2. **Invalid Configuration**:
- Check for typos or mismatched URLs in the settings.
- Verify `redirect_uri` matches the settings on the provider side.

## Steps for Resetting

1. **Reconfigure OAuth Settings**:
- Update the client ID and secret using environment variables in Platform.sh. Ensure the correct values are set for your project’s environment configuration.

2. **Re-test Integration**:
- Follow the testing steps outlined in the [Setting Up Social Login Integration guide](setting-up-social-login.md) to confirm that the changes are working correctly.
25 changes: 25 additions & 0 deletions docs/how-to-guides/setting-up-social-login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Setting Up Social Login Integration

Streamline user authentication by enabling social login for GitHub and Drupal.org. This enhances usability while maintaining security.
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a How-to? It's already set up for contrib tracker. Why would they want to do it again?


## Step-by-Step Configuration

1. **Prepare OAuth Credentials**:
- GitHub: Create an OAuth application via [GitHub Developer Settings](https://github.com/settings/developers).
- Drupal.org: Set up API access via your Drupal.org account.

2. **Add Credentials to System Settings**:
- Update `settings.php` with the obtained client ID and secret for each provider:

```php
$settings['github']['client_id'] = 'YOUR_CLIENT_ID';
$settings['github']['client_secret'] = 'YOUR_CLIENT_SECRET';
```

3. **Enable Social Login Modules**:
- Ensure the necessary modules (`social_auth_github`, `social_auth_drupal`) are enabled.

**Testing and Verification**

- Test logins with dummy accounts to confirm functionality.
- Check for errors in the logs or use debugging tools if issues arise.
31 changes: 31 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# Overview

The Contribution Tracking System is designed to facilitate the monitoring and analysis of contributions across various projects and initiatives within our organization. Leveraging the power of Drupal, this system provides robust features for capturing, categorizing, and reporting on our contributions, thereby enabling better resource allocation, performance evaluation, and recognition of employee achievements.

## 1. [Tutorials](tutorials/index.md)

Step-by-step guides to help you get started with the Contribution Tracker.

- [Getting Started with Contribution Tracker](tutorials/getting-started.md)

## 2. [How-to Guides](how-to-guides/index.md)

Practical solutions for common tasks in the Contribution Tracker.

- [How to Work on This Project](how-to-guides/how-to-work.md)
- [Adding a New Contribution Source](how-to-guides/add-custom-source.md)
- [Generating Contribution Reports](how-to-guides/generate-reports.md)
- [Setting Up Social Login Integration](how-to-guides/setting-up-social-login.md)
- [Resetting Social Login and Authentication Settings](how-to-guides/reset-authentication.md)

## 3. References

Technical resources and detailed information about the Contribution Tracker.

- Codebase Overview and Key Components
- API Documentation
- Contribution Plugin Manager Module

## 4. Explanations

Insights into the architecture, design choices, and inner workings of the Contribution Tracker.

- Architecture and Design Choices
- How Contribution Tracking Works
72 changes: 72 additions & 0 deletions docs/tutorials/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Getting Started with Contribution Tracker

## Overview

The Contribution Tracking System monitors and analyzes contributions across projects, leveraging Drupal’s features for capturing, categorizing, and reporting data. It aids in resource allocation, performance evaluation, and recognizing achievements.

## Tools & Prerequisites

Major tools that are required for setting up the site. It is recommended to use the latest version or at least the minimum version as mentioned below. It is mandatory to add [your SSH key to your GitHub account settings](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).

- [OrbStack](https://orbstack.dev/) or [Docker](https://docs.docker.com/install/)

- [Composer](https://getcomposer.org/download/) (optional if used via DDEV)

- [DDEV](https://ddev.com/get-started/) - v1.23.3 and above.

- [NodeJs](https://nodejs.org/en/download) (optional if used via DDEV)

## Local environment setup

Once you have all the tools installed, proceed to run the following to clone the repository.

```bash
git clone [email protected]:contrib-tracker/backend.git
```

Change to the directory of the repository and run DDEV to start.

```bash
cd backend
ddev start
```

Once DDEV has been set up successfully, it will display the links in the terminal. Next, run the following to fetch all dependencies.

```bash
ddev composer install
```

You can pull the database from the platform.sh directly. Make sure that the [PLATFORMSH_CLI_TOKEN is set](https://ddev.readthedocs.io/en/latest/users/providers/platform/).

```bash
ddev pull platform
```

Make sure code changes are updated.

```bash
ddev drush deploy -y
```

## Post Installation

Generate a one-time login link and reset the password through it.

```bash
ddev drush uli
```

Clear the cache using drush

```bash
ddev drush cr
```

## Theme Build

```bash
cd web/themes/custom/contribtracker && npm install && npm run build && ddev drush cr
```

You can access the site at: [https://contribtracker.ddev.site/](https://contribtracker.ddev.site/).
7 changes: 7 additions & 0 deletions docs/tutorials/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tutorials

Welcome to the Tutorials section of the Contribution Tracker documentation. These step-by-step guides introduce core concepts and workflows, helping new contributors get started quickly.

- [Getting Started with Contribution Tracker](getting-started.md)
- Overview of the system, its purpose, and core features.
- Setting up the local environment and installing dependencies.
Loading