Skip to content
Open
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
33 changes: 33 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# http://EditorConfig.org

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{css,scss}]
indent_style = tab

[*.{html,php,phtml}]
indent_style = tab

[*.js]
indent_style = tab

[*.md]
indent_size = 4
indent_style = tab

[*.neon]
indent_style = tab

[*.xml]
indent_style = tab

[*.yml]
indent_size = 2
indent_style = space

[Makefile]
indent_style = tab
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "monthly"
70 changes: 70 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Automated tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

tests:
# https://github.com/actions/virtual-environments
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./Extension

steps:
- name: Git checkout source code
uses: actions/checkout@v5
with:
path: Extension

# Composer tests

- name: Check PHP syntax
run: composer run-script php-lint

- name: Check PHTML syntax
run: composer run-script phtml-lint

- name: Use Composer cache
id: composer-cache
uses: actions/cache@v4
with:
path: Extension/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Run Composer install
run: composer install --prefer-dist --no-progress
if: steps.composer-cache.outputs.cache-hit != 'true'

- name: PHP_CodeSniffer
run: composer run-script phpcs

- name: Git checkout FreshRSS source code
uses: actions/checkout@v5
with:
repository: FreshRSS/FreshRSS
path: FreshRSS

- name: PHPStan
run: composer run-script phpstan

# NPM tests

- name: Uses Node.js
uses: actions/setup-node@v6
with:
# https://nodejs.org/en/about/releases/
node-version: 'lts/*'
cache: 'npm'
cache-dependency-path: 'Extension/package-lock.json'

- run: npm ci

- name: Check JavaScript syntax
run: npm run --silent eslint
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode/
bin/
node_modules/
tmp/
vendor/
19 changes: 19 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"default": true,
"blanks-around-fences": false,
"blanks-around-lists": false,
"first-line-heading": false,
"line-length": false,
"no-hard-tabs": false,
"no-inline-html": {
"allowed_elements": ["br", "img", "kbd", "details", "summary"]
},
"no-multiple-blanks": {
"maximum": 2
},
"no-trailing-spaces": true,
"ul-indent": false,
"ul-style": {
"style": "consistent"
}
}
4 changes: 4 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git/
node_modules/
tmp/
vendor/
4 changes: 2 additions & 2 deletions Controllers/helloController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

class FreshExtension_hello_Controller extends Minz_ActionController {
public function worldAction() {

public function worldAction(): void {
}
}
3 changes: 2 additions & 1 deletion Controllers/indexController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
declare(strict_types=1);

class FreshExtension_index_Controller extends FreshRSS_index_Controller {
public function aboutAction() {
public function aboutAction(): void {
Minz_View::prependTitle(_t('ext.hello_world.about.title') . ' · ');
}
}
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.DEFAULT_GOAL := help

##########
## HELP ##
##########
.PHONY: help
help:
@grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

######################
## Tests and linter ##
######################
.PHONY: lint
lint: vendor/bin/phpcs ## Run the linter on the PHP files
$(PHP) vendor/bin/phpcs . -p -s

.PHONY: lint-fix
lint-fix: vendor/bin/phpcbf ## Fix the errors detected by the linter
$(PHP) vendor/bin/phpcbf . -p -s

bin/composer:
mkdir -p bin/
wget 'https://raw.githubusercontent.com/composer/getcomposer.org/298f4ba7b62708d16c291573e1c52811b5e494bd/web/installer' -O - -q | php -- --quiet --install-dir='./bin/' --filename='composer'

vendor/bin/phpcs: bin/composer
bin/composer install --prefer-dist --no-progress
ln -s ../vendor/bin/phpcs bin/phpcs

vendor/bin/phpcbf: bin/composer
bin/composer install --prefer-dist --no-progress
ln -s ../vendor/bin/phpcbf bin/phpcbf

node_modules/.bin/eslint:
npm install

vendor/bin/phpstan: bin/composer
bin/composer install --prefer-dist --no-progress

.PHONY: composer-test
composer-test: vendor/bin/phpstan
bin/composer run-script test

.PHONY: composer-fix
composer-fix:
bin/composer run-script fix

.PHONY: npm-test
npm-test: node_modules/.bin/eslint
npm test

.PHONY: npm-fix
npm-fix: node_modules/.bin/eslint
npm run fix

# TODO: Add shellcheck, shfmt, hadolint
.PHONY: test-all
test-all: composer-test npm-test

.PHONY: fix-all
fix-all: composer-fix npm-fix
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Extension-HelloWorld

An HelloWorld extension for [FreshRSS](https://github.com/FreshRSS/FreshRSS).
An Hello World extension for [FreshRSS](https://github.com/FreshRSS/FreshRSS).

It is a bit described in the documentation: https://freshrss.github.io/FreshRSS/en/developers/03_Backend/05_Extensions.html#write-an-extension-for-freshrss
It is a bit described in the documentation: <https://freshrss.github.io/FreshRSS/en/developers/03_Backend/05_Extensions.html#write-an-extension-for-freshrss>

## Warning

It is not recommended to install this extension on your production server. This extension manipulates the important “About” page.
It is not recommended to install this extension on your production server.
This extension manipulates the important “About” page.

## How to install

To install this extension, download the extension archive first and extract it on your PC. Then, upload this on your server. Extensions must be in the `./extensions` directory of your FreshRSS installation.
To install this extension, download the extension archive first and extract it on your PC.
Then, upload this on your server. Extensions must be in the `./extensions` directory of your FreshRSS installation.

## What it does

Expand All @@ -21,3 +23,15 @@ As showcase it will manipulate some little things:
- the “Save” button titles will be changed
- the normal view article list will be changed
- it loads a CSS and a JavaScript file

## Development

Hint for VSCode with Intelephense:

```json
{
"intelephense.environment.includePaths": [
"../FreshRSS/",
]
}
```
74 changes: 74 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "freshrss.org/freshrss-hello-world",
"description": "Extension example for FreshRSS",
"type": "project",
"homepage": "https://github.com/FreshRSS/xExtension-HelloWorld/",
"license": "AGPL-3.0",
"support": {
"docs": "https://github.com/FreshRSS/xExtension-HelloWorld/blob/master/README.md",
"issues": "https://github.com/FreshRSS/xExtension-Hello-World/issues",
"source": "https://github.com/FreshRSS/xExtension-Hello-World/"
},
"keywords": [
"FreshRSS",
"extension"
],
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gmp": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-pcre": "*",
"ext-pdo": "*",
"ext-pdo_sqlite": "*",
"ext-session": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-zend-opcache": "*",
"ext-zip": "*",
"ext-zlib": "*"
},
"suggest": {
"ext-iconv": "*",
"ext-pdo_mysql": "*",
"ext-pdo_pgsql": "*"
},
"require-dev": {
"php": ">=8.1",
"ext-phar": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"phpstan/phpstan": "^2",
"phpstan/phpstan-strict-rules": "^2",
"squizlabs/php_codesniffer": "^4"
},
"scripts": {
"php-lint": "find . -type d -name 'vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
"phtml-lint": "find . -type d -name 'vendor' -prune -o -name '*.phtml' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
"phpcs": "phpcs . -s",
"phpcbf": "phpcbf . -p -s",
"phpstan": "phpstan analyse .",
"test": [
"@php-lint",
"@phtml-lint",
"@phpcs",
"@phpstan"
],
"fix": [
"@phpcbf"
]
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": false
}
}
}
Loading