ci #6

Merged
n merged 2 commits from ci into main 2024-02-11 22:11:45 +01:00
2 changed files with 105 additions and 91 deletions

27
.gitea/workflows/lint.yml Normal file
View file

@ -0,0 +1,27 @@
name: lint
run-name: lint is launched by ${{ github.actor }}
on: [push]
jobs:
check:
runs-on: ubuntu-latest
name: lint
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- name: Install linters using Composer
run: |
export COMPOSER_HOME=/tmp
echo "{}" > composer.json
composer config --no-interaction allow-plugins.bamarni/composer-bin-plugin true
composer require --dev bamarni/composer-bin-plugin
composer bin phplint require --dev overtrue/phplint
composer require --dev friendsofphp/php-cs-fixer
- name: Lint
run: vendor/bin/phplint --no-cache --no-progress --exclude=vendor --verbose
- name: PHP CS Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --verbose --diff .
- run: echo "🍏 This job's status is ${{ job.status }}."

View file

@ -85,8 +85,7 @@ function hook_shaargem_save_link($data)
{
// ugly hack to get scheme
if(isset($_POST['lf_url'])) {
if(strstr($_POST['lf_url'],"gemini://"))
{
if(strstr($_POST['lf_url'], "gemini://")) {
$new_url = str_replace("http://", "gemini://", $data['url']);
$data['url'] = $new_url;
}
@ -134,8 +133,7 @@ function fetch_iri_title($iri)
{
$ret = preg_match(",gemini://([\d\w\.\+\-@\:%._\~#=]+)/?,", $iri, $domain);
static $redirect_counter = 0;
if ($ret)
{
if ($ret) {
$stream_context = stream_context_create([ 'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
@ -157,13 +155,11 @@ function fetch_iri_title($iri)
error_log("[shaargem] status:".$status.", meta:".$meta);
// status 1x cannot be handled by shaarli, but input field can be used as title
if ($status[0] == 1)
{
if ($status[0] == 1) {
return $meta;
}
// status 2x ok
elseif ($status[0] == 2)
{
elseif ($status[0] == 2) {
$nblines = 1;
while($line = fgets($fp)) {
$ret = preg_match(",# (.*),", $line, $title);
@ -174,27 +170,19 @@ function fetch_iri_title($iri)
}
}
// status 3x redirect
elseif ($status[0] == 3 and $redirect_counter < $max_redirects)
{
elseif ($status[0] == 3 and $redirect_counter < $max_redirects) {
$redirect_counter++;
error_log("[shaargem] ".shaargem_t("Redirecting to")." ".$meta." (".$redirect_counter."/".$max_redirects.")");
$title[1] = fetch_iri_title($meta);
}
// 4x 5x 6x are error statuses, should find a better way to display that
elseif ($status[0] == 4)
{
elseif ($status[0] == 4) {
return shaargem_t('Error').' '.$status.' ('.shaargem_t('TEMPORARY FAILURE').'): '.$meta;
}
elseif ($status[0] == 5)
{
} elseif ($status[0] == 5) {
return shaargem_t('Error').' '.$status.' ('.shaargem_t('PERMANENT FAILURE').'): '.$meta;
}
elseif ($status[0] == 6)
{
} elseif ($status[0] == 6) {
return shaargem_t('Error').' '.$status.' ('.shaargem_t('CLIENT CERTIFICATE REQUIRED').'): '.$meta;
}
else
{
} else {
return shaargem_t('Invalid response').': '.$header;
}
fclose($fp);
@ -202,4 +190,3 @@ function fetch_iri_title($iri)
return $title[1];
}
}