-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Scheurich
committed
Nov 10, 2021
0 parents
commit 1c88ca1
Showing
8 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# OS files | ||
.DS_Store | ||
*.cache | ||
.idea | ||
*.map | ||
|
||
# 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 | ||
|
||
/node_modules | ||
/.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Michael Scheurich | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# A Website logger for Kirby3 | ||
|
||
 | ||
 | ||
|
||
## Commercial Usage | ||
|
||
This plugin is free but if you use it in a commercial project please consider to | ||
|
||
- [buy me a 🍺](https://buymeacoff.ee/michnhokn) | ||
|
||
## Installation | ||
|
||
- unzip [main.zip](https://github.com/michnhokn/kirby3-logger/archive/main.zip) as | ||
folder `site/plugins/kirby3-logger` or | ||
- `git submodule add https://github.com/michnhokn/kirby3-logger.git site/plugins/kirby3-logger` or | ||
- `composer require michnhokn/kirby3-logger` | ||
|
||
## Features | ||
|
||
|
||
## Setup | ||
|
||
|
||
## Misc | ||
|
||
**License**: `MIT` | ||
|
||
**Credits**: [MichnHokn](https://github.com/michnhokn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "michnhokn/kirby3-logger", | ||
"description": "Add a logger to your Kirby3 website", | ||
"type": "kirby-plugin", | ||
"version": "0.9.0", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Michael Scheurich", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"keywords": [ | ||
"kirby3", | ||
"kirby3-cms", | ||
"kirby3-plugin", | ||
"logger", | ||
"website-log", | ||
"user-log" | ||
], | ||
"config": { | ||
"optimize-autoloader": true | ||
}, | ||
"require": { | ||
"getkirby/composer-installer": "^1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
panel.plugin('michnhokn/logger', { | ||
components: { | ||
'k-logger-view': { | ||
props: {logs: Array}, | ||
template: ` | ||
<k-inside> | ||
<k-view class="k-logger-view"> | ||
<k-header>Logger</k-header> | ||
<pre>{{logs}}</pre> | ||
</k-view> | ||
</k-inside>`, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
\Kirby\Cms\App::plugin('michnhokn/logger', [ | ||
'hooks' => [ | ||
'*:before' => function (\Kirby\Cms\Event $event) { | ||
$type = $event->type(); | ||
$action = $event->action(); | ||
} | ||
], | ||
'routes' => [ | ||
[ | ||
'pattern' => 'db', | ||
'action' => function () { | ||
$logDir = kirby()->root('logs') . '/kirby3-logger/'; | ||
\Kirby\Filesystem\Dir::make($logDir, true); | ||
$database = new \Kirby\Database\Database([ | ||
'type' => 'sqlite', | ||
'database' => $logDir . 'logs.sqlite' | ||
]); | ||
$schema = \Kirby\Filesystem\F::read(__DIR__ . '/logs-schema.sql'); | ||
$database->execute($schema); | ||
dump( | ||
$database->table('logs')->insert([ | ||
'type' => 'test', | ||
'action' => 'action', | ||
'userId' => 'userId', | ||
'oldValue' => 'oldValue', | ||
'currentValue' => 'currentValue', | ||
]) | ||
); | ||
die; | ||
} | ||
], | ||
], | ||
'areas' => [ | ||
'kirby3-logger' => function ($kirby) { | ||
$logDir = kirby()->root('logs') . '/kirby3-logger/'; | ||
$database = new \Kirby\Database\Database([ | ||
'type' => 'sqlite', | ||
'database' => $logDir . 'logs.sqlite' | ||
]); | ||
|
||
return [ | ||
'label' => 'Logger', | ||
'icon' => 'table', | ||
'menu' => true, | ||
'link' => 'logger', | ||
'views' => [ | ||
[ | ||
'pattern' => 'logger', | ||
'action' => function () use ($database) { | ||
return [ | ||
'component' => 'k-logger-view', | ||
'title' => 'Logs', | ||
'props' => [ | ||
'logs' => $database->table('logs')->all() | ||
] | ||
]; | ||
} | ||
] | ||
] | ||
]; | ||
} | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CREATE TABLE IF NOT EXISTS logs | ||
( | ||
id INTEGER PRIMARY KEY, | ||
type TEXT NOT NULL, | ||
action TEXT NOT NULL, | ||
userId TEXT NULL, | ||
oldValue TEXT NULL, | ||
currentValue TEXT NOT NULL, | ||
timestamp TEXT NOT NULL DEFAULT current_timestamp | ||
); | ||
|
||
CREATE INDEX index_users ON logs (userId); | ||
CREATE INDEX index_actions ON logs (action); | ||
CREATE INDEX index_types ON logs (type); |