Initial commit: Minimal Profile app for Nextcloud 33

This commit is contained in:
2026-04-16 14:01:13 +02:00
commit 339a2969aa
7 changed files with 231 additions and 0 deletions

78
README.md Normal file
View File

@@ -0,0 +1,78 @@
# Minimal Profile
A Nextcloud 33 app that hides profile fields to create a minimal user profile.
## Features
- Hide profile fields like pronouns, social links, and more
- Works on personal settings page
## Installation
1. Copy the `minimalprofile` folder to your Nextcloud `apps/` directory
2. Enable the app:
```bash
occ app:enable minimalprofile
```
## Usage
### Set hidden fields using OCC config command
Hide the pronouns field:
```bash
occ config:app:set minimalprofile hidden_fields --value='["pronouns"]'
```
Hide multiple fields:
```bash
occ config:app:set minimalprofile hidden_fields --value='["pronouns","role","headline"]'
```
### View hidden fields
```bash
occ config:app:get minimalprofile hidden_fields
```
### Show all fields (reset)
```bash
occ config:app:delete minimalprofile hidden_fields
```
## Available Fields
| Field | Description |
|-------|-------------|
| `pronouns` | User pronouns (e.g., she/her) |
| `role` | Job title / role |
| `headline` | Personal tagline |
| `biography` | User bio |
| `organisation` | Organization |
| `phone` | Phone number |
| `address` | Physical address |
| `birthdate` | Birthdate |
| `website` | Website URL |
| `twitter` | Twitter handle |
| `fediverse` | Fediverse handle |
| `location` | Location |
## Examples
Hide just pronouns:
```bash
occ config:app:set minimalprofile hidden_fields --value='["pronouns"]'
```
Hide pronouns, role, and headline:
```bash
occ config:app:set minimalprofile hidden_fields --value='["pronouns","role","headline"]'
```
Hide all extra social fields:
```bash
occ config:app:set minimalprofile hidden_fields --value='["pronouns","role","headline","biography","website","twitter","fediverse"]'
```
## Compatibility
- Nextcloud 33

20
appinfo/info.xml Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<info xmlns="http://nextcloud.org/ns">
<id>minimalprofile</id>
<name>Minimal Profile</name>
<summary>Hides profile fields to create a minimal user profile</summary>
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
<version>1.0.0</version>
<licence>AGPL</licence>
<author>Your Name</author>
<namespace>MinimalProfile</namespace>
<categories>
<category>settings</category>
</categories>
<dependencies>
<nextcloud min-version="33" max-version="33"/>
</dependencies>
<scripts>
<script>minimalprofile</script>
</scripts>
</info>

4
appinfo/routes.xml Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<routes>
<route url="/api/v1/hidden-fields" method="GET" controller="OCA\MinimalProfile\Controller\ApiController:getHiddenFields"/>
</routes>

21
composer.json Normal file
View File

@@ -0,0 +1,21 @@
{
"name": "nextcloud/minimalprofile",
"description": "Hides profile fields to create a minimal user profile",
"type": "nextcloud-app",
"license": "AGPL-3.0-or-later",
"require": {
"nextcloud/ocp": "dev-master"
},
"require-dev": {
"nextcloud/coding-standard": "^1.2.0"
},
"autoload": {
"psr-4": {
"OCA\\MinimalProfile\\": "lib/"
}
},
"scripts": {
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix"
}
}

53
js/minimalprofile.js Normal file
View File

@@ -0,0 +1,53 @@
(function() {
'use strict';
var fieldSelectors = {
'pronouns': 'input[id="account-property-pronouns"]',
'role': 'input[id="account-property-role"]',
'headline': 'input[id="account-property-headline"]',
'biography': 'input[id="account-property-biography"]',
'organisation': 'input[id="account-property-organisation"]',
'phone': 'input[id="account-property-phone"]',
'address': 'input[id="account-property-address"]',
'birthdate': 'input[id="account-property-birthdate"]',
'website': 'input[id="account-property-website"]',
'twitter': 'input[id="account-property-twitter"]',
'fediverse': 'input[id="account-property-fediverse"]',
'location': 'input[id="account-property-location"]'
};
function hideFields(hiddenFields) {
hiddenFields.forEach(function(field) {
var selector = fieldSelectors[field];
if (selector) {
var elements = document.querySelectorAll(selector);
elements.forEach(function(el) {
var parent = el.parentElement;
while (parent && !parent.classList.contains('personal-settings-setting-box')) {
parent = parent.parentElement;
if (!parent) return;
}
if (parent && parent.classList.contains('personal-settings-setting-box')) {
parent.style.display = 'none';
}
});
}
});
}
OCP.registerLoadEndpoint(function() {
var req = new XMLHttpRequest();
req.onload = function() {
if (req.status === 200) {
try {
var data = JSON.parse(req.responseText);
if (data.hiddenFields && data.hiddenFields.length > 0) {
hideFields(data.hiddenFields);
}
} catch (e) {}
}
};
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
req.send();
});
})();

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace OCA\MinimalProfile\AppInfo;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
class Application extends App implements IBootstrap {
public const APP_ID = 'minimalprofile';
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}
public function register(IRegistrationContext $context): void {
}
public function boot(IBootContext $context): void {
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace OCA\MinimalProfile\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IConfig;
use OCP\IRequest;
class ApiController extends Controller {
public function __construct(
string $appName,
IRequest $request,
private IConfig $config,
) {
parent::__construct($appName, $request);
}
public function getHiddenFields(): JSONResponse {
$value = $this->config->getAppValue('minimalprofile', 'hidden_fields', '');
$hiddenFields = $value !== '' ? json_decode($value, true) ?? [] : [];
return new JSONResponse([
'hiddenFields' => $hiddenFields,
]);
}
}