Skip to content

Commit

Permalink
chore: INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricerenck committed Apr 18, 2024
1 parent c54e9b1 commit ff4ad33
Show file tree
Hide file tree
Showing 438 changed files with 62,845 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[*.{css,scss,less,js,json,ts,sass,html,hbs,mustache,phtml,html.twig,md,yml}]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
indent_size = 4
trim_trailing_whitespace = false

[site/templates/**.php]
indent_size = 2

[site/snippets/**.php]
indent_size = 2

[package.json,.{babelrc,editorconfig,eslintrc,lintstagedrc,stylelintrc}]
indent_style = space
indent_size = 2
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/content/ export-ignore
/site/ export-ignore
/src/ export-ignore
/media/ export-ignore
/tests/ export-ignore

/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.htaccess export-ignore
/index.site.php export-ignore
/package.json export-ignore
/package-lock.json export-ignore
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI
on:
push:
branches:
- main
jobs:
release:
name: Release
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install
run: npm install

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.PAT_SEMANTIC_RELEASE }}
run: npx semantic-release
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# files of Composer dependencies that are not needed for the plugin
/vendor/**/.*
/vendor/**/*.json
/vendor/**/*.txt
/vendor/**/*.md
/vendor/**/*.yml
/vendor/**/*.yaml
/vendor/**/*.xml
/vendor/**/*.dist
/vendor/**/readme.php
/vendor/**/LICENSE
/vendor/**/COPYING
/vendor/**/VERSION
/vendor/**/docs/*
/vendor/**/example/*
/vendor/**/examples/*
/vendor/**/test/*
/vendor/**/tests/*
/vendor/**/php4/*
/vendor/getkirby/composer-installer
/vendor/doctrine
/vendor/myclabs
/vendor/phar-io
/vendor/phpdocumentor
/vendor/phpspec
/vendor/phpunit
/vendor/sebastian
/vendor/symfony
/vendor/theseer
/vendor/webmozart
/.cache
/node_modules
/site/sessions
/site/accounts
/media
/.vscode
/kirby
/.sqlite
/site/cache
/content/phpunit-test
/~
/content/phpunit/.lock
/site/config
60 changes: 60 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Kirby .htaccess

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite

# In some environments it's necessary to
# set the RewriteBase to:
#
# RewriteBase /

# use the correct index file
RewriteRule index.php index.site.php [L]

# block files and folders beginning with a dot, such as .git
# except for the .well-known folder, which is used for Let's Encrypt and security.txt
RewriteRule (^|/)\.(?!well-known\/) index.php [L]

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]

# block all files in the site folder from being accessed directly
# except for requests to plugin assets files
RewriteRule ^site/(.*) index.php [L]

# Enable authentication header
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

# block direct access to kirby and the panel sources
RewriteRule ^kirby/(.*) index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

# compress text file responses
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"endOfLine": "lf",
"semi": false,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "es5",
"eslintIntegration": false,
"tslintIntegration": true,
"printWidth": 120,
"tslint.packageManager": "yarn",
"npm.packageManager": "yarn",
"prettier.tslintIntegration": true
}
52 changes: 52 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"tagFormat": "v${version}",
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{
"type": "docs",
"release": "patch"
},
{
"type": "refactor",
"release": "patch"
},
{
"type": "improvement",
"release": "patch"
}
]
},
"@semantic-release/release-notes-generator",
"@ambimax/semantic-release-composer",
"@semantic-release/github",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@ambimax/semantic-release-composer",
{
"skipOnMissingComposerJson": true
}
],
[
"@semantic-release/git",
{
"assets": [
"composer.json",
"package.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,76 @@
# dark-visitors
# Dark Visitors

Dark Visitors is a plugin for Kirby 3 and 4 that blocks unwanted AI Crawlers from your website using robots.txt. It uses the Dark Visitors API to identify and block unwanted visitors.

It also allows you to add custom rules and your sitemaps to your robots.txt file.

## Installation

```bash
composer require mauricerenck/dark-visitors
```

Or download the [latest release](https://github.com/mauricerenck/dark-visitors/releases) unzip it, copy it to `site/plugins/dark-visitors`

## Get the access token

You need a Dark Visitors access token to use this plugin.
Go to https://darkvisitors.com/ create an account and your own Project. Open your project and get your access token under settings.

## Usage

Edit your `config.php` and add the following line:

```php
'mauricerenck.dark-visitors.token' => 'YOUR TOKEN'
```

### AI crawlers

Set which types of AI crawlers you want to block:

```php
'mauricerenck.dark-visitors.aiTypes' => ['AI Assistant', 'AI Data Scraper', 'AI Search Crawler'],
```

### Your custom rules

Add your custom rules to the robots.txt file:

```php
'mauricerenck.dark-visitors.agents' => [
[
'userAgents' => ['Googlebot', 'Bingbot'],
'disallow' => ['/admin'],
],
[
'userAgents' => ['Bingbot'],
'allow' => ['/microsoft'],
],
],
```

Setting your custom rules will overwrite the default rules, which are:

````php
[
'userAgents' => ['*'],
'disallow' => ['/kirby', '/site'],
];
``D

### Sitemaps

Add your sitemaps to the robots.txt file:

```php
'mauricerenck.dark-visitors.sitemaps' => [
'Sitemap: https://your-site.tld/sitemap.xml',
'Sitemap: https://your-site.tld/sitemap2.xml',
],
````

## Learn more about robots.txt and AI crawlers

- [Google: Robots.txt specifications](https://developers.google.com/search/docs/advanced/robots/robots_txt)
- [Dark Visitors](https://darkvisitors.com/)
41 changes: 41 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "mauricerenck/darkvisitors",
"version": "1.0.0",
"description": "Kirby robots.txt plugin for blocking AI Crawlers and Bots",
"homepage": "https://github.com/mauricerenck/dark-visitors",
"type": "kirby-plugin",
"license": "MIT",
"authors": [
{
"name": "Maurice Renck",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"mauricerenck\\DarkVisitors\\": "plugin"
},
"classmap": ["plugin"]
},
"require": {
"getkirby/composer-installer": "^1.2",
"php": ">=8.0.0"
},
"require-dev": {
"getkirby/cms": "^4",
"phpunit/phpunit": "^9.5"
},
"config": {
"optimize-autoloader": true,
"allow-plugins": {
"getkirby/composer-installer": true
}
},
"scripts": {
"start": ["Composer\\Config::disableProcessTimeout", "php -S localhost:8000 kirby/router.php"],
"test": "vendor/bin/phpunit --testdox --colors=always tests",
"build-test-package": "git archive HEAD -o dark-visitors.zip --worktree-attributes",
"build-composer": "composer install --no-dev --optimize-autoloader",
"build-release": ["composer test", "composer install --no-dev --optimize-autoloader", "npm run build"]
}
}
Loading

0 comments on commit ff4ad33

Please sign in to comment.